The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
menu_events.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 - 2016 by Joerg Hinrichs <[email protected]>
3  wesnoth playturn Copyright (C) 2003 by David White <[email protected]>
4  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 /**
17  * @file
18  * Operations activated from menus/hotkeys while playing a game.
19  * E.g. Unitlist, status_table, save_game, save_map, chat, show_help, etc.
20  */
21 
22 #include "global.hpp"
23 
24 #include "actions/attack.hpp"
25 #include "actions/create.hpp"
26 #include "actions/move.hpp"
27 #include "actions/undo.hpp"
28 #include "actions/vision.hpp"
29 #include "ai/manager.hpp"
30 #include "chat_command_handler.hpp"
31 #include "config_assign.hpp"
32 #include "dialogs.hpp"
33 #include "display_chat_manager.hpp"
34 #include "filechooser.hpp"
35 #include "formatter.hpp"
36 #include "formula/string_utils.hpp"
37 #include "game_board.hpp"
38 #include "game_config_manager.hpp"
39 #include "game_end_exceptions.hpp"
40 #include "game_events/manager.hpp"
41 #include "game_events/pump.hpp"
42 #include "game_preferences.hpp"
43 #include "game_state.hpp"
44 #include "gettext.hpp"
45 #include "gui/dialogs/chat_log.hpp"
48 #include "gui/dialogs/message.hpp"
56 #include "gui/widgets/settings.hpp"
57 #include "gui/widgets/window.hpp"
58 #include "help/help.hpp"
59 #include "log.hpp"
60 #include "map/map.hpp"
61 #include "map/label.hpp"
62 #include "map_command_handler.hpp"
63 #include "marked-up_text.hpp"
64 #include "menu_events.hpp"
65 #include "mouse_events.hpp"
66 #include "play_controller.hpp"
68 #include "preferences_display.hpp"
69 #include "replay.hpp"
70 #include "replay_helper.hpp"
71 #include "resources.hpp"
72 #include "savegame.hpp"
73 #include "save_index.hpp"
76 #include "sound.hpp"
77 #include "statistics_dialog.hpp"
78 #include "synced_context.hpp"
79 #include "terrain/builder.hpp"
80 #include "units/unit.hpp"
81 #include "units/udisplay.hpp"
82 #include "wml_separators.hpp"
83 #include "whiteboard/manager.hpp"
84 #include "widgets/combo.hpp"
85 
86 #include <boost/range/algorithm/find_if.hpp>
87 
88 static lg::log_domain log_engine("engine");
89 #define ERR_NG LOG_STREAM(err, log_engine)
90 #define LOG_NG LOG_STREAM(info, log_engine)
91 
92 namespace events{
93 
95  gui_(gui),
96  pc_(pc),
97  game_config_(game_config),
98  textbox_info_(),
99  last_search_(),
100  last_search_hit_()
101 {
102 }
103 
105 {
106 }
107 
112 std::vector<team>& menu_handler::teams() const { return gamestate().board_.teams_; }
113 const gamemap& menu_handler::map() { return gamestate().board_.map(); }
114 
116  return textbox_info_;
117 }
118 
120 {
121  int controlled_recruiters = 0;
122  for(size_t i = 0; i < teams().size(); ++i) {
123  if(teams()[i].is_local_human() && !teams()[i].recruits().empty()
124  && units().find_leader(i + 1) != units().end()) {
125  ++controlled_recruiters;
126  }
127  }
128  std::stringstream msg;
129  if(controlled_recruiters >= 2) {
130  unit_map::const_iterator leader = units().find_leader(side_num);
131  if (leader != units().end() && !leader->name().empty()) {
132  msg << " (" << leader->name(); msg << ")";
133  }
134  }
135  return msg.str();
136 }
137 
138 void menu_handler::objectives(int side_num)
139 {
140  if (!gamestate().lua_kernel_) {
141  return ;
142  }
143 
144  config cfg;
145  cfg["side"] = std::to_string(side_num);
146  gamestate().lua_kernel_->run_wml_action("show_objectives", vconfig(cfg),
147  game_events::queued_event("_from_interface", map_location(),
148  map_location(), config()));
149  team &current_team = teams()[side_num - 1];
151  current_team.reset_objectives_changed();
152 }
153 
155 {
156  team &current_team = teams()[side_num - 1];
157  // Current Player name
158  const std::string &player = current_team.side_name();
159  //add player's name to title of dialog
160  std::stringstream title_str;
161  title_str << _("Statistics") << " (" << player << ")";
162  statistics_dialog stats_dialog(*gui_, title_str.str(),
163  side_num, current_team.save_id(), player);
164  stats_dialog.show();
165 }
166 
168 {
170 }
171 
172 namespace {
173 class leader_scroll_dialog : public gui::dialog {
174 public:
175  leader_scroll_dialog(display &disp, const std::string &title,
176  std::vector<bool> &leader_bools, int selected,
177  gui::DIALOG_RESULT extra_result) :
178  dialog(disp.video(), title, "", gui::NULL_DIALOG),
179  scroll_btn_(new gui::standard_dialog_button(disp.video(), _("Scroll To"), 0, false)),
180  leader_bools_(leader_bools),
181  extra_result_(extra_result)
182  {
183  scroll_btn_->enable(leader_bools[selected]);
185  add_button(new gui::standard_dialog_button(disp.video(),
186  _("Close"), 1, true), gui::dialog::BUTTON_STANDARD);
187  }
188  void action(gui::dialog_process_info &info) {
189  const bool leader_bool = leader_bools_[get_menu().selection()];
190  scroll_btn_->enable(leader_bool);
191  if(leader_bool && (info.double_clicked || (!info.key_down
192  && (info.key[SDLK_RETURN] || info.key[SDLK_KP_ENTER])))) {
193  set_result(get_menu().selection());
194  } else if(!info.key_down && info.key[SDLK_ESCAPE]) {
195  set_result(gui::CLOSE_DIALOG);
196  } else if(!info.key_down && info.key[SDLK_SPACE]) {
197  set_result(extra_result_);
198  } else if(result() == gui::CONTINUE_DIALOG) {
199  dialog::action(info);
200  }
201  }
202 private:
204  std::vector<bool> &leader_bools_;
206 };
207 } //end anonymous namespace
208 void menu_handler::status_table(int selected)
209 {
210  std::stringstream heading;
211  heading << HEADING_PREFIX << _("Leader") << COLUMN_SEPARATOR << ' ' << COLUMN_SEPARATOR
212  << _("Team") << COLUMN_SEPARATOR
213  << _("Gold") << COLUMN_SEPARATOR
214  << _("Villages") << COLUMN_SEPARATOR
215  << _("status^Units") << COLUMN_SEPARATOR
216  << _("Upkeep") << COLUMN_SEPARATOR
217  << _("Income");
218 
222 
223  std::vector<std::string> items;
224  std::vector<bool> leader_bools;
225  items.push_back(heading.str());
226 
227  const team& viewing_team = teams()[gui_->viewing_team()];
228 
229  unsigned total_villages = 0;
230  // a variable to check if there are any teams to show in the table
231  bool status_table_empty = true;
232 
233  //if the player is under shroud or fog, they don't get
234  //to see details about the other sides, only their own
235  //side, allied sides and a ??? is shown to demonstrate
236  //lack of information about the other sides But he see
237  //all names with in colors
238  for(size_t n = 0; n != teams().size(); ++n) {
239  if(teams()[n].hidden()) {
240  continue;
241  }
242  status_table_empty=false;
243 
244  const bool known = viewing_team.knows_about_team(n);
245  const bool enemy = viewing_team.is_enemy(n+1);
246 
247  std::stringstream str;
248 
249  const team_data data = board().calculate_team_data(teams()[n],n+1);
250 
252  std::string leader_name;
253  //output the number of the side first, and this will
254  //cause it to be displayed in the correct color
255  if(leader != units().end()) {
256  const bool fogged = viewing_team.fogged(leader->get_location());
257  // Add leader image. If it's fogged
258  // show only a random leader image.
259  if (!fogged || known || game_config::debug) {
260  str << IMAGE_PREFIX << leader->absolute_image();
261 #ifndef LOW_MEM
262  str << leader->image_mods();
263 #endif
264  leader_bools.push_back(true);
265  leader_name = leader->name();
266  } else {
267  str << IMAGE_PREFIX << std::string("units/unknown-unit.png");
268 #ifndef LOW_MEM
269  str << "~RC(magenta>" << teams()[n].color() << ")";
270 #endif
271  leader_bools.push_back(false);
272  leader_name = "Unknown";
273  }
274 
275  if (pc_.get_classification().campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER)
276  leader_name = teams()[n].side_name();
277 
278  } else {
279  leader_bools.push_back(false);
280  }
282  << leader_name << COLUMN_SEPARATOR
283  << (data.teamname.empty() ? teams()[n].team_name() : data.teamname)
284  << COLUMN_SEPARATOR;
285 
286  if(!known && !game_config::debug) {
287  // We don't spare more info (only name)
288  // so let's go on next side ...
289  items.push_back(str.str());
290  continue;
291  }
292 
293  if(game_config::debug) {
295  } else if(enemy && viewing_team.uses_fog()) {
296  str << ' ' << COLUMN_SEPARATOR;
297  } else {
299  }
300  str << data.villages;
301  if(!(viewing_team.uses_fog() || viewing_team.uses_shroud())) {
302  str << "/" << map().villages().size();
303  }
304  str << COLUMN_SEPARATOR
305  << data.units << COLUMN_SEPARATOR << data.upkeep << COLUMN_SEPARATOR
307  total_villages += data.villages;
308  items.push_back(str.str());
309  }
310  if (total_villages > map().villages().size()) {
311  ERR_NG << "Logic error: map has " << map().villages().size() << " villages but status table shows " << total_villages << " owned in total" << std::endl;
312  }
313 
314  if (status_table_empty)
315  {
316  // no sides to show - display empty table
317  std::stringstream str;
318  str << " ";
319  for (int i=0;i<7;++i)
320  str << COLUMN_SEPARATOR << " ";
321  leader_bools.push_back(false);
322  items.push_back(str.str());
323  }
324  int result = 0;
325  {
326  leader_scroll_dialog slist(*gui_, _("Current Status"), leader_bools, selected, gui::DIALOG_FORWARD);
327  slist.add_button(new gui::dialog_button(gui_->video(), _("More >"),
330  slist.set_menu(items, &sorter);
331  slist.get_menu().move_selection(selected);
332  result = slist.show();
333  selected = slist.get_menu().selection();
334  } // this will kill the dialog before scrolling
335 
336  if (result >= 0)
337  gui_->scroll_to_leader(selected+1);
338  else if (result == gui::DIALOG_FORWARD)
339  scenario_settings_table(selected);
340 }
341 
343 {
344  std::stringstream heading;
345  heading << HEADING_PREFIX << _("scenario settings^Leader") << COLUMN_SEPARATOR
347  << _("scenario settings^Side") << COLUMN_SEPARATOR
348  << _("scenario settings^Start\nGold") << COLUMN_SEPARATOR
349  << _("scenario settings^Base\nIncome") << COLUMN_SEPARATOR
350  << _("scenario settings^Gold Per\nVillage") << COLUMN_SEPARATOR
351  << _("scenario settings^Support Per\nVillage") << COLUMN_SEPARATOR
352  << _("scenario settings^Fog") << COLUMN_SEPARATOR
353  << _("scenario settings^Shroud");
354 
359 
360  std::vector<std::string> items;
361  std::vector<bool> leader_bools;
362  items.push_back(heading.str());
363 
364  const team& viewing_team = teams()[gui_->viewing_team()];
365  bool settings_table_empty = true;
366  bool fogged;
367 
368  for(size_t n = 0; n != teams().size(); ++n) {
369  if(teams()[n].hidden()) {
370  continue;
371  }
372  settings_table_empty = false;
373 
374  std::stringstream str;
376 
377  if(leader != units().end()) {
378  // Add leader image. If it's fogged
379  // show only a random leader image.
380  fogged=viewing_team.fogged(leader->get_location());
381  if (!fogged || viewing_team.knows_about_team(n)) {
382  str << IMAGE_PREFIX << leader->absolute_image();
383  leader_bools.push_back(true);
384  } else {
385  str << IMAGE_PREFIX << std::string("units/unknown-unit.png");
386  leader_bools.push_back(false);
387  }
388 #ifndef LOW_MEM
389  str << "~RC(" << leader->team_color() << '>'
390  << team::get_side_color_index(n+1) << ")";
391 #endif
392  } else {
393  leader_bools.push_back(false);
394  }
395 
397  << teams()[n].side_name() << COLUMN_SEPARATOR
398  << n + 1 << COLUMN_SEPARATOR
399  << teams()[n].start_gold() << COLUMN_SEPARATOR
400  << teams()[n].base_income() << COLUMN_SEPARATOR
401  << teams()[n].village_gold() << COLUMN_SEPARATOR
402  << teams()[n].village_support() << COLUMN_SEPARATOR
403  << (teams()[n].uses_fog() ? _("yes") : _("no")) << COLUMN_SEPARATOR
404  << (teams()[n].uses_shroud() ? _("yes") : _("no")) << COLUMN_SEPARATOR;
405 
406  items.push_back(str.str());
407  }
408 
409  if (settings_table_empty)
410  {
411  // no sides to show - display empty table
412  std::stringstream str;
413  for (int i=0;i<8;++i)
414  str << " " << COLUMN_SEPARATOR;
415  leader_bools.push_back(false);
416  items.push_back(str.str());
417  }
418  int result = 0;
419  {
420  leader_scroll_dialog slist(*gui_, _("Scenario Settings"), leader_bools, selected, gui::DIALOG_BACK);
421  slist.set_menu(items, &sorter);
422  slist.get_menu().move_selection(selected);
423  slist.add_button(new gui::dialog_button(gui_->video(), _(" < Back"),
426  result = slist.show();
427  selected = slist.get_menu().selection();
428  } // this will kill the dialog before scrolling
429 
430  if (result >= 0)
431  gui_->scroll_to_leader(selected+1);
432  else if (result == gui::DIALOG_BACK)
433  status_table(selected);
434 }
435 
437 {
439  int res = 0;
440  int overwrite = 1;
441  do {
442  res = dialogs::show_file_chooser_dialog_save(gui_->video(), input_name, _("Save the Map As"), ".map");
443  if (res == 0) {
444 
445  if (filesystem::file_exists(input_name)) {
446  const int res = gui2::show_message((*gui_).video(), "", _("The map already exists. Do you want to overwrite it?"), gui2::tmessage::yes_no_buttons);
447  overwrite = res == gui2::twindow::CANCEL ? 1 : 0;
448  }
449  else
450  overwrite = 0;
451  }
452  } while (res == 0 && overwrite != 0);
453 
454  // Try to save the map, if it fails we reset the filename.
455  if (res == 0) {
456  try {
457  filesystem::write_file(input_name, map().write());
458  gui2::show_transient_message(gui_->video(), "", _("Map saved."));
459  } catch (filesystem::io_exception& e) {
460  utils::string_map symbols;
461  symbols["msg"] = e.what();
462  const std::string msg = vgettext("Could not save the map: $msg",symbols);
464  }
465  }
466 }
467 
469 {
471  // Needed after changing fullscreen/windowed mode or display resolution
473 }
474 
476 {
477  config c;
478  c["name"] = "prototype of chat log";
479  gui2::tchat_log chat_log_dialog(vconfig(c), resources::recorder);
480  chat_log_dialog.show(gui_->video());
481  //std::string text = resources::recorder->build_chat_log();
482  //gui::show_dialog(*gui_,nullptr,_("Chat Log"),"",gui::CLOSE_ONLY,nullptr,nullptr,"",&text);
483 }
484 
486 {
488 }
489 
491 {
493  has_friends() ? board().is_observer() ? _("Send to observers only") : _("Send to allies only")
495 }
496 
498 {
500  speak();
501 }
502 
504 {
506  speak();
507 }
508 
510 {
511  if(board().is_observer()) {
512  return !gui_->observers().empty();
513  }
514 
515  for(size_t n = 0; n != teams().size(); ++n) {
516  if(n != gui_->viewing_team() && teams()[gui_->viewing_team()].team_name() == teams()[n].team_name() && teams()[n].is_network()) {
517  return true;
518  }
519  }
520 
521  return false;
522 }
523 
524 void menu_handler::recruit(int side_num, const map_location &last_hex)
525 {
526  std::vector<const unit_type*> sample_units;
527 
528  gui_->draw(); //clear the old menu
529 
530  std::set<std::string> recruits = actions::get_recruits(side_num, last_hex);
531 
532  for(std::set<std::string>::const_iterator it = recruits.begin(); it != recruits.end(); ++it) {
533  const unit_type* type = unit_types.find(*it);
534  if (!type) {
535  ERR_NG << "could not find unit '" << *it << "'" << std::endl;
536  return;
537  }
538 
539  sample_units.push_back(type);
540  }
541 
542  if(sample_units.empty()) {
543  gui2::show_transient_message(gui_->video(), "", _("You have no units available to recruit."));
544  return;
545  }
546 
547  gui2::tunit_recruit dlg(sample_units, teams()[side_num - 1]);
548 
549  dlg.show(gui_->video());
550 
551  if(dlg.get_retval() == gui2::twindow::OK) {
552  do_recruit(sample_units[dlg.get_selected_index()]->id(), side_num, last_hex);
553  }
554 }
555 
556 
557 void menu_handler::repeat_recruit(int side_num, const map_location &last_hex)
558 {
559  const std::string & last_recruit = teams()[side_num - 1].last_recruit();
560  if ( last_recruit.empty() == false )
561  do_recruit(last_recruit, side_num, last_hex);
562 }
563 
564 bool menu_handler::do_recruit(const std::string &name, int side_num,
565  const map_location &last_hex)
566 {
567  team &current_team = teams()[side_num - 1];
568 
569  //search for the unit to be recruited in recruits
570  if ( !util::contains(actions::get_recruits(side_num, last_hex), name) )
571  return false;
572 
573  const unit_type *u_type = unit_types.find(name);
574  assert(u_type);
575 
576  if (u_type->cost() > current_team.gold() - (pc_.get_whiteboard() ? pc_.get_whiteboard()->get_spent_gold_for(side_num) : 0)) {
578  _("You don’t have enough gold to recruit that unit"));
579  return false;
580  }
581 
582  current_team.last_recruit(name);
583  const events::command_disabler disable_commands;
584 
585  map_location loc = last_hex;
586  map_location recruited_from = map_location::null_location();
588  { wb::future_map_if_active future; /* start planned unit map scope if in planning mode */
589  msg = actions::find_recruit_location(side_num, loc, recruited_from, name);
590  } // end planned unit map scope
591  if (!msg.empty()) {
593  return false;
594  }
595 
596  if (!pc_.get_whiteboard() || !pc_.get_whiteboard()->save_recruit(name, side_num, loc)) {
597  //MP_COUNTDOWN grant time bonus for recruiting
598  current_team.set_action_bonus_count(1 + current_team.action_bonus_count());
599 
600  // Do the recruiting.
601 
602  synced_context::run_and_throw("recruit", replay_helper::get_recruit(u_type->id(), loc, recruited_from));
603  return true;
604  }
605  return false;
606 }
607 
608 void menu_handler::recall(int side_num, const map_location &last_hex)
609 {
610  if (pc_.get_disallow_recall()) {
611  gui2::show_transient_message(gui_->video(),"",_("You are separated from your soldiers and may not recall them"));
612  return;
613  }
614 
615  team &current_team = teams()[side_num - 1];
616 
617  boost::shared_ptr<std::vector<unit_const_ptr > > recall_list_team = boost::make_shared<std::vector<unit_const_ptr> >();
618  { wb::future_map future; // ensures recall list has planned recalls removed
619  *recall_list_team = actions::get_recalls(side_num, last_hex);
620  }
621 
622  gui_->draw(); //clear the old menu
623 
624 
625  DBG_WB <<"menu_handler::recall: Contents of wb-modified recall list:\n";
626  for(const unit_const_ptr & unit : *recall_list_team)
627  {
628  DBG_WB << unit->name() << " [" << unit->id() <<"]\n";
629  }
630 
631  if(current_team.recall_list().empty()) {
633  _("There are no troops available to recall\n(You must have"
634  " veteran survivors from a previous scenario)"));
635  return;
636  }
637  if(recall_list_team->empty()) {
639  _("You currently can't recall at the highlighted location"));
640  return;
641  }
642 
643  int res = dialogs::recall_dialog(*gui_, recall_list_team, side_num, get_title_suffix(side_num), current_team.recall_cost());
644  int unit_cost = current_team.recall_cost();
645  if (res < 0) {
646  return;
647  }
648  // we need to check if unit has a specific recall cost
649  // if it does we use it elsewise we use the team.recall_cost()
650  // the magic number -1 is what it gets set to if the unit doesn't
651  // have a special recall_cost of its own.
652  else if(recall_list_team->at(res)->recall_cost() > -1) {
653  unit_cost = recall_list_team->at(res)->recall_cost();
654  }
655 
656  int wb_gold = pc_.get_whiteboard() ? pc_.get_whiteboard()->get_spent_gold_for(side_num) : 0;
657  if (current_team.gold() - wb_gold < unit_cost) {
658  utils::string_map i18n_symbols;
659  i18n_symbols["cost"] = std::to_string(unit_cost);
661  "You must have at least 1 gold piece to recall a unit",
662  "You must have at least $cost gold pieces to recall this unit",
663  unit_cost, i18n_symbols);
665  return;
666  }
667 
668  LOG_NG << "recall index: " << res << "\n";
669  const events::command_disabler disable_commands;
670 
671  map_location recall_location = last_hex;
674  { wb::future_map_if_active future; // future unit map removes invisible units from map, don't do this outside of planning mode
675  err = actions::find_recall_location(side_num, recall_location, recall_from, *(recall_list_team->at(res)));
676  } // end planned unit map scope
677  if(!err.empty()) {
679  return;
680  }
681 
682  if (!pc_.get_whiteboard() || !pc_.get_whiteboard()->save_recall(*recall_list_team->at(res), side_num, recall_location)) {
683  bool success = synced_context::run_and_throw("recall",
684  replay_helper::get_recall(recall_list_team->at(res)->id(), recall_location, recall_from),
685  true,
686  true,
688 
689  if(!success)
690  {
691  ERR_NG << "menu_handler::recall(): Unit does not exist in the recall list." << std::endl;
692  }
693  }
694 }
695 
696 
697 // Highlights squares that an enemy could move to on their turn, showing how many can reach each square.
698 void menu_handler::show_enemy_moves(bool ignore_units, int side_num)
699 {
700  wb::future_map future; // use unit positions as if all planned actions were executed
701 
703 
704  // Compute enemy movement positions
705  for(unit_map::iterator u = units().begin(); u != units().end(); ++u) {
706  bool invisible = u->invisible(u->get_location());
707 
708  if (teams()[side_num - 1].is_enemy(u->side()) &&
709  !gui_->fogged(u->get_location()) && !u->incapacitated() && !invisible)
710  {
711  const unit_movement_resetter move_reset(*u);
712  const pathfind::paths& path = pathfind::paths(*u, false, true,
713  teams()[gui_->viewing_team()], 0, false, ignore_units);
714 
716  }
717  }
718 }
719 
721 {
722  team &current_team = teams()[side_num - 1];
723  bool auto_shroud = current_team.auto_shroud_updates();
724  // If we're turning automatic shroud updates on, then commit all moves
725  if (!auto_shroud) update_shroud_now(side_num);
726 
727  // Toggle the setting and record this.
729 }
730 
731 void menu_handler::update_shroud_now(int /* side_num */)
732 {
734 }
735 
736 
737 namespace { // Helpers for menu_handler::end_turn()
738  /**
739  * Returns true if @a side_num has at least one living unit.
740  */
741  bool units_alive(int side_num, const unit_map & units)
742  {
743  for ( unit_map::const_iterator un = units.begin(); un != units.end(); ++un ) {
744  if ( un->side() == side_num )
745  return true;
746  }
747  return false;
748  }
749  /**
750  * Returns true if @a side_num has at least one unit that can still move.
751  */
752  bool partmoved_units(int side_num, const unit_map & units, const game_board & board, const boost::shared_ptr<wb::manager> & whiteb)
753  {
754  for ( unit_map::const_iterator un = units.begin(); un != units.end(); ++un ) {
755  if ( un->side() == side_num ) {
756  // @todo whiteboard should take into consideration units that have
757  // a planned move but can still plan more movement in the same turn
758  if ( board.unit_can_move(*un) && !un->user_end_turn()
759  && (!whiteb || !whiteb->unit_has_actions(&*un)) )
760  return true;
761  }
762  }
763  return false;
764  }
765  /**
766  * Returns true if @a side_num has at least one unit that (can but) has not
767  * moved.
768  */
769  bool unmoved_units(int side_num, const unit_map & units, const game_board & board, const boost::shared_ptr<wb::manager> & whiteb)
770  {
771  for ( unit_map::const_iterator un = units.begin(); un != units.end(); ++un ) {
772  if ( un->side() == side_num ) {
773  if ( board.unit_can_move(*un) && !un->has_moved() && !un->user_end_turn()
774  && (!whiteb || !whiteb->unit_has_actions(&*un)) )
775  return true;
776  }
777  }
778  return false;
779  }
780 }
781 
782 bool menu_handler::end_turn(int side_num)
783 {
784  if(!gamedata().allow_end_turn()) {
785  gui2::show_transient_message((*gui_).video(), "", _("You cannot end your turn yet!"));
786  return false;
787  }
788 
789  size_t team_num = static_cast<size_t>(side_num - 1);
790  if ( team_num < teams().size() && teams()[team_num].no_turn_confirmation() ) {
791  // Skip the confirmations that follow.
792  }
793  // Ask for confirmation if the player hasn't made any moves.
794  else if ( preferences::confirm_no_moves() &&
796  (!pc_.get_whiteboard() || !pc_.get_whiteboard()->current_side_has_actions()) &&
797  units_alive(side_num, units()) )
798  {
799  const int res = gui2::show_message((*gui_).video(), "", _("You have not started your turn yet. Do you really want to end your turn?"), gui2::tmessage::yes_no_buttons);
800  if(res == gui2::twindow::CANCEL) {
801  return false;
802  }
803  }
804  // Ask for confirmation if units still have some movement left.
805  else if ( preferences::yellow_confirm() && partmoved_units(side_num, units(), board(), pc_.get_whiteboard()) ) {
806  const int res = gui2::show_message((*gui_).video(), "", _("Some units have movement left. Do you really want to end your turn?"), gui2::tmessage::yes_no_buttons);
807  if(res == gui2::twindow::CANCEL) {
808  return false;
809  }
810  }
811  // Ask for confirmation if units still have all movement left.
812  else if ( preferences::green_confirm() && unmoved_units(side_num, units(), board(), pc_.get_whiteboard()) ) {
813  const int res = gui2::show_message((*gui_).video(), "", _("Some units have not moved. Do you really want to end your turn?"), gui2::tmessage::yes_no_buttons);
814  if(res == gui2::twindow::CANCEL) {
815  return false;
816  }
817  }
818 
819  // Auto-execute remaining whiteboard planned actions
820  // Only finish turn if they all execute successfully, i.e. no ambush, etc.
821  if (pc_.get_whiteboard() && !pc_.get_whiteboard()->allow_end_turn()) {
822  return false;
823  }
824 
825  return true;
826 }
827 
828 void menu_handler::goto_leader(int side_num)
829 {
831  if(i != units().end()) {
832  gui_->scroll_to_tile(i->get_location(), game_display::WARP);
833  }
834 }
835 
837 {
839  if(un != units().end()) {
841  }
842 }
843 
845 {
846  const map_location& loc = mousehandler.get_last_hex();
847  if (map().on_board(loc) == false || gui_->shrouded(loc)) {
848  return;
849  }
850 
851  const terrain_type& type = map().get_terrain_info(loc);
852  //const terrain_type& info = board().map().get_terrain_info(terrain);
854 }
855 
857 {
858  const unit_map::iterator un = current_unit();
859  if (un == units().end() || gui_->viewing_side() != un->side())
860  return;
861  if (un->unrenamable())
862  return;
863 
864  std::string name = un->name();
865  const std::string title(N_("Rename Unit"));
866  const std::string label(N_("Name:"));
867 
868  if(gui2::tedit_text::execute(title, label, name, gui_->video())) {
869  resources::recorder->add_rename(name, un->get_location());
870  un->rename(name);
872  }
873 }
874 
876 {
877  const mouse_handler& mousehandler = pc_.get_mouse_handler_base();
878 
880  teams()[gui_->viewing_team()]);
881  if(res != units().end()) {
882  return res;
883  } else {
884  return board().find_visible_unit(mousehandler.get_selected_hex(),
885  teams()[gui_->viewing_team()]);
886  }
887 }
888 
889 namespace { // Helpers for create_unit()
890  /// Allows a function to return both a type and a gender.
891  typedef std::pair<const unit_type *, unit_race::GENDER> type_and_gender;
892 
893  /**
894  * Allows the user to select a type of unit, using GUI2.
895  * (Intended for use when a unit is created in debug mode via hotkey or
896  * context menu.)
897  * @returns the selected type and gender. If this is canceled, the
898  * returned type is nullptr.
899  */
900  type_and_gender choose_unit(game_display& gui)
901  {
902  //
903  // The unit creation dialog makes sure unit types
904  // are properly cached.
905  //
906  gui2::tunit_create create_dlg;
907  create_dlg.show(gui.video());
908 
909  if(create_dlg.no_choice()) {
910  return type_and_gender(nullptr, unit_race::NUM_GENDERS);
911  }
912 
913  const std::string& ut_id = create_dlg.choice();
914  const unit_type *utp = unit_types.find(ut_id);
915  if (!utp) {
916  ERR_NG << "Create unit dialog returned nonexistent or unusable unit_type id '" << ut_id << "'." << std::endl;
917  return type_and_gender(static_cast<const unit_type *>(nullptr), unit_race::NUM_GENDERS);
918  }
919  const unit_type &ut = *utp;
920 
921  unit_race::GENDER gender = create_dlg.gender();
922  // Do not try to set bad genders, may mess up l10n
923  /// @todo Is this actually necessary?
924  /// (Maybe create_dlg can enforce proper gender selection?)
925  if(ut.genders().end() == std::find(ut.genders().begin(), ut.genders().end(), gender)) {
926  gender = ut.genders().front();
927  }
928 
929  return type_and_gender(utp, gender);
930  }
931 
932  /**
933  * Creates a unit and places it on the board.
934  * (Intended for use with any units created via debug mode.)
935  */
936  void create_and_place(game_display& , const gamemap & , unit_map & ,
937  const map_location & loc, const unit_type & u_type,
939  {
940  synced_context::run_and_throw("debug_create_unit", config_of("x", loc.x + 1)("y", loc.y + 1)("type", u_type.id())("gender", gender_string(gender)));
941  }
942 
943 }// Anonymous namespace
944 
945 
946 /**
947  * Creates a unit (in debug mode via hotkey or context menu).
948  */
950 {
951  // Save the current mouse location before popping up the choice menu (which
952  // gives time for the mouse to move, changing the location).
953  const map_location destination = mousehandler.get_last_hex();
954  assert(gui_ != nullptr);
955 
956  // Let the user select the kind of unit to create.
957  type_and_gender selection = choose_unit(*gui_);
958  if ( selection.first != nullptr )
959  // Make it so.
960  create_and_place(*gui_, map(), units(), destination,
961  *selection.first, selection.second);
962 }
963 
965 {
966  const map_location& loc = mousehandler.get_last_hex();
967  const unit_map::iterator i = units().find(loc);
968  if(i == units().end()) {
969  if(!map().is_village(loc))
970  return;
971 
972  // village_owner returns -1 for free village, so team 0 will get it
973  int team = board().village_owner(loc) + 1;
974  // team is 0-based so team=team::nteams() is not a team
975  // but this will make get_village free it
976  if(team > static_cast<int> (teams().size())) {
977  team = 0;
978  }
979  actions::get_village(loc, team + 1);
980  } else {
981  int side = i->side();
982  ++side;
983  if(side > static_cast<int> (teams().size())) {
984  side = 1;
985  }
986  i->set_side(side);
987 
988  if(map().is_village(loc)) {
989  actions::get_village(loc, side);
990  }
991  }
992 }
993 
995 {
996  const map_location& loc = mousehandler.get_last_hex();
997  const unit_map::iterator i = units().find(loc);
998  if(i != units().end()) {
999  const int dying_side = i->side();
1000  pc_.pump().fire("last breath", loc, loc);
1001  if (i.valid()) {
1002  unit_display::unit_die(loc, *i);
1003  }
1004  gui_->redraw_minimap();
1005  pc_.pump().fire("die", loc, loc);
1006  if (i.valid()) {
1007  units().erase(i);
1008  }
1009  actions::recalculate_fog(dying_side);
1010  pc_.check_victory();
1011  }
1012 }
1013 
1014 void menu_handler::label_terrain(mouse_handler& mousehandler, bool team_only)
1015 {
1016  const map_location& loc = mousehandler.get_last_hex();
1017  if (map().on_board(loc) == false) {
1018  return;
1019  }
1020 
1021  const terrain_label* old_label = gui_->labels().get_label(loc);
1022  std::string label = old_label ? old_label->text() : "";
1023 
1024  if(gui2::tedit_label::execute(label, team_only, gui_->video())) {
1025  std::string team_name;
1026  SDL_Color color = font::LABEL_COLOR;
1027 
1028  if (team_only) {
1029  team_name = gui_->labels().team_name();
1030  } else {
1032  }
1033  const terrain_label* res = gui_->labels().set_label(loc, label, gui_->viewing_team(), team_name, color);
1034  if (res)
1036  }
1037 }
1038 
1040 {
1041  if (gui_->team_valid()
1042  && !board().is_observer())
1043  {
1044  gui_->labels().clear(gui_->current_team_name(), false);
1046  }
1047 }
1048 
1052 }
1053 
1054 void menu_handler::continue_move(mouse_handler &mousehandler, int side_num)
1055 {
1057  if (i == units().end() || !i->move_interrupted()) {
1058  i = units().find(mousehandler.get_selected_hex());
1059  if (i == units().end() || !i->move_interrupted()) return;
1060  }
1061  move_unit_to_loc(i, i->get_interrupted_move(), true,
1062  side_num, mousehandler);
1063 }
1064 
1066  const map_location& target, bool continue_move, int side_num,
1067  mouse_handler &mousehandler)
1068 {
1069  assert(ui != units().end());
1070 
1071  pathfind::marked_route route = mousehandler.get_route(&*ui, target, teams()[side_num - 1]);
1072 
1073  if(route.steps.empty())
1074  return;
1075 
1076  assert(route.steps.front() == ui->get_location());
1077 
1078  gui_->set_route(&route);
1080  {
1081  LOG_NG << "move_unit_to_loc " << route.steps.front() << " to " << route.steps.back() << "\n";
1083  }
1084  gui_->set_route(nullptr);
1086 }
1087 
1088 void menu_handler::execute_gotos(mouse_handler &mousehandler, int side)
1089 {
1090  // we will loop on all gotos and try to fully move a maximum of them,
1091  // but we want to avoid multiple blocking of the same unit,
1092  // so, if possible, it's better to first wait that the blocker move
1093 
1094  bool wait_blocker_move = true;
1095  std::set<map_location> fully_moved;
1096 
1097  bool change = false;
1098  bool blocked_unit = false;
1099  do {
1100  change = false;
1101  blocked_unit = false;
1102  for(unit_map::iterator ui = units().begin(); ui != units().end(); ++ui) {
1103  if (ui->side() != side || ui->movement_left() == 0)
1104  continue;
1105 
1106  const map_location &current_loc = ui->get_location();
1107  const map_location &goto_loc = ui->get_goto();
1108 
1109  if(goto_loc == current_loc){
1110  ui->set_goto(map_location());
1111  continue;
1112  }
1113 
1114  if(!map().on_board(goto_loc))
1115  continue;
1116 
1117  // avoid pathfinding calls for finished units
1118  if(fully_moved.count(current_loc))
1119  continue;
1120 
1121  pathfind::marked_route route = mousehandler.get_route(&*ui, goto_loc, teams()[side - 1]);
1122 
1123  if(route.steps.size() <= 1) { // invalid path
1124  fully_moved.insert(current_loc);
1125  continue;
1126  }
1127 
1128  // look where we will stop this turn (turn_1 waypoint or goto)
1129  map_location next_stop = goto_loc;
1130  pathfind::marked_route::mark_map::const_iterator w = route.marks.begin();
1131  for(; w != route.marks.end(); ++w) {
1132  if (w->second.turns == 1) {
1133  next_stop = w->first;
1134  break;
1135  }
1136  }
1137 
1138  if(next_stop == current_loc) {
1139  fully_moved.insert(current_loc);
1140  continue;
1141  }
1142 
1143  // we delay each blocked move because some other change
1144  // may open a another not blocked path
1145  if(units().count(next_stop)) {
1146  blocked_unit = true;
1147  if (wait_blocker_move)
1148  continue;
1149  }
1150 
1151  gui_->set_route(&route);
1152 
1153  {
1154  LOG_NG << "execute goto from " << route.steps.front() << " to " << route.steps.back() << "\n";
1155  int moves = actions::move_unit_and_record(route.steps, &pc_.get_undo_stack());
1156  change = moves > 0;
1157  }
1158 
1159  if (change) {
1160  // something changed, resume waiting blocker (maybe one can move now)
1161  wait_blocker_move = true;
1162  }
1163  }
1164 
1165  if(!change && wait_blocker_move) {
1166  // no change when waiting, stop waiting and retry
1167  wait_blocker_move = false;
1168  change = true;
1169  }
1170  } while(change && blocked_unit);
1171 
1172  // erase the footsteps after movement
1173  gui_->set_route(nullptr);
1175 }
1176 
1177 
1179 {
1181  gui_->invalidate_all();
1182 }
1183 
1185 {
1187  gui_->invalidate_all();
1188 }
1189 
1190 void menu_handler::unit_hold_position(mouse_handler &mousehandler, int side_num)
1191 {
1192  const unit_map::iterator un = units().find(mousehandler.get_selected_hex());
1193  if (un != units().end() && un->side() == side_num && un->movement_left() >= 0)
1194  {
1195  un->toggle_hold_position();
1196  gui_->invalidate(mousehandler.get_selected_hex());
1197 
1198  mousehandler.set_current_paths(pathfind::paths());
1199  gui_->draw();
1200 
1201  if (un->hold_position()) {
1202  mousehandler.cycle_units(false);
1203  }
1204  }
1205 }
1206 
1207 void menu_handler::end_unit_turn(mouse_handler &mousehandler, int side_num)
1208 {
1209  const unit_map::iterator un = units().find(mousehandler.get_selected_hex());
1210  if (un != units().end() && un->side() == side_num && un->movement_left() >= 0)
1211  {
1212  un->toggle_user_end_turn();
1213  gui_->invalidate(mousehandler.get_selected_hex());
1214 
1215  mousehandler.set_current_paths(pathfind::paths());
1216  gui_->draw();
1217 
1218  if (un->user_end_turn()) {
1219  mousehandler.cycle_units(false);
1220  }
1221  }
1222 }
1223 
1225 {
1226  std::ostringstream msg;
1227  msg << _("Search");
1228  if(last_search_hit_.valid()) {
1229  msg << " [" << last_search_ << "]";
1230  }
1231  msg << ':';
1232  textbox_info_.show(gui::TEXTBOX_SEARCH,msg.str(), "", false, *gui_);
1233 }
1234 
1236  //None of the two parameters really needs to be passed since the information belong to members of the class.
1237  //But since it makes the called method more generic, it is done anyway.
1238  chat_handler::do_speak(textbox_info_.box()->text(),textbox_info_.check() != nullptr ? textbox_info_.check()->checked() : false);
1239 }
1240 
1241 
1242 void menu_handler::add_chat_message(const time_t& time,
1243  const std::string& speaker, int side, const std::string& message,
1245 {
1246  gui_->get_chat_manager().add_chat_message(time, speaker, side, message, type, false);
1247 
1249  ("message", message)
1250  ("whisper", type == events::chat_handler::MESSAGE_PRIVATE));
1251 }
1252 
1253 //command handler for user :commands. Also understands all chat commands
1254 //via inheritance. This complicates some things a bit.
1255 class console_handler : public map_command_handler<console_handler>, private chat_command_handler
1256 {
1257  public:
1258  //convenience typedef
1261  : chmap(), chat_command_handler(menu_handler, true), menu_handler_(menu_handler), team_num_(menu_handler.pc_.current_side())
1262  {}
1263  using chmap::dispatch; //disambiguate
1265  using chmap::command_failed;
1266  protected:
1267  //chat_command_handler's init_map() and handlers will end up calling these.
1268  //this makes sure the commands end up in our map
1269  virtual void register_command(const std::string& cmd,
1271  const std::string& usage="", const std::string& flags="")
1272  {
1273  chmap::register_command(cmd, h, help, usage, flags + "N"); //add chat commands as network_only
1274  }
1275  virtual void assert_existence(const std::string& cmd) {
1277  }
1278  virtual void register_alias(const std::string& to_cmd,
1279  const std::string& cmd)
1280  {
1281  chmap::register_alias(to_cmd, cmd);
1282  }
1283  virtual std::string get_arg(unsigned i) const
1284  {
1285  return chmap::get_arg(i);
1286  }
1287  virtual std::string get_cmd() const
1288  {
1289  return chmap::get_cmd();
1290  }
1291  virtual std::string get_data(unsigned n = 1) const
1292  {
1293  return chmap::get_data(n);
1294  }
1295 
1296  //these are needed to avoid ambiguities introduced by inheriting from console_command_handler
1298  using chmap::register_alias;
1299  using chmap::help;
1300  using chmap::is_enabled;
1302 
1303  void do_refresh();
1304  void do_droid();
1305  void do_idle();
1306  void do_theme();
1307  void do_control();
1308  void do_controller();
1309  void do_clear();
1310  void do_sunset();
1311  void do_foreground();
1312  void do_layers();
1313  void do_fps();
1314  void do_benchmark();
1315  void do_save();
1316  void do_save_quit();
1317  void do_quit();
1318  void do_ignore_replay_errors();
1319  void do_nosaves();
1320  void do_next_level();
1321  void do_choose_level();
1322  void do_turn();
1323  void do_turn_limit();
1324  void do_debug();
1325  void do_nodebug();
1326  void do_lua();
1327  void do_unsafe_lua();
1328  void do_custom();
1329  void do_set_alias();
1330  void do_set_var();
1331  void do_show_var();
1332  void do_inspect();
1333  void do_control_dialog();
1334  void do_unit();
1335  // void do_buff();
1336  // void do_unbuff();
1337  void do_discover();
1338  void do_undiscover();
1339  void do_create();
1340  void do_fog();
1341  void do_shroud();
1342  void do_gold();
1343  void do_event();
1346  void do_toggle_whiteboard();
1347  void do_whiteboard_options();
1348 
1350  return _("(D) — debug only, (N) — network only, (A) — admin only");
1351  }
1352  using chat_command_handler::get_command_flags_description; //silence a warning
1353  std::string get_command_flags_description(const chmap::command& c) const
1354  {
1355  std::string space(" ");
1356  return (c.has_flag('D') ? space + _("(debug command)") : "")
1357  + (c.has_flag('N') ? space + _("(network only)") : "")
1358  + (c.has_flag('A') ? space + _("(admin only)") : "")
1359  + (c.has_flag('S') ? space + _("(not during other events)") : "");
1360  }
1361  using map::is_enabled;
1362  bool is_enabled(const chmap::command& c) const
1363  {
1364  return !((c.has_flag('D') && !game_config::debug)
1365  || (c.has_flag('N') && menu_handler_.pc_.is_networked_mp())
1366  || (c.has_flag('A') && !preferences::is_authenticated())
1367  || (c.has_flag('S') && (synced_context::get_synced_state() != synced_context::UNSYNCED)));
1368  }
1369  void print(const std::string& title, const std::string& message)
1370  {
1371  menu_handler_.add_chat_message(time(nullptr), title, 0, message);
1372  }
1373  void init_map()
1374  {
1375  chat_command_handler::init_map();//grab chat_ /command handlers
1376  chmap::get_command("log")->flags = ""; //clear network-only flag from log
1377  chmap::get_command("version")->flags = ""; //clear network-only flag
1378  chmap::get_command("ignore")->flags = ""; //clear network-only flag
1379  chmap::get_command("friend")->flags = ""; //clear network-only flag
1380  chmap::get_command("remove")->flags = ""; //clear network-only flag
1381  chmap::set_cmd_prefix(":");
1383  _("Refresh gui."));
1385  _("Switch a side to/from AI control."), _("do not translate the on/off^[<side> [on/off]]"));
1387  _("Switch a side to/from idle state."), _("do not translate the on/off^[<side> [on/off]]"));
1390  _("Assign control of a side to a different player or observer."), _("<side> <nickname>"), "N");
1392  _("Query the controller status of a side."), _("<side>"));
1394  _("Clear chat history."));
1396  _("Visualize the screen refresh procedure."), "", "D");
1398  _("Debug foreground terrain."), "", "D");
1400  _("Debug layers from terrain under the mouse."), "", "D");
1401  register_command("fps", &console_handler::do_fps, _("Show fps."));
1403  register_command("save", &console_handler::do_save, _("Save game."));
1404  register_alias("save", "w");
1405  register_command("quit", &console_handler::do_quit, _("Quit game."));
1406  // Note the next value is used hardcoded in the init tests.
1407  register_alias("quit", "q!");
1409  _("Save and quit."));
1410  register_alias("save_quit", "wq");
1412  _("Ignore replay errors."));
1414  _("Disable autosaves."));
1416  _("Advance to the next scenario, or scenario identified by 'id'"), _("<id>"), "DS");
1417  register_alias("next_level", "n");
1419  _("Choose next scenario"), "", "DS");
1420  register_alias("choose_level", "cl");
1422  _("Change turn number (and time of day), or increase by one if no number is specified."), _("[turn]"), "DS");
1424  _("Change turn limit, or turn the turn limit off if no number is specified or it’s −1."), _("[limit]"), "DS");
1426  _("Turn debug mode on."));
1428  _("Turn debug mode off."), "", "D");
1430  _("Execute a Lua statement."), _("<command>[;<command>...]"), "DS");
1432  _("Grant higher privileges to Lua scripts."), "", "D");
1434  _("Set the command used by the custom command hotkey"), _("<command>[;<command>...]"));
1435  register_command("give_control"
1437  , _("Invoke a dialog allowing changing control of MP sides.")
1438  , ""
1439  , "N");
1441  _("Launch the gamestate inspector"), "", "D");
1443  _("Set or show alias to a command"), _("<name>[=<command>]"));
1445  _("Set a scenario variable."), _("<var>=<value>"), "DS");
1447  _("Show a scenario variable."), _("<var>"), "D");
1449  _("Modify a unit variable. (Only top level keys are supported.)"), "", "DS");
1450 
1451  // register_command("buff", &console_handler::do_buff,
1452  // _("Add a trait to a unit."), "", "D");
1453  // register_command("unbuff", &console_handler::do_unbuff,
1454  // _("Remove a trait from a unit. (Does not work yet.)"), "", "D");
1456  _("Discover all units in help."), "");
1458  _("'Undiscover' all units in help."), "");
1460  _("Create a unit."), "", "DS");
1462  _("Toggle fog for the current player."), "", "DS");
1464  _("Toggle shroud for the current player."), "", "DS");
1466  _("Give gold to the current player."), "", "DS");
1468  _("Fire a game event."), "", "DS");
1469  register_alias("throw", "fire");
1471  _("Toggle overlaying of x,y coordinates on hexes."));
1472  register_alias("show_coordinates", "sc");
1474  _("Toggle overlaying of terrain codes on hexes."));
1475  register_alias("show_terrain_codes", "tc");
1477  _("Toggle planning mode."));
1478  register_alias("whiteboard", "wb");
1480  _("Access whiteboard options dialog."));
1481  register_alias("whiteboard_options", "wbo");
1482 
1483  if (const config &alias_list = preferences::get_alias())
1484  {
1485  for(const config::attribute &a : alias_list.attribute_range()) {
1486  register_alias(a.second, a.first);
1487  }
1488  }
1489  }
1490  private:
1492  const unsigned int team_num_;
1493 };
1494 
1496 {
1497  config cfg;
1498  cfg["id"] = preferences::login();
1499  cfg["message"] = message;
1500  const time_t time = ::time(nullptr);
1501  std::stringstream ss;
1502  ss << time;
1503  cfg["time"] = ss.str();
1504 
1505  const int side = board().is_observer() ? 0 : gui_->viewing_side();
1506  if(!board().is_observer()) {
1507  cfg["side"] = side;
1508  }
1509 
1510  bool private_message = has_friends() && allies_only;
1511 
1512  if(private_message) {
1513  if (board().is_observer()) {
1514  cfg["to_sides"] = game_config::observer_team_name;
1515  } else {
1516  cfg["to_sides"] = teams()[gui_->viewing_team()].allied_human_teams();
1517  }
1518  }
1519 
1520  resources::recorder->speak(cfg);
1521 
1522  add_chat_message(time, cfg["id"], side, message,
1524 }
1525 
1526 
1527 void menu_handler::do_search(const std::string& new_search)
1528 {
1529  if(new_search.empty() == false && new_search != last_search_)
1530  last_search_ = new_search;
1531 
1532  if(last_search_.empty()) return;
1533 
1534  bool found = false;
1536  //If this is a location search, just center on that location.
1537  std::vector<std::string> args = utils::split(last_search_, ',');
1538  if(args.size() == 2) {
1539  int x, y;
1540  x = lexical_cast_default<int>(args[0], 0)-1;
1541  y = lexical_cast_default<int>(args[1], 0)-1;
1542  if(x >= 0 && x < map().w() && y >= 0 && y < map().h()) {
1543  loc = map_location(x,y);
1544  found = true;
1545  }
1546  }
1547  //Start scanning the game map
1548  if(loc.valid() == false)
1549  loc = map_location(map().w()-1,map().h()-1);
1550  map_location start = loc;
1551  while (!found) {
1552  //Move to the next location
1553  loc.x = (loc.x + 1) % map().w();
1554  if(loc.x == 0)
1555  loc.y = (loc.y + 1) % map().h();
1556 
1557  //Search label
1558  if (!gui_->shrouded(loc)) {
1559  const terrain_label* label = gui_->labels().get_label(loc);
1560  if(label) {
1561  std::string label_text = label->text().str();
1562  if(std::search(label_text.begin(), label_text.end(),
1563  last_search_.begin(), last_search_.end(),
1564  chars_equal_insensitive) != label_text.end()) {
1565  found = true;
1566  }
1567  }
1568  }
1569  //Search unit name
1570  if (!gui_->fogged(loc)) {
1571  unit_map::const_iterator ui = units().find(loc);
1572  if(ui != units().end()) {
1573  const std::string name = ui->name();
1574  if(std::search(name.begin(), name.end(),
1575  last_search_.begin(), last_search_.end(),
1576  chars_equal_insensitive) != name.end()) {
1577  if (!teams()[gui_->viewing_team()].is_enemy(ui->side()) ||
1578  !ui->invisible(ui->get_location())) {
1579  found = true;
1580  }
1581  }
1582  }
1583  }
1584 
1585  if(loc == start)
1586  break;
1587  }
1588 
1589  if(found) {
1590  last_search_hit_ = loc;
1592  gui_->highlight_hex(loc);
1593  } else {
1595  //Not found, inform the player
1596  utils::string_map symbols;
1597  symbols["search"] = last_search_;
1598  const std::string msg = vgettext("Could not find label or unit "
1599  "containing the string ‘$search’.", symbols);
1601  }
1602 }
1603 
1605 {
1606  console_handler ch(*this);
1607  ch.dispatch(str);
1608 }
1609 
1610 std::vector<std::string> menu_handler::get_commands_list()
1611 {
1612  console_handler ch(*this);
1613  // HACK: we need to call dispatch() at least once to get the
1614  // command list populated *at all*. Terrible design.
1615  // An empty command is silently ignored and has negligible
1616  // overhead, so we use that for this purpose here.
1617  ch.dispatch("");
1618  return ch.get_commands_list();
1619 }
1620 
1623 
1625 
1627 }
1628 
1630  // :droid [<side> [on/off]]
1631  const std::string side_s = get_arg(1);
1632  const std::string action = get_arg(2);
1633  // default to the current side if empty
1634  const unsigned int side = side_s.empty() ?
1635  team_num_ : lexical_cast_default<unsigned int>(side_s);
1636 
1637  if (side < 1 || side > menu_handler_.teams().size()) {
1638  utils::string_map symbols;
1639  symbols["side"] = side_s;
1640  command_failed(vgettext("Can't droid invalid side: '$side'.", symbols));
1641  return;
1642  } else if (menu_handler_.teams()[side - 1].is_network()) {
1643  utils::string_map symbols;
1644  symbols["side"] = std::to_string(side);
1645  command_failed(vgettext("Can't droid networked side: '$side'.", symbols));
1646  return;
1647  } else if (menu_handler_.teams()[side - 1].is_local_human()) {
1648  if (menu_handler_.teams()[side - 1].is_droid() ? action == " on" : action == " off") {
1649  return;
1650  }
1651  menu_handler_.teams()[side - 1].toggle_droid();
1652  if(team_num_ == side) {
1653  if(playsingle_controller* psc = dynamic_cast<playsingle_controller*>(&menu_handler_.pc_)) {
1654  psc->set_player_type_changed();
1655  }
1656  }
1657  } else if (menu_handler_.teams()[side - 1].is_local_ai()) {
1658 // menu_handler_.teams()[side - 1].make_human();
1659 // menu_handler_.change_controller(std::to_string(side),"human");
1660 
1661  utils::string_map symbols;
1662  symbols["side"] = side_s;
1663  command_failed(vgettext("Can't droid a local ai side: '$side'.", symbols));
1664  }
1666 }
1667 
1669  // :idle [<side> [on/off]]
1670  const std::string side_s = get_arg(1);
1671  const std::string action = get_arg(2);
1672  // default to the current side if empty
1673  const unsigned int side = side_s.empty() ?
1674  team_num_ : lexical_cast_default<unsigned int>(side_s);
1675 
1676  if (side < 1 || side > menu_handler_.teams().size()) {
1677  utils::string_map symbols;
1678  symbols["side"] = side_s;
1679  command_failed(vgettext("Can't idle invalid side: '$side'.", symbols));
1680  return;
1681  } else if (menu_handler_.teams()[side - 1].is_network()) {
1682  utils::string_map symbols;
1683  symbols["side"] = std::to_string(side);
1684  command_failed(vgettext("Can't idle networked side: '$side'.", symbols));
1685  return;
1686  } else if (menu_handler_.teams()[side - 1].is_local_ai()) {
1687  utils::string_map symbols;
1688  symbols["side"] = std::to_string(side);
1689  command_failed(vgettext("Can't idle local ai side: '$side'.", symbols));
1690  return;
1691  } else if (menu_handler_.teams()[side - 1].is_local_human()) {
1692  if (menu_handler_.teams()[side - 1].is_idle() ? action == " on" : action == " off") {
1693  return;
1694  }
1695  //toggle the proxy controller between idle / non idle
1696  menu_handler_.teams()[side - 1].toggle_idle();
1697  if(team_num_ == side) {
1698  if(playsingle_controller* psc = dynamic_cast<playsingle_controller*>(&menu_handler_.pc_)) {
1699  psc->set_player_type_changed();
1700  }
1701  }
1702  }
1704 }
1705 
1708 }
1709 
1711 {
1712  save_id_matches(const std::string& save_id) : save_id_(save_id) {}
1713  bool operator()(const team& t)
1714  {
1715  return t.save_id() == save_id_;
1716  }
1718 };
1719 
1721  // :control <side> <nick>
1722  if (!menu_handler_.pc_.is_networked_mp()) return;
1723  const std::string side = get_arg(1);
1724  const std::string player = get_arg(2);
1725  if(player.empty())
1726  {
1728  return;
1729  }
1730  unsigned int side_num;
1731  try {
1732  side_num = lexical_cast<unsigned int>(side);
1733  } catch(bad_lexical_cast&) {
1734  std::vector<team>::const_iterator it_t = boost::find_if(*resources::teams, save_id_matches(side));
1735  if(it_t == resources::teams->end()) {
1736  utils::string_map symbols;
1737  symbols["side"] = side;
1738  command_failed(vgettext("Can't change control of invalid side: '$side'.", symbols));
1739  return;
1740  }
1741  else {
1742  side_num = it_t->side();
1743  }
1744  }
1745  if (side_num < 1 || side_num > menu_handler_.teams().size()) {
1746  utils::string_map symbols;
1747  symbols["side"] = side;
1748  command_failed(vgettext("Can't change control of out-of-bounds side: '$side'.", symbols));
1749  return;
1750  }
1751  menu_handler_.request_control_change(side_num,player);
1753 }
1755 {
1756  const std::string side = get_arg(1);
1757  unsigned int side_num;
1758  try {
1759  side_num = lexical_cast<unsigned int>(side);
1760  } catch(bad_lexical_cast&) {
1761  utils::string_map symbols;
1762  symbols["side"] = side;
1763  command_failed(vgettext("Can't query control of invalid side: '$side'.", symbols));
1764  return;
1765  }
1766  if (side_num < 1 || side_num > menu_handler_.teams().size()) {
1767  utils::string_map symbols;
1768  symbols["side"] = side;
1769  command_failed(vgettext("Can't query control of out-of-bounds side: '$side'.", symbols));
1770  return;
1771  }
1772 
1773  std::string report = menu_handler_.teams()[side_num - 1].controller().to_string();
1774  if (!menu_handler_.teams()[side_num - 1].is_proxy_human()) {
1775  report += " (" + menu_handler_.teams()[side_num - 1].proxy_controller().to_string() + ")";
1776  }
1777  if (menu_handler_.teams()[side_num - 1].is_network()) {
1778  report += " (networked)";
1779  }
1780 
1781  print(get_cmd(), report);
1782 }
1783 
1786 }
1788  int delay = lexical_cast_default<int>(get_data());
1789  menu_handler_.gui_->sunset(delay);
1791 }
1794 }
1795 
1797  const mouse_handler& mousehandler = menu_handler_.pc_.get_mouse_handler_base();
1798  const map_location &loc = mousehandler.get_last_hex();
1799 
1800  std::vector<std::string> layers;
1801  //NOTE: columns reflect WML keys, don't translate them
1802  std::string heading = std::string(1,HEADING_PREFIX) +
1803  "^#" + COLUMN_SEPARATOR + // 0
1804  "Image" + COLUMN_SEPARATOR + // 1
1805  "Name" + COLUMN_SEPARATOR + // 2
1806  "Loc" + COLUMN_SEPARATOR + // 3
1807  "Layer" + COLUMN_SEPARATOR + // 4
1808  "Base.x" + COLUMN_SEPARATOR + // 5
1809  "Base.y" + COLUMN_SEPARATOR + // 6
1810  "Center" // 7
1811 
1812  ;
1813  layers.push_back(heading);
1814 
1815  display& disp = *(menu_handler_.gui_);
1816  terrain_builder& builder = disp.get_builder();
1817  terrain_builder::tile* tile = builder.get_tile(loc);
1818 
1819  const std::string& tod_id = disp.get_time_of_day(loc).id;
1820  terrain_builder::tile::logs tile_logs;
1821  tile->rebuild_cache(tod_id, &tile_logs);
1822 
1823  int order = 1;
1824  for(const terrain_builder::tile::log_details det : tile_logs) {
1825  const terrain_builder::tile::rule_image_rand& ri = *det.first;
1826  const terrain_builder::rule_image_variant& variant = *det.second;
1827 
1828  /** @todo also use random image variations (not just take 1st) */
1829  const image::locator& img = variant.images.front().get_first_frame();
1830  const std::string& name = img.get_filename();
1831  /** @todo deal with (rarely used) ~modifications */
1832  //const std::string& modif = img.get_modifications();
1833  const map_location& loc_cut = img.get_loc();
1834 
1835  std::ostringstream str;
1836 
1837  int tz = game_config::tile_size;
1838  SDL_Rect r = sdl::create_rect(0,0,tz,tz);
1839 
1841 
1842  // calculate which part of the image the terrain engine uses
1843  if(loc_cut.valid()) {
1844  // copied from image.cpp : load_image_sub_file()
1845  r = sdl::create_rect(
1846  ((tz*3) / 4) * loc_cut.x
1847  , tz * loc_cut.y + (tz / 2) * (loc_cut.x % 2)
1848  , tz, tz);
1849 
1850  if(img.get_center_x() >= 0 && img.get_center_y()>= 0){
1851  r.x += surf->w/2 - img.get_center_x();
1852  r.y += surf->h/2 - img.get_center_y();
1853  }
1854  }
1855 
1856  str << (ri->is_background() ? "B ": "F ") << order
1857  << COLUMN_SEPARATOR
1858  << IMAGE_PREFIX << "terrain/foreground.png";
1859 
1860  // cut and mask the image
1861  // ~CROP and ~BLIT have limitations, we do some math to avoid them
1862  SDL_Rect r2 = sdl::intersect_rects(r, sdl::create_rect(0,0,surf->w,surf->h));
1863  if(r2.w > 0 && r2.h > 0) {
1864  str << "~BLIT("
1865  << name << "~CROP("
1866  << r2.x << "," << r2.y << ","
1867  << r2.w << "," << r2.h
1868  << ")"
1869  << "," << r2.x-r.x << "," << r2.y-r.y
1870  << ")"
1871  << "~MASK(" << "terrain/alphamask.png" << ")";
1872  }
1873 
1874  str << COLUMN_SEPARATOR
1875  << IMAGE_PREFIX << name << "~SCALE(72,72)"
1876  << IMG_TEXT_SEPARATOR << name
1877  << COLUMN_SEPARATOR << img.get_loc()
1878  << COLUMN_SEPARATOR << ri->layer
1879  << COLUMN_SEPARATOR << ri->basex
1880  << COLUMN_SEPARATOR << ri->basey
1881  << COLUMN_SEPARATOR
1882  << ri->center_x << ", " << ri->center_y;
1883  layers.push_back(str.str());
1884  ++order;
1885  }
1886 
1887  std::vector<std::string> flags(tile->flags.begin(),tile->flags.end());
1888  std::ostringstream info;
1889  // NOTE using ", " also allows better word wrapping
1890  info << "Flags :" << utils::join(flags, ", ");
1891  {
1892  gui::dialog menu(menu_handler_.gui_->video(), _("Layers"), info.str(), gui::OK_CANCEL);
1893  menu.set_menu(layers);
1894  menu.show();
1895  }
1896 }
1899 }
1902 }
1905 }
1907  do_save();
1908  do_quit();
1909 }
1912 }
1914  game_config::ignore_replay_errors = (get_data() != "off") ? true : false;
1915 }
1917  game_config::disable_autosave = (get_data() != "off") ? true : false;
1918 }
1919 
1921 {
1922  synced_context::run_and_throw("debug_next_level", config_of("next_level", get_data()));
1923 }
1924 
1926  std::vector<std::string> options;
1927  int next = 0, nb = 0;
1928  for(const config &sc : menu_handler_.game_config_.child_range("scenario"))
1929  {
1930  const std::string &id = sc["id"];
1931  options.push_back(id);
1932  if (id == menu_handler_.gamedata().next_scenario())
1933  next = nb;
1934  ++nb;
1935  }
1936  // find scenarios of multiplayer campaigns
1937  // (assumes that scenarios are ordered properly in the game_config)
1939  for(const config &mp : menu_handler_.game_config_.child_range("multiplayer"))
1940  {
1941  if (mp["id"] == scenario)
1942  {
1943  const std::string &id = mp["id"];
1944  options.push_back(id);
1945  if (id == menu_handler_.gamedata().next_scenario())
1946  next = nb;
1947  ++nb;
1948  scenario = mp["next_scenario"].str();
1949  }
1950  }
1951  std::sort(options.begin(), options.end());
1952  int choice = 0;
1953  {
1954  gui2::tsimple_item_selector dlg(_("Choose Scenario (Debug!)"), "", options);
1955  dlg.set_selected_index(next);
1956  dlg.show(menu_handler_.gui_->video());
1957  choice = dlg.selected_index();
1958  }
1959 
1960  if(choice == -1)
1961  return;
1962 
1963  if (size_t(choice) < options.size()) {
1964  synced_context::run_and_throw("debug_next_level", config_of("next_level", options[choice]));
1965  }
1966 }
1967 
1969 {
1971 
1972  int turn = tod_man.turn() + 1;
1973  const std::string& data = get_data();
1974  if (!data.empty()) {
1975  turn = lexical_cast_default<int>(data, 1);
1976  }
1977  synced_context::run_and_throw("debug_turn", config_of("turn", turn));
1978 }
1979 
1981 {
1982  int limit = get_data().empty() ? -1 : lexical_cast_default<int>(get_data(), 1);
1983  synced_context::run_and_throw("debug_turn_limit", config_of("turn_limit", limit));
1984 }
1985 
1988  print(get_cmd(), _("Debug mode activated!"));
1989  game_config::debug = true;
1990  } else {
1991  command_failed(_("Debug mode not available in network games"));
1992  }
1993 }
1995  if (game_config::debug) {
1996  print(get_cmd(), _("Debug mode deactivated!"));
1997  game_config::debug = false;
1998  }
1999 }
2002  return ;
2003  }
2004  synced_context::run_and_throw("debug_lua", config_of("code", get_data()));
2005 }
2006 
2008 {
2010  return ;
2011  }
2012  if (gui2::show_message(menu_handler_.gui_->video(), _("Unsafe Lua scripts."),
2013  _("You are about to open a security breach in Wesnoth. Are you sure you want to continue? If you have downloaded add-ons, do not click 'ok'! They would instantly take over your computer. You have been warned."),
2015  {
2016  print(get_cmd(), _("Unsafe mode enabled!"));
2017  menu_handler_.gamestate().lua_kernel_->load_package();
2018  }
2019 }
2020 
2023 }
2025  const std::string data = get_data();
2026  const std::string::const_iterator j = std::find(data.begin(),data.end(),'=');
2027  const std::string alias(data.begin(),j);
2028  if(j != data.end()) {
2029  const std::string command(j+1,data.end());
2030  if (!command.empty()) {
2031  register_alias(command, alias);
2032  } else {
2033  // "alias something=" deactivate this alias. We just set it
2034  // equal to itself here. Later preferences will filter empty alias.
2035  register_alias(alias, alias);
2036  }
2037  preferences::add_alias(alias, command);
2038  // directly save it for the moment, but will slow commands sequence
2040  } else {
2041  // "alias something" display its value
2042  // if no alias, will be "'something' = 'something'"
2043  const std::string command = chmap::get_actual_cmd(alias);
2044  print(get_cmd(), "'"+alias+"'" + " = " + "'"+command+"'");
2045  }
2046 }
2048  const std::string data = get_data();
2049  if (data.empty()) {
2051  return;
2052  }
2053  const std::string::const_iterator j = std::find(data.begin(),data.end(),'=');
2054  if(j != data.end()) {
2055  const std::string name(data.begin(),j);
2056  const std::string value(j+1,data.end());
2057  synced_context::run_and_throw("debug_set_var", config_of("name", name)("value", value));
2058  }
2059  else {
2060  command_failed(_("Variable not found"));
2061  }
2062 }
2065 }
2066 
2067 
2070  gui2::tgamestate_inspector inspect_dialog(cfg);
2071  inspect_dialog.show(menu_handler_.gui_->video());
2072 }
2073 
2075 {
2076  gui2::tmp_change_control mp_change_control(&menu_handler_);
2077  mp_change_control.show(menu_handler_.gui_->video());
2078 }
2079 
2081  // prevent SIGSEGV due to attempt to set HP during a fight
2082  if (events::commands_disabled > 0)
2083  return;
2085  if (i == menu_handler_.units().end()) return;
2086  const map_location loc = i->get_location();
2087  const std::string data = get_data(1);
2088  std::vector<std::string> parameters = utils::split(data, '=', utils::STRIP_SPACES);
2089  if (parameters.size() < 2) {
2090  return;
2091  }
2092 
2093  if (parameters[0] == "alignment") {
2094  unit_type::ALIGNMENT alignment;
2095  if (!alignment.parse(parameters[1]))
2096  {
2097  utils::string_map symbols;
2098  symbols["alignment"] = get_arg(1);
2099  command_failed(VGETTEXT("Invalid alignment: '$alignment', needs to be one of lawful, neutral, chaotic, or liminal.", symbols));
2100  return;
2101  }
2102  }
2103 
2104  synced_context::run_and_throw("debug_unit", config_of("x", loc.x + 1)("y", loc.y + 1)("name", parameters[0])("value", parameters[1]));
2105 }
2106 
2108  for(const unit_type_data::unit_type_map::value_type &i : unit_types.types()) {
2109  preferences::encountered_units().insert(i.second.id());
2110  }
2111 }
2112 
2114  const int res = gui2::show_message((*menu_handler_.gui_).video(), "Undiscover", _("Do you wish to clear all of your discovered units from help?"), gui2::tmessage::yes_no_buttons);
2115  if(res != gui2::twindow::CANCEL) {
2117  }
2118 }
2119 /**
2120  * Implements the (debug mode) console command that creates a unit.
2121  */
2123  const mouse_handler& mousehandler = menu_handler_.pc_.get_mouse_handler_base();
2124  const map_location &loc = mousehandler.get_last_hex();
2125  if (menu_handler_.map().on_board(loc)) {
2126  const unit_type *ut = unit_types.find(get_data());
2127  if (!ut) {
2128  command_failed(_("Invalid unit type"));
2129  return;
2130  }
2131 
2132  // Create the unit.
2133  create_and_place(*menu_handler_.gui_, menu_handler_.map(),
2134  menu_handler_.units(), loc, *ut);
2135  } else {
2136  command_failed(_("Invalid location"));
2137  }
2138 }
2140  synced_context::run_and_throw("debug_fog", config());
2141 }
2143  synced_context::run_and_throw("debug_shroud", config());
2144 }
2146  synced_context::run_and_throw("debug_gold", config_of("gold", lexical_cast_default<int>(get_data(),1000)));
2147 }
2149  synced_context::run_and_throw("debug_event", config_of("eventname", get_data()));
2150 }
2154 }
2158 }
2159 
2162  whiteb->set_active(!whiteb->is_active());
2163  if (whiteb->is_active()) {
2164  print(get_cmd(), _("Planning mode activated!"));
2165  whiteb->print_help_once();
2166  } else {
2167  print(get_cmd(), _("Planning mode deactivated!"));
2168  }
2169  }
2170 }
2171 
2173 {
2175  menu_handler_.pc_.get_whiteboard()->options_dlg();
2176  }
2177 }
2178 
2180  int side_num, mouse_handler& /*mousehandler*/)
2181 {
2182  try {
2183  add_chat_message(time(nullptr), _("wfl"), 0, ai::manager::evaluate_command(side_num, str));
2184  } catch(game_logic::formula_error&) {
2185  } catch(...) {
2186  add_chat_message(time(nullptr), _("wfl"), 0, "UNKNOWN ERROR IN FORMULA");
2187  }
2188 }
2189 
2191 {
2192  textbox_info_.show(gui::TEXTBOX_COMMAND, translation::sgettext("prompt^Command:"), "", false, *gui_);
2193 }
2194 
2195 void menu_handler::request_control_change ( int side_num, const std::string& player )
2196 {
2197  std::string side = std::to_string(side_num);
2198  if (teams()[side_num - 1].is_local_human() && player == preferences::login()) {
2199  //this is already our side.
2200  return;
2201  } else {
2202  //The server will (or won't because we aren't allowed to change the controller)
2203  //send us a [change_controller] back, which we then handle in playturn.cpp
2205  ("change_controller", config_of
2206  ("side", side)
2207  ("player", player)
2208  )
2209  );
2210 
2211  }
2212 }
2213 
2215 {
2216  std::vector<std::string> commands = utils::split(preferences::custom_command(), ';');
2217  std::vector<std::string>::iterator c = commands.begin();
2218  for (; c != commands.end() ; ++c) {
2219  do_command(*c);
2220  }
2221 }
2222 
2224 {
2225  if (!pc_.is_networked_mp()) {
2226  textbox_info_.show(gui::TEXTBOX_AI, translation::sgettext("prompt^Command:"), "", false, *gui_);
2227  }
2228 }
2229 
2231 {
2232  gui_->get_chat_manager().clear_chat_messages(); // also clear debug-messages and WML-error-messages
2233 }
2234 
2236 {
2237  pc_.send_to_wesnothd(cfg);
2238 }
2239 
2240 } // end namespace events
void command_failed(const std::string &message, bool=false)
void label_terrain(mouse_handler &mousehandler, bool team_only)
basic_sorter & set_alpha_sort(int column)
Definition: menu.cpp:48
std::pair< const rule_image_rand *, const rule_image_variant * > log_details
Definition: builder.hpp:296
static void sunset(const size_t delay=0)
Debug function to toggle the "sunset" mode.
Definition: display.cpp:1395
bool is_enabled(const chmap::command &c) const
bool uses_shroud() const
Definition: team.hpp:315
int layer
The layer of the image for horizontal layering.
Definition: builder.hpp:221
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
Definition: image.cpp:878
menu_handler & menu_handler_
child_itors child_range(const std::string &key)
Definition: config.cpp:613
virtual void highlight_hex(map_location hex)
Function to highlight a location.
int show_file_chooser_dialog_save(CVideo &video, std::string &filename, std::string const &title, const std::string &default_file_name, bool show_directory_buttons, const std::string &type_a_head, int xloc, int yloc)
Show a filechooser dialog in a "save" mode, that is, without relying on autocomplete to allow saving ...
Definition: filechooser.cpp:44
SDL_Rect intersect_rects(SDL_Rect const &rect1, SDL_Rect const &rect2)
Calculates the intersection of two rectangles.
Definition: rect.cpp:58
void do_search(const std::string &new_search)
void set_current_paths(const pathfind::paths &new_paths)
events::mouse_handler & get_mouse_handler_base()
Get a reference to a mouse handler member a derived class uses.
Game board class.
Definition: game_board.hpp:55
const std::string & id() const
Definition: unit.hpp:148
game_data & gamedata()
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
Definition: display.hpp:353
void set_grid(bool ison)
char const IMG_TEXT_SEPARATOR
virtual void send_to_wesnothd(const config &, const std::string &="unknown") const
void show_help(CVideo &video, const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
Definition: help.cpp:117
void goto_leader(int side_num)
std::string mp_scenario
unit_iterator end()
Definition: map.hpp:311
static bool execute(std::string &label, bool &team_only, CVideo &video)
The execute function see tdialog for more information.
Definition: edit_label.hpp:44
std::string const & gender_string(unit_race::GENDER gender)
Definition: race.cpp:151
tile * get_tile(const map_location &loc)
Definition: builder.cpp:1204
bool show_fps()
GLuint GLdouble GLdouble GLint GLint order
Definition: glew.h:2972
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
Definition: display.hpp:299
static std::string get_side_highlight(int side)
Definition: team.cpp:853
void write_preferences()
void set_draw_terrain_codes(bool value)
Setter for the terrain code debug overlay on tiles.
Definition: display.hpp:371
int get_retval() const
Definition: dialog.hpp:161
size_t move_unit_and_record(const std::vector< map_location > &steps, undo_list *undo_stack, bool continued_move, bool show_move, bool *interrupted, move_unit_spectator *move_spectator)
Moves a unit across the board.
Definition: move.cpp:1225
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
Definition: display.cpp:3536
map_location last_search_hit_
Definition: unit.hpp:95
const gamemap & map()
int recall_dialog(display &disp, const boost::shared_ptr< std::vector< unit_const_ptr > > &units, int side, const std::string &title_suffix, const int team_recall_cost)
Definition: dialogs.cpp:466
bool get_draw_terrain_codes() const
Getter for the terrain code debug overlay on tiles.
Definition: display.hpp:369
const t_string & name() const
The unit name for display.
Definition: unit.hpp:158
const util::scoped_ptr< gui::button > & check() const
static void toggle_benchmark()
Toggle to continuously redraw the screen.
Definition: display.cpp:1401
Various functions implementing vision (through fog of war and shroud).
const mp_game_settings & get_mp_settings()
const char * what() const
Definition: exceptions.hpp:35
bool get_village(const map_location &loc, int side, bool *action_timebonus, bool fire_event)
Makes it so the village at the given location is owned by the given side.
Definition: move.cpp:140
void speak(const config &cfg)
Definition: replay.cpp:342
const GLfloat * c
Definition: glew.h:12741
menu_handler(game_display *gui, play_controller &pc, const config &game_config)
Definition: menu_events.cpp:94
Various functions that implement attacks and attack calculations.
bool team_valid() const
Definition: display.hpp:99
map_command_handler< console_handler > chmap
std::string current_team_name() const
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
Definition: util.hpp:489
unit_iterator find_leader(int side)
Definition: map.cpp:297
static config get_recall(const std::string &unit_id, const map_location &loc, const map_location &from)
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1221
int get_center_y() const
Definition: image.hpp:89
bool show(CVideo &video, const unsigned auto_close_time=0)
Shows the window.
Definition: dialog.cpp:34
SDL_Color int_to_color(const Uint32 rgb)
Definition: utils.cpp:63
logger & info()
Definition: log.cpp:91
pathfind::marked_route get_route(const unit *un, map_location go_to, team &team) const
static int report(lua_State *L, int status)
Definition: lua.cpp:134
virtual void enable(bool new_val=true)
Definition: button.cpp:386
std::string private_message
void add_chat_message(const time_t &time, const std::string &speaker, int side, const std::string &message, events::chat_handler::MESSAGE_TYPE type=events::chat_handler::MESSAGE_PRIVATE)
bool is_enemy(int n) const
Definition: team.hpp:247
This file contains the window object, this object is a top level container which has the event manage...
std::string id
Definition: time_of_day.hpp:77
Enables auto close.
Definition: message.hpp:65
void do_command(const std::string &str)
Represent a rule_image applied with a random seed.
Definition: builder.hpp:314
attribute_map::value_type attribute
Definition: config.hpp:393
void redraw_everything()
Invalidates entire screen, including all tiles and sidebar.
Definition: display.cpp:2650
const t_string & objectives() const
Definition: team.hpp:244
gui::floating_textbox & get_textbox()
General purpose widgets.
void request_control_change(int side_num, const std::string &player)
void invalidate_unit()
Function to invalidate that unit status displayed on the sidebar.
static void set_sunset(const unsigned interval)
Definition: window.hpp:439
The class terrain_builder is constructed from a config object, and a gamemap object.
Definition: builder.hpp:43
std::string get_title_suffix(int side_num)
std::string get_flags_description() const
unit_iterator begin()
Definition: map.hpp:308
basic_sorter & set_redirect_sort(int column, int to)
Definition: menu.cpp:79
static config get_auto_shroud(bool turned_on)
Records that the player has toggled automatic shroud updates.
unit_type_data unit_types
Definition: types.cpp:1314
void print(const std::string &title, const std::string &message)
bool fire(const std::string &event, const entity_location &loc1=entity_location::null_entity, const entity_location &loc2=entity_location::null_entity, const config &data=config())
Function to fire an event.
Definition: pump.cpp:471
int basex
The position of the image base (that is, the point where the image reaches the floor) for vertical la...
Definition: builder.hpp:225
void update_shroud_now(int side_num)
int village_owner(const map_location &loc) const
Given the location of a village, will return the 0-based index of the team that currently owns it...
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.
Replay control code.
void check_victory()
Checks to see if a side has won.
virtual bool is_enabled(const command &) const
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1220
const std::string & choice() const
Unit type choice from the user.
Definition: unit_create.hpp:39
virtual void assert_existence(const std::string &cmd)
const std::vector< std::string > items
void show_unit_description(CVideo &video, const unit &u)
Definition: help.cpp:59
virtual void draw()
Draws invalidated items.
Definition: display.cpp:2706
const map_location & get_last_hex() const
int show(int xloc, int yloc)
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
virtual std::string get_arg(unsigned i) const
terrain_builder & get_builder()
Definition: display.hpp:484
GLsizeiptr const GLvoid GLenum usage
Definition: glew.h:1649
bool is_background() const
Definition: builder.hpp:216
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
Definition: glew.h:1347
bool show_theme_dialog(CVideo &video)
To lexical_cast(From value)
Lexical cast converts one type to another.
void create_unit(mouse_handler &mousehandler)
Creates a unit (in debug mode via hotkey or context menu).
bool unit_can_move(const unit &u) const
Will return true iff the unit u has any possible moves it can do (including attacking etc)...
GLdouble GLdouble t
Definition: glew.h:1366
void redraw_minimap()
Schedule the minimap to be redrawn.
Definition: display.hpp:629
save_id_matches(const std::string &save_id)
bool ellipses()
static synced_state get_synced_state()
map_location get_selected_hex() const
std::vector< unit_const_ptr > get_recalls(int side, const map_location &recall_loc)
Gets the recallable units for a side, restricted by that side's leaders' personal abilities to recall...
Definition: create.cpp:163
std::vector< std::string > get_commands_list() const
static config get_update_shroud()
Records that the player has manually updated fog/shroud.
void show_statistics(int side_num)
const std::string & last_recruit() const
Definition: team.hpp:233
const map_location & get_loc() const
Definition: image.hpp:87
char const IMAGE_PREFIX
void rebuild_cache(const std::string &tod, logs *log=nullptr)
Rebuilds the whole image cache, for a given time-of-day.
Definition: builder.cpp:110
void flush_cache()
Definition: image.cpp:191
const terrain_label * set_label(const map_location &loc, const t_string &text, const int creator=-1, const std::string &team="", const SDL_Color color=font::NORMAL_COLOR, const bool visible_in_fog=true, const bool visible_in_shroud=false, const bool immutable=false, const std::string &category="", const t_string &tooltip="")
Definition: label.cpp:145
Represents a tile of the game map, with all associated builder-specific parameters: flags...
Definition: builder.hpp:291
boost::scoped_ptr< game_lua_kernel > lua_kernel_
Definition: game_state.hpp:53
void do_consolesave(const std::string &filename)
This module controls the multiplayer lobby.
STRIP_SPACES : strips leading and trailing blank spaces.
unit_map units_
Definition: game_board.hpp:63
game_events::t_pump & pump()
const config & options()
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:50
bool end_turn(int side_num)
game_display * gui_
std::string half_signed_value(int val)
Sign with Unicode "−" if negative.
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:82
console_handler(menu_handler &menu_handler)
virtual void register_alias(const std::string &to_cmd, const std::string &cmd)
void toggle_shroud_updates(int side_num)
void set_custom_command(const std::string &command)
int recall_cost() const
Definition: team.hpp:198
static bool execute(const std::string &title, const std::string &label, std::string &text, CVideo &video)
Executes the dialog.
Definition: edit_text.hpp:51
GLsizei const char ** path
Definition: glew.h:4654
void throw_quit_game_exception()
bool chars_equal_insensitive(char a, char b)
Definition: util.hpp:206
const t_string & text() const
Definition: label.cpp:419
GLuint GLuint end
Definition: glew.h:1221
const char BAD_TEXT
GLuint64EXT * result
Definition: glew.h:10727
Dialog is closed with ok button.
Definition: window.hpp:125
void scroll_to_leader(int side, SCROLL_TYPE scroll_type=ONSCREEN, bool force=true)
Scrolls to the leader of a certain side.
std::map< std::string, t_string > string_map
bool auto_shroud_updates() const
Definition: team.hpp:335
virtual void register_alias(const std::string &to_cmd, const std::string &cmd)
virtual void assert_existence(const std::string &cmd)
std::vector< team > * teams
Definition: resources.cpp:29
This file contains the settings handling of the widget library.
game_board & board() const
std::vector< team > teams_
Definition: game_board.hpp:58
const unit_type_map & types() const
Definition: types.hpp:313
virtual config::attribute_value get_variable_const(const std::string &varname) const
returns a blank attribute value if varname is no valid variable name.
Definition: game_data.cpp:75
bool valid() const
Definition: location.hpp:69
const std::set< std::string > get_recruits(int side, const map_location &recruit_loc)
Gets the recruitable units from a side's leaders' personal recruit lists who can recruit on or from a...
Definition: create.cpp:63
GLint limit
Definition: glew.h:10112
void do_create()
Implements the (debug mode) console command that creates a unit.
Applies the planned unit map for the duration of the struct's life.
Definition: manager.hpp:249
std::string get_user_data_dir()
void clear(const std::string &, bool force)
Definition: label.cpp:217
bool disable_autosave
Definition: game_config.cpp:64
Dialog is closed with the cancel button.
Definition: window.hpp:126
void write_file(const std::string &fname, const std::string &data)
Throws io_exception if an error occurs.
static void ignore_error_function(const std::string &message, bool heavy)
a function to be passed to run_in_synced_context to ignore the error.
bool operator()(const team &t)
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1858
void show_preferences_dialog(CVideo &video, const config &game_cfg, const DIALOG_OPEN_TO initial_view)
t_string get_scenario_name()
GLsizei const GLfloat * value
Definition: glew.h:1817
bool get_draw_coordinates() const
Getter for the x,y debug overlay on tiles.
Definition: display.hpp:364
bool ignore_replay_errors
Definition: game_config.cpp:63
void set_menu(menu *const m)
void set_draw_coordinates(bool value)
Setter for the x,y debug overlay on tiles.
Definition: display.hpp:366
int w() const
Effective map width.
Definition: map.hpp:105
void recall(int side_num, const map_location &last_hex)
void status_table(int selected=0)
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
std::string selected
Definition: game_config.cpp:84
const config & game_config_
GLuint start
Definition: glew.h:1221
bool empty() const
Is it empty?
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:7319
void end_unit_turn(mouse_handler &mousehandler, int side_num)
void set_show_fps(bool value)
Encapsulates the map of the game.
Definition: map.hpp:37
void show_unit_list(display &gui)
Definition: dialogs.cpp:294
const std::vector< unit_race::GENDER > & genders() const
The returned vector will not be empty, provided this has been built to the HELP_INDEXED status...
Definition: types.hpp:198
Shows an ok and cancel button.
Definition: message.hpp:71
void recalculate_fog(int side)
Function that recalculates the fog of war.
Definition: vision.cpp:705
void recruit(int side_num, const map_location &last_hex)
std::vector< team > & teams() const
int selected_index() const
Returns the selected item index after displaying.
void do_speak(const std::string &message, bool allies_only=false)
tod_manager tod_manager_
Definition: game_state.hpp:50
Object which temporarily resets a unit's movement.
Definition: unit.hpp:561
void add_rename(const std::string &name, const map_location &loc)
Definition: replay.cpp:287
void highlight_another_reach(const pathfind::paths &paths_list)
Add more paths to highlight.
const std::string & team_name() const
Definition: label.cpp:125
Managing the AIs lifecycle - headers.
virtual std::string get_cmd() const
replay * recorder
Definition: resources.cpp:30
void create_buttons()
Definition: display.cpp:897
Structure which holds a single route and marks for special events.
Definition: pathfind.hpp:141
virtual const time_of_day & get_time_of_day(const map_location &loc=map_location::null_location()) const
Definition: display.cpp:430
void reset_objectives_changed() const
Definition: team.hpp:242
std::string get_command_flags_description(const map_command_handler< chat_command_handler >::command &c) const
game_state & gamestate() const
static const map_location & null_location()
Definition: location.hpp:195
void invalidate_all()
Function to invalidate all tiles.
Definition: display.cpp:3525
int viewing_side() const
Definition: display.hpp:103
std::string get_dir(const std::string &dir)
void set_message_private(bool value)
std::vector< log_details > logs
Definition: builder.hpp:298
bool no_choice() const
Whether the user actually chose a unit type or not.
Definition: unit_create.hpp:45
surf
Definition: filter.cpp:143
std::vector< animated< image::locator > > images
An animated image locator built according to the image string.
Definition: builder.hpp:195
GLuint GLuint GLsizei count
Definition: glew.h:1221
cl_event GLbitfield flags
Definition: glew.h:3070
GLuint color
Definition: glew.h:5801
void show_terrain_description(CVideo &video, const terrain_type &t)
Definition: help.cpp:64
const terrain_label * get_label(const map_location &loc, const std::string &team_name) const
Definition: label.cpp:97
const std::string & save_id() const
Definition: team.hpp:236
bool do_recruit(const std::string &name, int side_num, const map_location &last_hex)
std::string join(T const &v, const std::string &s=",")
Generates a new string joining container items in a list.
int cost() const
Definition: types.hpp:134
Encapsulates the map of the game.
Definition: location.hpp:38
const terrain_type & get_terrain_info(const t_translation::t_terrain &terrain) const
Definition: map.cpp:100
Various functions related to moving units.
const std::string & get_filename() const
Definition: image.hpp:86
std::string login()
void unit_die(const map_location &loc, unit &loser, const attack_type *attack, const attack_type *secondary_attack, const map_location &winner_loc, unit *winner)
Show a unit fading out.
Definition: udisplay.cpp:548
static bool execute(display_context &dc, CVideo &video)
The execute function.
Various functions related to the creation of units (recruits, recalls, and placed units)...
actions::undo_list & get_undo_stack()
void recalculate_labels()
Definition: label.cpp:255
GLuint res
Definition: glew.h:9258
const char NULL_MARKUP
static const std::string evaluate_command(side_number side, const std::string &str)
Evaluates a string command using command AI.
Definition: manager.cpp:483
void continue_move(mouse_handler &mousehandler, int side_num)
void add_alias(const std::string &alias, const std::string &command)
logger & err()
Definition: log.cpp:79
int h() const
Effective map height.
Definition: map.hpp:108
void scroll_to_tile(const map_location &loc, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, bool force=true)
Scroll such that location loc is on-screen.
Definition: display.cpp:2434
void unhighlight_reach()
Reset highlighting of paths.
const std::string space
whitespace is possible
void execute_gotos(mouse_handler &mousehandler, int side_num)
std::string last_search_
void set_selected_index(int index)
Sets the initially selected item index (-1 by default).
Game configuration data as global variables.
Definition: build_info.cpp:38
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
Definition: display.hpp:349
#define VGETTEXT(msgid, symbols)
An exception object used when an IO error occurs.
Definition: filesystem.hpp:40
const std::string & next_scenario() const
Definition: game_data.hpp:89
const SDL_Color LABEL_COLOR
Definition: font.cpp:574
std::set< std::string > flags
The list of flags present in this tile.
Definition: builder.hpp:311
int turn() const
void terrain_description(mouse_handler &mousehandler)
Define the game's event mechanism.
const std::string & parameters
Definition: filter.cpp:155
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:5910
const util::scoped_ptr< gui::textbox > & box() const
std::string find_recall_location(const int side, map_location &recall_location, map_location &recall_from, const unit &unit_recall)
Finds a location on which to recall unit_recall.
Definition: create.cpp:328
size_t i
Definition: function.cpp:1057
ONLY IF whiteboard is currently active, applies the planned unit map for the duration of the struct's...
Definition: manager.hpp:269
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:112
GLint GLint GLint GLint GLint x
Definition: glew.h:1220
void unit_hold_position(mouse_handler &mousehandler, int side_num)
virtual std::string get_arg(unsigned argn) const
bool fogged(const map_location &loc) const
Definition: team.cpp:575
void change_side(mouse_handler &mousehandler)
virtual std::string get_data(unsigned n=1) const
game_data gamedata_
Definition: game_state.hpp:48
std::set< std::string > & encountered_units()
GLdouble GLdouble GLdouble r
Definition: glew.h:1374
#define N_(String)
Definition: gettext.hpp:90
Definitions for the terrain builder.
int center_x
The position where the center of the image base should be.
Definition: builder.hpp:237
void show(gui::TEXTBOX_MODE mode, const std::string &label, const std::string &check_label, bool checked, game_display &gui)
static int sort(lua_State *L)
Definition: ltablib.cpp:246
void set_ellipses(bool ison)
DIALOG_RESULT
Definition: show_dialog.hpp:33
void objectives(int side_num)
void cycle_units(const bool browse, const bool reverse=false)
void kill_unit(mouse_handler &mousehandler)
basic_sorter & set_numeric_sort(int column)
Definition: menu.cpp:54
void scenario_settings_table(int selected=0)
const command * get_command(const std::string &cmd) const
std::string vgettext(const char *msgid, const utils::string_map &symbols)
Handling of system events.
Definition: manager.hpp:42
GLuint const GLchar * name
Definition: glew.h:1782
virtual const gamemap & map() const
Definition: game_board.hpp:98
size_t erase(const map_location &l)
Erases the unit at location l, if any.
Definition: map.cpp:277
const game_classification & get_classification()
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
bool on_board(const map_location &loc) const
Tell if a location is on the map.
Definition: map.cpp:467
bool knows_about_team(size_t index) const
Definition: team.cpp:615
#define next(ls)
Definition: llex.cpp:27
GLsizeiptr size
Definition: glew.h:1649
display_chat_manager & get_chat_manager()
static bool run_and_throw(const std::string &commandname, const config &data, bool use_undo=true, bool show=true, synced_command::error_handler_function error_handler=default_error_function)
bool has_friends() const
int gold() const
Definition: team.hpp:194
To store label data Class implements logic for rendering.
Definition: label.hpp:103
char const HEADING_PREFIX
GLclampd n
Definition: glew.h:5903
boost::shared_ptr< wb::manager > get_whiteboard()
char const COLUMN_SEPARATOR
unit_map::iterator current_unit()
game_state & gamestate()
const std::string & side_name() const
Definition: team.hpp:307
bool find(E event, F functor)
Tests whether an event handler is available.
bool player_acted() const
Returns true if the player has performed any actions this turn.
Definition: undo.hpp:82
bool uses_fog() const
Definition: team.hpp:316
void show_enemy_moves(bool ignore_units, int side_num)
const std::set< std::string > & observers() const
int get_center_x() const
Definition: image.hpp:88
static UNUSEDNOWARN std::string sgettext(const char *str)
Definition: gettext.hpp:66
game_board board_
Definition: game_state.hpp:49
#define DBG_WB
Definition: typedefs.hpp:29
GLint GLvoid * img
Definition: glew.h:1353
A variable-expanding proxy for the config class.
Definition: variable.hpp:36
Various functions that implement the undoing (and redoing) of in-game commands.
std::string find_recruit_location(const int side, map_location &recruit_location, map_location &recruited_from, const std::string &unit_type)
Finds a location on which to place a unit.
Definition: create.cpp:464
void set_action_bonus_count(const int count)
Definition: team.hpp:219
Standard logging facilities (interface).
game_display & get_display()
Get a reference to a display member a derived class uses.
CVideo & video()
Gets the underlying screen object.
Definition: display.hpp:202
Object which contains all the possible locations a unit can move to, with associated best routes to t...
Definition: pathfind.hpp:71
recall_list_manager & recall_list()
Definition: team.hpp:220
bool is_observer() const
Check if we are an observer in this game.
Container associating units to locations.
Definition: map.hpp:90
GLsizei GLenum GLuint GLuint GLsizei char * message
Definition: glew.h:2499
#define c
Definition: glew.h:12743
static std::string get_side_color_index(int side)
Definition: team.cpp:840
static vconfig empty_vconfig()
Definition: variable.cpp:97
int get_selected_index() const
const unit_type * find(const std::string &key, unit_type::BUILD_STATUS status=unit_type::FULL) const
Finds a unit_type by its id() and makes sure it is built to the specified level.
Definition: types.cpp:1155
static config get_recruit(const std::string &type_id, const map_location &loc, const map_location &from)
std::string vngettext(const char *sing, const char *plur, int n, const utils::string_map &symbols)
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
map_labels & labels()
Definition: display.cpp:2773
virtual std::string get_data(unsigned argn=1) const
#define e
Definition: help.cpp:57
unit_iterator find(size_t id)
Definition: map.cpp:285
size_t viewing_team() const
The viewing team is the team currently viewing the game.
Definition: display.hpp:102
static Uint32 get_side_rgb(int side)
Definition: team.hpp:367
virtual bool is_networked_mp() const
bool valid() const
Definition: map.hpp:229
std::string signed_value(int val)
Convert into a signed value (using the Unicode "−" and +0 convention.
const std::string & str() const
Definition: tstring.hpp:170
virtual void register_command(const std::string &cmd, command_handler h, const std::string &help="", const std::string &usage="", const std::string &flags="")
gui::floating_textbox textbox_info_
std::string get_command_flags_description(const chmap::command &c) const
void send_to_server(const config &cfg) override
std::string::const_iterator iterator
Definition: tokenizer.hpp:21
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
void add_chat_message(const time_t &time, const std::string &speaker, int side, const std::string &msg, events::chat_handler::MESSAGE_TYPE type, bool bell)
void notify_event(const std::string &name, const config &data)
Definition: manager.cpp:147
const config & get_alias()
int action_bonus_count() const
Definition: team.hpp:218
void set_route(const pathfind::marked_route *route)
Sets the route along which footsteps are drawn to show movement of a unit.
std::string custom_command()
unit_race::GENDER gender()
Gender choice from the user.
Definition: unit_create.hpp:51
std::vector< std::string > get_commands_list()
const std::vector< map_location > & villages() const
Return a list of the locations of villages on the map.
Definition: map.hpp:163
void send_chat_message(const std::string &message, bool allies_only=false)
void repeat_recruit(int side_num, const map_location &last_hex)
void move_unit_to_loc(const unit_map::iterator &ui, const map_location &target, bool continue_move, int side_num, mouse_handler &mousehandler)
bool file_exists(const std::string &name)
Returns true if a file or directory with such name already exists.
void write(std::ostream &out, configr_of const &cfg, unsigned int level)
Definition: parser.cpp:621
Thrown when a lexical_cast fails.
void close(game_display &gui)
void clear_labels(const std::string &, bool)
Definition: replay.cpp:277
static void toggle_debug_foreground()
Toggle to debug foreground terrain.
Definition: display.cpp:1406
GLsizei const GLcharARB ** string
Definition: glew.h:4503
const unsigned int team_num_
unit_map * units
Definition: resources.cpp:35
Shows a yes and no button.
Definition: message.hpp:75
unit_map::iterator find_visible_unit(const map_location &loc, const team &current_team, bool see_all=false)
Definition: game_board.cpp:173
Display units performing various actions: moving, attacking, and dying.
virtual void register_command(const std::string &cmd, chat_command_handler::command_handler h, const std::string &help="", const std::string &usage="", const std::string &flags="")
team_data calculate_team_data(const class team &tm, int side) const
play_controller & pc_
void show_objectives(const std::string &scenarioname, const std::string &objectives)
Definition: dialogs.cpp:425
std::vector< map_location > & steps
Definition: pathfind.hpp:187
const std::string & id() const
The id for this unit_type.
Definition: types.hpp:115
GLenum target
Definition: glew.h:5190
static plugins_manager * get()
Definition: manager.cpp:61
std::string teamname
void add_label(const terrain_label *)
Definition: replay.cpp:266
const std::string observer_team_name
observer team name used for observer team chat
std::string get_actual_cmd(const std::string &cmd) const
void do_ai_formula(const std::string &str, int side_num, mouse_handler &mousehandler)