nakee's new logmanager. added a console window for windows builds (prints to parent console on non-win32). also fix some random wxw bugs: main window's position is saved when using debugger, disabling windows from the tools menu are saved settings, some other small fixes

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2675 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman
2009-03-18 17:17:58 +00:00
parent 03ba466b5b
commit 2301d072a6
120 changed files with 1758 additions and 1103 deletions

View File

@ -1051,6 +1051,14 @@
RelativePath=".\Src\FrameWiimote.cpp"
>
</File>
<File
RelativePath=".\src\LogWindow.cpp"
>
</File>
<File
RelativePath=".\src\LogWindow.h"
>
</File>
<File
RelativePath=".\src\GameListCtrl.cpp"
>

View File

@ -21,7 +21,6 @@
#include "Core.h" // Core
#include "HW/EXI.h"
#include "HW/SI.h"
#include "ConsoleWindow.h"
#include "Globals.h" // Local
#include "ConfigMain.h"
@ -875,7 +874,7 @@ void CConfigMain::OnConfig(wxCommandEvent& event)
void CConfigMain::CallConfig(wxChoice* _pChoice)
{
int Index = _pChoice->GetSelection();
Console::Print("CallConfig: %i\n", Index);
INFO_LOG(CONSOLE, "CallConfig: %i\n", Index);
if (Index >= 0)
{
@ -888,7 +887,7 @@ void CConfigMain::CallConfig(wxChoice* _pChoice)
void CConfigMain::FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std::string& _SelectFilename)
{
Console::Print("FillChoiceBox\n");
INFO_LOG(CONSOLE, "FillChoiceBox\n");
_pChoice->Clear();
@ -924,7 +923,7 @@ bool CConfigMain::GetFilename(wxChoice* _pChoice, std::string& _rFilename)
{
const CPluginInfo* pInfo = static_cast<CPluginInfo*>(_pChoice->GetClientData(Index));
_rFilename = pInfo->GetFilename();
Console::Print("GetFilename: %i %s\n", Index, _rFilename.c_str());
INFO_LOG(CONSOLE, "GetFilename: %i %s\n", Index, _rFilename.c_str());
return(true);
}

View File

@ -48,7 +48,6 @@ be accessed from Core::GetWindowHandle().
#include "FileUtil.h"
#include "Timer.h"
#include "Setup.h"
#include "ConsoleWindow.h"
#include "ConfigManager.h" // Core
#include "Core.h"
@ -190,7 +189,7 @@ int abc = 0;
case WIIMOTE_RECONNECT:
// The Wiimote plugin has been shut down, now reconnect the Wiimote
//Console::Print("WIIMOTE_RECONNECT\n");
//INFO_LOG(CONSOLE, "WIIMOTE_RECONNECT\n");
Core::ReconnectWiimote();
return 0;
@ -210,7 +209,7 @@ int abc = 0;
case OPENGL_VIDEO_STOP:
// The Video thread has been shut down
Core::VideoThreadEnd();
//Console::Print("OPENGL_VIDEO_STOP\n");
//INFO_LOG(CONSOLE, "OPENGL_VIDEO_STOP\n");
return 0;
#endif
// -----------------------------
@ -273,6 +272,7 @@ EVT_MENU(IDM_TOGGLE_FULLSCREEN, CFrame::OnToggleFullscreen)
EVT_MENU(IDM_TOGGLE_DUALCORE, CFrame::OnToggleDualCore)
EVT_MENU(IDM_TOGGLE_SKIPIDLE, CFrame::OnToggleSkipIdle)
EVT_MENU(IDM_TOGGLE_TOOLBAR, CFrame::OnToggleToolbar)
EVT_MENU(IDM_TOGGLE_LOGWINDOW, CFrame::OnToggleLogWindow)
EVT_MENU(IDM_TOGGLE_STATUSBAR, CFrame::OnToggleStatusbar)
EVT_MENU_RANGE(IDM_LOADSLOT1, IDM_LOADSLOT10, CFrame::OnLoadState)
@ -293,13 +293,15 @@ END_EVENT_TABLE()
// Creation and close, quit functions
// ----------------------------------------------------------------------------
CFrame::CFrame(wxFrame* parent,
CFrame::CFrame(bool showLogWindow,
wxFrame* parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style)
: wxFrame(parent, id, title, pos, size, style)
, m_bLogWindow(showLogWindow || SConfig::GetInstance().m_InterfaceLogWindow)
, m_pStatusBar(NULL), bRenderToMain(true)
, HaveLeds(false), HaveSpeakers(false)
, m_Panel(NULL)
@ -326,6 +328,8 @@ CFrame::CFrame(wxFrame* parent,
// Give it a status bar
m_pStatusBar = CreateStatusBar(1, wxST_SIZEGRIP, ID_STATUSBAR);
if (!SConfig::GetInstance().m_InterfaceStatusbar)
m_pStatusBar->Hide();
// Give it a menu bar
CreateMenu();
@ -334,6 +338,10 @@ CFrame::CFrame(wxFrame* parent,
//m_Panel = new wxPanel(this, IDM_MPANEL);
m_Panel = new CPanel(this, IDM_MPANEL);
m_LogWindow = new CLogWindow(this);
if (m_bLogWindow)
m_LogWindow->Show();
m_GameListCtrl = new CGameListCtrl(m_Panel, LIST_CTRL,
wxDefaultPosition, wxDefaultSize,
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT);
@ -348,6 +356,8 @@ CFrame::CFrame(wxFrame* parent,
// Create the toolbar
RecreateToolbar();
if (!SConfig::GetInstance().m_InterfaceToolbar)
TheToolBar->Hide();
FitInside();

View File

@ -27,6 +27,7 @@
#include <wx/mstream.h>
////////////////////////////////
#include "CDUtils.h"
#include "LogWindow.h"
//////////////////////////////////////////////////////////////////////////
// A shortcut to access the bitmaps
@ -48,7 +49,8 @@ class CFrame : public wxFrame
{
public:
CFrame(wxFrame* parent,
CFrame(bool showLogWindow,
wxFrame* parent,
wxWindowID id = wxID_ANY,
const wxString& title = wxT("Dolphin"),
const wxPoint& pos = wxDefaultPosition,
@ -98,6 +100,8 @@ class CFrame : public wxFrame
wxPanel* m_Panel;
wxToolBar* TheToolBar;
wxToolBarToolBase* m_ToolPlay;
bool m_bLogWindow;
CLogWindow* m_LogWindow;
char **drives;
@ -199,6 +203,7 @@ class CFrame : public wxFrame
void OnToggleThrottle(wxCommandEvent& event);
void OnResize(wxSizeEvent& event);
void OnToggleToolbar(wxCommandEvent& event);
void OnToggleLogWindow(wxCommandEvent& event);
void OnToggleStatusbar(wxCommandEvent& event);
void OnKeyDown(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event);
void OnDoubleClick(wxMouseEvent& event); void OnMotion(wxMouseEvent& event);

View File

@ -44,11 +44,11 @@ be accessed from Core::GetWindowHandle().
#include "GameListCtrl.h"
#include "BootManager.h"
#include "SDCardWindow.h"
#include "LogWindow.h"
#include "Common.h" // Common
#include "FileUtil.h"
#include "Timer.h"
#include "ConsoleWindow.h"
#include "Setup.h"
#include "ConfigManager.h" // Core
@ -153,9 +153,11 @@ void CFrame::CreateMenu()
// Tools menu
wxMenu* toolsMenu = new wxMenu;
toolsMenu->AppendCheckItem(IDM_TOGGLE_TOOLBAR, _T("View &Toolbar"));
toolsMenu->Check(IDM_TOGGLE_TOOLBAR, true);
toolsMenu->Check(IDM_TOGGLE_TOOLBAR, SConfig::GetInstance().m_InterfaceToolbar);
toolsMenu->AppendCheckItem(IDM_TOGGLE_STATUSBAR, _T("View &Statusbar"));
toolsMenu->Check(IDM_TOGGLE_STATUSBAR, true);
toolsMenu->Check(IDM_TOGGLE_STATUSBAR, SConfig::GetInstance().m_InterfaceStatusbar);
toolsMenu->AppendCheckItem(IDM_TOGGLE_LOGWINDOW, _T("View &Logwindow"));
toolsMenu->Check(IDM_TOGGLE_LOGWINDOW, m_bLogWindow);
toolsMenu->AppendSeparator();
toolsMenu->Append(IDM_MEMCARD, _T("&Memcard Manager"));
toolsMenu->Append(IDM_CHEATS, _T("Action &Replay Manager"));
@ -350,7 +352,8 @@ void CFrame::InitBitmaps()
//////////////////////////
// Update in case the bitmap has been updated
if (GetToolBar() != NULL) RecreateToolbar();
if (GetToolBar() != NULL)
RecreateToolbar();
}
@ -733,7 +736,7 @@ void CFrame::OnToggleToolbar(wxCommandEvent& event)
{
wxToolBarBase* toolBar = GetToolBar();
if (event.IsChecked())
if (SConfig::GetInstance().m_InterfaceToolbar = event.IsChecked() == true)
{
CFrame::RecreateToolbar();
}
@ -749,7 +752,7 @@ void CFrame::OnToggleToolbar(wxCommandEvent& event)
// Let us enable and disable the status bar
void CFrame::OnToggleStatusbar(wxCommandEvent& event)
{
if (event.IsChecked())
if (SConfig::GetInstance().m_InterfaceStatusbar = event.IsChecked() == true)
m_pStatusBar->Show();
else
m_pStatusBar->Hide();
@ -757,6 +760,17 @@ void CFrame::OnToggleStatusbar(wxCommandEvent& event)
this->SendSizeEvent();
}
// Let us enable and disable the log window
void CFrame::OnToggleLogWindow(wxCommandEvent& event)
{
if (SConfig::GetInstance().m_InterfaceLogWindow = event.IsChecked() == true)
m_LogWindow->Show();
else
m_LogWindow->Hide();
this->SendSizeEvent();
}
// Update the enabled/disabled status
void CFrame::UpdateGUI()
@ -815,7 +829,8 @@ void CFrame::UpdateGUI()
m_pMenuItemPlay->SetText(_("&Play"));
}
if (GetToolBar() != NULL) GetToolBar()->Realize();
if (GetToolBar() != NULL)
GetToolBar()->Realize();
if (!initialized)

View File

@ -23,7 +23,6 @@
#include "Frame.h"
#include "FileUtil.h"
#include "StringUtil.h"
#include "ConsoleWindow.h"
#include "GameListCtrl.h"
#include "BootManager.h"
@ -414,7 +413,7 @@ void CFrame::DoMoveIcons()
for (int i = 0; i < 4; i++) m_StatBmp[i]->Hide();
else // if(!m_StatBmp[0]->IsShown())
for (int i = 0; i < 4; i++) m_StatBmp[i]->Show();
//Console::Print("LED: %i ", Rect.GetWidth());
//INFO_LOG(CONSOLE, "LED: %i ", Rect.GetWidth());
}
// If there is not room for the speaker icons hide them
@ -430,7 +429,7 @@ void CFrame::DoMoveIcons()
for(int i = 0; i < 3; i++) m_StatBmp[i + 4]->Hide();
else // if(!m_StatBmp[4]->IsShown())
for (int i = 0; i < 3; i++) m_StatBmp[i + 4]->Show();
//Console::Print("Speaker: %i\n", Rect.GetWidth());
//INFO_LOG(CONSOLE, "Speaker: %i\n", Rect.GetWidth());
}
}

View File

@ -183,7 +183,7 @@ void CGameListCtrl::Update()
SetColumnWidth(COLUMN_COMPANY, 100);
SetColumnWidth(COLUMN_NOTES, 150);
SetColumnWidth(COLUMN_COUNTRY, 32);
SetColumnWidth(COLUMN_EMULATION_STATE, 150);
SetColumnWidth(COLUMN_EMULATION_STATE, 130);
// add all items
for (int i = 0; i < (int)m_ISOFiles.size(); i++)
@ -883,10 +883,15 @@ void CGameListCtrl::AutomaticColumnWidth()
}
else if (GetColumnCount() > 4)
{
int resizable = rc.GetWidth() - (213 + GetColumnWidth(COLUMN_SIZE));
int resizable = rc.GetWidth() - (
GetColumnWidth(COLUMN_BANNER)
+ GetColumnWidth(COLUMN_COUNTRY)
+ GetColumnWidth(COLUMN_SIZE)
+ GetColumnWidth(COLUMN_EMULATION_STATE)
+ 5); // some pad to keep the horizontal scrollbar away :)
SetColumnWidth(COLUMN_TITLE, wxMax(0.3*resizable, 100));
SetColumnWidth(COLUMN_COMPANY, wxMax(0.2*resizable, 100));
SetColumnWidth(COLUMN_COMPANY, wxMax(0.2*resizable, 90));
SetColumnWidth(COLUMN_NOTES, wxMax(0.5*resizable, 100));
}
}

View File

@ -85,6 +85,7 @@ enum
IDM_TOGGLE_DUALCORE, // Other
IDM_TOGGLE_SKIPIDLE,
IDM_TOGGLE_TOOLBAR,
IDM_TOGGLE_LOGWINDOW,
IDM_TOGGLE_STATUSBAR,
IDM_NOTIFYMAPLOADED,
IDM_OPENCONTAININGFOLDER,

View File

@ -0,0 +1,360 @@
// Copyright (C) 2003-2009 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include <wx/wx.h>
#include <wx/button.h>
#include <wx/textctrl.h>
#include <wx/listbox.h>
#include <wx/checklst.h>
#include "Core.h" // for Core::GetState()
#include "LogWindow.h"
#include "Console.h"
#define UPDATETIME 1000
BEGIN_EVENT_TABLE(CLogWindow, wxDialog)
EVT_BUTTON(IDM_SUBMITCMD, CLogWindow::OnSubmit)
EVT_BUTTON(IDM_CLEARLOG, CLogWindow::OnClear)
EVT_BUTTON(IDM_TOGGLEALL, CLogWindow::OnToggleAll)
EVT_RADIOBOX(IDM_VERBOSITY, CLogWindow::OnOptionsCheck)
EVT_CHECKBOX(IDM_WRITEFILE, CLogWindow::OnOptionsCheck)
EVT_CHECKBOX(IDM_WRITECONSOLE, CLogWindow::OnOptionsCheck)
EVT_CHECKLISTBOX(IDM_LOGCHECKS, CLogWindow::OnLogCheck)
EVT_TIMER(IDTM_UPDATELOG, CLogWindow::OnLogTimer)
END_EVENT_TABLE()
CLogWindow::CLogWindow(wxWindow* parent)
: wxDialog(parent, wxID_ANY, wxT("Log/Console"),
wxPoint(100, 700), wxSize(800, 270),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
Listener("LogWindow")
{
m_logManager = LogManager::GetInstance();
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
m_logManager->addListener((LogTypes::LOG_TYPE)i, this);
m_fileLog = m_logManager->getFileListener();
m_console = m_logManager->getConsoleListener();
m_writeFile = true;
m_writeConsole = true;
CreateGUIControls();
LoadSettings();
}
void CLogWindow::CreateGUIControls()
{
wxBoxSizer* sUber = new wxBoxSizer(wxHORIZONTAL), // whole plane
* sLeft = new wxBoxSizer(wxVERTICAL), // LEFT sizer
* sRight = new wxBoxSizer(wxVERTICAL), // RIGHT sizer
* sRightBottom = new wxBoxSizer(wxHORIZONTAL); // submit row
// Left side: buttons (-submit), options, and log type selection
wxStaticBoxSizer* sbLeftOptions = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Options"));
wxArrayString wxLevels;
for (int i = 0; i < LOGLEVEL; ++i)
wxLevels.Add(wxString::Format(wxT("%i"), i));
m_verbosity = new wxRadioBox(this, IDM_VERBOSITY, wxT("Verbosity"), wxDefaultPosition, wxDefaultSize, wxLevels, 0, wxRA_SPECIFY_COLS, wxDefaultValidator);
sbLeftOptions->Add(m_verbosity);
m_writeFileCB = new wxCheckBox(this, IDM_WRITEFILE, wxT("Write to File"), wxDefaultPosition, wxDefaultSize, 0);
sbLeftOptions->Add(m_writeFileCB);
m_writeConsoleCB = new wxCheckBox(this, IDM_WRITECONSOLE, wxT("Write to Console"), wxDefaultPosition, wxDefaultSize, 0);
sbLeftOptions->Add(m_writeConsoleCB);
sLeft->Add(sbLeftOptions, 0, wxEXPAND);
wxBoxSizer* sLogCtrl = new wxBoxSizer(wxHORIZONTAL);
sLogCtrl->Add(new wxButton(this, IDM_TOGGLEALL, wxT("Toggle all"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT), 1);
sLogCtrl->Add(new wxButton(this, IDM_CLEARLOG, wxT("Clear"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT), 1);
sLeft->Add(sLogCtrl, 0, wxEXPAND);
m_checks = new wxCheckListBox(this, IDM_LOGCHECKS, wxDefaultPosition, wxDefaultSize);
sLeft->Add(m_checks, 1, wxEXPAND);
// Right side: Log viewer and submit row
m_log = new wxTextCtrl(this, IDM_LOG, wxEmptyString, wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
//m_log->SetFont(DebuggerFont);
m_cmdline = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition);
//m_cmdline->SetFont(DebuggerFont);
sRightBottom->Add(m_cmdline, 1, wxEXPAND);
sRightBottom->Add(new wxButton(this, IDM_SUBMITCMD, wxT("Submit"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT));
sRight->Add(m_log, 1, wxEXPAND | wxSHRINK);
sRight->Add(sRightBottom, 0, wxEXPAND);
// Take care of the main sizer and some settings
sUber->Add(sLeft, 0, wxEXPAND);
sUber->Add(sRight, 1, wxEXPAND);
SetSizer(sUber);
SetAffirmativeId(IDM_SUBMITCMD);
UpdateChecks();
m_cmdline->SetFocus();
m_logTimer = new wxTimer(this, IDTM_UPDATELOG);
m_logTimer->Start(UPDATETIME);
}
CLogWindow::~CLogWindow()
{
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
m_logManager->removeListener((LogTypes::LOG_TYPE)i, this);
}
m_logTimer->Stop();
delete m_logTimer;
SaveSettings();
}
void CLogWindow::SaveSettings()
{
IniFile ini;
ini.Set("LogWindow", "x", GetPosition().x);
ini.Set("LogWindow", "y", GetPosition().y);
ini.Set("LogWindow", "w", GetSize().GetWidth());
ini.Set("LogWindow", "h", GetSize().GetHeight());
ini.Set("Options", "Verbosity", m_verbosity->GetSelection());
ini.Set("Options", "WriteToFile", m_writeFile);
ini.Set("Options", "WriteToConsole", m_writeConsole);
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
ini.Set("Logs", m_logManager->getShortName((LogTypes::LOG_TYPE)i), m_checks->IsChecked(i));
ini.Save(LOGGER_CONFIG_FILE);
}
void CLogWindow::LoadSettings()
{
IniFile ini;
ini.Load(LOGGER_CONFIG_FILE);
int x,y,w,h,verbosity;
ini.Get("LogWindow", "x", &x, GetPosition().x);
ini.Get("LogWindow", "y", &y, GetPosition().y);
ini.Get("LogWindow", "w", &w, GetSize().GetWidth());
ini.Get("LogWindow", "h", &h, GetSize().GetHeight());
SetSize(x, y, w, h);
ini.Get("Options", "Verbosity", &verbosity, 2);
m_verbosity->SetSelection(verbosity);
ini.Get("Options", "WriteToFile", &m_writeFile, true);
m_writeFileCB->SetValue(m_writeFile);
ini.Get("Options", "WriteToConsole", &m_writeConsole, true);
m_writeConsoleCB->SetValue(m_writeConsole);
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
bool enable;
ini.Get("Logs", m_logManager->getShortName((LogTypes::LOG_TYPE)i), &enable, true);
if (enable)
m_logManager->addListener((LogTypes::LOG_TYPE)i, this);
else
m_logManager->removeListener((LogTypes::LOG_TYPE)i, this);
if (m_writeFile && enable)
m_logManager->addListener((LogTypes::LOG_TYPE)i, m_fileLog);
else
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog);
if (m_writeConsole && enable)
m_logManager->addListener((LogTypes::LOG_TYPE)i, m_console);
else
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_console);
}
UpdateChecks();
}
void CLogWindow::OnSubmit(wxCommandEvent& WXUNUSED (event))
{
Console_Submit(m_cmdline->GetValue().To8BitData());
m_cmdline->SetValue(wxEmptyString);
NotifyUpdate();
}
void CLogWindow::OnClear(wxCommandEvent& WXUNUSED (event))
{
m_log->Clear();
//msgQueue.Clear()
for (unsigned int i = 0; i < msgQueue.size(); i++)
msgQueue.pop();
m_console->ClearScreen();
NOTICE_LOG(CONSOLE, "Console cleared");
NotifyUpdate();
}
// Enable or disable all boxes for the current verbosity level and save the changes.
void CLogWindow::OnToggleAll(wxCommandEvent& WXUNUSED (event))
{
static bool enable = false;
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
m_checks->Check(i, enable);
m_logManager->setEnable((LogTypes::LOG_TYPE)i, enable);
if (enable)
{
m_logManager->addListener((LogTypes::LOG_TYPE)i, this);
if (m_writeFile)
m_logManager->addListener((LogTypes::LOG_TYPE)i, m_fileLog);
if (m_writeConsole)
m_logManager->addListener((LogTypes::LOG_TYPE)i, m_console);
}
else
{
m_logManager->removeListener((LogTypes::LOG_TYPE)i, this);
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog);
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_console);
}
}
enable = !enable;
SaveSettings();
}
// Append checkboxes and update checked groups.
void CLogWindow::UpdateChecks()
{
// This is only run once to append checkboxes to the wxCheckListBox.
if (m_checks->GetCount() == 0)
{
// [F|RES] hide the window while we fill it... wxwidgets gets trouble
// if you don't do it (at least the win version)
m_checks->Show(false);
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
m_checks->Append(wxString::FromAscii(m_logManager->getFullName( (LogTypes::LOG_TYPE)i )));
}
m_checks->Show(true);
}
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
m_checks->Check(i, m_logManager->isListener((LogTypes::LOG_TYPE)i, this));
}
}
// When an option is changed, save the change
void CLogWindow::OnOptionsCheck(wxCommandEvent& event)
{
switch (event.GetId())
{
case IDM_VERBOSITY:
{
// get selection
int v = m_verbosity->GetSelection();
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
m_logManager->setLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)v);
}
}
break;
case IDM_WRITEFILE:
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
m_writeFile = event.IsChecked();
if (m_checks->IsChecked(i))
{
if (m_writeFile)
m_logManager->addListener((LogTypes::LOG_TYPE)i, m_fileLog);
else
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog);
}
}
break;
case IDM_WRITECONSOLE:
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
m_writeConsole = event.IsChecked();
if (m_checks->IsChecked(i))
{
if (m_writeConsole)
m_logManager->addListener((LogTypes::LOG_TYPE)i, m_console);
else
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_console);
}
}
break;
}
SaveSettings();
}
// When a checkbox is changed
void CLogWindow::OnLogCheck(wxCommandEvent& event)
{
int i = event.GetInt();
if (m_checks->IsChecked(i))
{
m_logManager->addListener((LogTypes::LOG_TYPE)i, this);
if (m_writeFile)
m_logManager->addListener((LogTypes::LOG_TYPE)i, m_fileLog);
if (m_writeConsole)
m_logManager->addListener((LogTypes::LOG_TYPE)i, m_console);
}
else
{
m_logManager->removeListener((LogTypes::LOG_TYPE)i, this);
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog);
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_console);
}
SaveSettings();
}
void CLogWindow::OnLogTimer(wxTimerEvent& WXUNUSED(event))
{
UpdateLog();
}
void CLogWindow::NotifyUpdate()
{
UpdateChecks();
UpdateLog();
}
void CLogWindow::UpdateLog()
{
m_logTimer->Stop();
for (unsigned int i = 0; i < msgQueue.size(); i++)
{
m_log->AppendText(msgQueue.front());
msgQueue.pop();
}
m_logTimer->Start(UPDATETIME);
}
void CLogWindow::Log(LogTypes::LOG_LEVELS level, const char *text)
{
if (level > NOTICE_LEVEL)
return;
if (msgQueue.size() >= 100)
msgQueue.pop();
msgQueue.push(wxString::FromAscii(text));
}

View File

@ -0,0 +1,80 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef LOGWINDOW_H_
#define LOGWINDOW_H_
#include "LogManager.h"
#include "IniFile.h"
#include <queue>
enum
{
IDM_LOG,
IDM_CLEARLOG,
IDM_LOGCHECKS,
IDM_OPTIONS,
IDM_TOGGLEALL,
IDM_WRITEFILE,
IDM_WRITECONSOLE,
IDTM_UPDATELOG,
IDM_VERBOSITY,
IDM_SUBMITCMD = 300,
};
class wxTextCtrl;
class wxCheckListBox;
class wxString;
class CLogWindow : public wxDialog,Listener
{
public:
CLogWindow(wxWindow* parent);
~CLogWindow();
void NotifyUpdate();
void SaveSettings();
void LoadSettings();
void Log(LogTypes::LOG_LEVELS, const char *text);
private:
wxTextCtrl* m_log, * m_cmdline;
bool m_writeFile, m_writeConsole;
wxCheckBox* m_writeFileCB, * m_writeConsoleCB;
wxTimer *m_logTimer;
wxCheckListBox* m_checks;
wxRadioBox *m_verbosity;
FileLogListener *m_fileLog;
ConsoleListener *m_console;
LogManager *m_logManager;
std::queue<wxString> msgQueue;
DECLARE_EVENT_TABLE()
void CreateGUIControls();
void OnSubmit(wxCommandEvent& event);
void OnOptionsCheck(wxCommandEvent& event);
void OnLogCheck(wxCommandEvent& event);
void OnClear(wxCommandEvent& event);
void OnToggleAll(wxCommandEvent& event);
void OnLogTimer(wxTimerEvent& WXUNUSED(event));
void UpdateChecks();
void UpdateLog();
};
#endif /*LOGWINDOW_H_*/

View File

@ -35,10 +35,10 @@
#include "CPUDetect.h"
#include "IniFile.h"
#include "FileUtil.h"
#include "ConsoleWindow.h"
#include "Setup.h"
#include "Host.h" // Core
#include "PluginManager.h"
#include "Globals.h" // Local
#include "Main.h"
@ -62,6 +62,7 @@ IMPLEMENT_APP(DolphinApp)
CFrame* main_frame = NULL;
CCodeWindow* g_pCodeWindow = NULL;
LogManager *logManager = NULL;
#ifdef WIN32
//Has no error handling.
@ -100,6 +101,7 @@ bool DolphinApp::OnInit()
{
//Console::Open();
NOTICE_LOG(BOOT, "Starting application");
// Declarations and definitions
bool UseDebugger = false;
bool UseLogger = false;
@ -220,7 +222,7 @@ bool DolphinApp::OnInit()
#endif
// Load CONFIG_FILE settings
SConfig::GetInstance().LoadSettings();
SConfig::GetInstance().LoadSettings();
// Enable the PNG image handler
wxInitAllImageHandlers();
@ -232,10 +234,7 @@ bool DolphinApp::OnInit()
const char *title = "Dolphin SVN R " SVN_REV_STR;
#endif
// ---------------------------------------------------------------------------------------
// If we are debugging let use save the main window position and size
// TODO: Save position and size on exit
// ------------
IniFile ini;
ini.Load(DEBUGGER_CONFIG_FILE);
@ -245,19 +244,17 @@ bool DolphinApp::OnInit()
ini.Get("MainWindow", "y", &y, 100);
ini.Get("MainWindow", "w", &w, 800);
ini.Get("MainWindow", "h", &h, 600);
// -------------------
if (UseDebugger)
{
main_frame = new CFrame((wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title),
main_frame = new CFrame(UseLogger, (wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title),
wxPoint(x, y), wxSize(w, h));
}
else
{
main_frame = new CFrame((wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title),
wxPoint(100, 100), wxSize(w, h));
main_frame = new CFrame(UseLogger, (wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title),
wxPoint(100, 100), wxSize(800, 600));
}
// ------------------
// Create debugging window
if (UseDebugger)
@ -265,16 +262,6 @@ bool DolphinApp::OnInit()
g_pCodeWindow = new CCodeWindow(SConfig::GetInstance().m_LocalCoreStartupParameter, main_frame);
g_pCodeWindow->Show(true);
}
if(!UseDebugger && UseLogger)
{
#if LOGLEVEL > 0
// We aren't using debugger, just logger
// Should be fine for a local copy
CLogWindow* m_LogWindow = new CLogWindow(main_frame);
m_LogWindow->Show(true);
#endif
}
// ---------------------------------------------------
// Check the autoboot options.

View File

@ -26,11 +26,7 @@
#include "BootManager.h"
void* g_pCodeWindow = NULL;
void* main_frame = NULL;
bool wxPanicAlert(const char* text, bool /*yes_no*/)
{
return(true);
}
LogManager *logManager = NULL;
// OK, this thread boundary is DANGEROUS on linux
// wxPostEvent / wxAddPendingEvent is the solution.
@ -195,6 +191,7 @@ int main(int argc, char* argv[])
return(1);
}
std::string bootFile(args_info.inputs[0]);
logManager = (LogManager *)CPluginManager::GetInstance().GetGlobals()->logManager;
updateMainFrameEvent.Init();
cpu_info.Detect();

View File

@ -7,7 +7,6 @@ wxenv = env.Clone()
files = [
'BootManager.cpp',
# 'Config.cpp',
'cmdline.c',
]
@ -22,6 +21,7 @@ if wxenv['HAVE_WX']:
'ARCodeAddEdit.cpp',
'ConfigMain.cpp',
'Frame.cpp',
'LogWindow.cpp',
'FrameTools.cpp',
'GameListCtrl.cpp',
'Globals.cpp',
@ -29,7 +29,6 @@ if wxenv['HAVE_WX']:
'ISOProperties.cpp',
'MemcardManager.cpp',
'MemoryCards/GCMemcard.cpp',
# 'PluginManager.cpp',
'PatchAddEdit.cpp',
'CheatsWindow.cpp',
'stdafx.cpp',