The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
multiplayer_configure.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 - 2016 Boldizsár Lipka <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #include "global.hpp"
16 
17 #include "gettext.hpp"
18 #include "game_preferences.hpp"
19 #include "construct_dialog.hpp"
20 #include "settings.hpp"
21 #include "map/map.hpp"
22 #include "map/exception.hpp"
24 #include "gui/dialogs/message.hpp"
27 #include "minimap.hpp"
28 #include "mp_game_settings.hpp"
30 #include "filesystem.hpp"
31 #include "log.hpp"
32 #include "saved_game.hpp"
34 #include "wml_exception.hpp"
35 #include "wml_separators.hpp"
36 #include "formula/string_utils.hpp"
37 
38 #include "utils/functional.hpp"
39 
40 static lg::log_domain log_config("config");
41 #define ERR_CF LOG_STREAM(err, log_config)
42 
43 static lg::log_domain log_mp_configure("mp/configure");
44 #define DBG_MP LOG_STREAM(debug, log_mp_configure)
45 
46 namespace mp {
47 
49  : turns_slider_(video)
50  , turns_label_(video, "", font::SIZE_SMALL, font::LOBBY_COLOR)
51  , village_gold_slider_(video)
52  , village_gold_label_(video, "", font::SIZE_SMALL, font::LOBBY_COLOR)
53  , village_support_slider_(video)
54  , village_support_label_(video, "", font::SIZE_SMALL, font::LOBBY_COLOR)
55  , xp_modifier_slider_(video)
56  , xp_modifier_label_(video, "", font::SIZE_SMALL, font::LOBBY_COLOR)
57  , generic_label_(video, "`~ " + std::string(_("Generic")), font::SIZE_PLUS, font::LOBBY_COLOR)
58  , use_map_settings_(video, _("Use map settings"), gui::button::TYPE_CHECK)
59  , random_start_time_(video, _("Random start time"), gui::button::TYPE_CHECK)
60  , fog_game_(video, _("Fog of war"), gui::button::TYPE_CHECK)
61  , shroud_game_(video, _("Shroud"), gui::button::TYPE_CHECK)
62 {
63 
64 }
65 configure::configure(CVideo& video, twesnothd_connection* wesnothd_connection, const config &cfg, chat& c, config& gamelist, saved_game& game, bool local_players_only) :
66  ui(video, wesnothd_connection, _("Configure Game"), cfg, c, gamelist),
67 
68  local_players_only_(local_players_only),
69  tooltip_manager_(video),
72 
73  countdown_game_(video, _("Time limit"), gui::button::TYPE_CHECK),
82  name_entry_label_(video, _("Name of game:"), font::SIZE_PLUS, font::LOBBY_COLOR),
83  observers_game_(video, _("Observers"), gui::button::TYPE_CHECK),
84  registered_users_only_(video, _("Registered users only"), gui::button::TYPE_CHECK),
85  oos_debug_(video, _("Debug OOS"), gui::button::TYPE_CHECK),
86  shuffle_sides_(video, _("Shuffle sides"), gui::button::TYPE_CHECK),
87  random_faction_mode_label_(video, _("Random factions:"), font::SIZE_SMALL, font::LOBBY_COLOR),
88  random_faction_mode_(video, std::vector<std::string>()),
89  cancel_game_(video, _("Back")),
90  launch_game_(video, _("OK")),
91  password_button_(video, _("Set Password...")),
92  name_entry_(video, 32),
93  entry_points_label_(video, _("Select an entry point:"), font::SIZE_SMALL, font::LOBBY_COLOR),
94  entry_points_combo_(video, std::vector<std::string>()),
95  options_pane_left_(video),
96  options_pane_right_(video),
97  entry_points_(),
98  show_entry_points_(false),
100  state_(game),
102  engine_(state_),
103  options_manager_(cfg, video, &options_pane_right_, engine_.options_default()),
104  nolock_settings_(engine_.force_lock_settings() ? 0 : new nolock_settings(video))
105 {
106  // Build the list of scenarios to play
107 
108  DBG_MP << "constructing multiplayer configure dialog" << std::endl;
109 
111  countdown_game_.set_help_string(_("Enables user time limit"));
112 
117  countdown_init_time_slider_.set_help_string(_("Longest time allowed for first turn (seconds)"));
118 
123  countdown_reservoir_time_slider_.set_help_string(_("Longest time possible for any turn (seconds)"));
124 
129  countdown_turn_bonus_slider_.set_help_string(_("Time for general tasks each turn (seconds)"));
130 
135  countdown_action_bonus_slider_.set_help_string(_("Time for each attack, recruit, and capture"));
136 
138  observers_game_.set_help_string(_("Allow users who are not playing to watch the game"));
140 
142  registered_users_only_.set_help_string(_("Allow only registered users to join the game"));
144 
145  oos_debug_.set_check(false);
146  oos_debug_.set_help_string(_("More checks for OOS errors but also more network traffic"));
147  oos_debug_.enable(true);
148 
150  shuffle_sides_.set_help_string(_("Assign sides to players at random"));
151 
152  random_faction_mode_label_.set_help_string(_("Allow for mirror matchups when random factions are chosen"));
153 
154  std::vector<std::string> translated_modes;
155  for(size_t i = 0; i < mp_game_settings::RANDOM_FACTION_MODE::count; ++i) {
156  std::string mode_str = mp_game_settings::RANDOM_FACTION_MODE::from_int(i).to_string();
157  translated_modes.push_back(translation::gettext(mode_str.c_str()));
158  }
159  random_faction_mode_.set_items(translated_modes);
161  random_faction_mode_.set_help_string(_("Independent: Random factions assigned independently\nNo Mirror: No two players will get the same faction\nNo Ally Mirror: No two allied players will get the same faction"));
162 
163  if(nolock_settings_) {
164  nolock_settings_->use_map_settings_.enable(!engine_.force_lock_settings());
165  nolock_settings_->use_map_settings_.set_check(engine_.use_map_settings());
166  nolock_settings_->use_map_settings_.set_help_string(_("Use scenario specific settings"));
167 
168  nolock_settings_->turns_slider_.set_min(settings::turns_min);
169  nolock_settings_->turns_slider_.set_max(settings::turns_max);
170  nolock_settings_->turns_slider_.set_increment(settings::turns_step);
171  nolock_settings_->turns_slider_.set_value(engine_.num_turns_default());
172  nolock_settings_->turns_slider_.set_help_string(_("The maximum number of turns the game can last"));
173  nolock_settings_->turns_slider_.enable(!engine_.use_map_settings());
174 
175  nolock_settings_->village_gold_slider_.set_min(1);
176  nolock_settings_->village_gold_slider_.set_max(5);
177  nolock_settings_->village_gold_slider_.set_value(engine_.village_gold_default());
178  nolock_settings_->village_gold_slider_.set_help_string(_("The amount of income each village yields per turn"));
179  nolock_settings_->village_gold_slider_.enable(!engine_.use_map_settings());
180 
181  nolock_settings_->village_support_slider_.set_min(0);
182  nolock_settings_->village_support_slider_.set_max(4);
183  nolock_settings_->village_support_slider_.set_value(engine_.village_support_default());
184  nolock_settings_->village_support_slider_.set_help_string(_("The number of unit levels each village can support"));
185  nolock_settings_->village_support_slider_.enable(!engine_.use_map_settings());
186 
187  nolock_settings_->xp_modifier_slider_.set_min(30);
188  nolock_settings_->xp_modifier_slider_.set_max(200);
189  nolock_settings_->xp_modifier_slider_.set_value(engine_.xp_modifier_default());
190  nolock_settings_->xp_modifier_slider_.set_increment(10);
191  nolock_settings_->xp_modifier_slider_.set_help_string(_("The amount of experience a unit needs to advance"));
192  nolock_settings_->xp_modifier_slider_.enable(!engine_.use_map_settings());
193 
194  nolock_settings_->random_start_time_.set_check(engine_.random_start_time_default());
195  nolock_settings_->random_start_time_.set_help_string(_("Randomize time of day in begin"));
196  nolock_settings_->random_start_time_.enable(!engine_.use_map_settings());
197 
198  nolock_settings_->fog_game_.set_check(engine_.fog_game_default());
199  nolock_settings_->fog_game_.set_help_string(_("Enemy units cannot be seen unless they are in range of your units"));
200  nolock_settings_->fog_game_.enable(!engine_.use_map_settings());
201 
202  nolock_settings_->shroud_game_.set_check(engine_.shroud_game_default());
203  nolock_settings_->shroud_game_.set_help_string(_("The map is unknown until your units explore it"));
204  nolock_settings_->shroud_game_.enable(!engine_.use_map_settings());
205  }
206 #if 0
207  // The possible vision settings
208  std::vector<std::string> vision_types;
209  vision_types.push_back(_("Share View"));
210  vision_types.push_back(_("Share Maps"));
211  vision_types.push_back(_("Share None"));
212 #endif
213  // The starting points for campaign.
214 
215  if (engine_.entry_point_titles().size() > 1) {
218 
219  show_entry_points_ = true;
220  }
221 
223  if(state_.classification().campaign.empty()) {
225  }
226  else {
228  }
231 
233 
235 
236  plugins_context_.reset(new plugins_context("Multiplayer Configure"));
237 
238  //These structure initializers create a lobby::process_data_event
239  plugins_context_->set_callback("launch", std::bind(&configure::plugin_event_helper, this, process_event_data (true, false)));
240  plugins_context_->set_callback("quit", std::bind(&configure::plugin_event_helper, this, process_event_data (false, true)));
241  plugins_context_->set_callback("set_name", std::bind(&gui::textbox::set_text, &name_entry_, std::bind(get_str, _1, "name"), font::NORMAL_COLOR), true);
242 
243  if(!options_manager_.has_options() && engine_.force_lock_settings() && state_.classification().campaign_type != game_classification::CAMPAIGN_TYPE::MULTIPLAYER) {
245  }
246 }
247 
249 {
250  try {
251  // Only save the settings if the dialog was 'accepted'
252  if(get_result() != CREATE) {
253  DBG_MP << "destructing multiplayer configure dialog - aborted game creation" << std::endl;
254  return;
255  }
256  DBG_MP << "destructing multiplayer configure dialog - a game will be configured" << std::endl;
257 
258  // Save values for next game
259  DBG_MP << "storing parameter values in preferences" << std::endl;
269  // don't set observers preference if disabled (for singleplayer)
270  if (observers_game_.enabled())
272  // don't set registered_users_only preference if disabled (for singleplayer)
275 
276  // When using map settings, the following variables are determined by the map,
277  // so don't store them as the new preferences.
278  if(!engine_.use_map_settings()) {
286  }
287  } catch (...) {}
288 }
289 
291 {
292  DBG_MP << "getting parameter values from widgets" << std::endl;
293 
294  const int mp_countdown_turn_bonus_val = countdown_turn_bonus_slider_.value() <= countdown_turn_bonus_slider_.max_value() ?
296  const int mp_countdown_action_bonus_val = countdown_action_bonus_slider_.value() <= countdown_action_bonus_slider_.max_value() ?
298  const int mp_countdown_reservoir_time_val = countdown_reservoir_time_slider_.value() <= countdown_reservoir_time_slider_.max_value() ?
300  int mp_countdown_init_time_val = countdown_init_time_slider_.value() <= countdown_init_time_slider_.max_value() ?
302  if(mp_countdown_reservoir_time_val > 0 && mp_countdown_init_time_val > mp_countdown_reservoir_time_val)
303  mp_countdown_init_time_val = mp_countdown_reservoir_time_val;
304 
305  // Updates the values in the configure_engine to match
306  // the values selected by the user with the widgets:
308 
309  // CHECK
310  engine_.set_mp_countdown_init_time(mp_countdown_init_time_val);
311  engine_.set_mp_countdown_turn_bonus(mp_countdown_turn_bonus_val);
312  engine_.set_mp_countdown_reservoir_time(mp_countdown_reservoir_time_val);
313  engine_.set_mp_countdown_action_bonus(mp_countdown_action_bonus_val);
315  if(nolock_settings_) {
316  const int num_turns_val = nolock_settings_->turns_slider_.value() <
317  nolock_settings_->turns_slider_.max_value() ? nolock_settings_->turns_slider_.value() : -1;
318  engine_.set_num_turns(num_turns_val);
319  engine_.set_village_gold(nolock_settings_->village_gold_slider_.value());
320  engine_.set_village_support(nolock_settings_->village_support_slider_.value());
321  engine_.set_xp_modifier(nolock_settings_->xp_modifier_slider_.value());
322  engine_.set_use_map_settings(nolock_settings_->use_map_settings_.checked());
323  engine_.set_random_start_time(nolock_settings_->random_start_time_.checked());
324  engine_.set_fog_game(nolock_settings_->fog_game_.checked());
325  engine_.set_shroud_game(nolock_settings_->shroud_game_.checked());
327  }
332  engine_.set_random_faction_mode(mp_game_settings::RANDOM_FACTION_MODE::from_int(random_faction_mode_.selected()));
333 
335 
336 }
337 
339 {
340  process_event_impl(data);
341  return get_result() == mp::ui::CONTINUE;
342 }
343 
345 {
346  int mousex, mousey;
347  SDL_GetMouseState(&mousex,&mousey);
348  tooltips::process(mousex, mousey);
349 
351  data.launch = launch_game_.pressed();
352  data.quit = cancel_game_.pressed();
353 
354  process_event_impl(data);
355 }
356 
358 {
359  if(data.quit) {
360  set_result(QUIT);
361  return;
362  }
363 
364  if(data.launch) {
365  // check if the map is valid
366  if (name_entry_.text() == "") {
367  gui2::show_transient_message(video(), "", _("You must enter a name."));
368  } else {
370  return;
371  }
372  }
373 
374  if(password_button_.pressed()) {
377  , video());
378  }
379 
383  }
384  std::stringstream buf;
385  if(nolock_settings_) {
386  // Turns per game
387  const int cur_turns = nolock_settings_->turns_slider_.value();
388 
389  if(cur_turns < 100) {
390  buf << _("Turns: ") << cur_turns;
391  } else {
392  buf << _("Unlimited turns");
393  }
394  nolock_settings_->turns_label_.set_text(buf.str());
395 
396 
397  // Villages can produce between 1 and 5 gold a turn
398  const int village_gold = nolock_settings_->village_gold_slider_.value();
399  buf.str("");
400  buf << _("Village gold: ") << village_gold;
401  nolock_settings_->village_gold_label_.set_text(buf.str());
402 
403  // Unit levels supported per village
404  const int village_support = nolock_settings_->village_support_slider_.value();
405  buf.str("");
406  buf << _("Village support: ") << village_support;
407  nolock_settings_->village_support_label_.set_text(buf.str());
408 
409  // Experience modifier
410  const int xpmod = nolock_settings_->xp_modifier_slider_.value();
411  buf.str("");
412  buf << _("Experience modifier: ") << xpmod << "%";
413 
414  nolock_settings_->xp_modifier_label_.set_text(buf.str());
415 
416 
417  if(nolock_settings_->use_map_settings_.pressed() || force_use_map_settings_check_) {
419 
420  engine_.set_use_map_settings(nolock_settings_->use_map_settings_.checked());
421 
422  // If the map settings are wanted use them,
423  // if not properly defined fall back to the default settings
424  nolock_settings_->turns_slider_.set_value(engine_.num_turns_default());
425  nolock_settings_->xp_modifier_slider_.set_value(engine_.xp_modifier_default());
426  nolock_settings_->random_start_time_.set_check(engine_.random_start_time_default());
427  nolock_settings_->village_gold_slider_.set_value(engine_.village_gold_default());
428  nolock_settings_->village_support_slider_.set_value(engine_.village_support_default());
429  nolock_settings_->fog_game_.set_check(engine_.fog_game_default());
430  nolock_settings_->shroud_game_.set_check(engine_.shroud_game_default());
431 
432  // Set the widget states
433  nolock_settings_->turns_slider_.enable(!engine_.use_map_settings());
434  nolock_settings_->village_gold_slider_.enable(!engine_.use_map_settings());
435  nolock_settings_->village_support_slider_.enable(!engine_.use_map_settings());
436  nolock_settings_->xp_modifier_slider_.enable(!engine_.use_map_settings());
437  nolock_settings_->random_start_time_.enable(!engine_.use_map_settings());
438  nolock_settings_->fog_game_.enable(!engine_.use_map_settings());
439  nolock_settings_->shroud_game_.enable(!engine_.use_map_settings());
440  }
441  }
446 
451 
454  {
456  }
459  {
461  }
464 
465  buf.str("");
466  buf << _("Init. limit: ") << mp_countdown_init_time_; // << _(" sec.");
468 
469  const int mp_countdown_turn_bonus_val = countdown_turn_bonus_slider_.value();
470  buf.str("");
471  buf << _("Turn bonus: ") << mp_countdown_turn_bonus_val; // << _(" sec.");
473 
474  buf.str("");
475  buf << _("Reservoir: ") << mp_countdown_reservoir_time_; // << _(" sec.");
477 
478  const int mp_countdown_action_bonus_val = countdown_action_bonus_slider_.value();
479  buf.str("");
480  buf << _("Action bonus: ") << mp_countdown_action_bonus_val; // << _(" sec.");
482 
484 }
485 
487 {
488  DBG_MP << (hide ? "hiding" : "showing" ) << " children widgets" << std::endl;
489 
490  ui::hide_children(hide);
491  if (nolock_settings_)
492  {
493  nolock_settings_->turns_slider_.hide(hide);
494  nolock_settings_->turns_label_.hide(hide);
495  nolock_settings_->village_gold_slider_.hide(hide);
496  nolock_settings_->village_gold_label_.hide(hide);
497  nolock_settings_->village_support_slider_.hide(hide);
498  nolock_settings_->village_support_label_.hide(hide);
499  nolock_settings_->xp_modifier_slider_.hide(hide);
500  nolock_settings_->xp_modifier_label_.hide(hide);
501  nolock_settings_->generic_label_.hide(hide);
502  nolock_settings_->use_map_settings_.hide(hide);
503  nolock_settings_->random_start_time_.hide(hide);
504  nolock_settings_->fog_game_.hide(hide);
505  nolock_settings_->shroud_game_.hide(hide);
506  }
507 
516  countdown_game_.hide(hide);
517 
518  name_entry_label_.hide(hide);
519 
520  observers_game_.hide(hide);
522  oos_debug_.hide(hide);
523  shuffle_sides_.hide(hide);
526  cancel_game_.hide(hide);
527  launch_game_.hide(hide);
528 
529  password_button_.hide(hide);
530  name_entry_.hide(hide);
531 
534 
535  options_pane_left_.hide(hide);
537 
539 }
540 
541 void configure::layout_children(const SDL_Rect& rect)
542 {
543  DBG_MP << "laying out the children" << std::endl;
544 
545  ui::layout_children(rect);
546 
547  const int border_size = 6;
548  const int column_border_size = 10;
549 
550  SDL_Rect ca = client_area();
551  int xpos = ca.x;
552  int ypos = ca.y;
553  const int column_width = (ca.w - ca.x) / 2 - column_border_size;
554 
555  // Dialog title
556  ypos += title().height() + border_size;
557 
558  // Name Entry
559  name_entry_label_.set_location(xpos, ypos);
560  name_entry_.set_location(xpos + name_entry_label_.width() + border_size, ypos);
561  name_entry_.set_width(ca.w - name_entry_label_.width() - border_size);
562  ypos += std::max<int>(name_entry_.height(), name_entry_label_.height()) + border_size;
563 
564  // Save ypos here (column top)
565  int ypos_columntop = ypos;
566 
567  const int right_pane_height =
568  ca.h - (ypos_columntop - ca.y + launch_game_.height() + border_size);
569 
570  // First column: non-gameplay settings
571  options_pane_left_.set_location(xpos, ypos);
572  options_pane_left_.set_width(column_width);
574 
575  int slider_width = options_pane_left_.width() - 40;
576 
577  int xpos_left = 0;
578  int ypos_left = 0;
579 
580  ypos_left += 2 * border_size;
581  options_pane_left_.add_widget(&shuffle_sides_, xpos_left, ypos_left);
583  xpos_left + options_pane_left_.width() / 3 + border_size, ypos_left);
585  xpos_left + options_pane_left_.width() * 2/ 3 + border_size, ypos_left);
586  ypos_left += shuffle_sides_.height() + border_size;
587 
589  xpos_left += random_faction_mode_label_.width() + border_size;
590 
591  options_pane_left_.add_widget(&random_faction_mode_, xpos_left, ypos_left);
592  xpos_left += random_faction_mode_.width() + border_size;
593 
594  if(!local_players_only_) {
596  std::max(xpos_left + 2* border_size, (options_pane_left_.width() / 2) + border_size), ypos_left);
597  } else {
598  password_button_.hide(true);
599  }
600  xpos_left = 0;
601  ypos_left += random_faction_mode_.height() + border_size;
602 
603  options_pane_left_.add_widget(&countdown_game_, xpos_left, ypos_left);
604  ypos_left += countdown_game_.height() + border_size;
605 
607  ypos_left += countdown_init_time_label_.height() + border_size;
610  ypos_left += countdown_init_time_slider_.height() + border_size;
611 
613  ypos_left += countdown_turn_bonus_label_.height() + border_size;
616  ypos_left += countdown_turn_bonus_slider_.height() + border_size;
617 
619  ypos_left += countdown_reservoir_time_label_.height() + border_size;
622  ypos_left += countdown_reservoir_time_slider_.height() + border_size;
624  ypos_left += countdown_action_bonus_label_.height() + border_size;
627  ypos_left += countdown_action_bonus_slider_.height() + border_size;
628 
629  options_pane_left_.add_widget(&oos_debug_, xpos_left, ypos_left );
630  ypos_left += oos_debug_.height() + border_size;
631 
632  if (show_entry_points_) {
633  int x = ca.x;
634  int y = ca.y + ca.h - entry_points_combo_.height();
636  y -= entry_points_label_.height() + border_size;
638  }
639 
640  // Second column: gameplay settings
641  xpos += column_width + column_border_size;
642  ypos = ypos_columntop;
643 
644  options_pane_right_.set_location(xpos, ypos);
645  options_pane_right_.set_width(ca.w - (xpos - ca.x));
646  options_pane_right_.set_height(right_pane_height);
647 
648  slider_width = options_pane_right_.width() - 40;
649 
650  int xpos_right = 0;
651  int ypos_right = 0;
652  if(nolock_settings_)
653  {
654  options_pane_right_.add_widget(&nolock_settings_->generic_label_, xpos_right, ypos_right);
655  ypos_right += nolock_settings_->generic_label_.height() + border_size;
656 
657  options_pane_right_.add_widget(&nolock_settings_->use_map_settings_, xpos_right, ypos_right);
659  xpos_right + (options_pane_right_.width() - xpos_right)/2 + 5, ypos_right);
660  ypos_right += nolock_settings_->use_map_settings_.height() + border_size;
661 
662  options_pane_right_.add_widget(&nolock_settings_->random_start_time_, xpos_right, ypos_right);
664  xpos_right + (options_pane_right_.width() - xpos_right)/2 + 5, ypos_right);
665  ypos_right += nolock_settings_->random_start_time_.height() + border_size;
666 
667  options_pane_right_.add_widget(&nolock_settings_->turns_label_, xpos_right, ypos_right);
668  ypos_right += nolock_settings_->turns_label_.height() + border_size;
669  nolock_settings_->turns_slider_.set_width(slider_width);
670  options_pane_right_.add_widget(&nolock_settings_->turns_slider_, xpos_right, ypos_right);
671  ypos_right += nolock_settings_->turns_slider_.height() + border_size;
672 
673  options_pane_right_.add_widget(&nolock_settings_->xp_modifier_label_, xpos_right, ypos_right);
674  ypos_right += nolock_settings_->xp_modifier_label_.height() + border_size;
675  nolock_settings_->xp_modifier_slider_.set_width(slider_width);
676  options_pane_right_.add_widget(&nolock_settings_->xp_modifier_slider_, xpos_right, ypos_right);
677  ypos_right += nolock_settings_->xp_modifier_slider_.height() + border_size;
678 
679  options_pane_right_.add_widget(&nolock_settings_->village_support_label_, xpos_right, ypos_right);
680  ypos_right += nolock_settings_->village_support_label_.height() + border_size;
681  nolock_settings_->village_support_slider_.set_width(slider_width);
682  options_pane_right_.add_widget(&nolock_settings_->village_support_slider_, xpos_right, ypos_right);
683  ypos_right += nolock_settings_->village_support_slider_.height() + border_size;
684 
685  options_pane_right_.add_widget(&nolock_settings_->village_gold_label_, xpos_right, ypos_right);
686  ypos_right += nolock_settings_->village_gold_label_.height() + border_size;
687  nolock_settings_->village_gold_slider_.set_width(slider_width);
688 
689  options_pane_right_.add_widget(&nolock_settings_->village_gold_slider_, xpos_right, ypos_right);
690  ypos_right += nolock_settings_->village_gold_slider_.height() + 3 * border_size;
691 
692  }
693 
694  options_manager_.layout_widgets(xpos_right, ypos_right, column_width);
695 
696  // OK / Cancel buttons
697  gui::button* left_button = &launch_game_;
698  gui::button* right_button = &cancel_game_;
699 
700 #ifdef OK_BUTTON_ON_RIGHT
701  std::swap(left_button,right_button);
702 #endif
703 
704  // Buttons
705  right_button->set_location(ca.x + ca.w - right_button->width(),
706  ca.y + ca.h - right_button->height());
707  left_button->set_location(right_button->location().x - left_button->width() -
708  gui::ButtonHPadding, ca.y + ca.h - left_button->height());
709 }
710 
711 } // namespace mp
712 
713 
void set_registered_users_only(bool val)
int mp_countdown_reservoir_time_default() const
void set_shroud_game(bool val)
gui::button observers_game_
void set_check(bool check)
Definition: button.cpp:352
void set_village_support(int value)
void process_event_impl(const process_event_data &)
void set_mp_countdown_reservoir_time(int val)
const int turns_max
maximum number of turns
Definition: settings.hpp:46
gui::label countdown_turn_bonus_label_
void set_shuffle_sides(bool val)
int num_turns_default() const
const std::string & set_text(const std::string &text)
Definition: label.cpp:35
int village_support
Definition: game_config.cpp:39
void set_countdown_action_bonus(int value)
void set_countdown_turn_bonus(int value)
bool enabled() const
Definition: widget.cpp:212
gui::scrollpane options_pane_left_
void set_shroud(bool value)
virtual void enable(bool new_val=true)
Definition: widget.cpp:204
void set_countdown_init_time(int value)
int mp_countdown_init_time() const
Graphical text output.
static lg::log_domain log_config("config")
const GLfloat * c
Definition: glew.h:12741
gui::button shuffle_sides_
const mp_game_settings * mp_settings
Definition: resources.cpp:38
void set_value(int value)
Definition: slider.cpp:87
bool use_map_settings() const
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
int value() const
Definition: slider.cpp:112
boost::scoped_ptr< plugins_context > plugins_context_
void set_options(const config &values)
const std::vector< std::string > & entry_point_titles() const
gui::button registered_users_only_
mp_game_settings & parameters_
void hide_children(bool hide=true)
Definition: mp_options.cpp:197
bool registered_users_only() const
#define DBG_MP
void set_max(int value)
Definition: slider.cpp:77
Definition: video.hpp:58
void set_mp_countdown_turn_bonus(int val)
int mp_countdown_action_bonus() const
void set_scenario(const std::string &id)
Sets the selected scenario.
Definition: mp_options.cpp:161
virtual void enable(bool new_val=true)
Definition: button.cpp:386
gui::slider countdown_turn_bonus_slider_
virtual void layout_children(const SDL_Rect &rect)
Lays the children out.
result get_result()
Returns the result of the current widget.
bool random_start_time() const
int xp_modifier_default() const
General purpose widgets.
void set_width(int w)
Definition: widget.cpp:119
void set_increment(int increment)
Definition: slider.cpp:107
void set_text(const std::string &text, const SDL_Color &color=font::NORMAL_COLOR)
Definition: textbox.cpp:76
gui::button countdown_game_
void set_random_faction_mode(const std::string &value)
gui::label countdown_init_time_label_
STL namespace.
void show_transient_message(CVideo &video, const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup, const bool restore_background)
Shows a transient message to the user.
bool random_start_time_default() const
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1220
void set_modifications(const std::vector< std::string > &ids)
Sets the activated modifications.
Definition: mp_options.cpp:173
int mp_countdown_reservoir_time() const
const std::string text() const
Definition: textbox.cpp:69
void set_random_start_time(bool val)
const int SIZE_PLUS
Definition: font.hpp:65
bool fog_game_default() const
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
Definition: glew.h:1347
int selected() const
Definition: combo.cpp:38
void set_countdown(bool value)
const int turns_step
slider step size for turns
Definition: settings.hpp:48
const SDL_Color NORMAL_COLOR
Definition: font.cpp:564
virtual void set_location(SDL_Rect const &rect)
Definition: scrollpane.cpp:57
void set_village_gold(int val)
void set_registered_users_only(bool value)
virtual void hide_children(bool hide=true)
Hides or shows all gui::widget children of this widget.
const int ButtonHPadding
Definition: show_dialog.cpp:43
ng::configure_engine engine_
gui::label countdown_action_bonus_label_
This module controls the multiplayer lobby.
void set_use_map_settings(bool val)
std::vector< std::string > active_mods
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:82
bool allow_observers() const
void process(int mousex, int mousey)
Definition: tooltips.cpp:198
int max_value() const
Definition: slider.cpp:117
int mp_countdown_init_time_default() const
gui::label random_faction_mode_label_
A class that represents a TCP/IP connection to the wesnothd server.
void set_game_name(std::string name)
result set_result(result res)
Sets the result of this dialog, to be checked by get_result().
bool shuffle_sides_default() const
General settings and defaults for scenarios.
bool allow_observers_default() const
bool changed()
Definition: combo.cpp:43
virtual void hide(bool value=true)
Definition: widget.cpp:162
std::string game_name_default() const
void set_village_support(int val)
static bool execute(std::string &password, CVideo &video)
The excute function see tdialog for more information.
tooltips::manager tooltip_manager_
const gui::label & title() const
void set_era(const std::string &id)
Sets the selected era.
Definition: mp_options.cpp:156
void set_random_start_time(bool value)
virtual void enable(bool new_val=true)
Definition: slider.cpp:51
void set_oos_debug(bool val)
GLenum GLuint GLsizei const char * buf
Definition: glew.h:2498
gui::label countdown_reservoir_time_label_
void set_mp_countdown(bool val)
options::manager options_manager_
void set_fog_game(bool val)
void set_mp_countdown_action_bonus(int val)
bool shuffle_sides() const
bool pressed()
Definition: button.cpp:770
std::string campaign
the campaign being played
static UNUSEDNOWARN std::string gettext(const char *str)
Definition: gettext.hpp:64
CVideo & video()
bool force_lock_settings() const
GLuint GLuint GLsizei count
Definition: glew.h:1221
virtual void hide_children(bool hide=true)
Hides or shows all gui::widget children of this widget.
void set_help_string(const std::string &str)
Definition: widget.cpp:314
void set_allow_observers(bool value)
void set_allow_observers(bool val)
int village_gold_default() const
SDL_Rect client_area() const
gui::textbox name_entry_
void set_selected(int val)
Definition: combo.cpp:68
int mp_countdown_turn_bonus_default() const
gui::scrollpane options_pane_right_
bool has_options() const
Definition: mp_options.cpp:105
void set_mp_countdown_init_time(int val)
configure(CVideo &v, twesnothd_connection *wesnothd_connection, const config &game_config, chat &c, config &gamelist, saved_game &game, bool local_players_only)
gives the user the option to adjust the passed saved_game Call get_parameters to finalize; ...
virtual void layout_children(const SDL_Rect &rect)
Lays the children out.
const SDL_Color LOBBY_COLOR
Definition: font.cpp:566
config & gamelist()
Returns the current gamelist.
gui::slider countdown_init_time_slider_
gui::slider countdown_action_bonus_slider_
std::string get_scenario_id()
Definition: saved_game.cpp:533
size_t i
Definition: function.cpp:1057
bool registered_users_only_default() const
GLint GLint GLint GLint GLint x
Definition: glew.h:1220
void set_items(const std::vector< std::string > &items)
Definition: combo.cpp:52
void set_num_turns(int val)
Declarations for File-IO.
const int turns_min
minimum number of turns
Definition: settings.hpp:45
virtual void hide(bool value=true)
Definition: scrollpane.cpp:64
virtual void hide(bool value=true)
Definition: scrollarea.cpp:78
void set_turns(int value)
mp_game_settings::RANDOM_FACTION_MODE random_faction_mode() const
void set_random_faction_mode(mp_game_settings::RANDOM_FACTION_MODE val)
int village_support() const
gui::label entry_points_label_
gui::combo random_faction_mode_
game_classification & classification()
Definition: saved_game.hpp:54
static lg::log_domain log_mp_configure("mp/configure")
void set_scenario(size_t scenario_num)
void swap(game_board &one, game_board &other)
Definition: game_board.cpp:56
bool shroud_game_default() const
void set_campaign(const std::string &id)
Sets the selected campaign.
Definition: mp_options.cpp:167
bool checked() const
Definition: button.cpp:381
Standard logging facilities (interface).
bool mp_countdown() const
bool mp_countdown_default() const
void set_min(int value)
Definition: slider.cpp:67
const std::function< std::string(const config &, const std::string &) > get_str
Definition: context.cpp:121
gui::button password_button_
virtual void set_location(SDL_Rect const &rect)
Definition: widget.cpp:85
virtual void process_event()
void set_shuffle_sides(bool value)
std::vector< config const * > entry_points_
void set_fog(bool value)
this class memorizes a chat session.
int width() const
Definition: widget.cpp:134
const config & get_values()
Returns the the values for each option.
Definition: mp_options.cpp:207
SDL_Rect const & location() const
Definition: widget.cpp:144
gui::label name_entry_label_
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
gui::slider countdown_reservoir_time_slider_
void set_countdown_reservoir_time(int value)
void set_height(int h)
Definition: widget.cpp:124
void set_xp_modifier(int value)
boost::scoped_ptr< nolock_settings > nolock_settings_
void set_xp_modifier(int val)
gui::combo entry_points_combo_
void add_widget(widget *w, int x, int y, int z_order=0)
Definition: scrollpane.cpp:71
GLsizei const GLcharARB ** string
Definition: glew.h:4503
const config & options() const
int mp_countdown_action_bonus_default() const
void layout_widgets(int startx, int starty, int w)
Definition: mp_options.cpp:178
int village_support_default() const
void set_village_gold(int value)
void set_use_map_settings(bool value)
a base class for the different multiplayer base dialogs: game list, create game, wait game...
const int SIZE_SMALL
Definition: font.hpp:62
bool plugin_event_helper(const process_event_data &)
int mp_countdown_turn_bonus() const
virtual void gamelist_updated(bool silent=true)
Called each time the gamelist_ variable is updated.
int height() const
Definition: widget.cpp:139
void set_options(const config &cfg)