Author: mir3x Date: Fri Jul 22 20:29:19 2016 New Revision: 33299 URL: http://svn.gna.org/viewcvs/freeciv?rev=33299&view=rev Log: Qt client - use encapsulation in class pregame_options Patch by Louis Moureaux <louis94>
See patch #7486 Modified: branches/S2_6/client/gui-qt/fc_client.cpp branches/S2_6/client/gui-qt/fc_client.h branches/S2_6/client/gui-qt/optiondlg.cpp branches/S2_6/client/gui-qt/pages.cpp Modified: branches/S2_6/client/gui-qt/fc_client.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/fc_client.cpp?rev=33299&r1=33298&r2=33299&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/fc_client.cpp (original) +++ branches/S2_6/client/gui-qt/fc_client.cpp Fri Jul 22 20:29:19 2016 @@ -954,6 +954,39 @@ } /**************************************************************************** + Update the ruleset list +****************************************************************************/ +void pregame_options::set_rulesets(int num_rulesets, char **rulesets) +{ + int i; + int def_idx = -1; + + cruleset->clear(); + cruleset->blockSignals(true); + for (i = 0; i < num_rulesets; i++){ + cruleset->addItem(rulesets[i], i); + if (!strcmp("default", rulesets[i])) { + def_idx = i; + } + } + + /* HACK: server should tell us the current ruleset. */ + cruleset->setCurrentIndex(def_idx); + cruleset->blockSignals(false); +} + +/**************************************************************************** + Sets the value of the "aifill" option. Doesn't send the new value to the + server +****************************************************************************/ +void pregame_options::set_aifill(int aifill) +{ + max_players->blockSignals(true); + max_players->setValue(aifill); + max_players->blockSignals(false); +} + +/**************************************************************************** Slot for changing aifill value ****************************************************************************/ void pregame_options::max_players_change(int i) Modified: branches/S2_6/client/gui-qt/fc_client.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/fc_client.h?rev=33299&r1=33298&r2=33299&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/fc_client.h (original) +++ branches/S2_6/client/gui-qt/fc_client.h Fri Jul 22 20:29:19 2016 @@ -335,11 +335,14 @@ { Q_OBJECT QComboBox *ailevel; + QComboBox *cruleset; + QSpinBox *max_players; public: pregame_options() {}; void init(); - QComboBox *cruleset; - QSpinBox *max_players; + + void set_rulesets(int num_rulesets, char **rulesets); + void set_aifill(int aifill); private slots: void max_players_change(int i); void ailevel_change(int i); Modified: branches/S2_6/client/gui-qt/optiondlg.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/optiondlg.cpp?rev=33299&r1=33298&r2=33299&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/optiondlg.cpp (original) +++ branches/S2_6/client/gui-qt/optiondlg.cpp Fri Jul 22 20:29:19 2016 @@ -876,7 +876,7 @@ update_nationset_combo(); } if (strcmp(option_name(poption), "aifill") == 0) { - gui()->pr_options->max_players->setValue(option_int_get(poption)); + gui()->pr_options->set_aifill(option_int_get(poption)); } } } Modified: branches/S2_6/client/gui-qt/pages.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/pages.cpp?rev=33299&r1=33298&r2=33299&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/pages.cpp (original) +++ branches/S2_6/client/gui-qt/pages.cpp Fri Jul 22 20:29:19 2016 @@ -58,21 +58,7 @@ ****************************************************************************/ void qtg_set_rulesets(int num_rulesets, char **rulesets) { - int i; - int def_idx = -1; - - gui()->pr_options->cruleset->clear(); - gui()->pr_options->cruleset->blockSignals(true); - for (i = 0; i < num_rulesets; i++){ - gui()->pr_options->cruleset->addItem(rulesets[i], i); - if (!strcmp("default", rulesets[i])) { - def_idx = i; - } - } - - /* HACK: server should tell us the current ruleset. */ - gui()->pr_options->cruleset->setCurrentIndex(def_idx); - gui()->pr_options->cruleset->blockSignals(false); + gui()->pr_options->set_rulesets(num_rulesets, rulesets); } /************************************************************************** @@ -1268,9 +1254,7 @@ players_iterate(pplayer) { i++; } players_iterate_end; - gui()->pr_options->max_players->blockSignals(true); - gui()->pr_options->max_players->setValue(i); - gui()->pr_options->max_players->blockSignals(false); + gui()->pr_options->set_aifill(i); /** * Inserts playing players, observing custom players, and AI ) */ _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits