Move the log window options from the log window into a separate dialog openned from an item in the options menu. This gives the log window room to show logs.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7191 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2011-02-18 12:34:24 +00:00
parent 2183588030
commit c2bc463fe7
15 changed files with 390 additions and 253 deletions

View File

@ -60,6 +60,7 @@
<Midl />
</ItemDefinitionGroup>
<ItemGroup>
<msgfmt Include="cs.po" />
<msgfmt Include="da.po" />
<msgfmt Include="de.po" />
<msgfmt Include="el.po" />
@ -81,6 +82,7 @@
<msgfmt Include="zh_TW.po" />
</ItemGroup>
<ItemGroup>
<None Include="cs.po" />
<None Include="da.po" />
<None Include="de.po" />
<None Include="el.po" />
@ -107,4 +109,4 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="po.targets" />
</ImportGroup>
</Project>
</Project>

View File

@ -43,6 +43,7 @@ if(wxWidgets_FOUND)
Src/ISOProperties.cpp
Src/InputConfigDiag.cpp
Src/InputConfigDiagBitmaps.cpp
Src/LogConfigDiag.cpp
Src/LogWindow.cpp
Src/Main.cpp
Src/MemcardManager.cpp

View File

@ -239,6 +239,7 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
<ClCompile Include="Src\ISOFile.cpp" />
<ClCompile Include="Src\ISOProperties.cpp" />
<ClCompile Include="Src\Debugger\JitWindow.cpp" />
<ClCompile Include="Src\LogConfigDiag.cpp" />
<ClCompile Include="Src\LogWindow.cpp" />
<ClCompile Include="Src\Main.cpp" />
<ClCompile Include="Src\MainNoGUI.cpp">
@ -298,6 +299,7 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
<ClInclude Include="Src\ISOFile.h" />
<ClInclude Include="Src\ISOProperties.h" />
<ClInclude Include="Src\Debugger\JitWindow.h" />
<ClInclude Include="Src\LogConfigDiag.h" />
<ClInclude Include="Src\LogWindow.h" />
<ClInclude Include="Src\Main.h" />
<ClInclude Include="Src\MemcardManager.h" />

View File

@ -135,6 +135,9 @@
<ClCompile Include="Src\Debugger\BreakpointView.cpp">
<Filter>GUI\Debugger</Filter>
</ClCompile>
<ClCompile Include="Src\LogConfigDiag.cpp">
<Filter>GUI</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Src\Main.h" />
@ -258,6 +261,9 @@
<ClInclude Include="Src\Debugger\BreakpointView.h">
<Filter>GUI\Debugger</Filter>
</ClInclude>
<ClInclude Include="Src\LogConfigDiag.h">
<Filter>GUI</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Src\SConscript" />

View File

@ -259,6 +259,7 @@ EVT_MENU(IDM_CONFIG_DSP_EMULATOR, CFrame::OnConfigDSP)
EVT_MENU(IDM_CONFIG_PAD_PLUGIN, CFrame::OnConfigPAD)
EVT_MENU(IDM_CONFIG_WIIMOTE_PLUGIN, CFrame::OnConfigWiimote)
EVT_MENU(IDM_CONFIG_HOTKEYS, CFrame::OnConfigHotkey)
EVT_MENU(IDM_CONFIG_LOGGER, CFrame::OnConfigLogger)
EVT_MENU(IDM_SAVE_PERSPECTIVE, CFrame::OnToolBar)
EVT_AUITOOLBAR_TOOL_DROPDOWN(IDM_SAVE_PERSPECTIVE, CFrame::OnDropDownToolbarItem)

View File

@ -304,6 +304,7 @@ class CFrame : public CRenderFrame
void OnConfigPAD(wxCommandEvent& event);
void OnConfigWiimote(wxCommandEvent& event);
void OnConfigHotkey(wxCommandEvent& event);
void OnConfigLogger(wxCommandEvent& event);
void OnToggleFullscreen(wxCommandEvent& event);
void OnToggleDualCore(wxCommandEvent& event);

View File

@ -50,6 +50,7 @@ Core::GetWindowHandle().
#include "GameListCtrl.h"
#include "BootManager.h"
#include "LogWindow.h"
#include "LogConfigDiag.h"
#include "WxUtils.h"
#include "ConfigManager.h" // Core
@ -188,9 +189,10 @@ void CFrame::CreateMenu()
pOptionsMenu->AppendSeparator();
pOptionsMenu->Append(IDM_CONFIG_GFX_BACKEND, _("&Graphics Settings"));
pOptionsMenu->Append(IDM_CONFIG_DSP_EMULATOR, _("&DSP Settings"));
pOptionsMenu->Append(IDM_CONFIG_PAD_PLUGIN, _("&Gamecube Pad Settings"));
pOptionsMenu->Append(IDM_CONFIG_PAD_PLUGIN, _("Gamecube &Pad Settings"));
pOptionsMenu->Append(IDM_CONFIG_WIIMOTE_PLUGIN, _("&Wiimote Settings"));
pOptionsMenu->Append(IDM_CONFIG_HOTKEYS, _("&Hotkey Settings"));
pOptionsMenu->Append(IDM_CONFIG_LOGGER, _("&Logger Settings"));
if (g_pCodeWindow)
{
pOptionsMenu->AppendSeparator();
@ -1227,6 +1229,13 @@ void CFrame::OnConfigHotkey(wxCommandEvent& WXUNUSED (event))
UpdateGUI();
}
void CFrame::OnConfigLogger(wxCommandEvent& WXUNUSED (event))
{
LogConfigDiag m_LogConfigDiag(this, m_LogWindow);
m_LogConfigDiag.ShowModal();
m_LogConfigDiag.Destroy();
}
void CFrame::OnHelp(wxCommandEvent& event)
{
switch (event.GetId())

View File

@ -121,6 +121,7 @@ enum
IDM_CONFIG_PAD_PLUGIN,
IDM_CONFIG_WIIMOTE_PLUGIN,
IDM_CONFIG_HOTKEYS,
IDM_CONFIG_LOGGER,
// Views
IDM_LOGWINDOW,

View File

@ -284,7 +284,7 @@ void HotkeyConfigDialog::CreateHotkeyGUIControls(void)
SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkeyModifier[i]));
wxBoxSizer *sHotkey = new wxBoxSizer(wxHORIZONTAL);
sHotkey->Add(stHotkeys, 1, wxALIGN_LEFT | wxALL, 2);
sHotkey->Add(stHotkeys, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 2);
sHotkey->AddStretchSpacer();
sHotkey->Add(m_Button_Hotkeys[i], 0, wxALL, 2);
sHotkeys->Add(sHotkey,

View File

@ -0,0 +1,247 @@
// Copyright (C) 2003 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 "LogConfigDiag.h"
#include "LogManager.h"
#include "ConsoleListener.h"
#include "LogWindow.h"
#include "FileUtil.h"
#define _connect_macro_(b, f, c, s) \
(b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
LogConfigDiag::LogConfigDiag(wxWindow* parent, CLogWindow *log_window)
: wxDialog(parent, wxID_ANY, _("Logger Configuration"), wxDefaultPosition, wxDefaultSize)
, m_LogWindow(log_window)
{
Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, wxCloseEventHandler(LogConfigDiag::OnClose), (wxObject*)0, this);
m_LogManager = LogManager::GetInstance();
CreateGUIControls();
LoadSettings();
}
void LogConfigDiag::CreateGUIControls()
{
// Verbosity
wxArrayString wxLevels, wxLevelsUse;
wxLevels.Add(_("Notice"));
wxLevels.Add(_("Error"));
wxLevels.Add(_("Warning"));
wxLevels.Add(_("Info"));
wxLevels.Add(_("Debug"));
for (int i = 0; i < MAX_LOGLEVEL; ++i)
wxLevelsUse.Add(wxLevels[i]);
m_verbosity = new wxRadioBox(this, wxID_ANY, _("Verbosity"),
wxDefaultPosition, wxDefaultSize, wxLevelsUse, 0,
wxRA_SPECIFY_ROWS, wxDefaultValidator);
_connect_macro_(m_verbosity, LogConfigDiag::OnVerbosityChange, wxEVT_COMMAND_RADIOBOX_SELECTED, this);
// Options
m_writeFileCB = new wxCheckBox(this, wxID_ANY, _("Write to File"));
_connect_macro_(m_writeFileCB, LogConfigDiag::OnWriteFileChecked, wxEVT_COMMAND_CHECKBOX_CLICKED, this);
m_writeConsoleCB = new wxCheckBox(this, wxID_ANY, _("Write to Console"));
_connect_macro_(m_writeConsoleCB, LogConfigDiag::OnWriteConsoleChecked, wxEVT_COMMAND_CHECKBOX_CLICKED, this);
m_writeWindowCB = new wxCheckBox(this, wxID_ANY, _("Write to Window"));
_connect_macro_(m_writeWindowCB, LogConfigDiag::OnWriteWindowChecked, wxEVT_COMMAND_CHECKBOX_CLICKED, this);
wxButton *btn_toggle_all = new wxButton(this, wxID_ANY, _("Toggle All Log Types"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
_connect_macro_(btn_toggle_all, LogConfigDiag::OnToggleAll, wxEVT_COMMAND_BUTTON_CLICKED, this);
m_checks = new wxCheckListBox(this, wxID_ANY);
_connect_macro_(m_checks, LogConfigDiag::OnLogCheck, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, this);
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
m_checks->Append(wxString::FromAscii(m_LogManager->getFullName((LogTypes::LOG_TYPE)i)));
// Sizers
wxStaticBoxSizer* sbOptions = new wxStaticBoxSizer(wxVERTICAL, this, _("Logger Outputs"));
sbOptions->Add(m_writeFileCB, 0, wxDOWN, 1);
sbOptions->Add(m_writeConsoleCB, 0, wxDOWN, 1);
sbOptions->Add(m_writeWindowCB, 0);
wxStaticBoxSizer* sbLogTypes = new wxStaticBoxSizer(wxVERTICAL, this, _("Log Types"));
sbLogTypes->Add(m_checks, 1, wxEXPAND);
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
sButtons->AddStretchSpacer();
wxButton *btn_close = new wxButton(this, wxID_CLOSE);
_connect_macro_(btn_close, LogConfigDiag::OnClickClose, wxEVT_COMMAND_BUTTON_CLICKED, this);
sButtons->Add(btn_close, 0, wxALL, 5);
wxBoxSizer *sLeft = new wxBoxSizer(wxVERTICAL);
sLeft->Add(m_verbosity, 0, wxEXPAND | wxLEFT | wxRIGHT, 5);
sLeft->Add(sbOptions, 0, wxEXPAND | wxLEFT | wxRIGHT, 5);
sLeft->AddStretchSpacer();
sLeft->Add(btn_toggle_all, 0, wxEXPAND | wxLEFT | wxRIGHT, 5);
wxBoxSizer *sTop = new wxBoxSizer(wxHORIZONTAL);
sTop->Add(sLeft, 0, wxEXPAND);
sTop->Add(sbLogTypes, 0, wxEXPAND | wxRIGHT, 5);
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
sMain->Add(sTop, 0, wxEXPAND);
sMain->Add(sButtons, 0, wxEXPAND);
SetSizer(sMain);
Layout();
Fit();
}
void LogConfigDiag::LoadSettings()
{
IniFile ini;
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
int verbosity;
ini.Get("Options", "Verbosity", &verbosity, 0);
if (verbosity < 1) verbosity = 1;
if (verbosity > MAX_LOGLEVEL) verbosity = MAX_LOGLEVEL;
m_verbosity->SetSelection(verbosity - 1);
ini.Get("Options", "WriteToFile", &m_writeFile, false);
m_writeFileCB->SetValue(m_writeFile);
ini.Get("Options", "WriteToConsole", &m_writeConsole, true);
m_writeConsoleCB->SetValue(m_writeConsole);
ini.Get("Options", "WriteToWindow", &m_writeWindow, true);
m_writeWindowCB->SetValue(m_writeWindow);
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
bool log_enabled;
ini.Get("Logs", m_LogManager->getShortName((LogTypes::LOG_TYPE)i), &log_enabled, true);
m_checks->Check(i, log_enabled);
}
}
void LogConfigDiag::SaveSettings()
{
IniFile ini;
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
ini.Set("Options", "Verbosity", m_verbosity->GetSelection() + 1);
ini.Set("Options", "WriteToFile", m_writeFile);
ini.Set("Options", "WriteToConsole", m_writeConsole);
ini.Set("Options", "WriteToWindow", m_writeWindow);
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(File::GetUserPath(F_LOGGERCONFIG_IDX));
}
void LogConfigDiag::OnVerbosityChange(wxCommandEvent& event)
{
int v = m_verbosity->GetSelection() + 1;
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
m_LogManager->setLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)v);
event.Skip();
}
void LogConfigDiag::OnWriteFileChecked(wxCommandEvent& event)
{
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_LogManager->getFileListener());
else
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_LogManager->getFileListener());
}
}
}
void LogConfigDiag::OnWriteConsoleChecked(wxCommandEvent& event)
{
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_LogManager->getConsoleListener());
else
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_LogManager->getConsoleListener());
}
}
}
void LogConfigDiag::OnWriteWindowChecked(wxCommandEvent& event)
{
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
m_writeWindow = event.IsChecked();
if (m_checks->IsChecked(i))
{
if (m_writeWindow)
m_LogManager->addListener((LogTypes::LOG_TYPE)i, (LogListener *)m_LogWindow);
else
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, (LogListener *)m_LogWindow);
}
}
}
void LogConfigDiag::OnToggleAll(wxCommandEvent& WXUNUSED(event))
{
static bool enableAll = false;
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
ToggleLog(i, enableAll);
SaveSettings();
enableAll = !enableAll;
}
void LogConfigDiag::ToggleLog(int _logType, bool enable)
{
LogTypes::LOG_TYPE logType = (LogTypes::LOG_TYPE)_logType;
m_checks->Check(_logType, enable);
m_LogManager->setEnable(logType, enable);
if (enable)
{
if (m_writeWindow)
m_LogManager->addListener(logType, (LogListener *)m_LogWindow);
if (m_writeFile)
m_LogManager->addListener(logType, m_LogManager->getFileListener());
if (m_writeConsole)
m_LogManager->addListener(logType, m_LogManager->getConsoleListener());
}
else
{
m_LogManager->removeListener(logType, (LogListener *)m_LogWindow);
m_LogManager->removeListener(logType, m_LogManager->getFileListener());
m_LogManager->removeListener(logType, m_LogManager->getConsoleListener());
}
}
void LogConfigDiag::OnLogCheck(wxCommandEvent& event)
{
int i = event.GetInt();
ToggleLog(i, m_checks->IsChecked(i));
SaveSettings();
}
void LogConfigDiag::OnClickClose(wxCommandEvent& WXUNUSED(event))
{
Close();
}
void LogConfigDiag::OnClose(wxCloseEvent& WXUNUSED(event))
{
SaveSettings();
EndModal(wxID_CLOSE);
}

View File

@ -0,0 +1,58 @@
// Copyright (C) 2003 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 _LOG_CONFIG_DIAG_H_
#define _LOG_CONFIG_DIAG_H_
#include <vector>
#include <wx/wx.h>
class CFrame;
class LogManager;
class CLogWindow;
class LogConfigDiag : public wxDialog
{
public:
LogConfigDiag(wxWindow* parent, CLogWindow *log_window);
void SaveSettings();
void LoadSettings();
private:
LogManager *m_LogManager;
CLogWindow *m_LogWindow;
bool m_writeFile, m_writeConsole, m_writeWindow;
// Controls
wxCheckBox *m_writeFileCB, *m_writeConsoleCB, *m_writeWindowCB;
wxCheckListBox* m_checks;
wxRadioBox *m_verbosity;
void CreateGUIControls();
void OnVerbosityChange(wxCommandEvent& event);
void OnWriteFileChecked(wxCommandEvent& event);
void OnWriteConsoleChecked(wxCommandEvent& event);
void OnWriteWindowChecked(wxCommandEvent& event);
void OnToggleAll(wxCommandEvent& event);
void ToggleLog(int _logType, bool enable);
void OnLogCheck(wxCommandEvent& event);
void OnClickClose(wxCommandEvent& WXUNUSED(event));
void OnClose(wxCloseEvent& event);
};
#endif // _LOG_CONFIG_DIAG_H_

View File

@ -30,14 +30,8 @@ BEGIN_EVENT_TABLE(CLogWindow, wxPanel)
EVT_CLOSE(CLogWindow::OnClose)
EVT_TEXT_ENTER(IDM_SUBMITCMD, CLogWindow::OnSubmit)
EVT_BUTTON(IDM_CLEARLOG, CLogWindow::OnClear)
EVT_BUTTON(IDM_TOGGLEALL, CLogWindow::OnToggleAll)
EVT_RADIOBOX(IDM_VERBOSITY, CLogWindow::OnOptionsCheck)
EVT_CHOICE(IDM_FONT, CLogWindow::OnOptionsCheck)
EVT_CHECKBOX(IDM_WRAPLINE, CLogWindow::OnOptionsCheck)
EVT_CHECKBOX(IDM_WRITEFILE, CLogWindow::OnOptionsCheck)
EVT_CHECKBOX(IDM_WRITECONSOLE, CLogWindow::OnOptionsCheck)
EVT_CHECKBOX(IDM_WRITEWINDOW, CLogWindow::OnOptionsCheck)
EVT_CHECKLISTBOX(IDM_LOGCHECKS, CLogWindow::OnLogCheck)
EVT_CHOICE(IDM_FONT, CLogWindow::OnFontChange)
EVT_CHECKBOX(IDM_WRAPLINE, CLogWindow::OnWrapLineCheck)
EVT_TIMER(IDTM_UPDATELOG, CLogWindow::OnLogTimer)
EVT_SIZE(CLogWindow::OnSize)
END_EVENT_TABLE()
@ -81,25 +75,9 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
void CLogWindow::CreateGUIControls()
{
// Verbosity
wxArrayString wxLevels, wxLevelsUse;
wxLevels.Add(_("Notice"));
wxLevels.Add(_("Error"));
wxLevels.Add(_("Warning"));
wxLevels.Add(_("Info"));
wxLevels.Add(_("Debug"));
for (int i = 0; i < MAX_LOGLEVEL; ++i)
wxLevelsUse.Add(wxString::Format(wxT("%s"), wxLevels.Item(i).c_str()));
m_verbosity = new wxRadioBox(this, IDM_VERBOSITY, _("Verbosity"),
wxDefaultPosition, wxDefaultSize, wxLevelsUse, 0,
wxRA_SPECIFY_ROWS, wxDefaultValidator);
// Don't take up so much space
m_verbosity->SetFont(wxFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
// Font
m_FontChoice = new wxChoice(this, IDM_FONT,
wxDefaultPosition, wxDefaultSize, 0, NULL, 0, wxDefaultValidator);
m_FontChoice->Append(_("Default font"));
m_FontChoice->Append(_("Monospaced font"));
m_FontChoice->Append(_("Selected font"));
@ -110,16 +88,8 @@ void CLogWindow::CreateGUIControls()
LogFont.push_back(MonoSpaceFont);
LogFont.push_back(DebuggerFont);
// Options
// Line wrap
wxCheckBox * m_WrapLine = new wxCheckBox(this, IDM_WRAPLINE, _("Word Wrap"));
m_writeFileCB = new wxCheckBox(this, IDM_WRITEFILE,
_("Write to File"), wxDefaultPosition, wxDefaultSize, 0);
m_writeConsoleCB = new wxCheckBox(this, IDM_WRITECONSOLE,
_("Write to Console"), wxDefaultPosition, wxDefaultSize, 0);
m_writeWindowCB = new wxCheckBox(this, IDM_WRITEWINDOW,
_("Write to Window ->"), wxDefaultPosition, wxDefaultSize, 0);
m_checks = new wxCheckListBox(this, IDM_LOGCHECKS, wxDefaultPosition, wxDefaultSize);
// Log viewer and submit row
m_Log = CreateTextCtrl(this, IDM_LOG, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
@ -127,35 +97,19 @@ void CLogWindow::CreateGUIControls()
wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
// Sizers
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, _("Options"));
wxBoxSizer* sLogCtrl = new wxBoxSizer(wxHORIZONTAL);
sLogCtrl->Add(new wxButton(this, IDM_TOGGLEALL, _("Toggle all"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT), 1);
sLogCtrl->Add(new wxButton(this, IDM_CLEARLOG, _("Clear"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT), 1);
sbLeftOptions->Add(m_FontChoice, 0, (wxDOWN), 1);
sbLeftOptions->Add(m_WrapLine, 0, (wxDOWN), 1);
sbLeftOptions->Add(m_writeFileCB, 0, (wxDOWN), 1);
sbLeftOptions->Add(m_writeConsoleCB, 0, (wxDOWN), 1);
sbLeftOptions->Add(m_writeWindowCB, 0);
sLeft->Add(m_verbosity, 0, wxEXPAND | (wxLEFT | wxRIGHT), 5);
sLeft->Add(sbLeftOptions, 0, wxEXPAND | (wxLEFT | wxRIGHT), 5);
sLeft->Add(sLogCtrl, 0, wxEXPAND);
sLeft->Add(m_checks, 1, wxEXPAND);
wxBoxSizer *sTop = new wxBoxSizer(wxHORIZONTAL);
sTop->Add(new wxButton(this, IDM_CLEARLOG, _("Clear"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT));
sTop->Add(m_FontChoice, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 3);
sTop->Add(m_WrapLine, 0, wxALIGN_CENTER_VERTICAL);
sBottom = new wxBoxSizer(wxVERTICAL);
PopulateRight();
sUber->Add(sLeft, 0, wxEXPAND);
sUber->Add(sRight, 1, wxEXPAND);
this->SetSizer(sUber);
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
sMain->Add(sTop, 0, wxEXPAND);
sMain->Add(sBottom, 1, wxEXPAND);
SetSizer(sMain);
m_cmdline->SetFocus();
}
@ -199,13 +153,7 @@ void CLogWindow::SaveSettings()
ini.Set("LogWindow", "y", y);
ini.Set("LogWindow", "pos", winpos);
}
ini.Set("Options", "Verbosity", m_verbosity->GetSelection() + 1);
ini.Set("Options", "Font", m_FontChoice->GetSelection());
ini.Set("Options", "WriteToFile", m_writeFile);
ini.Set("Options", "WriteToConsole", m_writeConsole);
ini.Set("Options", "WriteToWindow", m_writeWindow);
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(File::GetUserPath(F_LOGGERCONFIG_IDX));
}
@ -222,17 +170,15 @@ void CLogWindow::LoadSettings()
ini.Get("Options", "Verbosity", &verbosity, 0);
if (verbosity < 1) verbosity = 1;
if (verbosity > MAX_LOGLEVEL) verbosity = MAX_LOGLEVEL;
m_verbosity->SetSelection(verbosity - 1);
ini.Get("Options", "Font", &font, 0);
m_FontChoice->SetSelection(font);
if (m_FontChoice->GetSelection() < (int)LogFont.size())
m_Log->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, LogFont[m_FontChoice->GetSelection()]));
ini.Get("Options", "WriteToFile", &m_writeFile, false);
m_writeFileCB->SetValue(m_writeFile);
ini.Get("Options", "WriteToConsole", &m_writeConsole, true);
m_writeConsoleCB->SetValue(m_writeConsole);
ini.Get("Options", "WriteToWindow", &m_writeWindow, true);
m_writeWindowCB->SetValue(m_writeWindow);
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
bool enable;
@ -254,7 +200,6 @@ void CLogWindow::LoadSettings()
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_console);
m_LogManager->setLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)(verbosity));
}
UpdateChecks();
}
void CLogWindow::OnSubmit(wxCommandEvent& WXUNUSED (event))
@ -277,59 +222,17 @@ void CLogWindow::OnClear(wxCommandEvent& WXUNUSED (event))
m_console->ClearScreen();
}
// Enable or disable all boxes for the current verbosity level and save the changes.
void CLogWindow::OnToggleAll(wxCommandEvent& WXUNUSED (event))
{
static bool enableAll = false;
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
ToggleLog(i, enableAll);
}
SaveSettings();
enableAll = !enableAll;
}
// 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->Freeze();
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
m_checks->Append(wxString::FromAscii(m_LogManager->getFullName( (LogTypes::LOG_TYPE)i )));
}
m_checks->Thaw();
}
m_checks->Freeze();
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
m_checks->Check(i,
m_LogManager->isListener((LogTypes::LOG_TYPE)i, this) ||
m_LogManager->isListener((LogTypes::LOG_TYPE)i, m_console) ||
m_LogManager->isListener((LogTypes::LOG_TYPE)i, m_fileLog));
}
m_checks->Thaw();
}
void CLogWindow::UnPopulateRight()
{
sRight->Detach(m_Log);
sRight->Detach(sRightBottom);
sRightBottom = new wxBoxSizer(wxHORIZONTAL);
sBottom->Detach(m_Log);
sBottom->Detach(m_cmdline);
}
void CLogWindow::PopulateRight()
{
sRightBottom->Add(m_cmdline, 1, wxEXPAND);
sRight->Add(m_Log, 1, wxEXPAND | wxSHRINK);
sRight->Add(sRightBottom, 0, wxEXPAND);
this->Layout();
sBottom->Add(m_Log, 1, wxEXPAND | wxSHRINK);
sBottom->Add(m_cmdline, 0, wxEXPAND);
Layout();
}
wxTextCtrl* CLogWindow::CreateTextCtrl(wxPanel* parent, wxWindowID id, long Style)
@ -348,134 +251,46 @@ wxTextCtrl* CLogWindow::CreateTextCtrl(wxPanel* parent, wxWindowID id, long Styl
return TC;
}
void CLogWindow::OnFontChange(wxCommandEvent& event)
{
// Update selected font
LogFont[LogFont.size()-1] = DebuggerFont;
m_Log->SetStyle(0, m_Log->GetLastPosition(),
wxTextAttr(wxNullColour, wxNullColour, LogFont[event.GetSelection()]));
m_Log->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, LogFont[event.GetSelection()]));
SaveSettings();
}
// When an option is changed, save the change
void CLogWindow::OnOptionsCheck(wxCommandEvent& event)
void CLogWindow::OnWrapLineCheck(wxCommandEvent& event)
{
wxString Text;
switch (event.GetId())
{
case IDM_VERBOSITY:
{
// get selection
int v = m_verbosity->GetSelection() + 1;
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
m_LogManager->setLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)v);
}
}
break;
case IDM_WRAPLINE:
#ifdef __WXGTK__
m_Log->SetWindowStyleFlag(m_Log->GetWindowStyleFlag() ^ (wxTE_WORDWRAP | wxTE_DONTWRAP));
m_Log->SetWindowStyleFlag(m_Log->GetWindowStyleFlag() ^ (wxTE_WORDWRAP | wxTE_DONTWRAP));
#else
// Unfortunately wrapping styles can only be changed dynamically with wxGTK
// Notice: To retain the colors when changing word wrapping we need to
// loop through every letter with GetStyle and then reapply them letter by letter
// Prevent m_Log access while it's being destroyed
m_LogAccess = false;
UnPopulateRight();
Text = m_Log->GetValue();
m_Log->Destroy();
if (event.IsChecked())
m_Log = CreateTextCtrl(this, IDM_LOG,
wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_WORDWRAP);
else
m_Log = CreateTextCtrl(this, IDM_LOG,
wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
m_Log->SetDefaultStyle(wxTextAttr(*wxWHITE));
m_Log->AppendText(Text);
PopulateRight();
m_LogAccess = true;
#endif
break;
case IDM_FONT:
// Update selected font
LogFont[LogFont.size()-1] = DebuggerFont;
m_Log->SetStyle(0, m_Log->GetLastPosition(),
wxTextAttr(wxNullColour, wxNullColour, LogFont[event.GetSelection()]));
m_Log->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, LogFont[event.GetSelection()]));
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_WRITEWINDOW:
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
m_writeWindow = event.IsChecked();
if (m_checks->IsChecked(i))
{
if (m_writeWindow)
m_LogManager->addListener((LogTypes::LOG_TYPE)i, this);
else
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, this);
}
}
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();
ToggleLog(i, m_checks->IsChecked(i));
SaveSettings();
}
void CLogWindow::ToggleLog(int _logType, bool enable)
{
LogTypes::LOG_TYPE logType = (LogTypes::LOG_TYPE)_logType;
m_checks->Check(_logType, enable);
m_LogManager->setEnable(logType, enable);
if (enable)
{
if (m_writeWindow)
m_LogManager->addListener(logType, this);
if (m_writeFile)
m_LogManager->addListener(logType, m_fileLog);
if (m_writeConsole)
m_LogManager->addListener(logType, m_console);
}
// Unfortunately wrapping styles can only be changed dynamically with wxGTK
// Notice: To retain the colors when changing word wrapping we need to
// loop through every letter with GetStyle and then reapply them letter by letter
// Prevent m_Log access while it's being destroyed
m_LogAccess = false;
UnPopulateRight();
Text = m_Log->GetValue();
m_Log->Destroy();
if (event.IsChecked())
m_Log = CreateTextCtrl(this, IDM_LOG,
wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_WORDWRAP);
else
{
m_LogManager->removeListener(logType, this);
m_LogManager->removeListener(logType, m_fileLog);
m_LogManager->removeListener(logType, m_console);
}
m_Log = CreateTextCtrl(this, IDM_LOG,
wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
m_Log->SetDefaultStyle(wxTextAttr(*wxWHITE));
m_Log->AppendText(Text);
PopulateRight();
m_LogAccess = true;
#endif
SaveSettings();
}
void CLogWindow::OnLogTimer(wxTimerEvent& WXUNUSED(event))

View File

@ -76,12 +76,9 @@ private:
bool m_writeFile, m_writeConsole, m_writeWindow, m_LogAccess;
// Controls
wxBoxSizer *sUber, *sLeft, *sRight, *sRightBottom;
wxBoxSizer *sBottom;
wxTextCtrl *m_Log, *m_cmdline;
wxChoice * m_FontChoice;
wxCheckBox *m_writeFileCB, *m_writeConsoleCB, *m_writeWindowCB;
wxCheckListBox* m_checks;
wxRadioBox *m_verbosity;
Common::CriticalSection m_LogSection;
@ -95,14 +92,10 @@ private:
void OnClose(wxCloseEvent& event);
void OnSize(wxSizeEvent& event);
void OnSubmit(wxCommandEvent& event);
void OnOptionsCheck(wxCommandEvent& event);
void OnLogCheck(wxCommandEvent& event);
void OnFontChange(wxCommandEvent& event);
void OnWrapLineCheck(wxCommandEvent& event);
void OnClear(wxCommandEvent& event);
void OnToggleAll(wxCommandEvent& event);
void OnLogTimer(wxTimerEvent& WXUNUSED(event));
void ToggleLog(int _logType, bool enable);
void UpdateChecks();
void UpdateLog();
// LogListener

View File

@ -20,6 +20,7 @@ else:
'FrameAui.cpp',
'FrameTools.cpp',
'LogWindow.cpp',
'LogConfigDiag.cpp',
'GameListCtrl.cpp',
'HotkeyDlg.cpp',
'InputConfigDiag.cpp',

View File

@ -82,7 +82,7 @@ void VideoConfigDiag::Event_Close(wxCloseEvent& ev)
// TODO: implement some hack to increase the tooltip display duration, because some of these are way too long for anyone to read in 5 seconds.
wxString profile_tooltip = wxTRANSLATE("Selects which game should be affect by the configuration changes done in this dialog.\nThe (Default) profile affects the standard settings used for every game.");
wxString profile_tooltip = wxTRANSLATE("Selects which game should be affected by the configuration changes done in this dialog.\nThe (Default) profile affects the standard settings used for every game.");
wxString adapter_tooltip = wxTRANSLATE("Select a hardware adapter to use.\nWhen in doubt, use the first one");
wxString ar_tooltip = wxTRANSLATE("Select what aspect ratio to use when rendering:\nAuto: Use the native aspect ratio (4:3)\nForce 16:9: Stretch the picture to an aspect ratio of 16:9.\nForce 4:3: Stretch the picture to an aspect ratio of 4:3.\nStretch to window: Stretch the picture to the window size.");
wxString ws_hack_tooltip = wxTRANSLATE("Force the game to output graphics for widescreen resolutions.\nNote that this might cause graphical glitches");