Lioncash 086ec7a9b7 DolphinWX: Break up ConfigMain.cpp into separate classes
Prior to this, ConfigMain.cpp was a large (52KB) cpp file that contained all of the UI setting code.

This breaks up the config code into subclasses of wxPanel, which are then just instantiated to add to the settings wxNoteBook. This keeps all the settings categories separated from one another and also cleans up the code in general.
2015-03-18 22:47:49 -04:00

96 lines
2.8 KiB
C++

// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <wx/notebook.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include "Common/CommonTypes.h"
#include "Core/ConfigManager.h"
#include "DolphinWX/WxUtils.h"
#include "DolphinWX/Config/AdvancedConfigPane.h"
#include "DolphinWX/Config/AudioConfigPane.h"
#include "DolphinWX/Config/ConfigMain.h"
#include "DolphinWX/Config/GameCubeConfigPane.h"
#include "DolphinWX/Config/GeneralConfigPane.h"
#include "DolphinWX/Config/InterfaceConfigPane.h"
#include "DolphinWX/Config/PathConfigPane.h"
#include "DolphinWX/Config/WiiConfigPane.h"
BEGIN_EVENT_TABLE(CConfigMain, wxDialog)
EVT_CLOSE(CConfigMain::OnClose)
EVT_BUTTON(wxID_OK, CConfigMain::OnOk)
END_EVENT_TABLE()
CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title,
const wxPoint& position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
// Control refreshing of the ISOs list
bRefreshList = false;
CreateGUIControls();
}
CConfigMain::~CConfigMain()
{
}
void CConfigMain::SetSelectedTab(int tab)
{
// TODO : this is just a quick and dirty way to do it, possible cleanup
switch (tab)
{
case ID_AUDIOPAGE:
Notebook->SetSelection(2);
break;
}
}
void CConfigMain::CreateGUIControls()
{
// Create the notebook and pages
Notebook = new wxNotebook(this, ID_NOTEBOOK);
wxPanel* const general_pane = new GeneralConfigPane(Notebook, ID_GENERALPAGE);
wxPanel* const interface_pane = new InterfaceConfigPane(Notebook, ID_DISPLAYPAGE);
wxPanel* const audio_pane = new AudioConfigPane(Notebook, ID_AUDIOPAGE);
wxPanel* const gamecube_pane = new GameCubeConfigPane(Notebook, ID_GAMECUBEPAGE);
wxPanel* const wii_pane = new WiiConfigPane(Notebook, ID_WIIPAGE);
wxPanel* const path_pane = new PathConfigPane(Notebook, ID_PATHSPAGE);
wxPanel* const advanced_pane = new AdvancedConfigPane(Notebook, ID_ADVANCEDPAGE);
Notebook->AddPage(general_pane, _("General"));
Notebook->AddPage(interface_pane, _("Interface"));
Notebook->AddPage(audio_pane, _("Audio"));
Notebook->AddPage(gamecube_pane, _("GameCube"));
Notebook->AddPage(wii_pane, _("Wii"));
Notebook->AddPage(path_pane, _("Paths"));
Notebook->AddPage(advanced_pane, _("Advanced"));
wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(Notebook, 1, wxEXPAND | wxALL, 5);
main_sizer->Add(CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
SetSizerAndFit(main_sizer);
Center();
SetFocus();
}
void CConfigMain::OnClose(wxCloseEvent& WXUNUSED(event))
{
EndModal((bRefreshList) ? wxID_OK : wxID_CANCEL);
}
void CConfigMain::OnOk(wxCommandEvent& WXUNUSED(event))
{
Close();
// Save the config. Dolphin crashes too often to only save the settings on closing
SConfig::GetInstance().SaveSettings();
}