diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.cpp b/Source/Core/DebuggerWX/Src/CodeWindow.cpp index 02a5ad5d83..6421662c08 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindow.cpp @@ -441,8 +441,9 @@ void CCodeWindow::Load() ini.Get("ShowOnStart", "JIT", &bJitWindow, false); ini.Get("ShowOnStart", "Sound", &bSoundWindow, false); ini.Get("ShowOnStart", "Video", &bVideoWindow, false); - + // Get notebook affiliation ini.Get("Notebook", "Log", &iLogWindow, 1); + ini.Get("Notebook", "Console", &iConsoleWindow, 1); ini.Get("Notebook", "Code", &iCodeWindow, 1); ini.Get("Notebook", "Registers", &iRegisterWindow, 1); ini.Get("Notebook", "Breakpoints", &iBreakpointWindow, 0); @@ -450,8 +451,9 @@ void CCodeWindow::Load() ini.Get("Notebook", "JIT", &iJitWindow, 1); ini.Get("Notebook", "Sound", &iSoundWindow, 0); ini.Get("Notebook", "Video", &iVideoWindow, 0); - // Remove bad values + iLogWindow = Limit(iLogWindow, 0, Parent->m_NB.size()-1); + iConsoleWindow = Limit(iConsoleWindow, 0, Parent->m_NB.size()-1); iCodeWindow = Limit(iCodeWindow, 0, Parent->m_NB.size()-1); iRegisterWindow = Limit(iRegisterWindow, 0, Parent->m_NB.size()-1); iBreakpointWindow = Limit(iBreakpointWindow, 0, Parent->m_NB.size()-1); @@ -485,6 +487,7 @@ void CCodeWindow::Save() ini.Set("ShowOnStart", "Video", GetMenuBar()->IsChecked(IDM_VIDEOWINDOW)); ini.Set("Notebook", "Log", iLogWindow); + ini.Set("Notebook", "Console", iConsoleWindow); ini.Set("Notebook", "Code", iCodeWindow); ini.Set("Notebook", "Registers", iRegisterWindow); ini.Set("Notebook", "Breakpoints", iBreakpointWindow); diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.h b/Source/Core/DebuggerWX/Src/CodeWindow.h index cbb9497810..ead86617db 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.h +++ b/Source/Core/DebuggerWX/Src/CodeWindow.h @@ -63,8 +63,6 @@ class CCodeWindow CFrame *Parent; wxMenuBar * GetMenuBar(); wxAuiToolBar * GetToolBar(); - wxWindow * GetWxWindow(wxString); - wxWindow * GetNootebookPage(wxString); int Limit(int,int,int); int GetNootebookAffiliation(wxString); wxBitmap m_Bitmaps[ToolbarDebugBitmapMax]; @@ -105,6 +103,7 @@ class CCodeWindow // Settings bool bAutomaticStart; bool bBootToPause; bool bLogWindow; bool iLogWindow; + bool bConsoleWindow; bool iConsoleWindow; bool bCodeWindow; int iCodeWindow; bool bRegisterWindow; int iRegisterWindow; bool bBreakpointWindow; int iBreakpointWindow; diff --git a/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp b/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp index cb8e90d8e5..940310b3cd 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp @@ -325,46 +325,6 @@ void CCodeWindow::OnChangeFont(wxCommandEvent& event) ///////////////////////////////////////////////////////////////////////////////////////////////////////// // Toogle windows // ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ -wxWindow * CCodeWindow::GetNootebookPage(wxString Name) -{ - for (int i = 0; i < Parent->m_NB.size(); i++) - { - if (!Parent->m_NB[i]) return NULL; - for(u32 j = 0; j <= Parent->m_NB[j]->GetPageCount(); j++) - { - if (Parent->m_NB[i]->GetPageText(j).IsSameAs(Name)) return Parent->m_NB[i]->GetPage(j); - } - } - return NULL; -} -wxWindow * CCodeWindow::GetWxWindow(wxString Name) -{ - #ifdef _WIN32 - HWND hWnd = ::FindWindow(NULL, Name.c_str()); - if (hWnd) - { - wxWindow * Win = new wxWindow(); - Win->SetHWND((WXHWND)hWnd); - Win->AdoptAttributesFromHWND(); - return Win; - } - else - #endif - if (Parent->FindWindowByName(Name)) - { - return Parent->FindWindowByName(Name); - } - else if (Parent->FindWindowByLabel(Name)) - { - return Parent->FindWindowByLabel(Name); - } - else if (GetNootebookPage(Name)) - { - return GetNootebookPage(Name); - } - else - return NULL; -} int CCodeWindow::Limit(int i, int Low, int High) { if (i < Low) return Low; @@ -450,7 +410,7 @@ void CCodeWindow::OnToggleSoundWindow(bool Show, int i) { if (i < 0 || i > Parent->m_NB.size()-1) return; #ifdef _WIN32 - wxWindow *Win = GetWxWindow(wxT("Sound")); + wxWindow *Win = Parent->GetWxWindow(wxT("Sound")); if (Win && Parent->m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; { @@ -465,7 +425,7 @@ void CCodeWindow::OnToggleSoundWindow(bool Show, int i) #ifdef _WIN32 } - Win = GetWxWindow(wxT("Sound")); + Win = Parent->GetWxWindow(wxT("Sound")); if (Win) { //Console->Log(LogTypes::LNOTICE, StringFromFormat("AddPage\n").c_str()); @@ -476,7 +436,7 @@ void CCodeWindow::OnToggleSoundWindow(bool Show, int i) else // hide { #ifdef _WIN32 - wxWindow *Win = GetWxWindow(wxT("Sound")); + wxWindow *Win = Parent->GetWxWindow(wxT("Sound")); Parent->DoRemovePage (Win, false); #endif // Close the sound dll that has an open debugger @@ -497,7 +457,7 @@ void CCodeWindow::OnToggleVideoWindow(bool Show, int i) { if (i < 0 || i > Parent->m_NB.size()-1) return; #ifdef _WIN32 - wxWindow *Win = GetWxWindow(wxT("Video")); + wxWindow *Win = Parent->GetWxWindow(wxT("Video")); if (Win && Parent->m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; { @@ -511,14 +471,14 @@ void CCodeWindow::OnToggleVideoWindow(bool Show, int i) #ifdef _WIN32 } - Win = GetWxWindow(wxT("Video")); + Win = Parent->GetWxWindow(wxT("Video")); if (Win) Parent->m_NB[i]->AddPage(Win, wxT("Video"), true, Parent->aNormalFile ); #endif } else // hide { #ifdef _WIN32 - wxWindow *Win = GetWxWindow(wxT("Video")); + wxWindow *Win = Parent->GetWxWindow(wxT("Video")); Parent->DoRemovePage (Win, false); #endif // Close the video dll that has an open debugger diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index fd9ea97673..d6ffe95645 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -265,7 +265,7 @@ EVT_MENU(IDM_TOGGLE_SKIPIDLE, CFrame::OnToggleSkipIdle) EVT_MENU(IDM_TOGGLE_TOOLBAR, CFrame::OnToggleToolbar) EVT_MENU(IDM_TOGGLE_STATUSBAR, CFrame::OnToggleStatusbar) EVT_MENU(IDM_LOGWINDOW, CFrame::OnToggleLogWindow) -EVT_MENU(IDM_CONSOLE, CFrame::OnToggleConsole) +EVT_MENU(IDM_CONSOLEWINDOW, CFrame::OnToggleConsole) EVT_MENU(IDM_LISTDRIVES, CFrame::GameListChanged) EVT_MENU(IDM_LISTWII, CFrame::GameListChanged) @@ -490,7 +490,7 @@ CFrame::CFrame(bool showLogWindow, m_Mgr->GetPane(wxT("Pane3")).CaptionVisible(true); */ - // Show window + // Show window Show(); // Create list of available plugins for the configuration window @@ -499,6 +499,7 @@ CFrame::CFrame(bool showLogWindow, // Open notebook pages if (UseDebugger) g_pCodeWindow->OpenPages(); if (m_bLogWindow) ToggleLogWindow(true, UseDebugger ? 1 : 0); + if (SConfig::GetInstance().m_InterfaceConsole) ToggleConsole(true, UseDebugger ? 1 : 0); if (!UseDebugger) SetSimplePaneSize(); //if we are ever going back to optional iso caching: diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index f0273fb9f9..0c16689537 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -105,12 +105,18 @@ class CFrame : public wxFrame // Perspectives wxString AuiFullscreen, AuiCurrent; wxArrayString AuiPerspective; + wxWindow * GetWxWindow(wxString); + #ifdef _WIN32 + wxWindow * GetWxWindowHwnd(HWND); + #endif + wxWindow * GetNootebookPage(wxString); void OnNotebookPageClose(wxAuiNotebookEvent& event); void OnAllowNotebookDnD(wxAuiNotebookEvent& event); void OnNotebookPageChanged(wxAuiNotebookEvent& event); int GetNootebookAffiliation(wxString Name); void DoToggleWindow(int,bool); void DoRemovePage(wxWindow *, bool Hide = true); + void DoRemovePageString(wxString, bool Hide = true); void DoLoadPerspective(int); void HidePane(); void SetSimplePaneSize(); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index f3751972fc..a7d99d60d6 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -202,8 +202,8 @@ void CFrame::CreateMenu() viewMenu->Check(IDM_TOGGLE_STATUSBAR, SConfig::GetInstance().m_InterfaceStatusbar); viewMenu->AppendCheckItem(IDM_LOGWINDOW, _T("Show &Logwindow")); viewMenu->Check(IDM_LOGWINDOW, m_bLogWindow); - viewMenu->AppendCheckItem(IDM_CONSOLE, _T("Show &Console")); - viewMenu->Check(IDM_CONSOLE, SConfig::GetInstance().m_InterfaceConsole); + viewMenu->AppendCheckItem(IDM_CONSOLEWINDOW, _T("Show &Console")); + viewMenu->Check(IDM_CONSOLEWINDOW, SConfig::GetInstance().m_InterfaceConsole); viewMenu->AppendSeparator(); viewMenu->AppendCheckItem(IDM_LISTWII, _T("Show Wii")); @@ -880,6 +880,55 @@ void CFrame::OnFrameSkip(wxCommandEvent& event) ///////////////////////////////////////////////////////////////////////////////////////////////////////// // Notebooks // ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +wxWindow * CFrame::GetNootebookPage(wxString Name) +{ + for (int i = 0; i < m_NB.size(); i++) + { + if (!m_NB[i]) return NULL; + for(u32 j = 0; j <= m_NB[j]->GetPageCount(); j++) + { + if (m_NB[i]->GetPageText(j).IsSameAs(Name)) return m_NB[i]->GetPage(j); + } + } + return NULL; +} +#ifdef _WIN32 +wxWindow * CFrame::GetWxWindowHwnd(HWND hWnd) +{ + wxWindow * Win = new wxWindow(); + Win->SetHWND((WXHWND)hWnd); + Win->AdoptAttributesFromHWND(); + return Win; +} +#endif +wxWindow * CFrame::GetWxWindow(wxString Name) +{ + #ifdef _WIN32 + HWND hWnd = ::FindWindow(NULL, Name.c_str()); + if (hWnd) + { + wxWindow * Win = new wxWindow(); + Win->SetHWND((WXHWND)hWnd); + Win->AdoptAttributesFromHWND(); + return Win; + } + else + #endif + if (FindWindowByName(Name)) + { + return FindWindowByName(Name); + } + else if (FindWindowByLabel(Name)) + { + return FindWindowByLabel(Name); + } + else if (GetNootebookPage(Name)) + { + return GetNootebookPage(Name); + } + else + return NULL; +} int CFrame::GetNootebookAffiliation(wxString Name) { for (int i = 0; i < m_NB.size(); i++) @@ -897,6 +946,7 @@ void CFrame::DoToggleWindow(int Id, bool Show) switch (Id) { case IDM_LOGWINDOW: ToggleLogWindow(Show, UseDebugger ? g_pCodeWindow->iLogWindow : 0); break; + case IDM_CONSOLEWINDOW: ToggleConsole(Show, UseDebugger ? g_pCodeWindow->iConsoleWindow : 0); break; case IDM_REGISTERWINDOW: g_pCodeWindow->OnToggleRegisterWindow(Show, g_pCodeWindow->iRegisterWindow); break; case IDM_BREAKPOINTWINDOW: g_pCodeWindow->OnToggleBreakPointWindow(Show, g_pCodeWindow->iBreakpointWindow); break; case IDM_MEMORYWINDOW: g_pCodeWindow->OnToggleMemoryWindow(Show, g_pCodeWindow->iMemoryWindow); break; @@ -908,8 +958,11 @@ void CFrame::DoToggleWindow(int Id, bool Show) void CFrame::OnNotebookPageChanged(wxAuiNotebookEvent& event) { event.Skip(); + if (!UseDebugger) return; + // Update the notebook affiliation if(GetNootebookAffiliation(wxT("Log")) >= 0) g_pCodeWindow->iLogWindow = GetNootebookAffiliation(wxT("Log")); + if(GetNootebookAffiliation(wxT("Console")) >= 0) g_pCodeWindow->iLogWindow = GetNootebookAffiliation(wxT("Console")); if(GetNootebookAffiliation(wxT("Code")) >= 0) g_pCodeWindow->iCodeWindow = GetNootebookAffiliation(wxT("Code")); if(GetNootebookAffiliation(wxT("Registers")) >= 0) g_pCodeWindow->iRegisterWindow = GetNootebookAffiliation(wxT("Registers")); if(GetNootebookAffiliation(wxT("Breakpoints")) >= 0) g_pCodeWindow->iBreakpointWindow = GetNootebookAffiliation(wxT("Breakpoints")); @@ -926,6 +979,7 @@ void CFrame::OnNotebookPageClose(wxAuiNotebookEvent& event) wxAuiNotebook* Ctrl = (wxAuiNotebook*)event.GetEventObject(); if (Ctrl->GetPageText(event.GetSelection()).IsSameAs(wxT("Log"))) { GetMenuBar()->FindItem(IDM_LOGWINDOW)->Check(false); DoToggleWindow(IDM_LOGWINDOW, false); } + if (Ctrl->GetPageText(event.GetSelection()).IsSameAs(wxT("Console"))) { GetMenuBar()->FindItem(IDM_CONSOLEWINDOW)->Check(false); DoToggleWindow(IDM_CONSOLEWINDOW, false); } if (Ctrl->GetPageText(event.GetSelection()).IsSameAs(wxT("Registers"))) { GetMenuBar()->FindItem(IDM_REGISTERWINDOW)->Check(false); DoToggleWindow(IDM_REGISTERWINDOW, false); } if (Ctrl->GetPageText(event.GetSelection()).IsSameAs(wxT("Breakpoints"))) { GetMenuBar()->FindItem(IDM_BREAKPOINTWINDOW)->Check(false); DoToggleWindow(IDM_BREAKPOINTWINDOW, false); } if (Ctrl->GetPageText(event.GetSelection()).IsSameAs(wxT("JIT"))) { GetMenuBar()->FindItem(IDM_JITWINDOW)->Check(false); DoToggleWindow(IDM_JITWINDOW, false); } @@ -950,7 +1004,21 @@ void CFrame::HidePane() SetSimplePaneSize(); } - +void CFrame::DoRemovePageString(wxString Str, bool Hide) +{ + for (int i = 0; i < m_NB.size(); i++) + { + if (m_NB[i]) + { + for (int j = 0; j < m_NB[i]->GetPageCount(); j++) + { + if (m_NB[i]->GetPageText(j).IsSameAs(Str)) { m_NB[i]->RemovePage(j); break; } + ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); + } + } + } + //if (Hide) Win->Hide(); +} void CFrame::DoRemovePage(wxWindow * Win, bool Hide) { // If m_dialog is NULL, then possibly the system @@ -1036,23 +1104,61 @@ void CFrame::ToggleLogWindow(bool Show, int i) // Enable and disable the console void CFrame::OnToggleConsole(wxCommandEvent& event) { - ToggleConsole(event.IsChecked()); + DoToggleWindow(event.GetId(), event.IsChecked()); + //ToggleConsole(event.IsChecked()); } void CFrame::ToggleConsole(bool Show, int i) { ConsoleListener *Console = LogManager::GetInstance()->getConsoleListener(); SConfig::GetInstance().m_InterfaceConsole = Show; - if (SConfig::GetInstance().m_InterfaceConsole) + + if (Show) + { + if (i < 0 || i > m_NB.size()-1) return; + #ifdef _WIN32 + wxWindow *Win = GetWxWindowHwnd(GetConsoleWindow()); + if (Win && m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; + { + #else Console->Open(); - else + #endif + + if(!GetConsoleWindow()) Console->Open(); + + #ifdef _WIN32 + } + Win = GetWxWindowHwnd(GetConsoleWindow()); + // Can we remove the border? + //Win->SetWindowStyleFlag(wxNO_BORDER); + //SetWindowLong(GetConsoleWindow(), GWL_STYLE, WS_VISIBLE); + if (Win) m_NB[i]->AddPage(Win, wxT("Console"), true, aNormalFile ); + #endif + } + else // hide + { + #ifdef _WIN32 + //wxWindow *Win = GetWxWindowHwnd(GetConsoleWindow()); + //DoRemovePage (Win, true); + DoRemovePageString(wxT("Console"), true); + #else Console->Close(); + #endif + //if(GetConsoleWindow()) + Console->Log(LogTypes::LNOTICE, StringFromFormat( + "close\n").c_str()); + Console->Close(); + } + + // Hide pane + if (!UseDebugger) HidePane(); // Make sure the check is updated (if wxw isn't calling this func) - GetMenuBar()->FindItem(IDM_CONSOLE)->Check(Show); + //GetMenuBar()->FindItem(IDM_CONSOLEWINDOW)->Check(Show); } ///////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////// // GUI // ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h index 238c8a5efc..f559ab0046 100644 --- a/Source/Core/DolphinWX/Src/Globals.h +++ b/Source/Core/DolphinWX/Src/Globals.h @@ -133,7 +133,7 @@ enum // Views IDM_FONTPICKER, IDM_LOGWINDOW, - IDM_CONSOLE, + IDM_CONSOLEWINDOW, IDM_CODEWINDOW, IDM_REGISTERWINDOW, IDM_BREAKPOINTWINDOW, diff --git a/Source/Core/DolphinWX/Src/LogWindow.cpp b/Source/Core/DolphinWX/Src/LogWindow.cpp index e61a4bd53d..2235f0db3e 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.cpp +++ b/Source/Core/DolphinWX/Src/LogWindow.cpp @@ -81,7 +81,7 @@ void CLogWindow::CreateGUIControls() m_writeConsoleCB = new wxCheckBox(this, IDM_WRITECONSOLE, wxT("Write to Console"), wxDefaultPosition, wxDefaultSize, 0); sbLeftOptions->Add(m_writeConsoleCB); - m_writeWindowCB = new wxCheckBox(this, IDM_WRITEWINDOW, wxT("Write to window ->"), wxDefaultPosition, wxDefaultSize, 0); + m_writeWindowCB = new wxCheckBox(this, IDM_WRITEWINDOW, wxT("Write to Window ->"), wxDefaultPosition, wxDefaultSize, 0); sbLeftOptions->Add(m_writeWindowCB); sLeft->Add(sbLeftOptions, 0, wxEXPAND);