2009-02-04 17:33:59 +00:00
|
|
|
// Copyright (C) 2003-2009 Dolphin Project.
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
// 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/
|
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
|
|
|
|
#include "IniFile.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "Debugger.h"
|
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
#include "../Config.h"
|
|
|
|
#include "../Globals.h"
|
2009-01-17 14:28:09 +00:00
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
extern int g_Preset;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CDebugger,wxDialog)
|
|
|
|
EVT_CLOSE(CDebugger::OnClose)
|
2009-02-04 17:33:59 +00:00
|
|
|
EVT_CHECKBOX(ID_SAVETOFILE,CDebugger::GeneralSettings)
|
2008-12-08 05:25:12 +00:00
|
|
|
EVT_CHECKBOX(ID_SHOWCONSOLE,CDebugger::GeneralSettings)
|
2009-02-04 17:33:59 +00:00
|
|
|
EVT_CHECKBOX(ID_INFOLOG,CDebugger::GeneralSettings)
|
|
|
|
EVT_CHECKBOX(ID_PRIMLOG,CDebugger::GeneralSettings)
|
|
|
|
EVT_CHECKBOX(ID_SAVETEXTURES,CDebugger::GeneralSettings)
|
|
|
|
EVT_CHECKBOX(ID_SAVETARGETS,CDebugger::GeneralSettings)
|
|
|
|
EVT_CHECKBOX(ID_SAVESHADERS,CDebugger::GeneralSettings)
|
2008-12-08 05:25:12 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
CDebugger::CDebugger(wxWindow *parent, wxWindowID id, const wxString &title,
|
|
|
|
const wxPoint &position, const wxSize& size, long style)
|
|
|
|
: wxDialog(parent, id, title, position, size, style)
|
|
|
|
{
|
|
|
|
CreateGUIControls();
|
|
|
|
|
2009-02-04 17:33:59 +00:00
|
|
|
LoadSettings();
|
2009-03-20 23:45:25 +00:00
|
|
|
DoShowConsole();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CDebugger::~CDebugger()
|
|
|
|
{
|
2009-02-04 17:33:59 +00:00
|
|
|
SaveSettings();
|
2009-01-17 14:28:09 +00:00
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-02-04 17:33:59 +00:00
|
|
|
void CDebugger::OnClose(wxCloseEvent& event)
|
2009-01-17 14:28:09 +00:00
|
|
|
{
|
2009-02-04 17:33:59 +00:00
|
|
|
// save the window position when we hide the window
|
|
|
|
SaveSettings();
|
2009-01-17 14:28:09 +00:00
|
|
|
|
2009-02-04 17:33:59 +00:00
|
|
|
event.Skip(); // This means wxDialog's Destroy is used
|
2009-01-17 14:28:09 +00:00
|
|
|
}
|
|
|
|
|
2009-03-20 23:45:25 +00:00
|
|
|
void CDebugger::DoShowConsole()
|
2009-01-17 14:28:09 +00:00
|
|
|
{
|
2009-03-20 23:45:25 +00:00
|
|
|
ConsoleListener* console = LogManager::GetInstance()->getConsoleListener();
|
2009-04-03 14:35:49 +00:00
|
|
|
if (m_Check[1]->IsChecked() && console->IsOpen())
|
2009-03-20 23:45:25 +00:00
|
|
|
console->Open();
|
2009-02-04 17:33:59 +00:00
|
|
|
else
|
2009-03-20 23:45:25 +00:00
|
|
|
console->Close();
|
2009-01-17 14:28:09 +00:00
|
|
|
}
|
|
|
|
|
2009-02-04 17:33:59 +00:00
|
|
|
void CDebugger::SaveSettings() const
|
2009-01-17 14:28:09 +00:00
|
|
|
{
|
2009-02-04 17:33:59 +00:00
|
|
|
IniFile file;
|
|
|
|
file.Load(DEBUGGER_CONFIG_FILE);
|
2009-01-17 14:28:09 +00:00
|
|
|
|
2009-02-04 17:33:59 +00:00
|
|
|
// TODO: make this work when we close the entire program too, currently on total close we get
|
2008-12-08 05:25:12 +00:00
|
|
|
// weird values, perhaps because of some conflict with the rendering window
|
2009-02-04 17:33:59 +00:00
|
|
|
// TODO: get the screen resolution and make limits from that
|
2009-04-03 14:35:49 +00:00
|
|
|
if (GetPosition().x < 1000 && GetPosition().y < 1000
|
|
|
|
&& GetSize().GetWidth() < 1000
|
|
|
|
&& GetSize().GetHeight() < 1000)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-02-04 17:33:59 +00:00
|
|
|
file.Set("VideoWindow", "x", GetPosition().x);
|
|
|
|
file.Set("VideoWindow", "y", GetPosition().y);
|
|
|
|
file.Set("VideoWindow", "w", GetSize().GetWidth());
|
|
|
|
file.Set("VideoWindow", "h", GetSize().GetHeight());
|
|
|
|
}
|
2009-04-03 14:35:49 +00:00
|
|
|
|
2009-02-04 17:33:59 +00:00
|
|
|
file.Set("VideoWindow", "WriteToFile", m_Check[0]->IsChecked());
|
|
|
|
file.Set("VideoWindow", "Console", m_Check[1]->IsChecked());
|
2009-04-03 14:35:49 +00:00
|
|
|
|
2009-02-04 17:33:59 +00:00
|
|
|
g_Config.iLog = bInfoLog ? CONF_LOG : 0;
|
|
|
|
g_Config.iLog |= bPrimLog ? CONF_PRIMLOG : 0;
|
|
|
|
g_Config.iLog |= bSaveTextures ? CONF_SAVETEXTURES : 0;
|
|
|
|
g_Config.iLog |= bSaveTargets ? CONF_SAVETARGETS : 0;
|
|
|
|
g_Config.iLog |= bSaveShaders ? CONF_SAVESHADERS : 0;
|
2009-04-03 14:35:49 +00:00
|
|
|
|
2009-02-04 17:33:59 +00:00
|
|
|
file.Set("VideoWindow", "ConfBits", g_Config.iLog);
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-02-04 17:33:59 +00:00
|
|
|
file.Save(DEBUGGER_CONFIG_FILE);
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-02-04 17:33:59 +00:00
|
|
|
void CDebugger::LoadSettings()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-02-04 17:33:59 +00:00
|
|
|
IniFile file;
|
|
|
|
file.Load(DEBUGGER_CONFIG_FILE);
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
int x,y,w,h;
|
2009-02-04 17:33:59 +00:00
|
|
|
file.Get("VideoWindow", "x", &x, GetPosition().x);
|
|
|
|
file.Get("VideoWindow", "y", &y, GetPosition().y);
|
|
|
|
file.Get("VideoWindow", "w", &w, GetSize().GetWidth());
|
|
|
|
file.Get("VideoWindow", "h", &h, GetSize().GetHeight());
|
2008-12-08 05:25:12 +00:00
|
|
|
SetSize(x, y, w, h);
|
|
|
|
|
2009-02-04 17:33:59 +00:00
|
|
|
bool Console;
|
|
|
|
file.Get("VideoWindow", "Console", &Console, m_Check[1]->IsChecked());
|
|
|
|
m_Check[1]->SetValue(Console);
|
|
|
|
|
|
|
|
file.Get("VideoWindow", "ConfBits", &g_Config.iLog, 0);
|
2009-02-20 22:04:52 +00:00
|
|
|
bInfoLog = (g_Config.iLog & CONF_LOG) ? true : false;
|
|
|
|
bPrimLog = (g_Config.iLog & CONF_PRIMLOG) ? true : false;
|
|
|
|
bSaveTextures = (g_Config.iLog & CONF_SAVETEXTURES) ? true : false;
|
|
|
|
bSaveTargets = (g_Config.iLog & CONF_SAVETARGETS) ? true : false;
|
|
|
|
bSaveShaders = (g_Config.iLog & CONF_SAVESHADERS) ? true : false;
|
2009-02-04 17:33:59 +00:00
|
|
|
m_Check[2]->SetValue(bInfoLog);
|
|
|
|
m_Check[3]->SetValue(bPrimLog);
|
|
|
|
m_Check[4]->SetValue(bSaveTextures);
|
|
|
|
m_Check[5]->SetValue(bSaveTargets);
|
|
|
|
m_Check[6]->SetValue(bSaveShaders);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2009-01-17 14:28:09 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
void CDebugger::CreateGUIControls()
|
|
|
|
{
|
|
|
|
// Basic settings
|
|
|
|
SetIcon(wxNullIcon);
|
2009-02-04 17:33:59 +00:00
|
|
|
CenterOnParent();
|
|
|
|
|
|
|
|
// MainPanel
|
|
|
|
m_MainPanel = new wxPanel(this, ID_MAINPANEL, wxDefaultPosition, wxDefaultSize);
|
|
|
|
|
|
|
|
// Options
|
|
|
|
wxStaticBoxSizer *sOptions = new wxStaticBoxSizer(wxVERTICAL, m_MainPanel, wxT("Options"));
|
|
|
|
m_Check[0] = new wxCheckBox(m_MainPanel, ID_SAVETOFILE, wxT("Save to file"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
|
|
|
m_Check[1] = new wxCheckBox(m_MainPanel, ID_SHOWCONSOLE, wxT("Show console"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
|
|
|
m_Check[2] = new wxCheckBox(m_MainPanel, ID_INFOLOG, wxT("Info log"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
|
|
|
m_Check[3] = new wxCheckBox(m_MainPanel, ID_PRIMLOG, wxT("Primary log"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
|
|
|
m_Check[4] = new wxCheckBox(m_MainPanel, ID_SAVETEXTURES, wxT("Save Textures"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
|
|
|
m_Check[5] = new wxCheckBox(m_MainPanel, ID_SAVETARGETS, wxT("Save Targets"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
|
|
|
m_Check[6] = new wxCheckBox(m_MainPanel, ID_SAVESHADERS, wxT("Save Shaders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
2009-04-03 14:35:49 +00:00
|
|
|
|
2009-02-04 17:33:59 +00:00
|
|
|
for (int i = 0; i < NUM_OPTIONS-ID_SAVETOFILE; ++i)
|
|
|
|
sOptions->Add(m_Check[i], 0, 0, 5);
|
|
|
|
|
|
|
|
// Layout everything on m_MainPanel
|
|
|
|
wxBoxSizer *sMain = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
sMain->Add(sOptions);
|
|
|
|
sMain->Add(100, 0); // Add some width so we can see the window title by default
|
|
|
|
m_MainPanel->SetSizerAndFit(sMain);
|
|
|
|
Fit();
|
|
|
|
}
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
// General settings
|
|
|
|
void CDebugger::GeneralSettings(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
2009-02-04 17:33:59 +00:00
|
|
|
case ID_SHOWCONSOLE:
|
2009-03-20 23:45:25 +00:00
|
|
|
DoShowConsole();
|
2009-02-04 17:33:59 +00:00
|
|
|
break;
|
|
|
|
case ID_INFOLOG:
|
|
|
|
bInfoLog = event.IsChecked();
|
|
|
|
break;
|
|
|
|
case ID_PRIMLOG:
|
|
|
|
bPrimLog = event.IsChecked();
|
|
|
|
break;
|
|
|
|
case ID_SAVETEXTURES:
|
|
|
|
bSaveTextures = event.IsChecked();
|
|
|
|
break;
|
|
|
|
case ID_SAVETARGETS:
|
|
|
|
bSaveTargets = event.IsChecked();
|
|
|
|
break;
|
|
|
|
case ID_SAVESHADERS:
|
|
|
|
bSaveShaders = event.IsChecked();
|
|
|
|
break;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2009-02-04 17:33:59 +00:00
|
|
|
SaveSettings();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|