Implement hotkey options group in HotkeyInputConfigDiag

This commit is contained in:
Michael Maltese 2017-02-07 18:26:06 -08:00
parent a6bc56b626
commit 8adad0729e
4 changed files with 47 additions and 31 deletions

View File

@ -14,7 +14,6 @@
#include "InputCommon/ControllerEmu/Control/Input.h" #include "InputCommon/ControllerEmu/Control/Input.h"
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h" #include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerEmu/Setting/BackgroundInputSetting.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" #include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/GCPadStatus.h" #include "InputCommon/GCPadStatus.h"
@ -228,11 +227,6 @@ ControllerEmu::ControlGroup* GetHotkeyGroup(HotkeyGroup group)
return static_cast<HotkeyManager*>(s_config.GetController(0))->GetHotkeyGroup(group); return static_cast<HotkeyManager*>(s_config.GetController(0))->GetHotkeyGroup(group);
} }
ControllerEmu::ControlGroup* GetOptionsGroup()
{
return static_cast<HotkeyManager*>(s_config.GetController(0))->GetOptionsGroup();
}
void Shutdown() void Shutdown()
{ {
s_config.ClearControllers(); s_config.ClearControllers();
@ -272,12 +266,6 @@ HotkeyManager::HotkeyManager()
m_keys[group]->controls.emplace_back(new ControllerEmu::Input(hotkey_labels[key])); m_keys[group]->controls.emplace_back(new ControllerEmu::Input(hotkey_labels[key]));
} }
} }
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
m_options->boolean_settings.emplace_back(
std::make_unique<ControllerEmu::BackgroundInputSetting>(_trans("Background Input")));
m_options->boolean_settings.emplace_back(std::make_unique<ControllerEmu::BooleanSetting>(
_trans("Iterative Input"), false, ControllerEmu::SettingType::VIRTUAL));
} }
HotkeyManager::~HotkeyManager() HotkeyManager::~HotkeyManager()
@ -309,11 +297,6 @@ ControllerEmu::ControlGroup* HotkeyManager::GetHotkeyGroup(HotkeyGroup group) co
return m_hotkey_groups[group]; return m_hotkey_groups[group];
} }
ControllerEmu::ControlGroup* HotkeyManager::GetOptionsGroup() const
{
return m_options;
}
int HotkeyManager::FindGroupByID(int id) const int HotkeyManager::FindGroupByID(int id) const
{ {
const auto i = std::find_if(groups_info.begin(), groups_info.end(), const auto i = std::find_if(groups_info.begin(), groups_info.end(),

View File

@ -199,7 +199,6 @@ public:
void GetInput(HotkeyStatus* const hk); void GetInput(HotkeyStatus* const hk);
std::string GetName() const override; std::string GetName() const override;
ControllerEmu::ControlGroup* GetHotkeyGroup(HotkeyGroup group) const; ControllerEmu::ControlGroup* GetHotkeyGroup(HotkeyGroup group) const;
ControllerEmu::ControlGroup* GetOptionsGroup() const;
int FindGroupByID(int id) const; int FindGroupByID(int id) const;
int GetIndexForGroup(int group, int id) const; int GetIndexForGroup(int group, int id) const;
void LoadDefaults(const ControllerInterface& ciface) override; void LoadDefaults(const ControllerInterface& ciface) override;
@ -207,7 +206,6 @@ public:
private: private:
ControllerEmu::Buttons* m_keys[NUM_HOTKEY_GROUPS]; ControllerEmu::Buttons* m_keys[NUM_HOTKEY_GROUPS];
std::array<ControllerEmu::ControlGroup*, NUM_HOTKEY_GROUPS> m_hotkey_groups; std::array<ControllerEmu::ControlGroup*, NUM_HOTKEY_GROUPS> m_hotkey_groups;
ControllerEmu::ControlGroup* m_options;
}; };
namespace HotkeyManagerEmu namespace HotkeyManagerEmu
@ -218,7 +216,6 @@ void LoadConfig();
InputConfig* GetConfig(); InputConfig* GetConfig();
ControllerEmu::ControlGroup* GetHotkeyGroup(HotkeyGroup group); ControllerEmu::ControlGroup* GetHotkeyGroup(HotkeyGroup group);
ControllerEmu::ControlGroup* GetOptionsGroup();
void GetStatus(); void GetStatus();
bool IsEnabled(); bool IsEnabled();
void Enable(bool enable_toggle); void Enable(bool enable_toggle);

View File

@ -2,10 +2,12 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <wx/checkbox.h>
#include <wx/notebook.h> #include <wx/notebook.h>
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include "Core/ConfigManager.h"
#include "Core/HotkeyManager.h" #include "Core/HotkeyManager.h"
#include "DolphinWX/Input/HotkeyInputConfigDiag.h" #include "DolphinWX/Input/HotkeyInputConfigDiag.h"
@ -24,7 +26,7 @@ HotkeyInputConfigDialog::HotkeyInputConfigDialog(wxWindow* parent, InputConfig&
UpdateGUI(); UpdateGUI();
} }
wxBoxSizer* HotkeyInputConfigDialog::CreateMainSizer() wxSizer* HotkeyInputConfigDialog::CreateMainSizer()
{ {
const int space5 = FromDIP(5); const int space5 = FromDIP(5);
auto* const main_sizer = new wxBoxSizer(wxVERTICAL); auto* const main_sizer = new wxBoxSizer(wxVERTICAL);
@ -41,24 +43,54 @@ wxBoxSizer* HotkeyInputConfigDialog::CreateMainSizer()
return main_sizer; return main_sizer;
} }
wxBoxSizer* HotkeyInputConfigDialog::CreateDeviceRelatedSizer() void HotkeyInputConfigDialog::OnBackgroundInputChanged(wxCommandEvent& event)
{
SConfig::GetInstance().m_BackgroundInput = event.IsChecked();
}
void HotkeyInputConfigDialog::OnIterativeInputChanged(wxCommandEvent& event)
{
m_iterate = event.IsChecked();
}
wxSizer* HotkeyInputConfigDialog::CreateOptionsSizer()
{
const int space3 = FromDIP(3);
auto background_input_checkbox = new wxCheckBox(this, wxID_ANY, _("Background Input"));
background_input_checkbox->SetValue(SConfig::GetInstance().m_BackgroundInput);
background_input_checkbox->Bind(wxEVT_CHECKBOX,
&HotkeyInputConfigDialog::OnBackgroundInputChanged, this);
auto iterative_input_checkbox = new wxCheckBox(this, wxID_ANY, _("Iterative Input"));
iterative_input_checkbox->SetValue(m_iterate);
iterative_input_checkbox->Bind(wxEVT_CHECKBOX, &HotkeyInputConfigDialog::OnIterativeInputChanged,
this);
auto sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Options"));
sizer->AddSpacer(space3);
sizer->Add(background_input_checkbox, 0, wxLEFT | wxRIGHT, space3);
sizer->AddSpacer(space3);
sizer->Add(iterative_input_checkbox, 0, wxLEFT | wxRIGHT, space3);
sizer->AddSpacer(space3);
return sizer;
}
wxSizer* HotkeyInputConfigDialog::CreateDeviceRelatedSizer()
{ {
const int space5 = FromDIP(5); const int space5 = FromDIP(5);
auto* const enclosing_sizer = new wxBoxSizer(wxHORIZONTAL); auto* const enclosing_sizer = new wxBoxSizer(wxHORIZONTAL);
auto* const reset_sizer = CreaterResetGroupBox(wxVERTICAL);
auto* const options_group_box =
new ControlGroupBox(HotkeyManagerEmu::GetOptionsGroup(), this, this);
enclosing_sizer->AddSpacer(space5); enclosing_sizer->AddSpacer(space5);
enclosing_sizer->Add(CreateDeviceProfileSizer(), 3, wxEXPAND); enclosing_sizer->Add(CreateDeviceProfileSizer(), 3, wxEXPAND);
enclosing_sizer->Add(reset_sizer, 0, wxEXPAND); enclosing_sizer->Add(CreaterResetGroupBox(wxVERTICAL), 0, wxEXPAND);
enclosing_sizer->Add(options_group_box, 1, wxEXPAND); enclosing_sizer->Add(CreateOptionsSizer(), 1, wxEXPAND);
enclosing_sizer->AddSpacer(space5); enclosing_sizer->AddSpacer(space5);
return enclosing_sizer; return enclosing_sizer;
} }
wxBoxSizer* HotkeyInputConfigDialog::CreateDeviceProfileSizer() wxSizer* HotkeyInputConfigDialog::CreateDeviceProfileSizer()
{ {
auto* const device_chooser = CreateDeviceChooserGroupBox(); auto* const device_chooser = CreateDeviceChooserGroupBox();
auto* const profile_chooser = CreateProfileChooserGroupBox(); auto* const profile_chooser = CreateProfileChooserGroupBox();

View File

@ -17,9 +17,10 @@ public:
bool using_debugger, int port_num = 0); bool using_debugger, int port_num = 0);
private: private:
wxBoxSizer* CreateMainSizer(); wxSizer* CreateMainSizer();
wxBoxSizer* CreateDeviceRelatedSizer(); wxSizer* CreateDeviceRelatedSizer();
wxBoxSizer* CreateDeviceProfileSizer(); wxSizer* CreateDeviceProfileSizer();
wxSizer* CreateOptionsSizer();
void InitializeNotebook(); void InitializeNotebook();
wxPanel* CreateGeneralPanel(); wxPanel* CreateGeneralPanel();
@ -31,6 +32,9 @@ private:
wxPanel* CreateSaveAndLoadStatePanel(); wxPanel* CreateSaveAndLoadStatePanel();
wxPanel* CreateOtherStateManagementPanel(); wxPanel* CreateOtherStateManagementPanel();
void OnBackgroundInputChanged(wxCommandEvent& event);
void OnIterativeInputChanged(wxCommandEvent& event);
wxNotebook* m_notebook; wxNotebook* m_notebook;
bool m_using_debugger; bool m_using_debugger;
}; };