diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 70955bda8..b222b9958 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -22,7 +22,6 @@ m_SaveUsing((SAVE_CHIP_TYPE)g_Settings->LoadDword(Game_SaveChip)), m_Plugins(Plugins), m_SyncCPU(NULL), m_SyncPlugins(NULL), -m_SyncWindow(NULL), m_MMU_VM(this, SavesReadOnly), m_TLB(this), m_Reg(this, this), @@ -75,11 +74,6 @@ CN64System::~CN64System() delete m_SyncPlugins; m_SyncPlugins = NULL; } - if (m_SyncWindow) - { - delete m_SyncWindow; - m_SyncWindow = NULL; - } } void CN64System::ExternalEvent(SystemEvent action) @@ -269,10 +263,7 @@ bool CN64System::EmulationStarting(HANDLE hThread, DWORD ThreadId) } catch (...) { - WriteTraceF(TraceError, __FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); - char Message[600]; - sprintf(Message, __FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); - MessageBox(NULL, Message, "Exception", MB_OK); + g_Notify->DisplayError(stdstr_f(__FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).ToUTF16().c_str()); } } else @@ -313,17 +304,15 @@ void CN64System::StartEmulation2(bool NewThread) if (CpuType == CPU_SyncCores) { + if (g_Plugins->SyncWindow() == NULL) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } g_Notify->DisplayMessage(5, L"Copy Plugins"); g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); -#if defined(WINDOWS_UI) - m_SyncWindow = new CMainGui(false); m_SyncPlugins = new CPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); - m_SyncPlugins->SetRenderWindows(m_SyncWindow, m_SyncWindow); - + m_SyncPlugins->SetRenderWindows(g_Plugins->SyncWindow(), NULL); m_SyncCPU = new CN64System(m_SyncPlugins, true); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif } if (CpuType == CPU_Recompiler || CpuType == CPU_SyncCores) @@ -1158,7 +1147,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) Error.Log("Register, Recompiler, Interpter\r\n"); #ifdef TEST_SP_TRACKING if (m_CurrentSP != GPR[29].UW[0]) { - Error.Log("m_CurrentSP,%X,%X\r\n",m_CurrentSP,GPR[29].UW[0]); + Error.Log("m_CurrentSP,%X,%X\r\n", m_CurrentSP, GPR[29].UW[0]); } #endif if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) { @@ -2058,7 +2047,7 @@ bool CN64System::WriteToProtectedMemory(uint32_t Address, int length) { g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - return m_Recomp->ClearRecompCode_Phys(Address,length,CRecompiler::Remove_ProtectedMem); + return m_Recomp->ClearRecompCode_Phys(Address, length, CRecompiler::Remove_ProtectedMem); #endif } return false; diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index 95b6d6606..b703e1861 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -123,7 +123,6 @@ private: CPlugins * const m_Plugins; //The plugin container CN64System * m_SyncCPU; CPlugins * m_SyncPlugins; - CMainGui * m_SyncWindow; CMipsMemoryVM m_MMU_VM; //Memory of the n64 CTLB m_TLB; CRegisters m_Reg; diff --git a/Source/Project64/Plugins/Audio Plugin.cpp b/Source/Project64/Plugins/Audio Plugin.cpp index 618fcee12..2d229cfee 100644 --- a/Source/Project64/Plugins/Audio Plugin.cpp +++ b/Source/Project64/Plugins/Audio Plugin.cpp @@ -51,7 +51,7 @@ bool CAudioPlugin::LoadFunctions(void) return true; } -bool CAudioPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) +bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) { struct AUDIO_INFO { @@ -88,7 +88,7 @@ bool CAudioPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) AUDIO_INFO Info = { 0 }; - Info.hwnd = (HWND)RenderWindow->m_hMainWindow;; + Info.hwnd = (HWND)Window->GetWindowHandle(); Info.hinst = GetModuleHandle(NULL); Info.MemoryBswaped = TRUE; Info.CheckInterrupts = DummyCheckInterrupts; diff --git a/Source/Project64/Plugins/Audio Plugin.h b/Source/Project64/Plugins/Audio Plugin.h index bd53392d4..1890986f5 100644 --- a/Source/Project64/Plugins/Audio Plugin.h +++ b/Source/Project64/Plugins/Audio Plugin.h @@ -9,6 +9,7 @@ * * ****************************************************************************/ #pragma once +#include "Plugin Base.h" class CAudioPlugin : public CPlugin { @@ -17,7 +18,7 @@ public: ~CAudioPlugin(); void DacrateChanged(SYSTEM_TYPE Type); - bool Initiate(CN64System * System, CMainGui * RenderWindow); + bool Initiate(CN64System * System, RenderWindow * Window); void(__cdecl *AiLenChanged)(void); uint32_t(__cdecl *AiReadLength)(void); diff --git a/Source/Project64/Plugins/Controller Plugin.cpp b/Source/Project64/Plugins/Controller Plugin.cpp index dc0810b0d..35bb21f6c 100644 --- a/Source/Project64/Plugins/Controller Plugin.cpp +++ b/Source/Project64/Plugins/Controller Plugin.cpp @@ -58,7 +58,7 @@ bool CControl_Plugin::LoadFunctions(void) return true; } -bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) +bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) { for (int32_t i = 0; i < 4; i++) { @@ -74,7 +74,7 @@ bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) void(__cdecl *InitiateControllers_1_0)(HWND hMainWindow, CONTROL Controls[4]); InitiateControllers_1_0 = (void(__cdecl *)(HWND, CONTROL *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); if (InitiateControllers_1_0 == NULL) { return false; } - InitiateControllers_1_0((HWND)RenderWindow->m_hMainWindow,m_PluginControllers); + InitiateControllers_1_0((HWND)Window->GetWindowHandle(),m_PluginControllers); m_Initialized = true; } else if (m_PluginInfo.Version >= 0x0101) @@ -104,7 +104,7 @@ bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) ControlInfo.Controls = m_PluginControllers; ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress()); ControlInfo.hinst = GetModuleHandle(NULL); - ControlInfo.hMainWindow = (HWND)RenderWindow->m_hMainWindow; + ControlInfo.hMainWindow = (HWND)Window->GetWindowHandle(); ControlInfo.MemoryBswaped = TRUE; InitiateControllers_1_1(&ControlInfo); diff --git a/Source/Project64/Plugins/Controller Plugin.h b/Source/Project64/Plugins/Controller Plugin.h index 5ac28657e..2613fbdb1 100644 --- a/Source/Project64/Plugins/Controller Plugin.h +++ b/Source/Project64/Plugins/Controller Plugin.h @@ -9,6 +9,7 @@ * * ****************************************************************************/ #pragma once +#include "Plugin Base.h" #pragma warning(push) #pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union @@ -87,7 +88,7 @@ public: CControl_Plugin(void); ~CControl_Plugin(); - bool Initiate(CN64System * System, CMainGui * RenderWindow); + bool Initiate(CN64System * System, RenderWindow * Window); void SetControl(CControl_Plugin const * const Plugin); void UpdateKeys(void); diff --git a/Source/Project64/Plugins/GFX plugin.cpp b/Source/Project64/Plugins/GFX plugin.cpp index b08397a3f..199f716b9 100644 --- a/Source/Project64/Plugins/GFX plugin.cpp +++ b/Source/Project64/Plugins/GFX plugin.cpp @@ -93,7 +93,7 @@ bool CGfxPlugin::LoadFunctions(void) return true; } -bool CGfxPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) +bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) { if (m_Initialized) { @@ -153,8 +153,8 @@ bool CGfxPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) GFX_INFO Info = { 0 }; Info.MemoryBswaped = TRUE; - Info.hWnd = (HWND)RenderWindow->m_hMainWindow; - Info.hStatusBar = (HWND)RenderWindow->m_hStatusWnd; + Info.hWnd = (HWND)Window->GetWindowHandle(); + Info.hStatusBar = (HWND)Window->GetStatusBar(); Info.CheckInterrupts = DummyCheckInterrupts; // We are initializing the plugin before any rom is loaded so we do not have any correct diff --git a/Source/Project64/Plugins/GFX plugin.h b/Source/Project64/Plugins/GFX plugin.h index 8f5f7a4d4..7deb1dc6c 100644 --- a/Source/Project64/Plugins/GFX plugin.h +++ b/Source/Project64/Plugins/GFX plugin.h @@ -9,6 +9,7 @@ * * ****************************************************************************/ #pragma once +#include "Plugin Base.h" class CGfxPlugin : public CPlugin { @@ -52,7 +53,7 @@ public: ~CGfxPlugin(); bool LoadFunctions(void); - bool Initiate(CN64System * System, CMainGui * RenderWindow); + bool Initiate(CN64System * System, RenderWindow * Window); void(__cdecl *CaptureScreen) (const char *); void(__cdecl *ChangeWindow) (void); diff --git a/Source/Project64/Plugins/Plugin Class.cpp b/Source/Project64/Plugins/Plugin Class.cpp index 30a5d291d..e614eed90 100644 --- a/Source/Project64/Plugins/Plugin Class.cpp +++ b/Source/Project64/Plugins/Plugin Class.cpp @@ -9,9 +9,12 @@ * * ****************************************************************************/ #include "stdafx.h" +#include +#include "Plugin Class.h" CPlugins::CPlugins(const stdstr & PluginDir) : - m_RenderWindow(NULL), m_DummyWindow(NULL), +m_MainWindow(NULL), +m_SyncWindow(NULL), m_PluginDir(PluginDir), m_Gfx(NULL), m_Audio(NULL), @@ -215,10 +218,10 @@ void CPlugins::DestroyControlPlugin(void) // g_Settings->UnknownSetting_CTRL = NULL; } -void CPlugins::SetRenderWindows( CMainGui * RenderWindow, CMainGui * DummyWindow ) +void CPlugins::SetRenderWindows(RenderWindow * MainWindow, RenderWindow * SyncWindow) { - m_RenderWindow = RenderWindow; - m_DummyWindow = DummyWindow; + m_MainWindow = MainWindow; + m_SyncWindow = SyncWindow; } void CPlugins::RomOpened(void) @@ -247,13 +250,13 @@ bool CPlugins::Initiate(CN64System * System) if (m_Control == NULL) { return false; } WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Starting"); - if (!m_Gfx->Initiate(System,m_RenderWindow)) { return false; } + if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Done"); WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Starting"); - if (!m_Audio->Initiate(System,m_RenderWindow)) { return false; } + if (!m_Audio->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Done"); WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Starting"); - if (!m_Control->Initiate(System,m_RenderWindow)) { return false; } + if (!m_Control->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done"); WriteTrace(TraceRSP, __FUNCTION__ ": RSP Initiate Starting"); if (!m_RSP->Initiate(this, System)) { return false; } @@ -264,12 +267,7 @@ bool CPlugins::Initiate(CN64System * System) bool CPlugins::ResetInUiThread(CN64System * System) { -#if defined(WINDOWS_UI) - return m_RenderWindow->ResetPlugins(this, System); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); - return false; -#endif + return m_MainWindow->ResetPluginsInUiThread(this, System); } bool CPlugins::Reset(CN64System * System) @@ -295,19 +293,19 @@ bool CPlugins::Reset(CN64System * System) if (m_Gfx && bGfxChange) { WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Starting"); - if (!m_Gfx->Initiate(System,m_RenderWindow)) { return false; } + if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Done"); } if (m_Audio && bAudioChange) { WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Starting"); - if (!m_Audio->Initiate(System,m_RenderWindow)) { return false; } + if (!m_Audio->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Done"); } if (m_Control && bContChange) { WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Starting"); - if (!m_Control->Initiate(System,m_RenderWindow)) { return false; } + if (!m_Control->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done"); } if (m_RSP && bRspChange) diff --git a/Source/Project64/Plugins/Plugin Class.h b/Source/Project64/Plugins/Plugin Class.h index 21c761293..f0acbc5de 100644 --- a/Source/Project64/Plugins/Plugin Class.h +++ b/Source/Project64/Plugins/Plugin Class.h @@ -81,8 +81,16 @@ enum PLUGIN_TYPE }; class CSettings; -class CMainGui; class CGfxPlugin; class CAudioPlugin; class CRSP_Plugin; class CControl_Plugin; +class CN64System; +class CPlugins; + +__interface RenderWindow +{ + bool ResetPluginsInUiThread(CPlugins * plugins, CN64System * System) = 0; + void * GetWindowHandle(void) const = 0; + void * GetStatusBar(void) const = 0; +}; class CPlugins : private CDebugSettings @@ -95,7 +103,7 @@ public: bool Initiate(CN64System * System); void RomOpened(void); void RomClosed(void); - void SetRenderWindows ( CMainGui * RenderWindow, CMainGui * DummyWindow ); + void SetRenderWindows(RenderWindow * MainWindow, RenderWindow * SyncWindow); void ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type); bool CopyPlugins(const stdstr & DstDir) const; void CreatePlugins(void); @@ -108,6 +116,8 @@ public: inline CRSP_Plugin * RSP(void) const { return m_RSP; } inline CControl_Plugin * Control(void) const { return m_Control; } + inline RenderWindow * MainWindow(void) const { return m_MainWindow; } + inline RenderWindow * SyncWindow(void) const { return m_SyncWindow; } private: CPlugins(void); // Disable default constructor @@ -121,8 +131,8 @@ private: static void PluginChanged(CPlugins * _this); - CMainGui * m_RenderWindow; - CMainGui * m_DummyWindow; + RenderWindow * m_MainWindow; + RenderWindow * m_SyncWindow; stdstr const m_PluginDir; diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index f1ba42901..ee2394dbb 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -32,1072 +32,1071 @@ m_MakingVisible(false), m_ResetPlugins(false), m_ResetInfo(NULL) { - m_Menu = NULL; + m_Menu = NULL; - m_hMainWindow = 0; - m_hStatusWnd = 0; - m_SaveMainWindowPos = false; - m_SaveMainWindowTop = 0; - m_SaveMainWindowLeft = 0; + m_hMainWindow = 0; + m_hStatusWnd = 0; + m_SaveMainWindowPos = false; + m_SaveMainWindowTop = 0; + m_SaveMainWindowLeft = 0; - m_SaveRomBrowserPos = false; - m_SaveRomBrowserTop = 0; - m_SaveRomBrowserLeft = 0; + m_SaveRomBrowserPos = false; + m_SaveRomBrowserTop = 0; + m_SaveRomBrowserLeft = 0; - if (m_bMainWindow) - { - g_Settings->RegisterChangeCB(RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); - g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); - g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); - } + if (m_bMainWindow) + { + g_Settings->RegisterChangeCB(RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); + g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); + g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); + } - //if this fails then it has already been created - RegisterWinClass(); - Create(WindowTitle); + //if this fails then it has already been created + RegisterWinClass(); + Create(WindowTitle); } CMainGui::~CMainGui(void) { - WriteTrace(TraceDebug, __FUNCTION__ ": Start"); - if (m_bMainWindow) - { - g_Settings->UnregisterChangeCB(RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); - g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); - g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); - } - if (m_hMainWindow) - { - DestroyWindow(m_hMainWindow); - } - WriteTrace(TraceDebug, __FUNCTION__ ": Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Start"); + if (m_bMainWindow) + { + g_Settings->UnregisterChangeCB(RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); + g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); + g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); + } + if (m_hMainWindow) + { + DestroyWindow(m_hMainWindow); + } + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); } bool CMainGui::RegisterWinClass(void) { - stdstr_f VersionDisplay("Project64 %s", VER_FILE_VERSION_STR); + stdstr_f VersionDisplay("Project64 %s", VER_FILE_VERSION_STR); - WNDCLASS wcl; + WNDCLASS wcl; - wcl.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; - wcl.cbClsExtra = 0; - wcl.cbWndExtra = 0; - wcl.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PJ64_Icon)); - wcl.hCursor = LoadCursor(NULL, IDC_ARROW); - wcl.hInstance = GetModuleHandle(NULL); + wcl.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; + wcl.cbClsExtra = 0; + wcl.cbWndExtra = 0; + wcl.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PJ64_Icon)); + wcl.hCursor = LoadCursor(NULL, IDC_ARROW); + wcl.hInstance = GetModuleHandle(NULL); - wcl.lpfnWndProc = (WNDPROC)MainGui_Proc; - wcl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wcl.lpszMenuName = NULL; - wcl.lpszClassName = VersionDisplay.c_str(); - if (RegisterClass(&wcl) == 0) return false; - return true; + wcl.lpfnWndProc = (WNDPROC)MainGui_Proc; + wcl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + wcl.lpszMenuName = NULL; + wcl.lpszClassName = VersionDisplay.c_str(); + if (RegisterClass(&wcl) == 0) return false; + return true; } - void RomBowserEnabledChanged(CMainGui * Gui) { - if (Gui && g_Settings->LoadBool(RomBrowser_Enabled)) - { - if (!Gui->RomBrowserVisible()) - { - Gui->ShowRomList(); - } - } - else - { - if (Gui->RomBrowserVisible()) - { - Gui->HideRomList(); - } - } + if (Gui && g_Settings->LoadBool(RomBrowser_Enabled)) + { + if (!Gui->RomBrowserVisible()) + { + Gui->ShowRomList(); + } + } + else + { + if (Gui->RomBrowserVisible()) + { + Gui->HideRomList(); + } + } } void RomBowserColoumnsChanged(CMainGui * Gui) { - Gui->ResetRomBrowserColomuns(); + Gui->ResetRomBrowserColomuns(); } void RomBrowserRecursiveChanged(CMainGui * Gui) { - Gui->RefreshRomBrowser(); - Gui->HighLightLastRom(); + Gui->RefreshRomBrowser(); + Gui->HighLightLastRom(); } void CMainGui::ChangeWinSize(long width, long height) { - CGuard Guard(m_CS); - WINDOWPLACEMENT wndpl; - RECT rc1, swrect; + CGuard Guard(m_CS); + WINDOWPLACEMENT wndpl; + RECT rc1, swrect; - wndpl.length = sizeof(wndpl); - GetWindowPlacement(m_hMainWindow, &wndpl); + wndpl.length = sizeof(wndpl); + GetWindowPlacement(m_hMainWindow, &wndpl); - if ((HWND)m_hStatusWnd != NULL) - { - GetClientRect((HWND)m_hStatusWnd, &swrect); - SetRect(&rc1, 0, 0, width, height + swrect.bottom); - } - else - { - SetRect(&rc1, 0, 0, width, height); - } + if ((HWND)m_hStatusWnd != NULL) + { + GetClientRect((HWND)m_hStatusWnd, &swrect); + SetRect(&rc1, 0, 0, width, height + swrect.bottom); + } + else + { + SetRect(&rc1, 0, 0, width, height); + } - AdjustWindowRectEx(&rc1, GetWindowLong(m_hMainWindow, GWL_STYLE), GetMenu(m_hMainWindow) != NULL, GetWindowLong(m_hMainWindow, GWL_EXSTYLE)); + AdjustWindowRectEx(&rc1, GetWindowLong(m_hMainWindow, GWL_STYLE), GetMenu(m_hMainWindow) != NULL, GetWindowLong(m_hMainWindow, GWL_EXSTYLE)); - MoveWindow(m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top, rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE); + MoveWindow(m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top, rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE); } void CMainGui::AboutBox(void) { - DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_About), m_hMainWindow, (DLGPROC)AboutBoxProc, (LPARAM)this); + DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_About), m_hMainWindow, (DLGPROC)AboutBoxProc, (LPARAM)this); } void CMainGui::AboutIniBox(void) { - DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About_Ini), m_hMainWindow, (DLGPROC)AboutIniBoxProc,(LPARAM)this); + DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About_Ini), m_hMainWindow, (DLGPROC)AboutIniBoxProc, (LPARAM)this); } DWORD CALLBACK AboutIniBoxProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lParam*/) { - static wchar_t RDBHomePage[300], CHTHomePage[300], RDXHomePage[300]; + static wchar_t RDBHomePage[300], CHTHomePage[300], RDXHomePage[300]; - switch (uMsg) { - case WM_INITDIALOG: - { - wchar_t String[200]; + switch (uMsg) { + case WM_INITDIALOG: + { + wchar_t String[200]; - //Title - LONG_PTR originalWndProc = GetWindowLongPtrW(hDlg, GWLP_WNDPROC); - SetWindowLongPtrW(hDlg, GWLP_WNDPROC, (LONG_PTR) DefWindowProcW); - SetWindowTextW(hDlg, GS(INI_TITLE)); - SetWindowLongPtrW(hDlg, GWLP_WNDPROC, originalWndProc); + //Title + LONG_PTR originalWndProc = GetWindowLongPtrW(hDlg, GWLP_WNDPROC); + SetWindowLongPtrW(hDlg, GWLP_WNDPROC, (LONG_PTR)DefWindowProcW); + SetWindowTextW(hDlg, GS(INI_TITLE)); + SetWindowLongPtrW(hDlg, GWLP_WNDPROC, originalWndProc); - //Language - SetDlgItemTextW(hDlg, IDC_LAN, GS(INI_CURRENT_LANG)); - set_about_field(hDlg, IDC_LAN_AUTHOR, GS(INI_AUTHOR), GS(LANGUAGE_AUTHOR)); - set_about_field(hDlg, IDC_LAN_VERSION, GS(INI_VERSION), GS(LANGUAGE_VERSION)); - set_about_field(hDlg, IDC_LAN_DATE, GS(INI_DATE), GS(LANGUAGE_DATE)); - if (wcslen(GS(LANGUAGE_NAME)) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_LAN), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_LAN_AUTHOR), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_LAN_VERSION), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_LAN_DATE), FALSE); - } - //RDB - CIniFile RdbIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); - wcsncpy(String, RdbIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - if (wcslen(String) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_RDB), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDB_AUTHOR), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDB_VERSION), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDB_DATE), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDB_HOME), FALSE); - } + //Language + SetDlgItemTextW(hDlg, IDC_LAN, GS(INI_CURRENT_LANG)); + set_about_field(hDlg, IDC_LAN_AUTHOR, GS(INI_AUTHOR), GS(LANGUAGE_AUTHOR)); + set_about_field(hDlg, IDC_LAN_VERSION, GS(INI_VERSION), GS(LANGUAGE_VERSION)); + set_about_field(hDlg, IDC_LAN_DATE, GS(INI_DATE), GS(LANGUAGE_DATE)); + if (wcslen(GS(LANGUAGE_NAME)) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_LAN), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_LAN_AUTHOR), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_LAN_VERSION), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_LAN_DATE), FALSE); + } + //RDB + CIniFile RdbIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); + wcsncpy(String, RdbIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + if (wcslen(String) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_RDB), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDB_AUTHOR), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDB_VERSION), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDB_DATE), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDB_HOME), FALSE); + } - set_about_field(hDlg, IDC_RDB_AUTHOR, GS(INI_AUTHOR), String); + set_about_field(hDlg, IDC_RDB_AUTHOR, GS(INI_AUTHOR), String); - wcsncpy(String, RdbIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_RDB_VERSION, GS(INI_VERSION), String); - wcsncpy(String, RdbIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_RDB_DATE, GS(INI_DATE), String); - wcsncpy(RDBHomePage, RdbIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(RDBHomePage) / sizeof(RDBHomePage[0])); - SetDlgItemTextW(hDlg, IDC_RDB_HOME, GS(INI_HOMEPAGE)); - if (wcslen(RDBHomePage) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_RDB_HOME), FALSE); - } + wcsncpy(String, RdbIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_RDB_VERSION, GS(INI_VERSION), String); + wcsncpy(String, RdbIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_RDB_DATE, GS(INI_DATE), String); + wcsncpy(RDBHomePage, RdbIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(RDBHomePage) / sizeof(RDBHomePage[0])); + SetDlgItemTextW(hDlg, IDC_RDB_HOME, GS(INI_HOMEPAGE)); + if (wcslen(RDBHomePage) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_RDB_HOME), FALSE); + } - //Cheat - SetDlgItemTextW(hDlg, IDC_CHT, GS(INI_CURRENT_CHT)); - CIniFile CheatIniFile(g_Settings->LoadStringVal(SupportFile_Cheats).c_str()); - wcsncpy(String, CheatIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - if (wcslen(String) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_CHT), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_CHT_AUTHOR), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_CHT_VERSION), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_CHT_DATE), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_CHT_HOME), FALSE); - } - set_about_field(hDlg, IDC_CHT_AUTHOR, GS(INI_AUTHOR), String); - wcsncpy(String, CheatIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_CHT_VERSION, GS(INI_VERSION), String); - wcsncpy(String, CheatIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_CHT_DATE, GS(INI_DATE), String); - wcsncpy(CHTHomePage, CheatIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(CHTHomePage) / sizeof(CHTHomePage[0])); - SetDlgItemTextW(hDlg, IDC_CHT_HOME, GS(INI_HOMEPAGE)); - if (wcslen(CHTHomePage) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_CHT_HOME), FALSE); - } + //Cheat + SetDlgItemTextW(hDlg, IDC_CHT, GS(INI_CURRENT_CHT)); + CIniFile CheatIniFile(g_Settings->LoadStringVal(SupportFile_Cheats).c_str()); + wcsncpy(String, CheatIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + if (wcslen(String) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_CHT), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_CHT_AUTHOR), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_CHT_VERSION), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_CHT_DATE), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_CHT_HOME), FALSE); + } + set_about_field(hDlg, IDC_CHT_AUTHOR, GS(INI_AUTHOR), String); + wcsncpy(String, CheatIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_CHT_VERSION, GS(INI_VERSION), String); + wcsncpy(String, CheatIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_CHT_DATE, GS(INI_DATE), String); + wcsncpy(CHTHomePage, CheatIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(CHTHomePage) / sizeof(CHTHomePage[0])); + SetDlgItemTextW(hDlg, IDC_CHT_HOME, GS(INI_HOMEPAGE)); + if (wcslen(CHTHomePage) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_CHT_HOME), FALSE); + } - //Extended Info - SetDlgItemTextW(hDlg, IDC_RDX, GS(INI_CURRENT_RDX)); - CIniFile RdxIniFile(g_Settings->LoadStringVal(SupportFile_ExtInfo).c_str()); - wcsncpy(String, RdxIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - if (wcslen(String) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_RDX), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDX_AUTHOR), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDX_VERSION), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDX_DATE), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDX_HOME), FALSE); - } - set_about_field(hDlg, IDC_RDX_AUTHOR, GS(INI_AUTHOR), String); - wcsncpy(String, RdxIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_RDX_VERSION, GS(INI_VERSION), String); - wcsncpy(String, RdxIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_RDX_DATE, GS(INI_DATE), String); - wcsncpy(RDXHomePage, RdxIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(RDXHomePage) / sizeof(RDXHomePage[0])); - SetDlgItemTextW(hDlg, IDC_RDX_HOME, GS(INI_HOMEPAGE)); - if (wcslen(RDXHomePage) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_RDX_HOME), FALSE); - } - SetDlgItemTextW(hDlg, IDOK, GS(CHEAT_OK)); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDC_RDB_HOME: ShellExecuteW(NULL, L"open", RDBHomePage, NULL, NULL, SW_SHOWNORMAL); break; - case IDC_CHT_HOME: ShellExecuteW(NULL, L"open", CHTHomePage, NULL, NULL, SW_SHOWNORMAL); break; - case IDC_RDX_HOME: ShellExecuteW(NULL, L"open", RDXHomePage, NULL, NULL, SW_SHOWNORMAL); break; - case IDOK: - case IDCANCEL: - EndDialog(hDlg, 0); - break; - } - default: - return FALSE; - } - return TRUE; + //Extended Info + SetDlgItemTextW(hDlg, IDC_RDX, GS(INI_CURRENT_RDX)); + CIniFile RdxIniFile(g_Settings->LoadStringVal(SupportFile_ExtInfo).c_str()); + wcsncpy(String, RdxIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + if (wcslen(String) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_RDX), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDX_AUTHOR), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDX_VERSION), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDX_DATE), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDX_HOME), FALSE); + } + set_about_field(hDlg, IDC_RDX_AUTHOR, GS(INI_AUTHOR), String); + wcsncpy(String, RdxIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_RDX_VERSION, GS(INI_VERSION), String); + wcsncpy(String, RdxIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_RDX_DATE, GS(INI_DATE), String); + wcsncpy(RDXHomePage, RdxIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(RDXHomePage) / sizeof(RDXHomePage[0])); + SetDlgItemTextW(hDlg, IDC_RDX_HOME, GS(INI_HOMEPAGE)); + if (wcslen(RDXHomePage) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_RDX_HOME), FALSE); + } + SetDlgItemTextW(hDlg, IDOK, GS(CHEAT_OK)); + } + break; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_RDB_HOME: ShellExecuteW(NULL, L"open", RDBHomePage, NULL, NULL, SW_SHOWNORMAL); break; + case IDC_CHT_HOME: ShellExecuteW(NULL, L"open", CHTHomePage, NULL, NULL, SW_SHOWNORMAL); break; + case IDC_RDX_HOME: ShellExecuteW(NULL, L"open", RDXHomePage, NULL, NULL, SW_SHOWNORMAL); break; + case IDOK: + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + default: + return FALSE; + } + return TRUE; } -bool CMainGui::ResetPlugins (CPlugins * plugins, CN64System * System) +bool CMainGui::ResetPluginsInUiThread(CPlugins * plugins, CN64System * System) { - RESET_PLUGIN info; - info.system = System; - info.plugins = plugins; - info.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - bool bRes = true; - if (info.hEvent) - { - PostMessage(m_hMainWindow, WM_RESET_PLUGIN, (WPARAM)&bRes, (LPARAM)&info); + RESET_PLUGIN info; + info.system = System; + info.plugins = plugins; + info.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + bool bRes = true; + if (info.hEvent) + { + PostMessage(m_hMainWindow, WM_RESET_PLUGIN, (WPARAM)&bRes, (LPARAM)&info); #ifdef _DEBUG - DWORD dwRes = WaitForSingleObject(info.hEvent, INFINITE); + DWORD dwRes = WaitForSingleObject(info.hEvent, INFINITE); #else - DWORD dwRes = WaitForSingleObject(info.hEvent, 5000); + DWORD dwRes = WaitForSingleObject(info.hEvent, 5000); #endif - dwRes = dwRes; - CloseHandle(info.hEvent); - } - else - { - WriteTrace(TraceError, __FUNCTION__ ": Failed to create event"); - bRes = false; - } - return bRes; + dwRes = dwRes; + CloseHandle(info.hEvent); + } + else + { + WriteTrace(TraceError, __FUNCTION__ ": Failed to create event"); + bRes = false; + } + return bRes; } void CMainGui::BringToTop(void) { - CGuard Guard(m_CS); - SetForegroundWindow(m_hMainWindow); - SetFocus(GetDesktopWindow()); - Sleep(100); - SetFocus(m_hMainWindow); + CGuard Guard(m_CS); + SetForegroundWindow(m_hMainWindow); + SetFocus(GetDesktopWindow()); + Sleep(100); + SetFocus(m_hMainWindow); } void CMainGui::MakeWindowOnTop(bool OnTop) { - CGuard Guard(m_CS); - SetWindowPos(m_hMainWindow, OnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW); + CGuard Guard(m_CS); + SetWindowPos(m_hMainWindow, OnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW); } void CMainGui::Caption(LPCWSTR Caption) { - CGuard Guard(m_CS); - SetWindowTextW(m_hMainWindow, Caption); + CGuard Guard(m_CS); + SetWindowTextW(m_hMainWindow, Caption); } void CMainGui::Create(const char * WindowTitle) { - stdstr_f VersionDisplay("Project64 %s", VER_FILE_VERSION_STR); - m_hMainWindow = (HWND)CreateWindowEx(WS_EX_ACCEPTFILES, VersionDisplay.c_str(), WindowTitle, WS_OVERLAPPED | WS_CLIPCHILDREN | - WS_CLIPSIBLINGS | WS_SYSMENU | WS_MINIMIZEBOX, 5, 5, 640, 480, - NULL, NULL, GetModuleHandle(NULL), this); - m_Created = m_hMainWindow != NULL; + stdstr_f VersionDisplay("Project64 %s", VER_FILE_VERSION_STR); + m_hMainWindow = (HWND)CreateWindowEx(WS_EX_ACCEPTFILES, VersionDisplay.c_str(), WindowTitle, WS_OVERLAPPED | WS_CLIPCHILDREN | + WS_CLIPSIBLINGS | WS_SYSMENU | WS_MINIMIZEBOX, 5, 5, 640, 480, + NULL, NULL, GetModuleHandle(NULL), this); + m_Created = m_hMainWindow != NULL; } void CMainGui::CreateStatusBar(void) { - m_hStatusWnd = (HWND)CreateStatusWindow(WS_CHILD | WS_VISIBLE, "", m_hMainWindow, StatusBarID); - SendMessage((HWND)m_hStatusWnd, SB_SETTEXT, 0, (LPARAM)""); + m_hStatusWnd = (HWND)CreateStatusWindow(WS_CHILD | WS_VISIBLE, "", m_hMainWindow, StatusBarID); + SendMessage((HWND)m_hStatusWnd, SB_SETTEXT, 0, (LPARAM)""); } WPARAM CMainGui::ProcessAllMessages(void) { - MSG msg; + MSG msg; - while (GetMessage(&msg, NULL, 0, 0)) - { - if (g_cheatUI != NULL && g_cheatUI->IsCheatMessage(&msg)) - { - continue; - } + while (GetMessage(&msg, NULL, 0, 0)) + { + if (g_cheatUI != NULL && g_cheatUI->IsCheatMessage(&msg)) + { + continue; + } - if (m_ResetPlugins) - { - m_ResetPlugins = false; - m_ResetInfo->res = m_ResetInfo->plugins->Reset(m_ResetInfo->system); - SetEvent(m_ResetInfo->hEvent); - m_ResetInfo = NULL; - } - if (g_cheatUI && g_cheatUI->IsCheatMessage(&msg)) { continue; } - if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; } - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return msg.wParam; + if (m_ResetPlugins) + { + m_ResetPlugins = false; + m_ResetInfo->res = m_ResetInfo->plugins->Reset(m_ResetInfo->system); + SetEvent(m_ResetInfo->hEvent); + m_ResetInfo = NULL; + } + if (g_cheatUI && g_cheatUI->IsCheatMessage(&msg)) { continue; } + if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; } + TranslateMessage(&msg); + DispatchMessage(&msg); + } + return msg.wParam; } bool CMainGui::ProcessGuiMessages(void) { - MSG msg; + MSG msg; - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) - { - if (m_ResetPlugins) - { - m_ResetPlugins = false; - } - if (msg.message == WM_QUIT) - { - return true; - } - PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); - if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; } - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return false; + while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) + { + if (m_ResetPlugins) + { + m_ResetPlugins = false; + } + if (msg.message == WM_QUIT) + { + return true; + } + PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); + if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; } + TranslateMessage(&msg); + DispatchMessage(&msg); + } + return false; } void CMainGui::Resize(DWORD /*fwSizeType*/, WORD nWidth, WORD nHeight) { - RECT clrect, swrect; - GetClientRect(m_hMainWindow, &clrect); - GetClientRect((HWND)m_hStatusWnd, &swrect); + RECT clrect, swrect; + GetClientRect(m_hMainWindow, &clrect); + GetClientRect((HWND)m_hStatusWnd, &swrect); - int Parts[2]; - Parts[0] = (nWidth - (int)(clrect.right * 0.25)); - Parts[1] = nWidth; + int Parts[2]; + Parts[0] = (nWidth - (int)(clrect.right * 0.25)); + Parts[1] = nWidth; - SendMessage((HWND)m_hStatusWnd, SB_SETPARTS, 2, (LPARAM)&Parts[0]); - MoveWindow((HWND)m_hStatusWnd, 0, clrect.bottom - swrect.bottom, nWidth, nHeight, TRUE); + SendMessage((HWND)m_hStatusWnd, SB_SETPARTS, 2, (LPARAM)&Parts[0]); + MoveWindow((HWND)m_hStatusWnd, 0, clrect.bottom - swrect.bottom, nWidth, nHeight, TRUE); } void CMainGui::Show(bool Visible) { - m_MakingVisible = true; + m_MakingVisible = true; - CGuard Guard(m_CS); - if (m_hMainWindow) - { - ShowWindow(m_hMainWindow, Visible ? SW_SHOW : SW_HIDE); - if (Visible && RomBrowserVisible()) - { - RomBrowserToTop(); - } - } + CGuard Guard(m_CS); + if (m_hMainWindow) + { + ShowWindow(m_hMainWindow, Visible ? SW_SHOW : SW_HIDE); + if (Visible && RomBrowserVisible()) + { + RomBrowserToTop(); + } + } - m_MakingVisible = false; + m_MakingVisible = false; } -void CMainGui::EnterLogOptions (void) +void CMainGui::EnterLogOptions(void) { - ::EnterLogOptions(m_hMainWindow); + ::EnterLogOptions(m_hMainWindow); } int CMainGui::Height(void) { - if (!m_hMainWindow) { return 0; } + if (!m_hMainWindow) { return 0; } - RECT rect; - GetWindowRect(m_hMainWindow, &rect); - return rect.bottom - rect.top; + RECT rect; + GetWindowRect(m_hMainWindow, &rect); + return rect.bottom - rect.top; } int CMainGui::Width(void) { - if (!m_hMainWindow) { return 0; } + if (!m_hMainWindow) { return 0; } - RECT rect; - GetWindowRect(m_hMainWindow, &rect); - return rect.right - rect.left; + RECT rect; + GetWindowRect(m_hMainWindow, &rect); + return rect.right - rect.left; } void CMainGui::SetPos(int X, int Y) { - SetWindowPos(m_hMainWindow, NULL, X, Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + SetWindowPos(m_hMainWindow, NULL, X, Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); } void CMainGui::SetWindowMenu(CBaseMenu * Menu) { - m_AttachingMenu = true; + m_AttachingMenu = true; - HMENU hMenu = NULL; - { - CGuard Guard(m_CS); - m_Menu = Menu; - hMenu = (HMENU)Menu->GetHandle(); - } + HMENU hMenu = NULL; + { + CGuard Guard(m_CS); + m_Menu = Menu; + hMenu = (HMENU)Menu->GetHandle(); + } - if (hMenu) - { - SetMenu(m_hMainWindow, hMenu); - } + if (hMenu) + { + SetMenu(m_hMainWindow, hMenu); + } - m_AttachingMenu = false; + m_AttachingMenu = false; } void CMainGui::RefreshMenu(void) { - if (!m_Menu) { return; } - m_Menu->ResetMenu(); + if (!m_Menu) { return; } + m_Menu->ResetMenu(); } void CMainGui::SetStatusText(int Panel, const wchar_t * Text) { - static wchar_t Message[2][500]; - if (Panel >= 2) - { - g_Notify->BreakPoint(__FILEW__, __LINE__); - return; - } - wchar_t * Msg = Message[Panel]; + static wchar_t Message[2][500]; + if (Panel >= 2) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + return; + } + wchar_t * Msg = Message[Panel]; - memset(Msg, 0, sizeof(Message[0])); - _snwprintf(Msg, sizeof(Message[0]) / sizeof(Message[0][0]), L"%s", Text); - Msg[(sizeof(Message[0]) / sizeof(Message[0][0])) - 1] = 0; - if (GetCurrentThreadId() == m_ThreadId) - { - SendMessageW((HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg); - } - else { - PostMessageW((HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg); - } + memset(Msg, 0, sizeof(Message[0])); + _snwprintf(Msg, sizeof(Message[0]) / sizeof(Message[0][0]), L"%s", Text); + Msg[(sizeof(Message[0]) / sizeof(Message[0][0])) - 1] = 0; + if (GetCurrentThreadId() == m_ThreadId) + { + SendMessageW((HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg); + } + else { + PostMessageW((HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg); + } } void CMainGui::ShowStatusBar(bool ShowBar) { - ShowWindow((HWND)m_hStatusWnd, ShowBar ? SW_SHOW : SW_HIDE); + ShowWindow((HWND)m_hStatusWnd, ShowBar ? SW_SHOW : SW_HIDE); } void CMainGui::SaveWindowLoc(void) { - bool flush = false; - if (m_SaveMainWindowPos) - { - m_SaveMainWindowPos = false; - g_Settings->SaveDword(UserInterface_MainWindowTop, m_SaveMainWindowTop); - g_Settings->SaveDword(UserInterface_MainWindowLeft, m_SaveMainWindowLeft); - flush = true; - } + bool flush = false; + if (m_SaveMainWindowPos) + { + m_SaveMainWindowPos = false; + g_Settings->SaveDword(UserInterface_MainWindowTop, m_SaveMainWindowTop); + g_Settings->SaveDword(UserInterface_MainWindowLeft, m_SaveMainWindowLeft); + flush = true; + } - if (m_SaveRomBrowserPos) - { - m_SaveRomBrowserPos = false; - g_Settings->SaveDword(RomBrowser_Top, m_SaveRomBrowserTop); - g_Settings->SaveDword(RomBrowser_Left, m_SaveRomBrowserLeft); - flush = true; - } + if (m_SaveRomBrowserPos) + { + m_SaveRomBrowserPos = false; + g_Settings->SaveDword(RomBrowser_Top, m_SaveRomBrowserTop); + g_Settings->SaveDword(RomBrowser_Left, m_SaveRomBrowserLeft); + flush = true; + } - if (flush) - { - CSettingTypeApplication::Flush(); - } + if (flush) + { + CSettingTypeApplication::Flush(); + } } LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) { - switch (uMsg) - { - case WM_CREATE: - { - //record class for future usage - LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; - CMainGui * _this = (CMainGui *)lpcs->lpCreateParams; - SetProp((HWND)hWnd, "Class", _this); + switch (uMsg) + { + case WM_CREATE: + { + //record class for future usage + LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; + CMainGui * _this = (CMainGui *)lpcs->lpCreateParams; + SetProp((HWND)hWnd, "Class", _this); - _this->m_hMainWindow = hWnd; - _this->CreateStatusBar(); + _this->m_hMainWindow = hWnd; + _this->CreateStatusBar(); - //Move the Main window to the location last executed from or center the window - int X = (GetSystemMetrics(SM_CXSCREEN) - _this->Width()) / 2; - int Y = (GetSystemMetrics(SM_CYSCREEN) - _this->Height()) / 2; + //Move the Main window to the location last executed from or center the window + int X = (GetSystemMetrics(SM_CXSCREEN) - _this->Width()) / 2; + int Y = (GetSystemMetrics(SM_CYSCREEN) - _this->Height()) / 2; - g_Settings->LoadDword(UserInterface_MainWindowTop, (uint32_t &)Y); - g_Settings->LoadDword(UserInterface_MainWindowLeft, (uint32_t &)X); + g_Settings->LoadDword(UserInterface_MainWindowTop, (uint32_t &)Y); + g_Settings->LoadDword(UserInterface_MainWindowLeft, (uint32_t &)X); - _this->SetPos(X, Y); + _this->SetPos(X, Y); - _this->ChangeWinSize(640, 480); - } - break; - case WM_SYSCOMMAND: - switch (wParam) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this && - _this->bCPURunning() && - !g_Settings->LoadBool(GameRunning_CPU_Paused) && - g_Settings->LoadDword(Setting_DisableScrSaver)) - { - return 0; - } - } - break; - case SC_MAXIMIZE: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this) - { - if (_this->RomBrowserVisible()) - { - _this->RomBrowserMaximize(true); - } - } - } - break; - } - return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); - break; - case WM_MOVE: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + _this->ChangeWinSize(640, 480); + } + break; + case WM_SYSCOMMAND: + switch (wParam) { + case SC_SCREENSAVE: + case SC_MONITORPOWER: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this && + _this->bCPURunning() && + !g_Settings->LoadBool(GameRunning_CPU_Paused) && + g_Settings->LoadDword(Setting_DisableScrSaver)) + { + return 0; + } + } + break; + case SC_MAXIMIZE: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this) + { + if (_this->RomBrowserVisible()) + { + _this->RomBrowserMaximize(true); + } + } + } + break; + } + return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); + break; + case WM_MOVE: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (!_this->m_bMainWindow || - !_this->m_Created || - _this->m_AttachingMenu || - _this->m_MakingVisible || - IsIconic((HWND)hWnd) || - _this->ShowingRomBrowser()) - { - break; - } + if (!_this->m_bMainWindow || + !_this->m_Created || + _this->m_AttachingMenu || + _this->m_MakingVisible || + IsIconic((HWND)hWnd) || + _this->ShowingRomBrowser()) + { + break; + } - if (IsZoomed((HWND)hWnd)) - { - if (_this->RomBrowserVisible()) - { - // save that browser is maximized - } - break; - } + if (IsZoomed((HWND)hWnd)) + { + if (_this->RomBrowserVisible()) + { + // save that browser is maximized + } + break; + } - //get the current position of the window - RECT WinRect; - GetWindowRect((HWND)hWnd, &WinRect); + //get the current position of the window + RECT WinRect; + GetWindowRect((HWND)hWnd, &WinRect); - //save the location of the window - if (_this->RomBrowserVisible()) - { - _this->m_SaveRomBrowserPos = true; - _this->m_SaveRomBrowserTop = WinRect.top; - _this->m_SaveRomBrowserLeft = WinRect.left; - } - else - { - _this->m_SaveMainWindowPos = true; - _this->m_SaveMainWindowTop = WinRect.top; - _this->m_SaveMainWindowLeft = WinRect.left; - } - KillTimer(hWnd, Timer_SetWindowPos); - SetTimer(hWnd, Timer_SetWindowPos, 1000, NULL); - } - if (CGuiSettings::bCPURunning() && g_BaseSystem) - { - if (g_Plugins->Gfx() && g_Plugins->Gfx()->MoveScreen) - { - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); - g_Plugins->Gfx()->MoveScreen((int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)); - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); - } - } - break; - case WM_TIMER: - if (wParam == Timer_SetWindowPos) - { - KillTimer(hWnd, Timer_SetWindowPos); - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - _this->SaveWindowLoc(); - break; - } - break; - case WM_SIZE: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this) { _this->Resize(wParam, LOWORD(lParam), HIWORD(lParam)); } - if (_this) - { - if (wParam == SIZE_MAXIMIZED) - { - if (_this->RomBrowserVisible()) - { - _this->RomBrowserMaximize(true); - } - } - _this->ResizeRomList(LOWORD(lParam), HIWORD(lParam)); - } - if (_this) - { - if (wParam == SIZE_RESTORED && _this->RomBrowserVisible()) - { - _this->RomBrowserMaximize(false); - } - } - } - break; - case WM_NOTIFY: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this) - { - if (_this->RomBrowserVisible() && !_this->RomListNotify(wParam, lParam)) - { - return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); - } - } - } - break; - case WM_DRAWITEM: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this) - { - if (!_this->RomListDrawItem(wParam, lParam)) - { - return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); - } - } - } - break; - case WM_PAINT: - { - // CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - // CN64System * System = _this->m_System; + //save the location of the window + if (_this->RomBrowserVisible()) + { + _this->m_SaveRomBrowserPos = true; + _this->m_SaveRomBrowserTop = WinRect.top; + _this->m_SaveRomBrowserLeft = WinRect.left; + } + else + { + _this->m_SaveMainWindowPos = true; + _this->m_SaveMainWindowTop = WinRect.top; + _this->m_SaveMainWindowLeft = WinRect.left; + } + KillTimer(hWnd, Timer_SetWindowPos); + SetTimer(hWnd, Timer_SetWindowPos, 1000, NULL); + } + if (CGuiSettings::bCPURunning() && g_BaseSystem) + { + if (g_Plugins->Gfx() && g_Plugins->Gfx()->MoveScreen) + { + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); + g_Plugins->Gfx()->MoveScreen((int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); + } + } + break; + case WM_TIMER: + if (wParam == Timer_SetWindowPos) + { + KillTimer(hWnd, Timer_SetWindowPos); + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + _this->SaveWindowLoc(); + break; + } + break; + case WM_SIZE: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this) { _this->Resize(wParam, LOWORD(lParam), HIWORD(lParam)); } + if (_this) + { + if (wParam == SIZE_MAXIMIZED) + { + if (_this->RomBrowserVisible()) + { + _this->RomBrowserMaximize(true); + } + } + _this->ResizeRomList(LOWORD(lParam), HIWORD(lParam)); + } + if (_this) + { + if (wParam == SIZE_RESTORED && _this->RomBrowserVisible()) + { + _this->RomBrowserMaximize(false); + } + } + } + break; + case WM_NOTIFY: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this) + { + if (_this->RomBrowserVisible() && !_this->RomListNotify(wParam, lParam)) + { + return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); + } + } + } + break; + case WM_DRAWITEM: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this) + { + if (!_this->RomListDrawItem(wParam, lParam)) + { + return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); + } + } + } + break; + case WM_PAINT: + { + // CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); + // CN64System * System = _this->m_System; - // if (bCPURunning() && Settings->Load(CPU_Paused)) { - // CPlugins * Plugins = System->Plugins(); - // if (Plugins->Gfx()->DrawScreen) { - // Plugins->Gfx()->DrawScreen(); - // } - // } - ValidateRect((HWND)hWnd, NULL); - } - break; - case WM_KEYUP: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + // if (bCPURunning() && Settings->Load(CPU_Paused)) { + // CPlugins * Plugins = System->Plugins(); + // if (Plugins->Gfx()->DrawScreen) { + // Plugins->Gfx()->DrawScreen(); + // } + // } + ValidateRect((HWND)hWnd, NULL); + } + break; + case WM_KEYUP: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->m_bMainWindow && bCPURunning()) - { - if (g_BaseSystem) - { - if (g_Plugins && g_Plugins->Control()->WM_KeyUp) { - g_Plugins->Control()->WM_KeyUp(wParam, lParam); - } - } - } - } - break; - case WM_KEYDOWN: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->m_bMainWindow && bCPURunning()) + { + if (g_BaseSystem) + { + if (g_Plugins && g_Plugins->Control()->WM_KeyUp) { + g_Plugins->Control()->WM_KeyUp(wParam, lParam); + } + } + } + } + break; + case WM_KEYDOWN: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->m_bMainWindow && bCPURunning()) - { - if (g_BaseSystem) - { - if (g_Plugins && g_Plugins->Control()->WM_KeyDown) - { - g_Plugins->Control()->WM_KeyDown(wParam, lParam); - } - } - } - } - break; - case WM_SETFOCUS: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->RomBrowserVisible()) - { - PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0); - break; - } + if (_this->m_bMainWindow && bCPURunning()) + { + if (g_BaseSystem) + { + if (g_Plugins && g_Plugins->Control()->WM_KeyDown) + { + g_Plugins->Control()->WM_KeyDown(wParam, lParam); + } + } + } + } + break; + case WM_SETFOCUS: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->RomBrowserVisible()) + { + PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0); + break; + } - if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) - { - if (g_BaseSystem) - { - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_AppGainedFocus); - } - } - } - break; - case WM_KILLFOCUS: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->RomBrowserVisible()) - { - break; - } + if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) + { + if (g_BaseSystem) + { + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_AppGainedFocus); + } + } + } + break; + case WM_KILLFOCUS: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->RomBrowserVisible()) + { + break; + } - if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) - { - if (g_BaseSystem) - { - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_AppLostFocus); - } - } - } - break; - case WM_ACTIVATEAPP: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - DWORD fActive = (BOOL)wParam; + if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) + { + if (g_BaseSystem) + { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_AppLostFocus); + } + } + } + break; + case WM_ACTIVATEAPP: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + DWORD fActive = (BOOL)wParam; - if (fActive && _this->RomBrowserVisible()) - { - PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0); - } - if (_this->m_bMainWindow && bCPURunning()) - { - if (!fActive && g_Settings->LoadBool(UserInterface_InFullScreen)) - { - Notify().WindowMode(); - if (bAutoSleep() && g_BaseSystem) - { - //System->ExternalEvent(PauseCPU_AppLostActiveDelayed ); - } - break; - } - if (bAutoSleep() || fActive) - { - if (g_BaseSystem) - { - g_BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive); - } - } - } - } - break; - case WM_HIDE_CUROSR: - if (!wParam) - { - while (ShowCursor(FALSE) >= 0) { Sleep(0); } - } - else - { - while (ShowCursor(TRUE) < 0) { Sleep(0); } - } - break; - case WM_MAKE_FOCUS: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - _this->BringToTop(); - } - break; - case WM_BORWSER_TOP: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - _this->RomBrowserToTop(); - } - break; - case WM_RESET_PLUGIN: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->m_ResetInfo != NULL) - { - g_Notify->BreakPoint(__FILEW__, __LINE__); - } - _this->m_ResetInfo = (RESET_PLUGIN *)lParam; - _this->m_ResetPlugins = true; - } - break; - case WM_COMMAND: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this == NULL) { break; } + if (fActive && _this->RomBrowserVisible()) + { + PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0); + } + if (_this->m_bMainWindow && bCPURunning()) + { + if (!fActive && g_Settings->LoadBool(UserInterface_InFullScreen)) + { + Notify().WindowMode(); + if (bAutoSleep() && g_BaseSystem) + { + //System->ExternalEvent(PauseCPU_AppLostActiveDelayed ); + } + break; + } + if (bAutoSleep() || fActive) + { + if (g_BaseSystem) + { + g_BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive); + } + } + } + } + break; + case WM_HIDE_CUROSR: + if (!wParam) + { + while (ShowCursor(FALSE) >= 0) { Sleep(0); } + } + else + { + while (ShowCursor(TRUE) < 0) { Sleep(0); } + } + break; + case WM_MAKE_FOCUS: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + _this->BringToTop(); + } + break; + case WM_BORWSER_TOP: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + _this->RomBrowserToTop(); + } + break; + case WM_RESET_PLUGIN: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->m_ResetInfo != NULL) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + _this->m_ResetInfo = (RESET_PLUGIN *)lParam; + _this->m_ResetPlugins = true; + } + break; + case WM_COMMAND: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this == NULL) { break; } - switch (LOWORD(wParam)) { - case ID_POPUPMENU_PLAYGAME: g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); break; - case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(); break; - case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomBrowser(); break; - case ID_POPUPMENU_ROMINFORMATION: - { - RomInformation Info(_this->CurrentedSelectedRom()); - Info.DisplayInformation(hWnd); - } - break; - case ID_POPUPMENU_EDITSETTINGS: - case ID_POPUPMENU_EDITCHEATS: - { - CN64Rom Rom; - Rom.LoadN64Image(_this->CurrentedSelectedRom(), true); - Rom.SaveRomSettingID(true); + switch (LOWORD(wParam)) { + case ID_POPUPMENU_PLAYGAME: g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); break; + case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(); break; + case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomBrowser(); break; + case ID_POPUPMENU_ROMINFORMATION: + { + RomInformation Info(_this->CurrentedSelectedRom()); + Info.DisplayInformation(hWnd); + } + break; + case ID_POPUPMENU_EDITSETTINGS: + case ID_POPUPMENU_EDITCHEATS: + { + CN64Rom Rom; + Rom.LoadN64Image(_this->CurrentedSelectedRom(), true); + Rom.SaveRomSettingID(true); - if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS) - { - CSettingConfig SettingConfig(true); - SettingConfig.Display(hWnd); - } + if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS) + { + CSettingConfig SettingConfig(true); + SettingConfig.Display(hWnd); + } - if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) - { - CCheatsUI * cheatUI = new CCheatsUI; - g_cheatUI = cheatUI; - cheatUI->SelectCheats(hWnd, true); - if (g_cheatUI == cheatUI) - { - g_cheatUI = NULL; - } - } + if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) + { + CCheatsUI * cheatUI = new CCheatsUI; + g_cheatUI = cheatUI; + cheatUI->SelectCheats(hWnd, true); + if (g_cheatUI == cheatUI) + { + g_cheatUI = NULL; + } + } - if (g_Rom) - { - g_Rom->SaveRomSettingID(false); - } - else - { - Rom.ClearRomSettingID(); - } - } - break; - default: - if (_this->m_Menu) - { - if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100) - { - if (g_Plugins->RSP()) - { - g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam)); - } - } - else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200) - { - if (g_Plugins->Gfx()) - { - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); - g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam)); - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); - } - } - else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300) - { - if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != NULL) - { - CN64Rom Rom; - if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(), true)) - { - break; - } - Rom.SaveRomSettingID(true); - g_Notify->DisplayMessage(0, L""); - BYTE * RomHeader = Rom.GetRomAddress(); - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Starting"); - g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam), hWnd, RomHeader); - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Done"); - if (g_Rom) - { - g_Rom->SaveRomSettingID(false); - } - else - { - g_Settings->SaveString(Game_IniKey, ""); - } - } - } - else if (_this->m_Menu->ProcessMessage(hWnd, HIWORD(wParam), LOWORD(wParam))) - { - return true; - } - } - } - } - break; - case WM_DROPFILES: - { - char filename[MAX_PATH]; + if (g_Rom) + { + g_Rom->SaveRomSettingID(false); + } + else + { + Rom.ClearRomSettingID(); + } + } + break; + default: + if (_this->m_Menu) + { + if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100) + { + if (g_Plugins->RSP()) + { + g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam)); + } + } + else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200) + { + if (g_Plugins->Gfx()) + { + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); + g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam)); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); + } + } + else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300) + { + if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != NULL) + { + CN64Rom Rom; + if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(), true)) + { + break; + } + Rom.SaveRomSettingID(true); + g_Notify->DisplayMessage(0, L""); + BYTE * RomHeader = Rom.GetRomAddress(); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Starting"); + g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam), hWnd, RomHeader); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Done"); + if (g_Rom) + { + g_Rom->SaveRomSettingID(false); + } + else + { + g_Settings->SaveString(Game_IniKey, ""); + } + } + } + else if (_this->m_Menu->ProcessMessage(hWnd, HIWORD(wParam), LOWORD(wParam))) + { + return true; + } + } + } + } + break; + case WM_DROPFILES: + { + char filename[MAX_PATH]; - HDROP hDrop = (HDROP)wParam; - DragQueryFile(hDrop, 0, filename, sizeof(filename)); - DragFinish(hDrop); + HDROP hDrop = (HDROP)wParam; + DragQueryFile(hDrop, 0, filename, sizeof(filename)); + DragFinish(hDrop); - CN64System::RunFileImage(filename); - } - break; - case WM_DESTROY: - WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - start"); - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->m_bMainWindow) - { - Notify().WindowMode(); - } - _this->m_hMainWindow = NULL; - WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 1"); - if (_this->m_bMainWindow) - { - _this->SaveRomListColoumnInfo(); - WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 2"); - _this->SaveWindowLoc(); - } - } - WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 3"); - RemoveProp((HWND)hWnd, "Class"); - WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 4"); - PostQuitMessage(0); - WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - Done"); - break; - default: - return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); - } - return TRUE; + CN64System::RunFileImage(filename); + } + break; + case WM_DESTROY: + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - start"); + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->m_bMainWindow) + { + Notify().WindowMode(); + } + _this->m_hMainWindow = NULL; + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 1"); + if (_this->m_bMainWindow) + { + _this->SaveRomListColoumnInfo(); + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 2"); + _this->SaveWindowLoc(); + } + } + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 3"); + RemoveProp((HWND)hWnd, "Class"); + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 4"); + PostQuitMessage(0); + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - Done"); + break; + default: + return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); + } + return TRUE; } DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) { - static HBITMAP hbmpBackgroundTop = NULL; - static HFONT hPageHeadingFont = NULL; - static HFONT hTextFont = NULL; - static HFONT hAuthorFont = NULL; + static HBITMAP hbmpBackgroundTop = NULL; + static HFONT hPageHeadingFont = NULL; + static HFONT hTextFont = NULL; + static HFONT hAuthorFont = NULL; - switch (uMsg) { - case WM_INITDIALOG: - { - //Title - SetWindowTextW(hWnd, GS(PLUG_ABOUT)); + switch (uMsg) { + case WM_INITDIALOG: + { + //Title + SetWindowTextW(hWnd, GS(PLUG_ABOUT)); - // Use the size of the image - hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO)); + // Use the size of the image + hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO)); - BITMAP bmTL; - GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL); + BITMAP bmTL; + GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL); - hTextFont = ::CreateFont(18, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); - hAuthorFont = ::CreateFont(18, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); + hTextFont = ::CreateFont(18, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); + hAuthorFont = ::CreateFont(18, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); - hPageHeadingFont = ::CreateFont(24, 0, 0, 0, FW_BOLD, 0, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial Bold"); + hPageHeadingFont = ::CreateFont(24, 0, 0, 0, FW_BOLD, 0, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial Bold"); - SendDlgItemMessage(hWnd, IDC_VERSION, WM_SETFONT, (WPARAM)hTextFont, TRUE); - SendDlgItemMessage(hWnd, IDC_TEAM, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE); - SendDlgItemMessage(hWnd, IDC_THANKS, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE); + SendDlgItemMessage(hWnd, IDC_VERSION, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_TEAM, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE); + SendDlgItemMessage(hWnd, IDC_THANKS, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE); - SendDlgItemMessage(hWnd, IDC_ZILMAR, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); - SendDlgItemMessage(hWnd, IDC_JABO, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); - SendDlgItemMessage(hWnd, IDC_SMIFF, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); - SendDlgItemMessage(hWnd, IDC_GENT, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); + SendDlgItemMessage(hWnd, IDC_ZILMAR, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); + SendDlgItemMessage(hWnd, IDC_JABO, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); + SendDlgItemMessage(hWnd, IDC_SMIFF, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); + SendDlgItemMessage(hWnd, IDC_GENT, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); - SendDlgItemMessage(hWnd, IDC_ZILMAR_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); - SendDlgItemMessage(hWnd, IDC_JABO_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); - SendDlgItemMessage(hWnd, IDC_SMIFF_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); - SendDlgItemMessage(hWnd, IDC_GENT_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_ZILMAR_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_JABO_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_SMIFF_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_GENT_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); - SendDlgItemMessage(hWnd, IDC_THANK_LIST, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_THANK_LIST, WM_SETFONT, (WPARAM)hTextFont, TRUE); - stdstr_f VersionDisplay("Version: %s", VER_FILE_VERSION_STR); - SetWindowText(GetDlgItem(hWnd, IDC_VERSION), VersionDisplay.c_str()); - } - break; - case WM_CTLCOLORSTATIC: - { - HDC hdcStatic = (HDC)wParam; - SetTextColor(hdcStatic, RGB(0, 0, 0)); - SetBkMode(hdcStatic, TRANSPARENT); - return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); - } - break; - case WM_ERASEBKGND: - { - HPEN outline; - HBRUSH fill; - RECT rect; + stdstr_f VersionDisplay("Version: %s", VER_FILE_VERSION_STR); + SetWindowText(GetDlgItem(hWnd, IDC_VERSION), VersionDisplay.c_str()); + } + break; + case WM_CTLCOLORSTATIC: + { + HDC hdcStatic = (HDC)wParam; + SetTextColor(hdcStatic, RGB(0, 0, 0)); + SetBkMode(hdcStatic, TRANSPARENT); + return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); + } + break; + case WM_ERASEBKGND: + { + HPEN outline; + HBRUSH fill; + RECT rect; - outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF); - fill = CreateSolidBrush(0x00FFFFFF); - SelectObject((HDC)wParam, outline); - SelectObject((HDC)wParam, fill); + outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF); + fill = CreateSolidBrush(0x00FFFFFF); + SelectObject((HDC)wParam, outline); + SelectObject((HDC)wParam, fill); - GetClientRect(hWnd, &rect); + GetClientRect(hWnd, &rect); - Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom); - } - break; - case WM_PAINT: - { - PAINTSTRUCT ps; + Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom); + } + break; + case WM_PAINT: + { + PAINTSTRUCT ps; - if (BeginPaint(hWnd, &ps)) - { - RECT rcClient; - GetClientRect(hWnd, &rcClient); + if (BeginPaint(hWnd, &ps)) + { + RECT rcClient; + GetClientRect(hWnd, &rcClient); - BITMAP bmTL_top; - GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top); + BITMAP bmTL_top; + GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top); - HDC memdc = CreateCompatibleDC(ps.hdc); - HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop); - BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY); - SelectObject(memdc, save); - DeleteDC(memdc); + HDC memdc = CreateCompatibleDC(ps.hdc); + HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop); + BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY); + SelectObject(memdc, save); + DeleteDC(memdc); - EndPaint(hWnd, &ps); - } - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDOK: - case IDCANCEL: - if (hbmpBackgroundTop) - { - DeleteObject(hbmpBackgroundTop); - } - if (hTextFont) - { - ::DeleteObject(hTextFont); - } - if (hPageHeadingFont) - { - ::DeleteObject(hPageHeadingFont); - } - if (hAuthorFont) - { - ::DeleteObject(hAuthorFont); - } - //ReleaseCapture(); - EndDialog(hWnd, 0); - break; - } - default: - return FALSE; - } - return TRUE; + EndPaint(hWnd, &ps); + } + } + break; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDOK: + case IDCANCEL: + if (hbmpBackgroundTop) + { + DeleteObject(hbmpBackgroundTop); + } + if (hTextFont) + { + ::DeleteObject(hTextFont); + } + if (hPageHeadingFont) + { + ::DeleteObject(hPageHeadingFont); + } + if (hAuthorFont) + { + ::DeleteObject(hAuthorFont); + } + //ReleaseCapture(); + EndDialog(hWnd, 0); + break; + } + default: + return FALSE; + } + return TRUE; } BOOL set_about_field(HWND hDlg, int nIDDlgItem, const wchar_t * config_string, const wchar_t * language_string) { - wchar_t temp_string[200]; + wchar_t temp_string[200]; - swprintf(temp_string, sizeof(temp_string) / sizeof(temp_string[0]), L"%s: %s", config_string, language_string); - return SetDlgItemTextW(hDlg, nIDDlgItem, temp_string); -} + swprintf(temp_string, sizeof(temp_string) / sizeof(temp_string[0]), L"%s: %s", config_string, language_string); + return SetDlgItemTextW(hDlg, nIDDlgItem, temp_string); +} \ No newline at end of file diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index 264bcc7c6..0ab6b34f6 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -11,6 +11,7 @@ #pragma once #include +#include class CGfxPlugin; //Plugin that controls the rendering class CAudioPlugin; //Plugin for audio, need the hwnd @@ -28,6 +29,7 @@ enum }; class CMainGui : + public RenderWindow, public CRomBrowser, public CDebuggerUI, private CGuiSettings @@ -80,10 +82,11 @@ public: void AboutBox(void); //Plugins - bool ResetPlugins ( CPlugins * plugins, CN64System * System ); + bool ResetPluginsInUiThread(CPlugins * plugins, CN64System * System); //Get Window Handle - inline HWND GetHandle ( void ) const { return m_hMainWindow; } + void * GetWindowHandle(void) const { return m_hMainWindow; } + void * GetStatusBar(void) const { return m_hStatusWnd; } private: CMainGui(void); // Disable default constructor diff --git a/Source/Project64/User Interface/Notification Class.cpp b/Source/Project64/User Interface/Notification Class.cpp index bbeb27394..764ea07ba 100644 --- a/Source/Project64/User Interface/Notification Class.cpp +++ b/Source/Project64/User Interface/Notification Class.cpp @@ -1,335 +1,322 @@ #include "stdafx.h" #include -CNotification & Notify ( void ) +CNotification & Notify(void) { - static CNotification g_Notify; - return g_Notify; + static CNotification g_Notify; + return g_Notify; } CNotification::CNotification() : - m_hWnd(NULL), - m_gfxPlugin(NULL), - m_NextMsg(0) +m_hWnd(NULL), +m_gfxPlugin(NULL), +m_NextMsg(0) { - _tzset(); + _tzset(); } void CNotification::AppInitDone(void) { - CNotificationSettings::RegisterNotifications(); + CNotificationSettings::RegisterNotifications(); } -void CNotification::SetMainWindow ( CMainGui * Gui ) +void CNotification::SetMainWindow(CMainGui * Gui) { - m_hWnd = Gui; + m_hWnd = Gui; } -void CNotification::WindowMode ( void ) const +void CNotification::WindowMode(void) const { - static bool InsideFunc = false; - if (InsideFunc) - { - return; - } - InsideFunc = true; - if (InFullScreen()) - { - ChangeFullScreen(); - for (int i = 0; i < 5; i++) - { - Sleep(50); - if (ProcessGuiMessages()) - { - break; - } - } - } - InsideFunc = false; + static bool InsideFunc = false; + if (InsideFunc) + { + return; + } + InsideFunc = true; + if (InFullScreen()) + { + ChangeFullScreen(); + for (int i = 0; i < 5; i++) + { + Sleep(50); + if (ProcessGuiMessages()) + { + break; + } + } + } + InsideFunc = false; } void CNotification::DisplayError(LanguageStringID StringID) const { - DisplayError(g_Lang->GetString(StringID).c_str()); + DisplayError(g_Lang->GetString(StringID).c_str()); } void CNotification::DisplayError(const wchar_t * Message) const { - if (this == NULL) { return; } + if (this == NULL) { return; } stdstr TraceMessage; - TraceMessage.FromUTF16(Message); - WriteTrace(TraceError,TraceMessage.c_str()); - WindowMode(); + TraceMessage.FromUTF16(Message); + WriteTrace(TraceError, TraceMessage.c_str()); + WindowMode(); - HWND Parent = NULL; - if (m_hWnd) - { - Parent = m_hWnd->GetHandle(); + HWND Parent = NULL; + if (m_hWnd) + { + Parent = reinterpret_cast(m_hWnd->GetWindowHandle()); } - MessageBoxW(Parent, Message, GS(MSG_MSGBOX_TITLE), MB_OK | MB_ICONERROR | MB_SETFOREGROUND); + MessageBoxW(Parent, Message, GS(MSG_MSGBOX_TITLE), MB_OK | MB_ICONERROR | MB_SETFOREGROUND); } void CNotification::DisplayMessage(int DisplayTime, LanguageStringID StringID) const { - DisplayMessage(DisplayTime, g_Lang->GetString(StringID).c_str()); + DisplayMessage(DisplayTime, g_Lang->GetString(StringID).c_str()); } void CNotification::DisplayMessage(int DisplayTime, const wchar_t * Message) const { - if (!m_hWnd) { return; } + if (!m_hWnd) { return; } - if (m_NextMsg > 0 || DisplayTime > 0) - { - time_t Now = time(NULL); - if (DisplayTime == 0 && Now < m_NextMsg) - { - return; - } - if (DisplayTime > 0) - { - m_NextMsg = Now + DisplayTime; - } - if (m_NextMsg == 0) - { - m_NextMsg = 0; - } - } - - if (InFullScreen()) - { - if (m_gfxPlugin && m_gfxPlugin->DrawStatus) - { - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": DrawStatus - Starting"); - stdstr PluginMessage; - PluginMessage.FromUTF16(Message); - m_gfxPlugin->DrawStatus(PluginMessage.c_str(), FALSE); - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": DrawStatus - Done"); - } - } - else + if (m_NextMsg > 0 || DisplayTime > 0) { -#if defined(WINDOWS_UI) - m_hWnd->SetStatusText(0, Message); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif - } + time_t Now = time(NULL); + if (DisplayTime == 0 && Now < m_NextMsg) + { + return; + } + if (DisplayTime > 0) + { + m_NextMsg = Now + DisplayTime; + } + if (m_NextMsg == 0) + { + m_NextMsg = 0; + } + } + + if (InFullScreen()) + { + if (m_gfxPlugin && m_gfxPlugin->DrawStatus) + { + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": DrawStatus - Starting"); + stdstr PluginMessage; + PluginMessage.FromUTF16(Message); + m_gfxPlugin->DrawStatus(PluginMessage.c_str(), FALSE); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": DrawStatus - Done"); + } + } + else + { + m_hWnd->SetStatusText(0, Message); + } } -void CNotification::DisplayMessage2 ( const wchar_t * Message ) const +void CNotification::DisplayMessage2(const wchar_t * Message) const { - if (!m_hWnd) { return; } + if (!m_hWnd) { return; } -#if defined(WINDOWS_UI) - m_hWnd->SetStatusText(1, Message); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif + m_hWnd->SetStatusText(1, Message); } -void CNotification::SetGfxPlugin( CGfxPlugin * Plugin ) +void CNotification::SetGfxPlugin(CGfxPlugin * Plugin) { - m_gfxPlugin = Plugin; + m_gfxPlugin = Plugin; } -void CNotification::SetWindowCaption (const wchar_t * Caption) +void CNotification::SetWindowCaption(const wchar_t * Caption) { - static const size_t TITLE_SIZE = 256; - wchar_t WinTitle[TITLE_SIZE]; + static const size_t TITLE_SIZE = 256; + wchar_t WinTitle[TITLE_SIZE]; - _snwprintf(WinTitle, TITLE_SIZE, L"%s - %s", Caption, g_Settings->LoadStringVal(Setting_ApplicationName).ToUTF16().c_str()); - WinTitle[TITLE_SIZE - 1] = 0; + _snwprintf(WinTitle, TITLE_SIZE, L"%s - %s", Caption, g_Settings->LoadStringVal(Setting_ApplicationName).ToUTF16().c_str()); + WinTitle[TITLE_SIZE - 1] = 0; #if defined(WINDOWS_UI) - m_hWnd->Caption(WinTitle); + m_hWnd->Caption(WinTitle); #else - g_Notify -> BreakPoint(__FILEW__, __LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); #endif } void CNotification::FatalError(LanguageStringID StringID) const { - FatalError(g_Lang->GetString(StringID).c_str()); + FatalError(g_Lang->GetString(StringID).c_str()); } void CNotification::FatalError(const wchar_t * Message) const { - WindowMode(); + WindowMode(); - HWND Parent = NULL; - if (m_hWnd) { Parent = reinterpret_cast(m_hWnd->GetHandle()); } - MessageBoxW(Parent, Message, L"Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); - ExitThread(0); + HWND Parent = NULL; + if (m_hWnd) { Parent = reinterpret_cast(m_hWnd->GetWindowHandle()); } + MessageBoxW(Parent, Message, L"Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); + ExitThread(0); } -void CNotification::AddRecentDir ( const char * RomDir ) +void CNotification::AddRecentDir(const char * RomDir) { - //Validate the passed string - if (HIWORD(RomDir) == NULL) { return; } + //Validate the passed string + if (HIWORD(RomDir) == NULL) { return; } - //Get Information about the stored rom list - size_t MaxRememberedDirs = g_Settings->LoadDword(Directory_RecentGameDirCount); - strlist RecentDirs; - size_t i; - for (i = 0; i < MaxRememberedDirs; i ++ ) - { - stdstr RecentDir = g_Settings->LoadStringIndex(Directory_RecentGameDirIndex,i); - if (RecentDir.empty()) - { - break; - } - RecentDirs.push_back(RecentDir); - } - - //See if the dir is already in the list if so then move it to the top of the list - strlist::iterator iter; - for (iter = RecentDirs.begin(); iter != RecentDirs.end(); iter++) - { - if (_stricmp(RomDir,iter->c_str()) != 0) - { - continue; - } - RecentDirs.erase(iter); - break; - } - RecentDirs.push_front(RomDir); - if (RecentDirs.size() > MaxRememberedDirs) - { - RecentDirs.pop_back(); - } - - for (i = 0, iter = RecentDirs.begin(); iter != RecentDirs.end(); iter++, i++) - { - g_Settings->SaveStringIndex(Directory_RecentGameDirIndex,i,*iter); - } -} - -void CNotification::AddRecentRom ( const char * ImagePath ) -{ - if (HIWORD(ImagePath) == NULL) { return; } - - //Get Information about the stored rom list - size_t MaxRememberedFiles = g_Settings->LoadDword(File_RecentGameFileCount); - strlist RecentGames; - size_t i; - for (i = 0; i < MaxRememberedFiles; i ++ ) - { - stdstr RecentGame = g_Settings->LoadStringIndex(File_RecentGameFileIndex,i); - if (RecentGame.empty()) - { - break; - } - RecentGames.push_back(RecentGame); - } - - //See if the dir is already in the list if so then move it to the top of the list - strlist::iterator iter; - for (iter = RecentGames.begin(); iter != RecentGames.end(); iter++) - { - if (_stricmp(ImagePath,iter->c_str()) != 0) - { - continue; - } - RecentGames.erase(iter); - break; - } - RecentGames.push_front(ImagePath); - if (RecentGames.size() > MaxRememberedFiles) - { - RecentGames.pop_back(); - } - - for (i = 0, iter = RecentGames.begin(); iter != RecentGames.end(); iter++, i++) - { - g_Settings->SaveStringIndex(File_RecentGameFileIndex,i,*iter); - } -} - -void CNotification::RefreshMenu ( void ) -{ - if (m_hWnd == NULL) { return; } - -#if defined(WINDOWS_UI) - m_hWnd->RefreshMenu(); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif -} - -void CNotification::HideRomBrowser ( void ) -{ - if (m_hWnd == NULL) { return; } - m_hWnd->HideRomList(); -} - -void CNotification::ShowRomBrowser ( void ) -{ - if (m_hWnd == NULL) { return; } - if (g_Settings->LoadDword(RomBrowser_Enabled)) + //Get Information about the stored rom list + size_t MaxRememberedDirs = g_Settings->LoadDword(Directory_RecentGameDirCount); + strlist RecentDirs; + size_t i; + for (i = 0; i < MaxRememberedDirs; i++) { - //Display the rom browser - m_hWnd->ShowRomList(); - m_hWnd->HighLightLastRom(); - } -} - -void CNotification::BringToTop ( void ) -{ - if (m_hWnd == NULL) { return; } - -#if defined(WINDOWS_UI) - m_hWnd->BringToTop(); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif -} - -void CNotification::MakeWindowOnTop ( bool OnTop ) -{ - if (m_hWnd == NULL) { return; } - -#if defined(WINDOWS_UI) - m_hWnd->MakeWindowOnTop(OnTop); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif -} - -void CNotification::ChangeFullScreen ( void ) const -{ - if (m_hWnd == NULL) { return; } - SendMessage((HWND)(m_hWnd->GetHandle()),WM_COMMAND,MAKELPARAM(ID_OPTIONS_FULLSCREEN2,false),0); -} - -bool CNotification::ProcessGuiMessages ( void ) const -{ - if (m_hWnd == NULL) { return false; } - -#if defined(WINDOWS_UI) - return m_hWnd->ProcessGuiMessages(); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); - return false; -#endif -} - -void CNotification::BreakPoint ( const wchar_t * FileName, const int LineNumber ) -{ - if (g_Settings->LoadBool(Debugger_Enabled)) - { - DisplayError(stdstr_f("Break point found at\n%ws\n%d", FileName, LineNumber).ToUTF16().c_str()); - if (IsDebuggerPresent() != 0) - { - DebugBreak(); - } - else + stdstr RecentDir = g_Settings->LoadStringIndex(Directory_RecentGameDirIndex, i); + if (RecentDir.empty()) { - g_BaseSystem->CloseCpu(); - } - } - else + break; + } + RecentDirs.push_back(RecentDir); + } + + //See if the dir is already in the list if so then move it to the top of the list + strlist::iterator iter; + for (iter = RecentDirs.begin(); iter != RecentDirs.end(); iter++) { - DisplayError(L"Fatal Error: Stopping emulation"); - g_BaseSystem->CloseCpu(); - } + if (_stricmp(RomDir, iter->c_str()) != 0) + { + continue; + } + RecentDirs.erase(iter); + break; + } + RecentDirs.push_front(RomDir); + if (RecentDirs.size() > MaxRememberedDirs) + { + RecentDirs.pop_back(); + } + + for (i = 0, iter = RecentDirs.begin(); iter != RecentDirs.end(); iter++, i++) + { + g_Settings->SaveStringIndex(Directory_RecentGameDirIndex, i, *iter); + } } + +void CNotification::AddRecentRom(const char * ImagePath) +{ + if (HIWORD(ImagePath) == NULL) { return; } + + //Get Information about the stored rom list + size_t MaxRememberedFiles = g_Settings->LoadDword(File_RecentGameFileCount); + strlist RecentGames; + size_t i; + for (i = 0; i < MaxRememberedFiles; i++) + { + stdstr RecentGame = g_Settings->LoadStringIndex(File_RecentGameFileIndex, i); + if (RecentGame.empty()) + { + break; + } + RecentGames.push_back(RecentGame); + } + + //See if the dir is already in the list if so then move it to the top of the list + strlist::iterator iter; + for (iter = RecentGames.begin(); iter != RecentGames.end(); iter++) + { + if (_stricmp(ImagePath, iter->c_str()) != 0) + { + continue; + } + RecentGames.erase(iter); + break; + } + RecentGames.push_front(ImagePath); + if (RecentGames.size() > MaxRememberedFiles) + { + RecentGames.pop_back(); + } + + for (i = 0, iter = RecentGames.begin(); iter != RecentGames.end(); iter++, i++) + { + g_Settings->SaveStringIndex(File_RecentGameFileIndex, i, *iter); + } +} + +void CNotification::RefreshMenu(void) +{ + if (m_hWnd == NULL) { return; } + +#if defined(WINDOWS_UI) + m_hWnd->RefreshMenu(); +#else + g_Notify->BreakPoint(__FILEW__, __LINE__); +#endif +} + +void CNotification::HideRomBrowser(void) +{ + if (m_hWnd == NULL) { return; } + m_hWnd->HideRomList(); +} + +void CNotification::ShowRomBrowser(void) +{ + if (m_hWnd == NULL) { return; } + if (g_Settings->LoadDword(RomBrowser_Enabled)) + { + //Display the rom browser + m_hWnd->ShowRomList(); + m_hWnd->HighLightLastRom(); + } +} + +void CNotification::BringToTop(void) +{ + if (m_hWnd == NULL) { return; } + +#if defined(WINDOWS_UI) + m_hWnd->BringToTop(); +#else + g_Notify->BreakPoint(__FILEW__, __LINE__); +#endif +} + +void CNotification::MakeWindowOnTop(bool OnTop) +{ + if (m_hWnd == NULL) { return; } + +#if defined(WINDOWS_UI) + m_hWnd->MakeWindowOnTop(OnTop); +#else + g_Notify->BreakPoint(__FILEW__, __LINE__); +#endif +} + +void CNotification::ChangeFullScreen(void) const +{ + if (m_hWnd == NULL) { return; } + SendMessage((HWND)(m_hWnd->GetWindowHandle()), WM_COMMAND, MAKELPARAM(ID_OPTIONS_FULLSCREEN2, false), 0); +} + +bool CNotification::ProcessGuiMessages(void) const +{ + if (m_hWnd == NULL) { return false; } + + return m_hWnd->ProcessGuiMessages(); +} + +void CNotification::BreakPoint(const wchar_t * FileName, const int LineNumber) +{ + if (g_Settings->LoadBool(Debugger_Enabled)) + { + DisplayError(stdstr_f("Break point found at\n%ws\n%d", FileName, LineNumber).ToUTF16().c_str()); + if (IsDebuggerPresent() != 0) + { + DebugBreak(); + } + else + { + g_BaseSystem->CloseCpu(); + } + } + else + { + DisplayError(L"Fatal Error: Stopping emulation"); + g_BaseSystem->CloseCpu(); + } +} \ No newline at end of file