18 #include <QGridLayout>
44 connect(
ui.nation, &QPushButton::clicked,
this,
46 ui.qclientoptions->setText(
_(
"Interface Options"));
47 connect(
ui.qclientoptions, &QAbstractButton::clicked,
48 [=]() { popup_client_options(); });
51 const char *level_name =
52 ai_level_translated_name(
static_cast<ai_level
>(
level));
53 ui.ailevel->addItem(level_name,
level);
56 ui.ailevel->setCurrentIndex(-1);
57 connect(
ui.max_players, QOverload<int>::of(&QSpinBox::valueChanged),
this,
59 connect(
ui.ailevel, QOverload<int>::of(&QComboBox::currentIndexChanged),
61 connect(
ui.cruleset, QOverload<int>::of(&QComboBox::currentIndexChanged),
63 ui.qserveroptions->setText(
_(
"More Game Options"));
64 ui.qserveroptions->setIcon(
66 connect(
ui.qserveroptions, &QPushButton::clicked,
67 [=]() { option_dialog_popup(_(
"Game Options"), server_optset); });
68 ui.lnations->setText(
_(
"Nation:"));
69 ui.lrules->setText(
_(
"Rules:"));
70 ui.lplayers->setText(
_(
"Players:"));
71 setLayout(
ui.gridLayout);
84 ui.cruleset->blockSignals(
true);
86 for (
auto r : rulesets) {
87 ui.cruleset->addItem(r, i);
88 if (QString(
"default") == r) {
95 ui.cruleset->setCurrentIndex(def_idx);
96 ui.cruleset->blockSignals(
false);
105 ui.max_players->blockSignals(
true);
107 ui.max_players->blockSignals(
false);
118 if (pplayer !=
nullptr) {
119 if (pplayer->
nation !=
nullptr) {
123 .replace(QLatin1String(
"&"), QLatin1String(
"&&")));
125 ui.nation->setIconSize(pixmap->size());
126 ui.nation->setIcon(QIcon(*pixmap));
128 ui.nation->setText(
_(
"Random"));
142 if (ai_level_is_valid(
level)) {
143 int i =
ui.ailevel->findData(
level);
145 ui.ailevel->setCurrentIndex(i);
147 ui.ailevel->setCurrentIndex(-1);
165 QVariant v =
ui.ailevel->currentData();
168 enum ai_level k =
static_cast<ai_level
>(v.toInt());
185 if (!
ui.cruleset->currentText().isEmpty()) {
188 rn_bytes =
ui.cruleset->currentText().toLocal8Bit();
int send_chat_printf(const char *format,...)
Send the message as a chat to the server.
static fcIcons * instance()
Returns instance of fc_icons.
void pick_nation()
Slot for picking a nation.
void update_ai_level()
Updates the AI skill level control.
void ailevel_change(int i)
Slot for changing level of AI.
Ui::FormPregameOptions ui
void set_aifill(int aifill)
Sets the value of the "aifill" option.
void max_players_change(int i)
Slot for changing aifill value.
void set_rulesets(int num_rulesets, QStringList rulesets)
Update the ruleset list.
pregame_options(QWidget *parent)
Pregame options contructor.
void ruleset_change(int i)
Slot for changing ruleset.
void update_buttons()
Updates the buttons whenever the game state has changed.
struct player * client_player()
Either controlling or observing.
enum ai_level server_ai_level()
Returns the current AI skill level on the server, if the same level is currently used for all current...
void set_ruleset(const char *ruleset)
Called by the GUI code when the user sets the ruleset.
void popup_races_dialog(struct player *pplayer)
Popup the nation selection dialog.
const char * nation_adjective_for_player(const struct player *pplayer)
Return the (translated) adjective for the given nation of a player.
const struct option_set * server_optset
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Returns the option corresponding of the name in this option set.
bool option_int_set(struct option *poption, int val)
Sets the value of this integer option.
bool is_settable_ai_level(enum ai_level level)
Return is AI can be set to given level.
#define ai_level_cmd(_level_)
void option_dialog_popup(const char *name, const struct option_set *poptset)
Popup the option dialog for the option set.
struct setting_list * level[OLEVELS_NUM]
const char * aifill(int amount)
Fill or remove players to meet the given aifill.
struct nation_type * nation
const QPixmap * get_nation_shield_sprite(const struct tileset *t, const struct nation_type *pnation)
Return the shield sprite for the nation.