ConfigMain.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Copyright 2015 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. #include <wx/notebook.h>
  5. #include <wx/panel.h>
  6. #include <wx/sizer.h>
  7. #include <wx/stattext.h>
  8. #include "Common/CommonTypes.h"
  9. #include "Core/ConfigManager.h"
  10. #include "Core/Movie.h"
  11. #include "Core/NetPlayProto.h"
  12. #include "DolphinWX/WxUtils.h"
  13. #include "DolphinWX/Config/AdvancedConfigPane.h"
  14. #include "DolphinWX/Config/AudioConfigPane.h"
  15. #include "DolphinWX/Config/ConfigMain.h"
  16. #include "DolphinWX/Config/GameCubeConfigPane.h"
  17. #include "DolphinWX/Config/GeneralConfigPane.h"
  18. #include "DolphinWX/Config/InterfaceConfigPane.h"
  19. #include "DolphinWX/Config/PathConfigPane.h"
  20. #include "DolphinWX/Config/WiiConfigPane.h"
  21. // Sent by child panes to signify that the game list should
  22. // be updated when this modal dialog closes.
  23. wxDEFINE_EVENT(wxDOLPHIN_CFG_REFRESH_LIST, wxCommandEvent);
  24. CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title,
  25. const wxPoint& position, const wxSize& size, long style)
  26. : wxDialog(parent, id, title, position, size, style)
  27. {
  28. // Control refreshing of the ISOs list
  29. m_refresh_game_list_on_close = false;
  30. Bind(wxEVT_CLOSE_WINDOW, &CConfigMain::OnClose, this);
  31. Bind(wxEVT_BUTTON, &CConfigMain::OnOk, this, wxID_OK);
  32. Bind(wxDOLPHIN_CFG_REFRESH_LIST, &CConfigMain::OnSetRefreshGameListOnClose, this);
  33. CreateGUIControls();
  34. }
  35. CConfigMain::~CConfigMain()
  36. {
  37. }
  38. void CConfigMain::SetSelectedTab(int tab)
  39. {
  40. // TODO : this is just a quick and dirty way to do it, possible cleanup
  41. switch (tab)
  42. {
  43. case ID_AUDIOPAGE:
  44. Notebook->SetSelection(2);
  45. break;
  46. }
  47. }
  48. void CConfigMain::CreateGUIControls()
  49. {
  50. // Create the notebook and pages
  51. Notebook = new wxNotebook(this, ID_NOTEBOOK);
  52. wxPanel* const general_pane = new GeneralConfigPane(Notebook, ID_GENERALPAGE);
  53. wxPanel* const interface_pane = new InterfaceConfigPane(Notebook, ID_DISPLAYPAGE);
  54. wxPanel* const audio_pane = new AudioConfigPane(Notebook, ID_AUDIOPAGE);
  55. wxPanel* const gamecube_pane = new GameCubeConfigPane(Notebook, ID_GAMECUBEPAGE);
  56. wxPanel* const wii_pane = new WiiConfigPane(Notebook, ID_WIIPAGE);
  57. wxPanel* const path_pane = new PathConfigPane(Notebook, ID_PATHSPAGE);
  58. wxPanel* const advanced_pane = new AdvancedConfigPane(Notebook, ID_ADVANCEDPAGE);
  59. Notebook->AddPage(general_pane, _("General"));
  60. Notebook->AddPage(interface_pane, _("Interface"));
  61. Notebook->AddPage(audio_pane, _("Audio"));
  62. Notebook->AddPage(gamecube_pane, _("GameCube"));
  63. Notebook->AddPage(wii_pane, _("Wii"));
  64. Notebook->AddPage(path_pane, _("Paths"));
  65. Notebook->AddPage(advanced_pane, _("Advanced"));
  66. if (Movie::IsMovieActive() || NetPlay::IsNetPlayRunning())
  67. advanced_pane->Disable();
  68. wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
  69. main_sizer->Add(Notebook, 1, wxEXPAND | wxALL, 5);
  70. main_sizer->Add(CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
  71. main_sizer->SetMinSize(400, 0);
  72. SetSizerAndFit(main_sizer);
  73. Center();
  74. SetFocus();
  75. }
  76. void CConfigMain::OnClose(wxCloseEvent& WXUNUSED(event))
  77. {
  78. EndModal((m_refresh_game_list_on_close) ? wxID_OK : wxID_CANCEL);
  79. }
  80. void CConfigMain::OnOk(wxCommandEvent& WXUNUSED(event))
  81. {
  82. Close();
  83. // Save the config. Dolphin crashes too often to only save the settings on closing
  84. SConfig::GetInstance().SaveSettings();
  85. }
  86. void CConfigMain::OnSetRefreshGameListOnClose(wxCommandEvent& WXUNUSED(event))
  87. {
  88. m_refresh_game_list_on_close = true;
  89. }