2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 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-09-13 09:23:30 +00:00
|
|
|
#include "VideoConfig.h"
|
2009-04-03 14:35:49 +00:00
|
|
|
#include "../Globals.h"
|
2010-02-02 21:56:29 +00:00
|
|
|
#include "FileUtil.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
|
|
|
|
2009-07-02 17:11:27 +00:00
|
|
|
BEGIN_EVENT_TABLE(GFXDebuggerOGL,wxDialog)
|
|
|
|
EVT_CLOSE(GFXDebuggerOGL::OnClose)
|
|
|
|
EVT_CHECKBOX(ID_SAVETOFILE,GFXDebuggerOGL::GeneralSettings)
|
|
|
|
EVT_CHECKBOX(ID_INFOLOG,GFXDebuggerOGL::GeneralSettings)
|
|
|
|
EVT_CHECKBOX(ID_PRIMLOG,GFXDebuggerOGL::GeneralSettings)
|
|
|
|
EVT_CHECKBOX(ID_SAVETEXTURES,GFXDebuggerOGL::GeneralSettings)
|
|
|
|
EVT_CHECKBOX(ID_SAVETARGETS,GFXDebuggerOGL::GeneralSettings)
|
|
|
|
EVT_CHECKBOX(ID_SAVESHADERS,GFXDebuggerOGL::GeneralSettings)
|
2008-12-08 05:25:12 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2009-07-02 17:11:27 +00:00
|
|
|
GFXDebuggerOGL::GFXDebuggerOGL(wxWindow *parent, wxWindowID id, const wxString &title,
|
2008-12-08 05:25:12 +00:00
|
|
|
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();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-07-02 17:11:27 +00:00
|
|
|
GFXDebuggerOGL::~GFXDebuggerOGL()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-02-04 17:33:59 +00:00
|
|
|
SaveSettings();
|
2009-09-07 13:33:40 +00:00
|
|
|
m_DebuggerFrame = NULL;
|
2009-09-07 12:40:43 +00:00
|
|
|
NOTICE_LOG(CONSOLE, "Stop [Video Thread]: Closing OpenGL debugging window");
|
2009-01-17 14:28:09 +00:00
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-07-02 17:11:27 +00:00
|
|
|
void GFXDebuggerOGL::OnClose(wxCloseEvent& event)
|
2009-01-17 14:28:09 +00:00
|
|
|
{
|
2009-09-07 13:33:40 +00:00
|
|
|
// This means wxDialog's Destroy is used
|
|
|
|
//event.Skip();
|
|
|
|
|
|
|
|
// Save the window position
|
2009-02-04 17:33:59 +00:00
|
|
|
SaveSettings();
|
2009-01-17 14:28:09 +00:00
|
|
|
|
2009-09-07 13:33:40 +00:00
|
|
|
// Destroy
|
|
|
|
delete this;
|
2009-01-17 14:28:09 +00:00
|
|
|
}
|
|
|
|
|
2009-07-02 17:11:27 +00:00
|
|
|
void GFXDebuggerOGL::SaveSettings() const
|
2009-01-17 14:28:09 +00:00
|
|
|
{
|
2009-02-04 17:33:59 +00:00
|
|
|
IniFile file;
|
2010-02-02 21:56:29 +00:00
|
|
|
file.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
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
|
|
|
{
|
2010-06-03 18:05:08 +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-02-04 17:33:59 +00:00
|
|
|
}
|
2009-04-03 14:35:49 +00:00
|
|
|
|
2010-06-03 18:05:08 +00:00
|
|
|
file.Set("VideoWindow", "WriteToFile", m_Check[0]->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
|
|
|
|
2010-06-03 18:05:08 +00:00
|
|
|
file.Set("VideoWindow", "ConfBits", g_Config.iLog);
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2010-02-02 21:56:29 +00:00
|
|
|
file.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
2009-02-04 17:33:59 +00:00
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-07-02 17:11:27 +00:00
|
|
|
void GFXDebuggerOGL::LoadSettings()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-02-04 17:33:59 +00:00
|
|
|
IniFile file;
|
2010-02-02 21:56:29 +00:00
|
|
|
file.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
2009-02-04 17:33:59 +00:00
|
|
|
|
2009-07-02 17:11:27 +00:00
|
|
|
int x = 100, y = 100, w = 100, h = 100;
|
2010-06-03 18:05:08 +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);
|
|
|
|
|
2010-06-03 18:05:08 +00:00
|
|
|
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-07-02 17:11:27 +00:00
|
|
|
m_Check[1]->SetValue(bInfoLog);
|
|
|
|
m_Check[2]->SetValue(bPrimLog);
|
|
|
|
m_Check[3]->SetValue(bSaveTextures);
|
|
|
|
m_Check[4]->SetValue(bSaveTargets);
|
|
|
|
m_Check[5]->SetValue(bSaveShaders);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2009-01-17 14:28:09 +00:00
|
|
|
|
2009-07-02 17:11:27 +00:00
|
|
|
void GFXDebuggerOGL::CreateGUIControls()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
|
|
|
// 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);
|
2009-07-02 17:11:27 +00:00
|
|
|
m_Check[1] = new wxCheckBox(m_MainPanel, ID_INFOLOG, wxT("Info log"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
|
|
|
m_Check[2] = new wxCheckBox(m_MainPanel, ID_PRIMLOG, wxT("Primary log"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
|
|
|
m_Check[3] = new wxCheckBox(m_MainPanel, ID_SAVETEXTURES, wxT("Save Textures"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
|
|
|
m_Check[4] = new wxCheckBox(m_MainPanel, ID_SAVETARGETS, wxT("Save Targets"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
|
|
|
m_Check[5] = 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
|
2009-07-02 17:11:27 +00:00
|
|
|
void GFXDebuggerOGL::GeneralSettings(wxCommandEvent& event)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
2009-02-04 17:33:59 +00:00
|
|
|
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
|
|
|
}
|