The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
multiplayer_create.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2016 by David White <[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 /**
16  * @file
17  * Create a multiplayer-game: select map, players, options etc.
18  */
19 
20 #include "global.hpp"
21 
22 #include "gettext.hpp"
23 #include "game_config_manager.hpp"
24 #include "video.hpp"
25 #include "game_preferences.hpp"
26 #include "config_assign.hpp"
27 #include "construct_dialog.hpp"
28 #include "settings.hpp"
29 #include "map/map.hpp"
30 #include "map/exception.hpp"
32 #include "gui/dialogs/message.hpp"
36 #include "gui/widgets/window.hpp"
37 #include "minimap.hpp"
38 #include "multiplayer_create.hpp"
39 #include "filesystem.hpp"
40 #include "savegame.hpp"
42 #include "log.hpp"
43 #include "wml_exception.hpp"
44 #include "wml_separators.hpp"
45 #include "formula/string_utils.hpp"
46 #include "widgets/multimenu.hpp"
47 #include "sdl/utils.hpp"
48 #include "sdl/rect.hpp"
49 
50 #include "utils/functional.hpp"
51 
52 static lg::log_domain log_config("config");
53 #define ERR_CF LOG_STREAM(err, log_config)
54 
55 static lg::log_domain log_mp_create("mp/create");
56 #define DBG_MP LOG_STREAM(debug, log_mp_create)
57 
58 namespace {
59 const SDL_Rect null_rect = {0, 0, 0, 0};
60 }
61 
62 namespace mp {
63 
65 {
66  assert(eng_ptr);
67  const ng::create_engine & eng = *eng_ptr;
68  return config_of("id", eng.current_level().id())
69  ("name", eng.current_level().name())
70  ("icon", eng.current_level().icon())
71  ("description", eng.current_level().description())
72  ("allow_era_choice", eng.current_level().allow_era_choice())
73  ("type", eng.current_level_type());
74 }
75 
76 static config find_helper(const ng::create_engine * eng_ptr, const config & cfg)
77 {
78  assert(eng_ptr);
79  const ng::create_engine & eng = *eng_ptr;
80  std::string str = cfg["id"].str();
81 
82  return config_of("index", eng.find_level_by_id(str))("type", eng.find_level_type_by_id(str));
83 }
84 
85 create::create(CVideo& video, twesnothd_connection* wesnothd_connection, const config& cfg, saved_game& state, chat& c, config& gamelist) :
86  ui(video, wesnothd_connection, _("Create Game"), cfg, c, gamelist),
87  tooltip_manager_(video),
88  era_selection_(-1),
89  mod_selection_(-1),
90  level_selection_(-1),
91  eras_menu_(video, std::vector<std::string>()),
92  levels_menu_(video, std::vector<std::string>()),
93  mods_menu_(video, std::vector<std::string>()),
94  filter_name_label_(video, _("Filter:"), font::SIZE_SMALL, font::LOBBY_COLOR),
95  filter_num_players_label_(video, _("Number of players: any"), font::SIZE_SMALL, font::LOBBY_COLOR),
96  map_generator_label_(video, _("Random map options:"), font::SIZE_SMALL, font::LOBBY_COLOR),
97  era_label_(video, _("Era:"), font::SIZE_SMALL, font::LOBBY_COLOR),
98  no_era_label_(video, _("No eras available\nfor this game."),
100  mod_label_(video, _("Modifications:"), font::SIZE_SMALL, font::LOBBY_COLOR),
101  map_size_label_(video, "", font::SIZE_SMALL, font::LOBBY_COLOR),
102  num_players_label_(video, "", font::SIZE_SMALL, font::LOBBY_COLOR),
103  level_type_label_(video, "Game type:", font::SIZE_SMALL, font::LOBBY_COLOR),
104  launch_game_(video, _("Next")),
105  cancel_game_(video, _("Cancel")),
106  regenerate_map_(video, _("Regenerate")),
107  generator_settings_(video, _("Settings...")),
108  load_game_(video, _("Load Game...")),
109  level_type_combo_(video, std::vector<std::string>()),
110  filter_num_players_slider_(video),
111  description_(video, 100, "", false),
112  filter_name_(video, 100, "", true, 256, font::SIZE_SMALL),
113  image_restorer_(nullptr),
114  image_rect_(null_rect),
115  available_level_types_(),
116  engine_(video, state)
117 {
121 
122  DBG_MP << "constructing multiplayer create dialog" << std::endl;
123 
125 
126  typedef std::pair<ng::level::TYPE, std::string> level_type_info;
127  std::vector<level_type_info> all_level_types;
128  all_level_types.push_back(std::make_pair(ng::level::TYPE::SCENARIO, _("Scenarios")));
129  all_level_types.push_back(std::make_pair(ng::level::TYPE::CAMPAIGN, _("Campaigns")));
130  all_level_types.push_back(std::make_pair(ng::level::TYPE::USER_MAP, _("User Maps")));
131  all_level_types.push_back(std::make_pair(ng::level::TYPE::USER_SCENARIO, _("User Scenarios")));
132  all_level_types.push_back(std::make_pair(ng::level::TYPE::RANDOM_MAP, _("Random Maps")));
133 
134  if (game_config::debug) {
135  all_level_types.push_back(std::make_pair(ng::level::TYPE::SP_CAMPAIGN,
136  "SP Campaigns"));
137  }
138 
139  std::vector<std::string> combo_level_names;
140 
141  for (level_type_info type_info : all_level_types) {
142  if (!engine_.get_levels_by_type_unfiltered(type_info.first).empty()) {
143  available_level_types_.push_back(type_info.first);
144  combo_level_names.push_back(type_info.second);
145  }
146  }
147 
148  if (available_level_types_.empty()) {
149  gui2::show_transient_message(video, "", _("No games found."));
150  throw game::error(_("No games found."));
151  }
152 
153  level_type_combo_.set_items(combo_level_names);
154 
155  size_t combo_new_selection = 0;
156  size_t level_new_selection = 0;
157 
158  // Set level selection according to the preferences, if possible.
159  size_t type_index = 0;
161  if (preferences::level_type() == type.cast<int>()) {
162  break;
163  }
164  type_index++;
165  }
166  if (type_index < available_level_types_.size()) {
167  combo_new_selection = type_index;
168 
169  int level_index = engine_.find_level_by_id(preferences::level());
170  if (level_index != -1) {
171  level_new_selection = level_index;
172  }
173  }
174 
175  level_type_combo_.set_selected(combo_new_selection);
176  init_level_type_changed(level_new_selection);
177 
178  const std::vector<std::string>& era_names =
180  if(era_names.empty()) {
181  gui2::show_transient_message(video, "", _("No eras found."));
182  throw config::error(_("No eras found"));
183  }
184  eras_menu_.set_items(era_names);
185 
186  // Set era selection according to the preferences, if possible.
187  int era_new_selection = engine_.find_extra_by_id(ng::create_engine::ERA,
188  preferences::era());
189  eras_menu_.move_selection((era_new_selection != -1) ? era_new_selection : 0);
190 
191  std::vector<std::string> mods = engine_.extras_menu_item_names(ng::create_engine::MOD);
192  mods_menu_.set_items(mods);
194  // don't set 0 explicitly, because move_selection(0) may fail if there's
195  // no modifications at all
197 
198  if (mod_selection_ == -1) {
199  mod_label_.set_text(_("Modifications:\nNone found."));
200  }
201 
203 
204  plugins_context_.reset(new plugins_context("Multiplayer Create"));
205 
206  //These structure initializers create a lobby::process_data_event
207  plugins_context_->set_callback("create", std::bind(&create::plugin_event_helper, this, process_event_data (true, false, false)));
208  plugins_context_->set_callback("load", std::bind(&create::plugin_event_helper, this, process_event_data (false, true, false)));
209  plugins_context_->set_callback("quit", std::bind(&create::plugin_event_helper, this, process_event_data (false, false, true)));
210  plugins_context_->set_callback("chat", std::bind(&create::send_chat_message, this, std::bind(get_str, _1, "message"), false), true);
211  plugins_context_->set_callback("select_level", std::bind(&gui::menu::move_selection, &levels_menu_, std::bind(get_size_t, _1, "index", 0u)), true);
212  plugins_context_->set_callback("select_type", std::bind(&create::select_level_type_helper, this, std::bind(get_str, _1, "type")), true);
213 
214  plugins_context_->set_accessor("game_config", std::bind(&create::game_config, this));
215  plugins_context_->set_accessor("get_selected", std::bind(&get_selected_helper, &engine_));
216  plugins_context_->set_accessor("find_level", std::bind(&find_helper, &engine_, _1));
217 }
218 
220 {
221  for (size_t idx = 0; idx < available_level_types_.size(); idx++) {
222  if (available_level_types_[idx].to_string() == str) {
225  process_event_impl(process_event_data(false, false, false));
226  }
227  }
228 }
229 
231 {
232  try {
233  // Only save the settings if the dialog was 'accepted'
234  if(get_result() != CREATE) {
235  DBG_MP << "destructing multiplayer create dialog - aborted game creation" << std::endl;
236  return;
237  }
238  DBG_MP << "destructing multiplayer create dialog - a game will be created" << std::endl;
239 
240  // Save values for next game
241  DBG_MP << "storing parameter values in preferences" << std::endl;
246  } catch (...) {}
247 }
248 
250 {
251  return engine_.get_parameters();
252 }
253 
255 {
256  process_event_impl(data);
257  return get_result() == mp::ui::CONTINUE;
258 }
259 
261 {
262  int mousex, mousey;
263  SDL_GetMouseState(&mousex,&mousey);
264  tooltips::process(mousex, mousey);
265 
267  data.quit = cancel_game_.pressed();
269  data.load = load_game_.pressed();
270 
271  process_event_impl(data);
272 }
273 
275 {
276  if (data.quit) {
277  set_result(QUIT);
278  return;
279  }
280 
281  if (data.create) {
282  if (engine_.current_level().can_launch_game()) {
283 
285 
286  if (engine_.current_level_type() == ng::level::TYPE::CAMPAIGN ||
287  engine_.current_level_type() == ng::level::TYPE::SP_CAMPAIGN) {
288 
290  if (difficulty == "CANCEL") {
291  return;
292  }
293 
294  engine_.prepare_for_campaign(difficulty);
295  }
297  {
299  }
300  else
301  {
302  //This means define= doesn't work for random generated scenarios
304  }
305 
307 
309  return;
310  } else {
312  _("The level is invalid."));
313  }
314  }
315 
316  if (level_type_combo_.changed()) {
318  }
319 
320  if (data.load) {
321  try
322  {
325 
326  if (data.filename) {
327  if (!load.load_game(*data.filename, false, false, false, "", true)) {
328  return ;
329  }
330  } else {
331  if (!load.load_multiplayer_game()) {
332  return ;
333  }
334  }
335 
336  if (load.cancel_orders())
338 
341 
342  return;
343  }
344  catch(config::error&) {
345  }
346  }
347 
352  }
353 
354  int changed_mod = mods_menu_.last_changed();
355  if (changed_mod != -1) {
356  engine_.set_current_mod_index(changed_mod);
359  }
360 
361  bool era_changed = era_selection_ != eras_menu_.selection();
363 
364  if (era_changed) {
366 
369  }
370 
374  }
375 
376  bool level_changed = level_selection_ != levels_menu_.selection();
378 
379  if (level_changed && level_selection_ >= 0) {
381 
383  }
384 
387 
388  level_changed = true;
389  }
390 
392  (level_changed || regenerate_map_.pressed())) {
393  const cursor::setter cursor_setter(cursor::WAIT);
395 
397 
398  if (!engine_.current_level().data()["error_message"].empty())
399  gui2::show_message(video(), "map generation error",
400  engine_.current_level().data()["error_message"]);
401 
402  level_changed = true;
403  }
404 
405  if(level_changed) {
406  std::stringstream players;
407  std::stringstream map_size;
408 
409  players << _("Players: ");
410 
412 
414 
416 
417  switch (engine_.current_level_type().v) {
419  case ng::level::TYPE::USER_MAP:
420  case ng::level::TYPE::USER_SCENARIO:
421  case ng::level::TYPE::RANDOM_MAP: {
422 
423  ng::scenario* current_scenario =
424  dynamic_cast<ng::scenario*>(&engine_.current_level());
425 
426  assert(current_scenario);
427 
428  players << current_scenario->num_players();
429  map_size << _("Size: ") << current_scenario->map_size();
430 
431  break;
432  }
433  case ng::level::TYPE::CAMPAIGN:
434  case ng::level::TYPE::SP_CAMPAIGN: {
435  ng::campaign* current_campaign =
436  dynamic_cast<ng::campaign*>(&engine_.current_level());
437 
438  assert(current_campaign);
439 
440  players << current_campaign->min_players();
441  if (current_campaign->max_players() !=
442  current_campaign->min_players()) {
443 
444  players << " to " << current_campaign->max_players();
445  }
446 
447  break;
448  }
449  } // end switch
450 
451  map_size_label_.set_text(map_size.str());
452  num_players_label_.set_text(players.str());
453 
454  launch_game_.enable(engine_.current_level().can_launch_game());
457  }
458 
460  const int val = filter_num_players_slider_.value();
462  std::stringstream ss;
463  if (val == 1) {
464  ss << _("Number of players: any");
465  } else {
466  ss << _("Number of players: ") << val;
467  }
470  }
471 }
472 
474 {
476  if (selected < 0) {
477  selected = 0;
478  }
479 
481  const std::vector<std::string>& menu_item_names =
483 
484  init_level_changed((index < menu_item_names.size()) ? index : 0);
485 
486  levels_menu_.set_items(menu_item_names);
488 
489  level_selection_ = -1;
490 }
491 
493 {
494  engine_.set_current_level(index);
495 
496  // N.B. the order of hide() calls here is important
497  // to avoid redrawing glitches.
499  no_era_label_.hide(true);
500  eras_menu_.hide(false);
501  } else {
502  eras_menu_.hide(true);
503  no_era_label_.hide(false);
504  }
505 }
506 
508 {
509  DBG_MP << "Synchronizing with the dependency manager" << std::endl;
510  if (era_selection_ != engine_.dependency_manager().get_era_index()) {
512  process_event();
513  }
514 
515  if (engine_.current_level_type() != ng::level::TYPE::CAMPAIGN &&
516  engine_.current_level_type() != ng::level::TYPE::SP_CAMPAIGN) {
517  if (engine_.current_level().id() !=
518  engine_.dependency_manager().get_scenario()) {
519 
520  // Match scenario and scenario type
521  ng::level::TYPE level_type_at_index;
523  engine_.dependency_manager().get_scenario());
524  size_t type_index;
525 
526  if (index == -1) {
527  return;
528  }
529  level_type_at_index = engine_.find_level_type_by_id(
530  engine_.dependency_manager().get_scenario());
531  engine_.set_current_level_type(level_type_at_index);
532 
533  init_level_changed(index);
536  type_index = 0;
538  if (level_type_at_index == type) {
539  level_type_combo_.set_selected(type_index);
540  break;
541  }
542  type_index++;
543  }
544  }
545 
546  process_event();
547  }
548 
550  update_mod_menu();
551 }
552 
554 {
555  surface image(
557 
558  if (!image.null()) {
559  SDL_Color back_color = {0,0,0,SDL_ALPHA_OPAQUE};
561  video().getSurface());
562  } else {
563  surface& display(video().getSurface());
564  sdl::fill_rect(display, &image_rect_,
565  SDL_MapRGB(display->format, 0, 0, 0));
567  }
568 }
569 
570 void create::set_description(const std::string& description)
571 {
572  description_.set_text(description.empty() ? _("No description available.") :
573  description);
574 }
575 
577 {
578  for (size_t i = 0; i<mods_menu_.number_of_items(); i++) {
579  mods_menu_.set_active(i, engine_.dependency_manager().is_modification_active(i));
580  }
581 }
582 
583 void create::hide_children(bool hide)
584 {
585  DBG_MP << (hide ? "hiding" : "showing" ) << " children widgets" << std::endl;
586 
587  ui::hide_children(hide);
588 
591  levels_menu_.hide(hide);
592  mods_menu_.hide(hide);
593 
594  filter_name_.hide(hide);
597  map_size_label_.hide(hide);
598  era_label_.hide(hide);
599  mod_label_.hide(hide);
600  num_players_label_.hide(hide);
601  level_type_label_.hide(hide);
602 
603  level_type_combo_.hide(hide);
604 
605  cancel_game_.hide(hide);
606  launch_game_.hide(hide);
607 
608  load_game_.hide(hide);
609 
610  regenerate_map_.hide(hide);
612 
614 
615  description_.hide(hide);
616  filter_name_.hide(hide);
617 
618  if (hide) {
619  image_restorer_.assign(nullptr);
620  } else {
622 
625  }
626 }
627 
628 void create::layout_children(const SDL_Rect& rect)
629 {
630  DBG_MP << "laying out the children" << std::endl;
631 
632  ui::layout_children(rect);
633 
634  const int border_size = 6;
635  const int column_border_size = 10;
636 
637  SDL_Rect ca = client_area();
638  int xpos = ca.x;
639  int ypos = ca.y;
640 
641  // 222 is two times a button's minimal width plus one time border_size.
642  // Instead of binding this value to the actual button widths, I chose this
643  // because it makes no difference for most languages, and where it does, I
644  // guess we'd prefer having the buttons less neatly aligned to having a
645  // potentially giant image.
646  const int image_width = ca.h < 500 ? 111 : 222;
647  const int menu_width = (ca.w - 3 * column_border_size - image_width) / 3;
648  const int eras_menu_height = (ca.h / 2 - era_label_.height() -
649  2 * border_size - cancel_game_.height());
650  const int mods_menu_height = (ca.h / 2 - mod_label_.height() -
651  3 * border_size - cancel_game_.height());
652 
653  // Dialog title
654  ypos += title().height() + border_size;
655 
656  // Save ypos here (column top)
657  int ypos_columntop = ypos;
658 
659  // First column: image & random map options
660  image_rect_ = sdl::create_rect(xpos, ypos, image_width, image_width);
661  ypos += image_width + border_size;
662 
663  num_players_label_.set_location(xpos, ypos);
664  ypos += num_players_label_.height() + border_size;
665 
666  map_size_label_.set_location(xpos, ypos);
667  ypos += map_size_label_.height() + 2 * border_size;
668 
669  const int ypos1 = ypos;
670  const int xpos1 = xpos;
671  // The description box is set later
672 
673  // Second column: filtering options
674  ypos = ypos_columntop;
675  xpos += image_width + column_border_size;
676  filter_name_label_.set_location(xpos, ypos);
677  filter_name_.set_location(xpos + filter_name_label_.width() + border_size, ypos);
679  ypos += filter_name_.height() + border_size;
681  ypos += filter_num_players_label_.height() + border_size;
684  ypos += filter_num_players_slider_.height() + border_size;
686  ypos += map_generator_label_.height() + border_size;
687  regenerate_map_.set_location(xpos, ypos);
688  ypos += regenerate_map_.height() + border_size;
689  generator_settings_.set_location(xpos, ypos);
690  ypos += generator_settings_.height() + border_size;
691  load_game_.set_location(xpos, ypos + 4 * border_size);
692 
693  // And now the description box
694  description_.set_location(xpos1, std::max(ypos,ypos1));
695  description_.set_measurements(image_width + border_size + menu_width, ca.h + ca.y - std::max(ypos,ypos1) - border_size);
696  description_.set_wrap(true);
697  ypos += description_.height() + border_size;
698 
699  //Third column: levels menu
700  ypos = ypos_columntop;
701  xpos += menu_width + column_border_size;
702  level_type_label_.set_location(xpos, ypos);
703  ypos += level_type_label_.height() + border_size;
704  level_type_combo_.set_location(xpos, ypos);
705  ypos += level_type_combo_.height() + border_size;
706 
707  const int levels_menu_y_offset = (ca.w < 900 || ca.h < 500) ?
708  ((cancel_game_.height() + border_size) * -1) : 0;
709  levels_menu_.set_max_width(menu_width);
710  levels_menu_.set_max_height(ca.h + ca.y - ypos + levels_menu_y_offset);
711  levels_menu_.set_location(xpos, ypos);
712  // Menu dimensions are only updated when items are set. So do this now.
713  int levelsel = levels_menu_.selection();
715  levels_menu_.move_selection(levelsel);
716 
717  // Place game type combo and label in the middle of levels menu
718  // by x axis.
719  const int level_type_combo_x_offset = (levels_menu_.width() -
720  level_type_combo_.width()) / 2;
722  level_type_combo_.location().x + level_type_combo_x_offset,
724  const int level_type_label_x_offset = (levels_menu_.width() -
725  level_type_label_.width()) / 2;
727  level_type_label_.location().x + level_type_label_x_offset,
729 
730  //Fourth column: eras & mods menu
731  ypos = ypos_columntop;
732  xpos += menu_width + column_border_size;
733  era_label_.set_location(xpos, ypos);
734  ypos += era_label_.height() + border_size;
735  no_era_label_.set_location(xpos, ypos);
736  eras_menu_.set_max_width(menu_width);
737  eras_menu_.set_max_height(eras_menu_height);
738  eras_menu_.set_location(xpos, ypos);
739  // Menu dimensions are only updated when items are set. So do this now.
740  int erasel_save = eras_menu_.selection();
742  eras_menu_.move_selection(erasel_save);
743  ypos += eras_menu_height;
744 
745  //TODO: use when mods_menu_ would be functional.
746  mod_label_.set_location(xpos, ypos);
747  ypos += mod_label_.height() + border_size;
748  mods_menu_.set_max_width(menu_width);
749  mods_menu_.set_max_height(mods_menu_height);
750  mods_menu_.set_location(xpos, ypos);
751  if (mods_menu_.number_of_items() > 0) {
752  ypos += mods_menu_.height() + border_size;
753  }
754 
755  // Make eras and mods menus the same width for alignment
758 
759  // OK / Cancel buttons
760  gui::button* left_button = &launch_game_;
761  gui::button* right_button = &cancel_game_;
762 
763 #ifdef OK_BUTTON_ON_RIGHT
764  std::swap(left_button,right_button);
765 #endif
766 
767  // Buttons
768  right_button->set_location(ca.x + ca.w - right_button->width(),
769  ca.y + ca.h - right_button->height());
770  left_button->set_location(right_button->location().x - left_button->width() -
771  gui::ButtonHPadding, ca.y + ca.h - left_button->height());
772 
773  if (ca.h < 500) {
774  load_game_.set_location(left_button->location().x - load_game_.width() -
775  gui::ButtonHPadding, ca.y + ca.h - load_game_.height());
776  }
777 }
778 
779 } // namespace mp
780 
781 
void set_current_mod_index(const size_t index)
const std::function< size_t(const config &, const std::string &, size_t) > get_size_t
Definition: context.cpp:130
TYPE
UNSCALED : image will be drawn "as is" without changing size, even in case of redraw SCALED_TO_ZOOM :...
Definition: image.hpp:208
std::vector< std::string > levels_menu_item_names() const
gui::textbox filter_name_
gui::menu eras_menu_
gui::button cancel_game_
saved_game & get_state()
void set_numeric_keypress_selection(bool value)
Definition: menu.cpp:761
The class for loading a savefile.
Definition: savegame.hpp:36
void fill_rect(surface &dst, SDL_Rect *dst_rect, const Uint32 color)
Fill a rectangle on a given surface.
Definition: rect.hpp:143
const std::string & set_text(const std::string &text)
Definition: label.cpp:35
std::string era()
gui::multimenu mods_menu_
const depcheck::manager & dependency_manager() const
static lg::log_domain log_mp_create("mp/create")
Graphical text output.
const GLfloat * c
Definition: glew.h:12741
int player_num_filter() const
const mp_game_settings & get_parameters()
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
boost::optional< std::string > filename
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1221
gui::label era_label_
int value() const
Definition: slider.cpp:112
static l_noret error(LoadState *S, const char *why)
Definition: lundump.cpp:29
boost::scoped_ptr< plugins_context > plugins_context_
level & current_level() const
void set_max(int value)
Definition: slider.cpp:77
Definition: video.hpp:58
virtual std::string name() const
virtual void enable(bool new_val=true)
Definition: button.cpp:386
virtual void layout_children(const SDL_Rect &rect)
Lays the children out.
result get_result()
Returns the result of the current widget.
This file contains the window object, this object is a top level container which has the event manage...
void generator_user_config(CVideo &v)
std::vector< level_ptr > get_levels_by_type_unfiltered(level::TYPE type) const
SDL_Rect image_rect_
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glew.h:3783
int min_players() const
static config get_selected_helper(const ng::create_engine *eng_ptr)
void set_width(int w)
Definition: widget.cpp:119
void set_increment(int increment)
Definition: slider.cpp:107
GLuint const GLfloat * val
Definition: glew.h:2614
gui::label map_generator_label_
void set_text(const std::string &text, const SDL_Color &color=font::NORMAL_COLOR)
Definition: textbox.cpp:76
STL namespace.
void set_current_era_index(const size_t index, bool force=false)
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.
const std::string text() const
Definition: textbox.cpp:69
unsigned image_width(const std::string &filename)
Definition: help_impl.cpp:1379
void set_current_level(const size_t index)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
Definition: glew.h:1347
size_t number_of_items() const
Definition: menu.hpp:205
bool empty() const
Definition: config.cpp:1105
int selected() const
Definition: combo.cpp:38
gui::button regenerate_map_
const mp_game_settings & get_parameters()
void set_location(int x, int y)
Definition: slider.hpp:47
void prepare_for_era_and_mods()
-file util.hpp
bool generator_assigned() const
bool toggle_current_mod(bool force=false)
std::string select_campaign_difficulty(int set_value=-1)
select_campaign_difficulty
virtual void hide_children(bool hide=true)
Hides or shows all gui::widget children of this widget.
void init_level_type_changed(size_t index)
void set_measurements(int w, int h)
Definition: widget.cpp:129
const int ButtonHPadding
Definition: show_dialog.cpp:43
This module controls the multiplayer lobby.
static game_config_manager * get()
#define DBG_MP
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:82
void set_level_type(int value)
void process(int mousex, int mousey)
Definition: tooltips.cpp:198
virtual void layout_children(const SDL_Rect &rect)
Lays the children out.
std::string level()
A class that represents a TCP/IP connection to the wesnothd server.
result set_result(result res)
Sets the result of this dialog, to be checked by get_result().
void set_wrap(bool val)
Definition: textbox.cpp:277
gui::slider filter_num_players_slider_
void draw_centered_on_background(surface surf, const SDL_Rect &rect, const SDL_Color &color, surface target)
Definition: utils.cpp:2518
void synchronize_selections()
General settings and defaults for scenarios.
bool changed()
Definition: combo.cpp:43
const config & game_config() const
Returns the main game config, as defined by loading the preprocessed WML files.
gui::button generator_settings_
virtual void hide(bool value=true)
Definition: widget.cpp:162
const extras_metadata & current_extra(const MP_EXTRA extra_type) const
gui::button load_game_
gui::label num_players_label_
std::string selected
Definition: game_config.cpp:84
void show_message(CVideo &video, const std::string &title, const std::string &message, const std::string &button_caption, const bool auto_close, const bool message_use_markup)
Shows a message to the user.
Definition: message.cpp:143
gui::label mod_label_
ng::create_engine engine_
const gui::label & title() const
void init_level_changed(size_t index)
virtual void set_metadata()=0
bool plugin_event_helper(const process_event_data &)
void set_max_width(const int new_max_width)
Definition: menu.cpp:485
gui::label filter_num_players_label_
const config & data() const
bool pressed()
Definition: button.cpp:770
CVideo & video()
gui::label map_size_label_
gui::label filter_name_label_
std::vector< std::string > & active_mods()
void apply_level_filter(const std::string &name)
void init_generated_level_data()
int find_extra_by_id(const MP_EXTRA extra_type, const std::string &id) const
static config find_helper(const ng::create_engine *eng_ptr, const config &cfg)
virtual surface create_image_surface(const SDL_Rect &image_rect)=0
virtual void set_items(const std::vector< std::string > &items, bool strip_spaces=true, bool keep_viewport=false)
Set new items to show and redraw/recalculate everything.
Definition: multimenu.cpp:63
virtual bool allow_era_choice() const
void set_level(const std::string &value)
virtual void set_items(const std::vector< std::string > &items, bool strip_spaces=true, bool keep_viewport=false)
Set new items to show and redraw/recalculate everything.
Definition: menu.cpp:446
void move_selection(size_t id)
Definition: menu.cpp:567
void set_description(const std::string &description)
std::vector< std::string > extras_menu_item_names(const MP_EXTRA extra_type, bool escape_markup=true) const
void send_chat_message(const std::string &message, bool allies_only=false)
gui::label level_type_label_
static lg::log_domain log_config("config")
gui::combo level_type_combo_
level::TYPE find_level_type_by_id(const std::string &id) const
SDL_Rect client_area() const
void set_selected(int val)
Definition: combo.cpp:68
GLuint index
Definition: glew.h:1782
const SDL_Color LOBBY_COLOR
Definition: font.cpp:566
void assign(const resource_type &o)
size_t i
Definition: function.cpp:1057
void set_items(const std::vector< std::string > &items)
Definition: combo.cpp:52
Declarations for File-IO.
void prepare_for_campaign(const std::string &difficulty)
std::vector< ng::level::TYPE > available_level_types_
bool double_clicked()
Definition: menu.cpp:749
const std::string & level_name_filter() const
level::TYPE current_level_type() const
virtual void hide(bool value=true)
Definition: scrollarea.cpp:78
gui::label no_era_label_
create(CVideo &v, twesnothd_connection *wesnothd_connection, const config &game_config, saved_game &state, chat &c, config &gamelist)
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
Creates an empty SDL_Rect.
Definition: rect.cpp:28
void cancel_orders()
Definition: saved_game.cpp:567
void select_level_type_helper(const std::string &str)
Contains the SDL_Rect helper code.
int max_players() const
gui::textbox description_
void set_active(size_t index, bool active=true)
Definition: multimenu.cpp:70
gui::menu levels_menu_
virtual void process_event()
void set_modifications(const std::vector< std::string > &value, bool mp)
void swap(game_board &one, game_board &other)
Definition: game_board.cpp:56
this module manages the cache of images.
Definition: image.cpp:75
Standard logging facilities (interface).
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
virtual std::string description() const
void set_current_level_type(const level::TYPE)
virtual std::string icon() const
virtual void set_location(SDL_Rect const &rect)
Definition: widget.cpp:85
int num_players() const
void set_era(const std::string &value)
virtual std::string id() const
this class memorizes a chat session.
int width() const
Definition: widget.cpp:134
virtual void hide_children(bool hide=true)
Hides or shows all gui::widget children of this widget.
SDL_Rect const & location() const
Definition: widget.cpp:144
int last_changed()
Returns the item last activated/deactivated.
Definition: multimenu.cpp:75
gui::button launch_game_
int find_level_by_id(const std::string &id) const
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
std::string map_size() const
void update_rect(const SDL_Rect &)
Definition: dummy_video.cpp:27
void process_event_impl(const process_event_data &)
GLsizei const GLcharARB ** string
Definition: glew.h:4503
void set_max_height(const int new_max_height)
Set a new max height for this menu.
Definition: menu.cpp:477
util::scoped_ptr< surface_restorer > image_restorer_
int selection() const
Definition: menu.cpp:369
a base class for the different multiplayer base dialogs: game list, create game, wait game...
const int SIZE_SMALL
Definition: font.hpp:62
virtual void gamelist_updated(bool silent=true)
Called each time the gamelist_ variable is updated.
int height() const
Definition: widget.cpp:139