Qt/PadMappingDialog: Retain previous settings
This commit is contained in:
parent
beeb6754d2
commit
4af021ea03
|
@ -45,11 +45,24 @@ void PadMappingDialog::CreateWidgets()
|
||||||
void PadMappingDialog::ConnectWidgets()
|
void PadMappingDialog::ConnectWidgets()
|
||||||
{
|
{
|
||||||
connect(m_button_box, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
connect(m_button_box, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
for (auto& combo_group : {m_gc_boxes, m_wii_boxes})
|
||||||
|
{
|
||||||
|
for (auto& combo : combo_group)
|
||||||
|
{
|
||||||
|
connect(combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||||
|
&PadMappingDialog::OnMappingChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int PadMappingDialog::exec()
|
int PadMappingDialog::exec()
|
||||||
{
|
{
|
||||||
m_players = Settings::Instance().GetNetPlayClient()->GetPlayers();
|
auto* client = Settings::Instance().GetNetPlayClient();
|
||||||
|
auto* server = Settings::Instance().GetNetPlayServer();
|
||||||
|
// Load Settings
|
||||||
|
m_players = client->GetPlayers();
|
||||||
|
m_pad_mapping = server->GetPadMapping();
|
||||||
|
m_wii_mapping = server->GetWiimoteMapping();
|
||||||
|
|
||||||
QStringList players;
|
QStringList players;
|
||||||
|
|
||||||
|
@ -63,18 +76,24 @@ int PadMappingDialog::exec()
|
||||||
|
|
||||||
for (auto& combo_group : {m_gc_boxes, m_wii_boxes})
|
for (auto& combo_group : {m_gc_boxes, m_wii_boxes})
|
||||||
{
|
{
|
||||||
for (auto& combo : combo_group)
|
bool gc = combo_group == m_gc_boxes;
|
||||||
|
for (size_t i = 0; i < combo_group.size(); i++)
|
||||||
{
|
{
|
||||||
|
auto& combo = combo_group[i];
|
||||||
|
const bool old = combo->blockSignals(true);
|
||||||
|
|
||||||
combo->clear();
|
combo->clear();
|
||||||
combo->addItems(players);
|
combo->addItems(players);
|
||||||
connect(combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
|
||||||
&PadMappingDialog::OnMappingChanged);
|
const auto index = gc ? m_pad_mapping[i] : m_wii_mapping[i];
|
||||||
|
|
||||||
|
combo->setCurrentIndex(index == -1 ? 0 : index);
|
||||||
|
combo->blockSignals(old);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QDialog::exec();
|
return QDialog::exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
PadMappingArray PadMappingDialog::GetGCPadArray()
|
PadMappingArray PadMappingDialog::GetGCPadArray()
|
||||||
{
|
{
|
||||||
return m_pad_mapping;
|
return m_pad_mapping;
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void CreateWidgets();
|
void CreateWidgets();
|
||||||
void ConnectWidgets();
|
void ConnectWidgets();
|
||||||
|
|
||||||
void OnMappingChanged();
|
void OnMappingChanged();
|
||||||
|
|
||||||
PadMappingArray m_pad_mapping;
|
PadMappingArray m_pad_mapping;
|
||||||
|
|
Loading…
Reference in New Issue