diff --git a/Core/Host.h b/Core/Host.h index 45010d60c5..dde373e2cc 100644 --- a/Core/Host.h +++ b/Core/Host.h @@ -48,6 +48,7 @@ public: virtual void GoFullscreen(bool) {} virtual void ShutdownSound() = 0; virtual void PollControllers(InputState &input_state) {} + virtual void ToggleDebugConsoleVisibility() {} //this is sent from EMU thread! Make sure that Host handles it properly! virtual void BootDone() {} diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 14ef6e0415..e1d1065d5a 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -42,9 +42,6 @@ #ifdef _WIN32 namespace MainWindow { - enum { - WM_USER_LOG_STATUS_CHANGED = WM_USER + 101, - }; extern HWND hwndMain; } #endif @@ -479,8 +476,6 @@ void DeveloperToolsScreen::CreateViews() { using namespace UI; root_ = new ScrollView(ORIENT_VERTICAL); - enableLogging_ = g_Config.bEnableLogging; - I18NCategory *d = GetI18NCategory("Dialog"); I18NCategory *de = GetI18NCategory("Developer"); I18NCategory *gs = GetI18NCategory("Graphics"); @@ -498,7 +493,7 @@ void DeveloperToolsScreen::CreateViews() { if (!File::Exists(g_Config.memCardDirectory + "pspautotests/tests/")) cpuTests->SetEnabled(false); - list->Add(new CheckBox(&enableLogging_, de->T("Enable Logging")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoggingChanged); + list->Add(new CheckBox(&g_Config.bEnableLogging, de->T("Enable Logging")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoggingChanged); list->Add(new Choice(de->T("Logging Channels")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLogConfig); list->Add(new ItemHeader(de->T("Language"))); list->Add(new Choice(de->T("Load language ini")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoadLanguageIni); @@ -515,10 +510,6 @@ void DeveloperToolsScreen::sendMessage(const char *message, const char *value){ UI::EventReturn DeveloperToolsScreen::OnBack(UI::EventParams &e) { screenManager()->finishDialog(this, DR_OK); - g_Config.bEnableLogging = enableLogging_; -#ifdef _WIN32 - PostMessage(MainWindow::hwndMain, MainWindow::WM_USER_LOG_STATUS_CHANGED, 0, 0); -#endif g_Config.Save(); return UI::EVENT_DONE; @@ -542,9 +533,7 @@ UI::EventReturn GameSettingsScreen::OnRestoreDefaultSettings(UI::EventParams &e) } UI::EventReturn DeveloperToolsScreen::OnLoggingChanged(UI::EventParams &e) { -#ifdef _WIN32 - PostMessage(MainWindow::hwndMain, MainWindow::WM_USER_LOG_STATUS_CHANGED, 0, 0); -#endif + host->ToggleDebugConsoleVisibility(); return UI::EVENT_DONE; } diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 75b71ab77d..12a0ffcfd8 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -102,7 +102,4 @@ private: UI::EventReturn OnLoadLanguageIni(UI::EventParams &e); UI::EventReturn OnSaveLanguageIni(UI::EventParams &e); UI::EventReturn OnLogConfig(UI::EventParams &e); - - // Temporary variable. - bool enableLogging_; }; diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 201a59cb74..09da666360 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -169,8 +169,6 @@ void WindowsHost::SetDebugMode(bool mode) } } -extern BOOL g_bFullScreen; - void WindowsHost::PollControllers(InputState &input_state) { bool doPad = true; @@ -376,3 +374,7 @@ void WindowsHost::GoFullscreen(bool viewFullscreen) { else MainWindow::_ViewNormal(MainWindow::GetHWND()); } + +void WindowsHost::ToggleDebugConsoleVisibility() { + MainWindow::ToggleDebugConsoleVisibility(); +} diff --git a/Windows/WindowsHost.h b/Windows/WindowsHost.h index a68f270038..dc235f8edf 100644 --- a/Windows/WindowsHost.h +++ b/Windows/WindowsHost.h @@ -62,6 +62,7 @@ public: virtual void GPUNotifyDraw(); virtual void GPUNotifyTextureAttachment(u32 addr); virtual bool GPUAllowTextureCache(u32 addr); + virtual void ToggleDebugConsoleVisibility(); virtual bool CanCreateShortcut() {return false;} // Turn on when fixed virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title); diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 06ed3c4a38..4f15372a9a 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -1588,16 +1588,6 @@ namespace MainWindow SetCursor(LoadCursor(0, IDC_ARROW)); break; - case WM_USER_LOG_STATUS_CHANGED: - if(!g_Config.bEnableLogging) { - LogManager::GetInstance()->GetConsoleListener()->Show(false); - EnableMenuItem(menu, ID_DEBUG_LOG, MF_GRAYED); - } else { - LogManager::GetInstance()->GetConsoleListener()->Show(true); - EnableMenuItem(menu, ID_DEBUG_LOG, MF_ENABLED); - } - break; - case WM_USER_UPDATE_UI: TranslateMenus(); Update(); @@ -1863,4 +1853,15 @@ namespace MainWindow HINSTANCE GetHInstance() { return hInst; } + + void ToggleDebugConsoleVisibility() { + if (!g_Config.bEnableLogging) { + LogManager::GetInstance()->GetConsoleListener()->Show(false); + EnableMenuItem(menu, ID_DEBUG_LOG, MF_GRAYED); + } + else { + LogManager::GetInstance()->GetConsoleListener()->Show(true); + EnableMenuItem(menu, ID_DEBUG_LOG, MF_ENABLED); + } + } } diff --git a/Windows/WndMainWindow.h b/Windows/WndMainWindow.h index 36e0500949..61078c9574 100644 --- a/Windows/WndMainWindow.h +++ b/Windows/WndMainWindow.h @@ -9,10 +9,9 @@ namespace MainWindow { enum { WM_USER_SAVESTATE_FINISH = WM_USER + 100, - WM_USER_LOG_STATUS_CHANGED = WM_USER + 101, - WM_USER_UPDATE_UI = WM_USER + 102, - WM_USER_UPDATE_SCREEN = WM_USER + 103, - WM_USER_WINDOW_TITLE_CHANGED = WM_USER + 104, + WM_USER_UPDATE_UI = WM_USER + 101, + WM_USER_UPDATE_SCREEN = WM_USER + 102, + WM_USER_WINDOW_TITLE_CHANGED = WM_USER + 103, }; enum { @@ -65,6 +64,7 @@ namespace MainWindow void SaveStateActionFinished(bool result, void *userdata); void _ViewFullScreen(HWND hWnd); void _ViewNormal(HWND hWnd); + void ToggleDebugConsoleVisibility(); void TranslateMenus(); void setTexScalingMultiplier(int level); } diff --git a/Windows/main.cpp b/Windows/main.cpp index 39bff5597e..92cbab298c 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -170,11 +170,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin } SetCurrentDirectory(modulePath); // GetCurrentDirectory(MAX_PATH, modulePath); // for checking in the debugger -#ifndef _DEBUG - bool hideLog = true; -#else - bool hideLog = false; -#endif VFSRegister("", new DirectoryAssetReader("assets/")); VFSRegister("", new DirectoryAssetReader("")); @@ -237,7 +232,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin switch (__argv[i][1]) { case 'l': - hideLog = false; + g_Config.bEnableLogging = true; break; case 's': g_Config.bAutoRun = false; @@ -252,9 +247,12 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin g_Config.bFullScreen = false; } } +#ifdef _DEBUG + g_Config.bEnableLogging = true; +#endif LogManager::Init(); - LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console"); + LogManager::GetInstance()->GetConsoleListener()->Open(!g_Config.bEnableLogging, 150, 120, "PPSSPP Debug Console"); //Windows, API init stuff