diff --git a/GLidenUI/GLideNUI.cpp b/GLidenUI/GLideNUI.cpp index 0a817235..7bcf6034 100644 --- a/GLidenUI/GLideNUI.cpp +++ b/GLidenUI/GLideNUI.cpp @@ -1,3 +1,5 @@ +#include + #include "GLideNUI.h" #include "ConfigDialog.h" #include @@ -18,7 +20,6 @@ void _writeSettings() settings.setValue("version", config.version); settings.beginGroup("video"); - settings.setValue("fullscreen", config.video.fullscreen); settings.setValue("fullscreenWidth", config.video.fullscreenWidth); settings.setValue("fullscreenHeight", config.video.fullscreenHeight); settings.setValue("windowedWidth", config.video.windowedWidth); @@ -91,7 +92,7 @@ void _loadSettings() config.version = settings.value("version").toInt(); settings.beginGroup("video"); - config.video.fullscreen = settings.value("fullscreen", 0).toInt(); + config.video.fullscreen = 0; config.video.fullscreenWidth = settings.value("fullscreenWidth", 640).toInt(); config.video.fullscreenHeight = settings.value("fullscreenHeight", 480).toInt(); config.video.windowedWidth = settings.value("windowedWidth", 640).toInt(); @@ -158,7 +159,7 @@ void _loadSettings() config.font.colorf[0] = _FIXED2FLOAT(config.font.color[0], 8); config.font.colorf[1] = _FIXED2FLOAT(config.font.color[1], 8); config.font.colorf[2] = _FIXED2FLOAT(config.font.color[2], 8); - config.font.colorf[3] = _FIXED2FLOAT(config.font.color[3], 8); + config.font.colorf[3] = config.font.color[3] == 0 ? 1.0f : _FIXED2FLOAT(config.font.color[3], 8); settings.endGroup(); settings.beginGroup("bloomFilter"); @@ -170,58 +171,35 @@ void _loadSettings() settings.endGroup(); } -//#define USE_WIN_THREADS - -#ifdef USE_WIN_THREADS - -int main(int argc, char *argv[]) -{ - argc = 0; - argv = 0; - QApplication a(argc, argv); - ConfigDialog w; - w.show(); - - return a.exec(); -} - - -int runThread(HINSTANCE hInstance) { - HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)main, (LPVOID)hInstance, 0, NULL); - DWORD res = WaitForSingleObject(hThread, INFINITE); - return res; -} - -#else -#include -int main() +static +int openConfigDialog() { _loadSettings(); + int argc = 0; char * argv = 0; - int res; QApplication a(argc, &argv); - { - ConfigDialog w; - w.show(); - res = a.exec(); - } + ConfigDialog w; + w.show(); + int res = a.exec(); + _writeSettings(); return res; } -int runThread(HINSTANCE /*hInstance*/) { - std::thread first(main); - first.join(); +int runThread() { + std::thread configThread(openConfigDialog); + configThread.join(); return 0; } -#endif - -EXPORT int CALL RunConfig(HINSTANCE hInstance /*HWND hParent*/) +EXPORT int CALL RunConfig() { - return runThread(hInstance); + return runThread(); } - +EXPORT void CALL LoadConfig() +{ + _loadSettings(); +} diff --git a/GLidenUI/GLideNUI.h b/GLidenUI/GLideNUI.h index cc6b9782..078379b3 100644 --- a/GLidenUI/GLideNUI.h +++ b/GLidenUI/GLideNUI.h @@ -1,23 +1,20 @@ #ifndef GLIDENUII_H #define GLIDENUII_H -#include - #if defined(__cplusplus) extern "C" { #endif +#ifdef OS_WINDOWS #define EXPORT __declspec(dllexport) -#define CALL __cdecl +#define CALL __cdecl +#else +#define EXPORT __attribute__((visibility("default"))) +#define CALL _cdecl +#endif - /****************************************************************** - Function: DllConfig - Purpose: This function is optional function that is provided - to allow the user to configure the dll - input: a handle to the window that calls this function - output: none - *******************************************************************/ - EXPORT int CALL RunConfig(HINSTANCE hInstance /*HWND hParent*/); + EXPORT int CALL RunConfig(); + EXPORT void CALL LoadConfig(); #if defined(__cplusplus) } diff --git a/windows/Config_windows.cpp b/windows/Config_windows.cpp index 2dfb4207..6b17a085 100644 --- a/windows/Config_windows.cpp +++ b/windows/Config_windows.cpp @@ -1,7 +1,4 @@ #include "GLideN64_Windows.h" -#include -#include - #include "../Config.h" #include "../GLideN64.h" #include "../Resource.h" @@ -11,6 +8,11 @@ #include "../GLideNUI/glidenui.h" Config config; + +#ifdef LEGACY_UI +#include +#include + HWND hConfigDlg; const u32 uMegabyte = 1024U*1024U; @@ -393,3 +395,14 @@ void Config_DoConfig(HWND hParent) // DialogBox( hInstance, MAKEINTRESOURCE(IDD_CONFIGDLG), hParent, (DLGPROC)ConfigDlgProc ); RunConfig(hInstance); } +#else // LEGACY_UI +void Config_DoConfig(HWND hParent) +{ + RunConfig(); +} + +void Config_LoadConfig() +{ + LoadConfig(); +} +#endif // LEGACY_UI