start porting config from mfc to qt

This commit is contained in:
Joshua Peisach 2025-05-31 18:33:38 -04:00 committed by Anonymous Maarten
parent 215c3f1480
commit 877c278ce9
6 changed files with 68 additions and 54 deletions

View File

@ -491,7 +491,9 @@ if (ISLE_BUILD_APP)
endif()
if (ISLE_BUILD_CONFIG)
add_executable(config WIN32
find_package(Qt6 REQUIRED COMPONENTS Core Widgets)
qt_standard_project_setup()
qt_add_executable(config
LEGO1/mxdirectx/mxdirectxinfo.cpp
LEGO1/mxdirectx/legodxinfo.cpp
CONFIG/config.cpp
@ -503,7 +505,8 @@ if (ISLE_BUILD_CONFIG)
CONFIG/res/config.rc
)
if (ISLE_MINIWIN)
target_link_libraries(config PRIVATE minimfc)
target_link_libraries(config PRIVATE minimfc)
target_link_libraries(config PRIVATE Qt6::Core Qt6::Widgets)
endif()
list(APPEND isle_targets config)
target_compile_definitions(config PRIVATE _AFXDLL MXDIRECTX_FOR_CONFIG)

View File

@ -6,14 +6,16 @@ DECOMP_SIZE_ASSERT(CDialog, 0x60)
DECOMP_SIZE_ASSERT(CAboutDialog, 0x60)
// FUNCTION: CONFIG 0x00403c20
CAboutDialog::CAboutDialog() : CDialog(IDD)
CAboutDialog::CAboutDialog() : QDialog()
{
}
// FUNCTION: CONFIG 0x00403d20
/*
void CAboutDialog::DoDataExchange(CDataExchange* pDX)
{
}
*/
//}
BEGIN_MESSAGE_MAP(CAboutDialog, CDialog)
END_MESSAGE_MAP()
/*BEGIN_MESSAGE_MAP(CAboutDialog, CDialog)*/
/*END_MESSAGE_MAP()*/

View File

@ -7,7 +7,7 @@
// VTABLE: CONFIG 0x00406308
// SIZE 0x60
class CAboutDialog : public CDialog {
class CAboutDialog : public QDialog {
public:
CAboutDialog();
enum {
@ -15,10 +15,10 @@ class CAboutDialog : public CDialog {
};
protected:
void DoDataExchange(CDataExchange* pDX) override;
/*void DoDataExchange(CDataExchange* pDX) override;*/
protected:
DECLARE_MESSAGE_MAP()
/*DECLARE_MESSAGE_MAP()*/
};
// SYNTHETIC: CONFIG 0x00403cb0

View File

@ -4,7 +4,9 @@
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#ifdef MINIMFC
#include "miniwin/mfc.h"
/*#include "miniwin/mfc.h"*/
#include <QApplication>
#include <QDialog>
#else
#include <afxext.h> // MFC extensions
#include <afxwin.h> // MFC core and standard components

View File

@ -1,6 +1,7 @@
#if !defined(AFX_CONFIG_H)
#define AFX_CONFIG_H
#include "AboutDlg.h"
#include "StdAfx.h"
#include "compat.h"
#include "decomp.h"
@ -19,7 +20,7 @@ struct MxDriver;
// VTABLE: CONFIG 0x00406040
// SIZE 0x108
class CConfigApp : public CWinApp {
class CConfigApp : public QApplication {
public:
CConfigApp();

View File

@ -3,12 +3,15 @@
#ifdef MINIWIN
#include "miniwin/ddraw.h"
#include "miniwin/dinput.h"
#include "miniwin/mfc.h"
#include "qoperatingsystemversion.h"
#include "qlibrary.h"
#else
#include <ddraw.h>
#include <dinput.h>
#endif
typedef struct IUnknown* LPUNKNOWN;
typedef HRESULT WINAPI DirectDrawCreate_fn(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnknown FAR* pUnkOuter);
typedef HRESULT WINAPI
DirectInputCreateA_fn(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA* ppDI, LPUNKNOWN punkOuter);
@ -25,93 +28,96 @@ BOOL DetectDirectX5()
// FUNCTION: CONFIG 0x00404920
void DetectDirectX(unsigned int* p_version, BOOL* p_found)
{
OSVERSIONINFOA os_version;
QOperatingSystemVersion os_version = QOperatingSystemVersion::current();
os_version.dwOSVersionInfoSize = sizeof(os_version);
if (!GetVersionEx(&os_version)) {
if (os_version.type() == QOperatingSystemVersion::Unknown) {
*p_version = 0;
*p_found = 0;
return;
}
if (os_version.dwPlatformId == 2) {
if (os_version.type() == QOperatingSystemVersion::Windows) {
*p_found = 2;
if (os_version.dwMajorVersion < 4) {
if (os_version.majorVersion() < 4) {
*p_found = 0;
return;
}
if (os_version.dwMajorVersion != 4) {
if (os_version.majorVersion() != 4) {
*p_version = 0x501;
return;
}
*p_version = 0x200;
HMODULE dinput_module = LoadLibrary("DINPUT.DLL");
if (!dinput_module) {
OutputDebugString("Couldn't LoadLibrary DInput\r\n");
QLibrary dinput_module("DINPUT.DLL");
dinput_module.load();
if (!dinput_module.isLoaded()) {
QT_DEBUG("Couldn't LoadLibrary DInput\r\n");
return;
}
DirectInputCreateA_fn* func_DirectInputCreateA =
(DirectInputCreateA_fn*) GetProcAddress(dinput_module, "DirectInputCreateA");
FreeLibrary(dinput_module);
reinterpret_cast<DirectInputCreateA_fn*>(dinput_module.resolve("DirectInputCreateA"));
dinput_module.unload();
if (!func_DirectInputCreateA) {
OutputDebugString("Couldn't GetProcAddress DInputCreate\r\n");
QT_DEBUG("Couldn't GetProcAddress DInputCreate\r\n");
return;
}
*p_version = 0x300;
return;
}
*p_found = 1;
if (LOWORD(os_version.dwBuildNumber) >= 0x550) {
if (os_version.majorVersion() >= 0x550) {
QT_DEBUG("what is this for??");
*p_version = 0x501;
return;
}
HMODULE ddraw_module = LoadLibrary("DDRAW.DLL");
if (!ddraw_module) {
QLibrary ddraw_module("DDRAW.DLL");
ddraw_module.load();
if (!ddraw_module.isLoaded()) {
*p_version = 0;
*p_found = 0;
FreeLibrary(ddraw_module);
ddraw_module.unload();
return;
}
DirectDrawCreate_fn* func_DirectDrawCreate =
(DirectDrawCreate_fn*) GetProcAddress(ddraw_module, "DirectDrawCreate");
reinterpret_cast<DirectDrawCreate_fn*>(ddraw_module.resolve("DirectDrawCreate"));
if (!func_DirectDrawCreate) {
*p_version = 0;
*p_found = 0;
FreeLibrary(ddraw_module);
OutputDebugString("Couldn't LoadLibrary DDraw\r\n");
ddraw_module.unload();
QT_DEBUG("Couldn't LoadLibrary DDraw\r\n");
return;
}
LPDIRECTDRAW ddraw;
if (FAILED(func_DirectDrawCreate(NULL, &ddraw, NULL))) {
if (func_DirectDrawCreate(NULL, &ddraw, NULL) < 0) {
*p_version = 0;
*p_found = 0;
FreeLibrary(ddraw_module);
OutputDebugString("Couldn't create DDraw\r\n");
ddraw_module.unload();
QT_DEBUG("Couldn't create DDraw\r\n");
return;
}
*p_version = 0x100;
LPDIRECTDRAW2 ddraw2;
if (FAILED(ddraw->QueryInterface(IID_IDirectDraw2, (LPVOID*) &ddraw2))) {
if (ddraw->QueryInterface(IID_IDirectDraw2, (LPVOID*) &ddraw2) < 0) {
ddraw->Release();
FreeLibrary(ddraw_module);
OutputDebugString("Couldn't QI DDraw2\r\n");
ddraw_module.unload();
QT_DEBUG("Couldn't QI DDraw2\r\n");
return;
}
ddraw->Release();
*p_version = 0x200;
HMODULE dinput_module = LoadLibrary("DINPUT.DLL");
if (!dinput_module) {
OutputDebugString("Couldn't LoadLibrary DInput\r\n");
QLibrary dinput_module("DINPUT.DLL");
dinput_module.load();
if (!dinput_module.isLoaded()) {
QT_DEBUG("Couldn't LoadLibrary DInput\r\n");
ddraw2->Release();
FreeLibrary(ddraw_module);
ddraw_module.unload();
return;
}
DirectInputCreateA_fn* func_DirectInputCreateA =
(DirectInputCreateA_fn*) GetProcAddress(dinput_module, "DirectInputCreateA");
FreeLibrary(dinput_module);
reinterpret_cast<DirectInputCreateA_fn*>(dinput_module.resolve("DirectInputCreateA"));
dinput_module.unload();
if (!func_DirectInputCreateA) {
FreeLibrary(ddraw_module);
ddraw_module.unload();
ddraw2->Release();
OutputDebugString("Couldn't GetProcAddress DInputCreate\r\n");
QT_DEBUG("Couldn't GetProcAddress DInputCreate\r\n");
return;
}
*p_version = 0x300;
@ -120,29 +126,29 @@ void DetectDirectX(unsigned int* p_version, BOOL* p_found)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS;
surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (FAILED(ddraw2->SetCooperativeLevel(NULL, DDSCL_NORMAL))) {
if (ddraw2->SetCooperativeLevel(NULL, DDSCL_NORMAL) < 0) {
ddraw2->Release();
FreeLibrary(ddraw_module);
ddraw_module.unload();
*p_version = 0;
OutputDebugString("Couldn't Set coop level\r\n");
QT_DEBUG("Couldn't Set coop level\r\n");
return;
}
LPDIRECTDRAWSURFACE surface;
if (FAILED(ddraw2->CreateSurface(&surface_desc, &surface, NULL))) {
if (ddraw2->CreateSurface(&surface_desc, &surface, NULL) < 0) {
ddraw2->Release();
FreeLibrary(ddraw_module);
ddraw_module.unload();
*p_version = 0;
OutputDebugString("Couldn't CreateSurface\r\n");
QT_DEBUG("Couldn't CreateSurface\r\n");
return;
}
LPDIRECTDRAWSURFACE3 surface3;
if (FAILED(surface->QueryInterface(IID_IDirectDrawSurface3, (LPVOID*) &surface3))) {
if (surface->QueryInterface(IID_IDirectDrawSurface3, reinterpret_cast<LPVOID*>(&surface3)) < 0) {
ddraw2->Release();
FreeLibrary(ddraw_module);
ddraw_module.unload();
return;
}
*p_version = 0x500;
surface3->Release();
ddraw2->Release();
FreeLibrary(ddraw_module);
ddraw_module.unload();
}