[Project64] Add ability to monitor Game Cpu Running to Gui

This commit is contained in:
zilmar 2015-11-15 15:44:40 +11:00
parent 8aa5b6ef47
commit 7d7026c33d
3 changed files with 84 additions and 43 deletions

View File

@ -321,12 +321,9 @@ void CN64System::StartEmulation2(bool NewThread)
{ {
g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT); g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT);
Notify().ShowRomBrowser();
} }
else
Notify().MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); {
ThreadInfo * Info = new ThreadInfo; ThreadInfo * Info = new ThreadInfo;
HANDLE * hThread = new HANDLE; HANDLE * hThread = new HANDLE;
*hThread = NULL; *hThread = NULL;
@ -337,24 +334,12 @@ void CN64System::StartEmulation2(bool NewThread)
*hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, &Info->ThreadID); *hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, &Info->ThreadID);
} }
}
else else
{ {
//mark the emulation as starting and fix up menus //mark the emulation as starting and fix up menus
g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED);
if (g_Settings->LoadBool(Setting_AutoFullscreen))
{
WriteTrace(TraceDebug, __FUNCTION__ " 15");
CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
stdstr Status = g_Settings->LoadStringVal(Rdb_Status);
char String[100];
RomIniFile.GetString("Rom Status", stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(), "true", String, sizeof(String));
if (_stricmp(String, "true") == 0)
{
Notify().ChangeFullScreen();
}
}
ExecuteCPU(); ExecuteCPU();
} }
} }
@ -887,23 +872,15 @@ void CN64System::ExecuteRecompiler()
void CN64System::ExecuteSyncCPU() void CN64System::ExecuteSyncCPU()
{ {
Notify().BringToTop();
m_Recomp->Run(); m_Recomp->Run();
} }
void CN64System::CpuStopped() void CN64System::CpuStopped()
{ {
g_Settings->SaveBool(GameRunning_CPU_Running, (DWORD)false);
Notify().WindowMode();
if (!m_InReset) if (!m_InReset)
{ {
Notify().RefreshMenu(); g_Settings->SaveBool(GameRunning_CPU_Running, (uint32_t)false);
Notify().MakeWindowOnTop(false);
g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED); g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED);
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
Notify().ShowRomBrowser();
}
} }
if (m_SyncCPU) if (m_SyncCPU)
{ {

View File

@ -50,6 +50,7 @@ m_ResetInfo(NULL)
g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged);
g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged);
g_Settings->RegisterChangeCB(GameRunning_CPU_Running, this, (CSettings::SettingChangedFunc)GameCpuRunning);
g_Settings->RegisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused); g_Settings->RegisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused);
g_Settings->RegisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded); g_Settings->RegisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded);
} }
@ -68,6 +69,7 @@ CMainGui::~CMainGui(void)
g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged);
g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged);
g_Settings->UnregisterChangeCB(GameRunning_CPU_Running, this, (CSettings::SettingChangedFunc)GameCpuRunning);
g_Settings->UnregisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused); g_Settings->UnregisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused);
g_Settings->UnregisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded); g_Settings->UnregisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded);
} }
@ -150,6 +152,15 @@ void CMainGui::SetWindowCaption(const wchar_t * title)
Caption(WinTitle); Caption(WinTitle);
} }
void CMainGui::ShowRomBrowser(void)
{
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
ShowRomList();
HighLightLastRom();
}
}
void RomBowserEnabledChanged(CMainGui * Gui) void RomBowserEnabledChanged(CMainGui * Gui)
{ {
if (Gui && g_Settings->LoadBool(RomBrowser_Enabled)) if (Gui && g_Settings->LoadBool(RomBrowser_Enabled))
@ -171,6 +182,15 @@ void RomBowserEnabledChanged(CMainGui * Gui)
void CMainGui::LoadingInProgressChanged(CMainGui * Gui) void CMainGui::LoadingInProgressChanged(CMainGui * Gui)
{ {
Gui->RefreshMenu(); Gui->RefreshMenu();
if (!g_Settings->LoadBool(GameRunning_LoadingInProgress) && g_Settings->LoadStringVal(Game_File).length() == 0)
{
Notify().WindowMode();
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
Gui->ShowRomBrowser();
}
Gui->MakeWindowOnTop(false);
}
} }
void CMainGui::GameLoaded(CMainGui * Gui) void CMainGui::GameLoaded(CMainGui * Gui)
@ -181,7 +201,6 @@ void CMainGui::GameLoaded(CMainGui * Gui)
WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom"); WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom");
Gui->AddRecentRom(FileLoc.c_str()); Gui->AddRecentRom(FileLoc.c_str());
Gui->SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str()); Gui->SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str());
Gui->HideRomList(); Gui->HideRomList();
} }
} }
@ -191,6 +210,33 @@ void CMainGui::GamePaused(CMainGui * Gui)
Gui->RefreshMenu(); Gui->RefreshMenu();
} }
void CMainGui::GameCpuRunning(CMainGui * Gui)
{
if (g_Settings->LoadBool(GameRunning_CPU_Running))
{
Gui->MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop));
if (g_Settings->LoadBool(Setting_AutoFullscreen))
{
WriteTrace(TraceDebug, __FUNCTION__ " 15");
CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
stdstr Status = g_Settings->LoadStringVal(Rdb_Status);
char String[100];
RomIniFile.GetString("Rom Status", stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(), "true", String, sizeof(String));
if (_stricmp(String, "true") == 0)
{
g_Notify->ChangeFullScreen();
}
}
Gui->RefreshMenu();
Gui->BringToTop();
}
else
{
PostMessage(Gui->m_hMainWindow, WM_GAME_CLOSED, 0, 0);
}
}
void RomBowserColoumnsChanged(CMainGui * Gui) void RomBowserColoumnsChanged(CMainGui * Gui)
{ {
Gui->ResetRomBrowserColomuns(); Gui->ResetRomBrowserColomuns();
@ -375,6 +421,7 @@ bool CMainGui::ResetPluginsInUiThread(CPlugins * plugins, CN64System * System)
WriteTrace(TraceError, __FUNCTION__ ": Failed to create event"); WriteTrace(TraceError, __FUNCTION__ ": Failed to create event");
bRes = false; bRes = false;
} }
Notify().RefreshMenu();
return bRes; return bRes;
} }
@ -908,6 +955,20 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
_this->m_ResetPlugins = true; _this->m_ResetPlugins = true;
} }
break; break;
case WM_GAME_CLOSED:
{
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
Notify().WindowMode();
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
_this->ShowRomBrowser();
}
_this->RefreshMenu();
_this->MakeWindowOnTop(false);
_this->SetStatusText(0, L"");
_this->SetStatusText(1, L"");
}
break;
case WM_COMMAND: case WM_COMMAND:
{ {
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");

View File

@ -26,6 +26,7 @@ enum
WM_HIDE_CUROSR = WM_USER + 10, WM_HIDE_CUROSR = WM_USER + 10,
WM_MAKE_FOCUS = WM_USER + 17, WM_MAKE_FOCUS = WM_USER + 17,
WM_RESET_PLUGIN = WM_USER + 18, WM_RESET_PLUGIN = WM_USER + 18,
WM_GAME_CLOSED = WM_USER + 19,
WM_BORWSER_TOP = WM_USER + 40, WM_BORWSER_TOP = WM_USER + 40,
}; };
@ -105,6 +106,7 @@ private:
void Resize(DWORD fwSizeType, WORD nWidth, WORD nHeight); //responding to WM_SIZE void Resize(DWORD fwSizeType, WORD nWidth, WORD nHeight); //responding to WM_SIZE
void AddRecentRom(const char * ImagePath); void AddRecentRom(const char * ImagePath);
void SetWindowCaption(const wchar_t * Caption); void SetWindowCaption(const wchar_t * Caption);
void ShowRomBrowser(void);
friend DWORD CALLBACK AboutBoxProc(HWND, DWORD, DWORD, DWORD); friend DWORD CALLBACK AboutBoxProc(HWND, DWORD, DWORD, DWORD);
friend DWORD CALLBACK AboutIniBoxProc(HWND, DWORD, DWORD, DWORD); friend DWORD CALLBACK AboutIniBoxProc(HWND, DWORD, DWORD, DWORD);
@ -116,6 +118,7 @@ private:
static void LoadingInProgressChanged(CMainGui * Gui); static void LoadingInProgressChanged(CMainGui * Gui);
static void GameLoaded(CMainGui * Gui); static void GameLoaded(CMainGui * Gui);
static void GamePaused(CMainGui * Gui); static void GamePaused(CMainGui * Gui);
static void GameCpuRunning(CMainGui * Gui);
CBaseMenu * m_Menu; CBaseMenu * m_Menu;