From 334d11bf07149f933eb791c4d7c011f8977a4b38 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Tue, 1 Sep 2009 14:33:16 +0000 Subject: [PATCH] GUI: Fixed saving of m_InterfaceLogWindow and m_InterfaceConsole, one crashfix git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4140 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/ConsoleListener.cpp | 6 ++++-- Source/Core/Common/Src/LogManager.h | 2 +- Source/Core/Core/Src/ConfigManager.h | 5 ++++- Source/Core/DolphinWX/Src/Frame.cpp | 25 +++++++++------------- Source/Core/DolphinWX/Src/Frame.h | 4 +--- Source/Core/DolphinWX/Src/FrameTools.cpp | 15 ++++++++----- Source/Core/DolphinWX/Src/Main.cpp | 9 ++------ 7 files changed, 32 insertions(+), 34 deletions(-) diff --git a/Source/Core/Common/Src/ConsoleListener.cpp b/Source/Core/Common/Src/ConsoleListener.cpp index b5ce181d25..37c3748dd4 100644 --- a/Source/Core/Common/Src/ConsoleListener.cpp +++ b/Source/Core/Common/Src/ConsoleListener.cpp @@ -44,20 +44,22 @@ ConsoleListener::~ConsoleListener() // 100, 100, "Dolphin Log Console" // Open console window - width and height is the size of console window // Name is the window title -void ConsoleListener::Open(int Width, int Height, const char *Title) +void ConsoleListener::Open(bool Hidden, int Width, int Height, const char *Title) { #ifdef _WIN32 if (!GetConsoleWindow()) { // Open the console window and create the window handle for GetStdHandle() AllocConsole(); + // Hide + if (Hidden) ShowWindow(GetConsoleWindow(), SW_HIDE); // Save the window handle that AllocConsole() created hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Set the console window title SetConsoleTitle(Title); // Set letter space LetterSpace(80, 1000); - MoveWindow(GetConsoleWindow(), 200,200, 800,800, true); + //MoveWindow(GetConsoleWindow(), 200,200, 800,800, true); } else { diff --git a/Source/Core/Common/Src/LogManager.h b/Source/Core/Common/Src/LogManager.h index b41dbe1b59..68e6561ad0 100644 --- a/Source/Core/Common/Src/LogManager.h +++ b/Source/Core/Common/Src/LogManager.h @@ -73,7 +73,7 @@ public: ConsoleListener(); ~ConsoleListener(); - void Open(int Width = 100, int Height = 100, const char * Name = "Console"); + void Open(bool Hidden = false, int Width = 100, int Height = 100, const char * Name = "Console"); void UpdateHandle(); void Close(); bool IsOpen(); diff --git a/Source/Core/Core/Src/ConfigManager.h b/Source/Core/Core/Src/ConfigManager.h index b1050c82a7..9cd8d81467 100644 --- a/Source/Core/Core/Src/ConfigManager.h +++ b/Source/Core/Core/Src/ConfigManager.h @@ -91,7 +91,10 @@ struct SConfig /* Return the permanent and somewhat globally used instance of this struct there is also a Core::GetStartupParameter() instance of it with almost - the same values */ + the same values + + Is this still true or do we only have one now? + */ static SConfig& GetInstance() {return(m_Instance);} private: diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index f4cf6925a3..314293ef42 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -299,8 +299,7 @@ END_EVENT_TABLE() //--------------- // Creation and close, quit functions -CFrame::CFrame(bool showLogWindow, - wxFrame* parent, +CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, const wxPoint& pos, @@ -311,16 +310,15 @@ CFrame::CFrame(bool showLogWindow, , UseDebugger(_UseDebugger), m_LogWindow(NULL) , m_GameListCtrl(NULL), m_pStatusBar(NULL), bRenderToMain(true), HaveLeds(false) , HaveSpeakers(false), m_Panel(NULL), m_ToolBar(NULL), m_ToolBarDebug(NULL) - , m_bLogWindow(showLogWindow || SConfig::GetInstance().m_InterfaceLogWindow) , m_fLastClickTime(0), m_iLastMotionTime(0), LastMouseX(0), LastMouseY(0) #if wxUSE_TIMER , m_timer(this) #endif { - // Give it a console + // Give it a console early to show potential messages from this onward ConsoleListener *Console = LogManager::GetInstance()->getConsoleListener(); - if (SConfig::GetInstance().m_InterfaceConsole) Console->Open(); + if (SConfig::GetInstance().m_InterfaceConsole) Console->Open(true); // Start debugging mazimized if (UseDebugger) this->Maximize(true); @@ -423,7 +421,7 @@ CFrame::CFrame(bool showLogWindow, if (!UseDebugger) { SetSimplePaneSize(); - if (m_bLogWindow) DoToggleWindow(IDM_LOGWINDOW, true); + if (SConfig::GetInstance().m_InterfaceLogWindow) DoToggleWindow(IDM_LOGWINDOW, true); if (SConfig::GetInstance().m_InterfaceConsole) DoToggleWindow(IDM_CONSOLEWINDOW, true); } @@ -718,7 +716,7 @@ void CFrame::ReloadPanes() // Open notebook pages AddRemoveBlankPage(); g_pCodeWindow->OpenPages(); - if (m_bLogWindow) DoToggleWindow(IDM_LOGWINDOW, true); + if (SConfig::GetInstance().m_InterfaceLogWindow) DoToggleWindow(IDM_LOGWINDOW, true); if (SConfig::GetInstance().m_InterfaceConsole) DoToggleWindow(IDM_CONSOLEWINDOW, true); //Console->Log(LogTypes::LNOTICE, StringFromFormat("ReloadPanes end: Sound %i\n", FindWindowByName(wxT("Sound"))).c_str()); @@ -733,11 +731,12 @@ void CFrame::DoLoadPerspective() // Show ShowAllNotebooks(true); + /* ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); Console->Log(LogTypes::LCUSTOM, StringFromFormat( "Loaded: %s (%i panes, %i NBs)\n", Perspectives.at(ActivePerspective).Name.c_str(), m_Mgr->GetAllPanes().GetCount(), GetNotebookCount()).c_str()); - + */ } // Update the local perspectives array @@ -786,11 +785,7 @@ void CFrame::SaveLocal() } void CFrame::Save() { - if (Perspectives.size() == 0) - { - wxMessageBox(wxT("Please create a perspective before saving"), wxT("Notice"), wxOK, this); - return; - } + if (Perspectives.size() == 0) return; if (ActivePerspective >= Perspectives.size()) ActivePerspective = 0; // Turn off edit before saving @@ -837,12 +832,12 @@ void CFrame::Save() // Update the local vector SaveLocal(); - /**/ + /* ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); Console->Log(LogTypes::LCUSTOM, StringFromFormat( "Saved: %s (%i panes, %i NBs)\n", Perspectives.at(ActivePerspective).Name.c_str(), m_Mgr->GetAllPanes().GetCount(), GetNotebookCount()).c_str()); - + */ TogglePaneStyle(m_ToolBarAui->GetToolToggled(IDM_EDIT_PERSPECTIVES)); } diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index a6e69e2e7b..186f06968e 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -46,8 +46,7 @@ class CFrame : public wxFrame { public: - CFrame(bool showLogWindow, - wxFrame* parent, + CFrame(wxFrame* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Dolphin"), const wxPoint& pos = wxDefaultPosition, @@ -163,7 +162,6 @@ class CFrame : public wxFrame CGameListCtrl* m_GameListCtrl; wxPanel* m_Panel; wxToolBarToolBase* m_ToolPlay; - bool m_bLogWindow; CLogWindow* m_LogWindow; char **drives; diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index e8205aab37..6aca0a745f 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -199,7 +199,7 @@ void CFrame::CreateMenu() viewMenu->AppendCheckItem(IDM_TOGGLE_STATUSBAR, _T("Show &Statusbar")); viewMenu->Check(IDM_TOGGLE_STATUSBAR, SConfig::GetInstance().m_InterfaceStatusbar); viewMenu->AppendCheckItem(IDM_LOGWINDOW, _T("Show &Logwindow")); - viewMenu->Check(IDM_LOGWINDOW, m_bLogWindow); + viewMenu->Check(IDM_LOGWINDOW, SConfig::GetInstance().m_InterfaceLogWindow); viewMenu->AppendCheckItem(IDM_CONSOLEWINDOW, _T("Show &Console")); viewMenu->Check(IDM_CONSOLEWINDOW, SConfig::GetInstance().m_InterfaceConsole); viewMenu->AppendSeparator(); @@ -703,6 +703,11 @@ void CFrame::OnToolBar(wxCommandEvent& event) switch (event.GetId()) { case IDM_SAVE_PERSPECTIVE: + if (Perspectives.size() == 0) + { + wxMessageBox(wxT("Please create a perspective before saving"), wxT("Notice"), wxOK, this); + return; + } Save(); break; case IDM_PERSPECTIVES_ADD_PANE: @@ -1329,11 +1334,11 @@ void CFrame::OnToggleStatusbar(wxCommandEvent& event) // Enable and disable the log window void CFrame::OnToggleLogWindow(wxCommandEvent& event) { + SConfig::GetInstance().m_InterfaceLogWindow = event.IsChecked(); DoToggleWindow(event.GetId(), event.IsChecked()); } void CFrame::ToggleLogWindow(bool Show, int i) -{ - SConfig::GetInstance().m_InterfaceLogWindow = Show; +{ if (Show) { if (!m_LogWindow) m_LogWindow = new CLogWindow(this); @@ -1361,12 +1366,12 @@ void CFrame::ToggleLogWindow(bool Show, int i) // Enable and disable the console void CFrame::OnToggleConsole(wxCommandEvent& event) { + SConfig::GetInstance().m_InterfaceConsole = event.IsChecked(); DoToggleWindow(event.GetId(), event.IsChecked()); } void CFrame::ToggleConsole(bool Show, int i) { - ConsoleListener *Console = LogManager::GetInstance()->getConsoleListener(); - SConfig::GetInstance().m_InterfaceConsole = Show; + ConsoleListener *Console = LogManager::GetInstance()->getConsoleListener(); if (Show) { diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index 24a35f6290..74f198e409 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -89,7 +89,6 @@ bool DolphinApp::OnInit() NOTICE_LOG(BOOT, "Starting application"); // Declarations and definitions bool UseDebugger = false; - bool UseLogger = false; bool LoadElf = false; wxString ElfFile; @@ -198,9 +197,6 @@ bool DolphinApp::OnInit() { wxCMD_LINE_SWITCH, _T("d"), _T("debugger"), _T("Opens the debugger") }, - { - wxCMD_LINE_SWITCH, _T("l"), _T("logger"), _T("Opens The Logger") - }, { wxCMD_LINE_OPTION, _T("e"), _T("elf"), _T("Loads an elf file"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL @@ -262,7 +258,6 @@ bool DolphinApp::OnInit() } UseDebugger = parser.Found(_T("debugger")); - UseLogger = parser.Found(_T("logger")); LoadElf = parser.Found(_T("elf"), &ElfFile); if( LoadElf && ElfFile == wxEmptyString ) @@ -297,12 +292,12 @@ bool DolphinApp::OnInit() if (UseDebugger) { - main_frame = new CFrame(UseLogger, (wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title), + main_frame = new CFrame((wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title), wxPoint(x, y), wxSize(w, h), true); } else { - main_frame = new CFrame(UseLogger, (wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title), + main_frame = new CFrame((wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title), wxPoint(100, 100), wxSize(800, 600)); }