From 9c868351dead6cd43bc2778771ad2e8d4b295f77 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sun, 13 Oct 2013 14:14:28 -0400 Subject: [PATCH 1/2] Make Enable Debug Logging checkbox instant as it was intended to be. --- Core/Host.h | 1 + UI/GameSettingsScreen.cpp | 15 ++------------- UI/GameSettingsScreen.h | 3 --- Windows/WindowsHost.cpp | 6 ++++-- Windows/WindowsHost.h | 1 + Windows/WndMainWindow.cpp | 21 +++++++++++---------- Windows/WndMainWindow.h | 8 ++++---- 7 files changed, 23 insertions(+), 32 deletions(-) diff --git a/Core/Host.h b/Core/Host.h index 45010d60c5..d6f613ba72 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 ShowDebugConsole(bool) {} //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..8bd513d6d0 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->ShowDebugConsole(g_Config.bEnableLogging); 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..2992370d41 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::ShowDebugConsole(bool showConsole) { + MainWindow::ShowDebugConsole(showConsole); +} diff --git a/Windows/WindowsHost.h b/Windows/WindowsHost.h index a68f270038..18db0e3d2c 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 ShowDebugConsole(bool); 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..c71f5d3e58 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 ShowDebugConsole(bool) { + 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..e69a62a7b4 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 ShowDebugConsole(bool); void TranslateMenus(); void setTexScalingMultiplier(int level); } From 7000b6308227c575eb536180ed168b9daa6d5407 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sun, 13 Oct 2013 14:25:59 -0400 Subject: [PATCH 2/2] When using a debug build, always show the debug log/enable logging on start. --- Core/Host.h | 2 +- UI/GameSettingsScreen.cpp | 2 +- Windows/WindowsHost.cpp | 4 ++-- Windows/WindowsHost.h | 2 +- Windows/WndMainWindow.cpp | 2 +- Windows/WndMainWindow.h | 2 +- Windows/main.cpp | 12 +++++------- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Core/Host.h b/Core/Host.h index d6f613ba72..dde373e2cc 100644 --- a/Core/Host.h +++ b/Core/Host.h @@ -48,7 +48,7 @@ public: virtual void GoFullscreen(bool) {} virtual void ShutdownSound() = 0; virtual void PollControllers(InputState &input_state) {} - virtual void ShowDebugConsole(bool) {} + 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 8bd513d6d0..e1d1065d5a 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -533,7 +533,7 @@ UI::EventReturn GameSettingsScreen::OnRestoreDefaultSettings(UI::EventParams &e) } UI::EventReturn DeveloperToolsScreen::OnLoggingChanged(UI::EventParams &e) { - host->ShowDebugConsole(g_Config.bEnableLogging); + host->ToggleDebugConsoleVisibility(); return UI::EVENT_DONE; } diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 2992370d41..09da666360 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -375,6 +375,6 @@ void WindowsHost::GoFullscreen(bool viewFullscreen) { MainWindow::_ViewNormal(MainWindow::GetHWND()); } -void WindowsHost::ShowDebugConsole(bool showConsole) { - MainWindow::ShowDebugConsole(showConsole); +void WindowsHost::ToggleDebugConsoleVisibility() { + MainWindow::ToggleDebugConsoleVisibility(); } diff --git a/Windows/WindowsHost.h b/Windows/WindowsHost.h index 18db0e3d2c..dc235f8edf 100644 --- a/Windows/WindowsHost.h +++ b/Windows/WindowsHost.h @@ -62,7 +62,7 @@ public: virtual void GPUNotifyDraw(); virtual void GPUNotifyTextureAttachment(u32 addr); virtual bool GPUAllowTextureCache(u32 addr); - virtual void ShowDebugConsole(bool); + 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 c71f5d3e58..4f15372a9a 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -1854,7 +1854,7 @@ namespace MainWindow return hInst; } - void ShowDebugConsole(bool) { + void ToggleDebugConsoleVisibility() { if (!g_Config.bEnableLogging) { LogManager::GetInstance()->GetConsoleListener()->Show(false); EnableMenuItem(menu, ID_DEBUG_LOG, MF_GRAYED); diff --git a/Windows/WndMainWindow.h b/Windows/WndMainWindow.h index e69a62a7b4..61078c9574 100644 --- a/Windows/WndMainWindow.h +++ b/Windows/WndMainWindow.h @@ -64,7 +64,7 @@ namespace MainWindow void SaveStateActionFinished(bool result, void *userdata); void _ViewFullScreen(HWND hWnd); void _ViewNormal(HWND hWnd); - void ShowDebugConsole(bool); + 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