Skip to content

Commit

Permalink
simplify combobox value extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
smanolloff committed Oct 10, 2024
1 parent 50ce5c8 commit 773a7fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ endif()
############################################
# Finding packages #
############################################

set(BOOST_COMPONENTS date_time filesystem locale program_options system thread)
if(ENABLE_INNOEXTRACT)
list(APPEND BOOST_COMPONENTS iostreams)
Expand Down
32 changes: 12 additions & 20 deletions launcher/settingsView/csettingsview_moc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@ void CSettingsView::loadSettings()
#endif

#ifdef ENABLE_MMAI
auto value = "MMAI";
auto label = "MMAI (experimental)";
for (auto &b : {ui->comboBoxFriendlyAI, ui->comboBoxNeutralAI, ui->comboBoxEnemyAI}) {
b->addItem(label, value);
}
ui->comboBoxFriendlyAI->addItem("MMAI (experimental)", "MMAI");
ui->comboBoxNeutralAI->addItem("MMAI (experimental)", "MMAI");
ui->comboBoxEnemyAI->addItem("MMAI (experimental)", "MMAI");
#endif

fillValidScalingRange();
Expand Down Expand Up @@ -433,31 +431,25 @@ void CSettingsView::on_comboBoxDisplayIndex_currentIndexChanged(int index)
fillValidResolutionsForScreen(index);
}

void CSettingsView::on_comboBoxFriendlyAI_currentTextChanged(const QString & arg1)
void CSettingsView::on_comboBoxFriendlyAI_currentTextChanged(const QString & text)
{
Settings node = settings.write["server"]["friendlyAI"];
auto qstr = ui->comboBoxFriendlyAI->currentData().toString();
if (qstr.isEmpty())
qstr = arg1;
node->String() = qstr.toUtf8().data();
auto value = ui->comboBoxFriendlyAI->currentData().toString();
node->String() = value.isEmpty() ? text.toUtf8().data() : value.toUtf8().data();
}

void CSettingsView::on_comboBoxNeutralAI_currentTextChanged(const QString & arg1)
void CSettingsView::on_comboBoxNeutralAI_currentTextChanged(const QString & text)
{
Settings node = settings.write["server"]["neutralAI"];
auto qstr = ui->comboBoxNeutralAI->currentData().toString();
if (qstr.isEmpty())
qstr = arg1;
node->String() = qstr.toUtf8().data();
auto value = ui->comboBoxNeutralAI->currentData().toString();
node->String() = value.isEmpty() ? text.toUtf8().data() : value.toUtf8().data();
}

void CSettingsView::on_comboBoxEnemyAI_currentTextChanged(const QString & arg1)
void CSettingsView::on_comboBoxEnemyAI_currentTextChanged(const QString & text)
{
Settings node = settings.write["server"]["enemyAI"];
auto qstr = ui->comboBoxEnemyAI->currentData().toString();
if (qstr.isEmpty())
qstr = arg1;
node->String() = qstr.toUtf8().data();
auto value = ui->comboBoxEnemyAI->currentData().toString();
node->String() = value.isEmpty() ? text.toUtf8().data() : value.toUtf8().data();
}

void CSettingsView::on_spinBoxNetworkPort_valueChanged(int arg1)
Expand Down

0 comments on commit 773a7fb

Please sign in to comment.