91 #define ERR_NG LOG_STREAM(err, log_engine)
92 #define LOG_NG LOG_STREAM(info, log_engine)
142 gui2::dialogs::statistics_dialog::display(
pc_.
statistics(),
board().get_team(side_num));
161 const std::string& input_name
180 symbols[
"msg"] =
e.what();
181 const std::string
msg =
VGETTEXT(
"Could not save the map: $msg", symbols);
188 gui2::dialogs::preferences_dialog::display();
196 c[
"name"] =
"prototype of chat log";
210 ?
board().is_observer()
211 ?
_(
"Send to observers only")
212 :
_(
"Send to allies only")
230 if(
board().is_observer()) {
246 std::map<const unit_type*, t_string> sample_units;
250 std::vector<t_string> unknown_units;
251 for(
const auto&
recruit : recruits) {
255 unknown_units.emplace_back(
recruit);
263 if(!unknown_units.empty()) {
268 const auto message =
VNGETTEXT(
"Error: there’s an unknown unit type on your recruit list: $unknown_ids",
269 "Error: there are several unknown unit types on your recruit list: $unknown_ids",
270 unknown_units.size(),
275 if(sample_units.empty()) {
289 do_recruit(
type->id(), side_num, recruit_hex);
293 void menu_handler::repeat_recruit(
int side_num,
const map_location& last_hex)
295 const std::string& last_recruit = board().get_team(side_num).last_recruit();
296 if(last_recruit.empty() ==
false) {
298 do_recruit(last_recruit, side_num, recruit_hex);
307 team& current_team = board().get_team(side_num);
310 if(u_type ==
nullptr) {
311 return _(
"Internal error. Please report this as a bug! Details:\n")
312 +
"menu_handler::can_recruit: u_type == nullptr for " + name;
317 return VGETTEXT(
"You cannot recruit a $unit_type_name at this time.",
325 wb_gold = (pc_.get_whiteboard() ? pc_.get_whiteboard()->get_spent_gold_for(side_num) : 0);
327 if(u_type->
cost() > current_team.
gold() - wb_gold)
331 return _(
"At this point in your plan, you will not have enough gold to recruit this unit.");
333 return _(
"You do not have enough gold to recruit this unit.");
350 bool menu_handler::do_recruit(
const std::string& name,
int side_num,
map_location& loc)
353 const std::string res = can_recruit(name, side_num, loc, recruited_from);
354 team& current_team = board().get_team(side_num);
356 if(res.empty() && (!pc_.get_whiteboard() || !pc_.get_whiteboard()->save_recruit(name, side_num, loc))) {
364 }
else if(res.empty()) {
375 if(pc_.get_disallow_recall()) {
380 team& current_team = board().get_team(side_num);
382 std::vector<unit_const_ptr> recall_list_team;
390 DBG_WB <<
"menu_handler::recall: Contents of wb-modified recall list:";
397 _(
"There are no troops available to recall.\n(You must have veteran survivors from a previous scenario.)"));
400 if(recall_list_team.empty()) {
423 unit_cost = recall_list_team[res]->recall_cost();
426 int wb_gold = pc_.get_whiteboard() ? pc_.get_whiteboard()->get_spent_gold_for(side_num) : 0;
427 if(current_team.
gold() - wb_gold < unit_cost) {
429 i18n_symbols[
"cost"] = std::to_string(unit_cost);
430 std::string
msg =
VNGETTEXT(
"You must have at least 1 gold piece to recall a unit.",
431 "You must have at least $cost gold pieces to recall this unit.", unit_cost, i18n_symbols);
436 LOG_NG <<
"recall index: " << res;
453 if(!pc_.get_whiteboard()
454 || !pc_.get_whiteboard()->save_recall(*recall_list_team[res].get(), side_num, recall_location)) {
460 ERR_NG <<
"menu_handler::recall(): Unit does not exist in the recall list.";
466 void menu_handler::show_enemy_moves(
bool ignore_units,
int side_num)
473 gui_->unhighlight_reach();
476 for(
auto& u : pc_.get_units()) {
477 bool invisible = u.invisible(u.get_location());
479 if(board().get_team(side_num).is_enemy(u.side()) && !gui_->fogged(u.get_location()) && !u.incapacitated()
483 =
pathfind::paths(u,
false,
true, pc_.get_teams()[gui_->viewing_team()], 0,
false, ignore_units);
485 gui_->highlight_another_reach(
path, hex_under_mouse);
489 gui_->invalidate(u.get_location());
494 const bool selected_hex_has_unit = mh.
hex_hosts_unit(hex_under_mouse);
496 if(selected_hex_has_unit) {
505 void menu_handler::toggle_shroud_updates(
int side_num)
507 team& current_team = board().get_team(side_num);
511 update_shroud_now(side_num);
518 void menu_handler::update_shroud_now(
int )
527 bool units_alive(
int side_num,
const unit_map& units)
529 for(
auto&
unit : units) {
538 bool partmoved_units(
539 int side_num,
const unit_map& units,
const game_board& board,
const std::shared_ptr<wb::manager>& whiteb)
541 for(
auto&
unit : units) {
556 int side_num,
const unit_map& units,
const game_board& board,
const std::shared_ptr<wb::manager>& whiteb)
558 for(
auto&
unit : units) {
561 && (!whiteb || !whiteb->unit_has_actions(&
unit))) {
571 bool menu_handler::end_turn(
int side_num)
576 reason =
_(
"You cannot end your turn yet!");
582 std::size_t team_num =
static_cast<std::size_t
>(side_num - 1);
583 if(team_num < pc_.get_teams().size() && pc_.get_teams()[team_num].no_turn_confirmation()) {
588 && (!pc_.get_whiteboard() || !pc_.get_whiteboard()->current_side_has_actions())
589 && units_alive(side_num, pc_.get_units())) {
591 _(
"You have not started your turn yet. Do you really want to end your turn?"),
600 _(
"Some units have movement left. Do you really want to end your turn?"),
609 _(
"Some units have not moved. Do you really want to end your turn?"),
618 if(pc_.get_whiteboard() && !pc_.get_whiteboard()->allow_end_turn()) {
625 void menu_handler::goto_leader(
int side_num)
629 if(
i != pc_.get_units().end() &&
i->is_visible_to_team(dc.
get_team(gui_->viewing_side()),
false)) {
634 void menu_handler::unit_description()
637 if(un != pc_.get_units().end()) {
645 if(pc_.get_map().on_board(loc) ==
false || gui_->shrouded(loc)) {
654 void menu_handler::rename_unit()
657 if(un == pc_.get_units().end() || gui_->viewing_side() != un->side()) {
661 if(un->unrenamable()) {
665 std::string name = un->name();
666 const std::string title(
_(
"Rename Unit"));
667 const std::string
label(
_(
"Name:"));
669 if(gui2::dialogs::edit_text::execute(title,
label, name)) {
672 gui_->invalidate_unit();
678 const mouse_handler& mousehandler = pc_.get_mouse_handler_base();
679 const bool see_all = gui_->show_everything() || (pc_.is_replay() && pc_.get_replay_controller()->see_all());
682 if(res != pc_.get_units().end()) {
693 typedef std::tuple<const unit_type*, unit_race::GENDER, std::string> type_gender_variation;
702 type_gender_variation choose_unit()
715 const std::string& ut_id = create_dlg.
choice();
718 ERR_NG <<
"Create unit dialog returned nonexistent or unusable unit_type id '" << ut_id <<
"'.";
731 return type_gender_variation(utp, gender, create_dlg.
variation());
744 const std::string& variation =
"")
752 "variation", variation,
767 assert(gui_ !=
nullptr);
770 if(
const auto& [
type, gender, variation] = choose_unit();
type !=
nullptr) {
772 create_and_place(*gui_, pc_.get_map(), pc_.get_units(), destination, *
type, gender, variation);
780 if(
i == pc_.get_units().end()) {
781 if(!pc_.get_map().is_village(loc)) {
789 if(
team >
static_cast<int>(pc_.get_teams().size())) {
794 int side =
i->side();
796 if(side >
static_cast<int>(pc_.get_teams().size())) {
801 if(pc_.get_map().is_village(loc)) {
813 void menu_handler::label_terrain(
mouse_handler& mousehandler,
bool team_only)
816 if(pc_.get_map().on_board(loc) ==
false) {
820 const terrain_label* old_label = gui_->labels().get_label(loc);
821 std::string
label = old_label ? old_label->
text() :
"";
823 if(gui2::dialogs::edit_label::execute(
label, team_only)) {
824 std::string team_name;
828 team_name = gui_->labels().team_name();
832 const terrain_label* res = gui_->labels().set_label(loc,
label, gui_->viewing_team(), team_name, color);
839 void menu_handler::clear_labels()
841 if(gui_->team_valid() && !board().is_observer()) {
844 _(
"Are you sure you want to clear map labels?"),
849 gui_->labels().clear(gui_->current_team_name(),
false);
855 void menu_handler::label_settings()
857 if(gui2::dialogs::label_settings::execute(board())) {
858 gui_->labels().recalculate_labels();
865 if(
i == pc_.get_units().end() || !
i->move_interrupted()) {
867 if(
i == pc_.get_units().end() || !
i->move_interrupted()) {
871 move_unit_to_loc(
i,
i->get_interrupted_move(),
true, side_num, mousehandler);
880 assert(ui != pc_.get_units().end());
884 if(route.
steps.empty()) {
888 assert(route.
steps.front() == ui->get_location());
890 gui_->set_route(&route);
891 gui_->unhighlight_reach();
894 LOG_NG <<
"move_unit_to_loc " << route.
steps.front() <<
" to " << route.
steps.back();
899 gui_->set_route(
nullptr);
900 gui_->invalidate_game_status();
909 bool wait_blocker_move =
true;
910 std::set<map_location> fully_moved;
913 bool blocked_unit =
false;
916 blocked_unit =
false;
917 for(
auto&
unit : pc_.get_units()) {
925 if(goto_loc == current_loc) {
930 if(!pc_.get_map().on_board(goto_loc)) {
935 if(fully_moved.count(current_loc)) {
941 if(route.
steps.size() <= 1) {
942 fully_moved.insert(current_loc);
948 pathfind::marked_route::mark_map::const_iterator
w = route.
marks.begin();
949 for(;
w != route.
marks.end(); ++
w) {
950 if(
w->second.turns == 1) {
951 next_stop =
w->first;
956 if(next_stop == current_loc) {
957 fully_moved.insert(current_loc);
963 if(pc_.get_units().count(next_stop)) {
965 if(wait_blocker_move)
969 gui_->set_route(&route);
972 LOG_NG <<
"execute goto from " << route.
steps.front() <<
" to " << route.
steps.back();
979 wait_blocker_move =
true;
983 if(!change && wait_blocker_move) {
985 wait_blocker_move =
false;
988 }
while(change && blocked_unit);
991 gui_->set_route(
nullptr);
992 gui_->invalidate_game_status();
995 void menu_handler::toggle_ellipses()
998 gui_->invalidate_all();
1001 void menu_handler::toggle_grid()
1004 gui_->invalidate_all();
1007 void menu_handler::unit_hold_position(
mouse_handler& mousehandler,
int side_num)
1010 if(un != pc_.get_units().end() && un->side() == side_num && un->movement_left() >= 0) {
1011 un->toggle_hold_position();
1016 if(un->hold_position()) {
1025 if(un != pc_.get_units().end() && un->side() == side_num && un->movement_left() >= 0) {
1026 un->toggle_user_end_turn();
1031 if(un->user_end_turn()) {
1043 void menu_handler::search()
1045 std::ostringstream
msg;
1047 if(last_search_hit_.valid()) {
1048 msg <<
" [" << last_search_ <<
"]";
1054 void menu_handler::do_speak()
1058 chat_handler::do_speak(
1059 textbox_info_.box()->text(), textbox_info_.check() !=
nullptr ? textbox_info_.check()->checked() :
false);
1062 void menu_handler::add_chat_message(
const std::time_t& time,
1063 const std::string& speaker,
1065 const std::string& message,
1068 gui_->get_chat_manager().add_chat_message(time, speaker, side, message,
type,
false);
1095 using chmap::get_commands_list;
1096 using chmap::command_failed;
1102 chat_command_handler::command_handler
h,
1103 const std::string&
help =
"",
1104 const std::string& usage =
"",
1105 const std::string& flags =
"")
1107 chmap::register_command(cmd,
h,
help, usage, flags +
"N");
1112 chmap::register_alias(to_cmd, cmd);
1117 return chmap::get_arg(
i);
1122 return chmap::get_cmd();
1127 return chmap::get_data(
n);
1131 using chmap::register_command;
1132 using chmap::register_alias;
1134 using chmap::is_enabled;
1135 using chmap::command_failed_need_arg;
1143 void do_controller();
1145 void do_foreground();
1148 void do_benchmark();
1150 void do_save_quit();
1152 void do_ignore_replay_errors();
1154 void do_next_level();
1155 void do_choose_level();
1157 void do_turn_limit();
1161 void do_unsafe_lua();
1163 void do_set_alias();
1167 void do_control_dialog();
1172 void do_undiscover();
1178 void do_toggle_draw_coordinates();
1179 void do_toggle_draw_terrain_codes();
1180 void do_toggle_draw_num_of_bitmaps();
1181 void do_toggle_whiteboard();
1182 void do_whiteboard_options();
1186 return _(
"(D) — debug only, (N) — network only, (A) — admin only");
1189 using chat_command_handler::get_command_flags_description;
1192 std::string space(
" ");
1193 return (
c.has_flag(
'D') ? space +
_(
"(debug command)") :
"")
1194 + (
c.has_flag(
'N') ? space +
_(
"(network only)") :
"")
1195 + (
c.has_flag(
'A') ? space +
_(
"(admin only)") :
"")
1196 + (
c.has_flag(
'S') ? space +
_(
"(not during other events)") :
"");
1199 using map::is_enabled;
1203 || (
c.has_flag(
'N') && !menu_handler_.pc_.is_networked_mp())
1208 void print(
const std::string& title,
const std::string& message)
1210 menu_handler_.add_chat_message(std::time(
nullptr), title, 0, message);
1215 chat_command_handler::init_map();
1217 chmap::get_command(
"log")->flags =
"";
1218 chmap::get_command(
"version")->flags =
"";
1219 chmap::get_command(
"ignore")->flags =
"";
1220 chmap::get_command(
"friend")->flags =
"";
1221 chmap::get_command(
"remove")->flags =
"";
1223 chmap::set_cmd_prefix(
":");
1224 chmap::set_cmd_flag(
true);
1226 register_command(
"refresh", &console_handler::do_refresh,
_(
"Refresh gui."));
1227 register_command(
"droid", &console_handler::do_droid,
_(
"Switch a side to/from AI control."),
1231 _(
"[<side> [on/off/full]]\n“on” = enable but retain vision, “full” = as if it’s controlled by another player"));
1232 register_command(
"terrain", &console_handler::do_terrain,
_(
"Change terrain type of current hex"),
1234 _(
"<terrain type> [both|base|overlay]"),
"DS");
1235 register_command(
"idle", &console_handler::do_idle,
_(
"Switch a side to/from idle state."),
1239 _(
"command_idle^[<side> [on/off]]"));
1240 register_command(
"theme", &console_handler::do_theme,
_(
"Change the in-game theme."));
1241 register_command(
"control", &console_handler::do_control,
1242 _(
"Assign control of a side to a different player or observer."),
_(
"<side> <nickname>"),
"N");
1243 register_command(
"controller", &console_handler::do_controller,
_(
"Query the controller status of a side."),
1245 register_command(
"clear", &console_handler::do_clear,
_(
"Clear chat history."));
1246 register_command(
"foreground", &console_handler::do_foreground,
_(
"Debug foreground terrain."),
"",
"D");
1248 "layers", &console_handler::do_layers,
_(
"Debug layers from terrain under the mouse."),
"",
"D");
1249 register_command(
"fps", &console_handler::do_fps,
_(
"Display and log fps (Frames Per Second)."));
1250 register_command(
"benchmark", &console_handler::do_benchmark,
_(
"Similar to the 'fps' command, but also forces everything to redraw instead of only things that have changed."));
1251 register_command(
"save", &console_handler::do_save,
_(
"Save game."));
1252 register_alias(
"save",
"w");
1253 register_command(
"quit", &console_handler::do_quit,
_(
"Quit game."));
1255 register_alias(
"quit",
"q!");
1256 register_command(
"save_quit", &console_handler::do_save_quit,
_(
"Save and quit."));
1257 register_alias(
"save_quit",
"wq");
1258 register_command(
"ignore_replay_errors", &console_handler::do_ignore_replay_errors,
_(
"Ignore replay errors."));
1259 register_command(
"nosaves", &console_handler::do_nosaves,
_(
"Disable autosaves."));
1260 register_command(
"next_level", &console_handler::do_next_level,
1261 _(
"Advance to the next scenario, or scenario identified by 'id'"),
_(
"<id>"),
"DS");
1262 register_alias(
"next_level",
"n");
1263 register_command(
"choose_level", &console_handler::do_choose_level,
_(
"Choose next scenario"),
"",
"DS");
1264 register_alias(
"choose_level",
"cl");
1265 register_command(
"turn", &console_handler::do_turn,
1266 _(
"Change turn number (and time of day), or increase by one if no number is specified."),
_(
"[turn]"),
1268 register_command(
"turn_limit", &console_handler::do_turn_limit,
1269 _(
"Change turn limit, or turn the turn limit off if no number is specified or it’s −1."),
_(
"[limit]"),
1271 register_command(
"debug", &console_handler::do_debug,
_(
"Turn debug mode on."));
1272 register_command(
"nodebug", &console_handler::do_nodebug,
_(
"Turn debug mode off."),
"",
"D");
1274 "lua", &console_handler::do_lua,
_(
"Execute a Lua statement."),
_(
"<command>[;<command>...]"),
"DS");
1276 "unsafe_lua", &console_handler::do_unsafe_lua,
_(
"Grant higher privileges to Lua scripts."),
"",
"D");
1277 register_command(
"custom", &console_handler::do_custom,
_(
"Set the command used by the custom command hotkey"),
1278 _(
"<command>[;<command>...]"));
1279 register_command(
"give_control", &console_handler::do_control_dialog,
1280 _(
"Invoke a dialog allowing changing control of MP sides."),
"",
"N");
1281 register_command(
"inspect", &console_handler::do_inspect,
_(
"Launch the gamestate inspector"),
"",
"D");
1283 "alias", &console_handler::do_set_alias,
_(
"Set or show alias to a command"),
_(
"<name>[=<command>]"));
1285 "set_var", &console_handler::do_set_var,
_(
"Set a scenario variable."),
_(
"<var>=<value>"),
"DS");
1286 register_command(
"show_var", &console_handler::do_show_var,
_(
"Show a scenario variable."),
_(
"<var>"),
"D");
1287 register_command(
"unit", &console_handler::do_unit,
1289 _(
"Modify a unit variable. (Only top level keys are supported, and advances=<number>.)"),
1290 _(
"<var>=<value>"),
"DS");
1296 register_command(
"discover", &console_handler::do_discover,
_(
"Discover all units in help."),
"");
1297 register_command(
"undiscover", &console_handler::do_undiscover,
_(
"'Undiscover' all units in help."),
"");
1298 register_command(
"create", &console_handler::do_create,
_(
"Create a unit."),
_(
"<unit type id>"),
"DS");
1299 register_command(
"fog", &console_handler::do_fog,
_(
"Toggle fog for the current player."),
"",
"DS");
1300 register_command(
"shroud", &console_handler::do_shroud,
_(
"Toggle shroud for the current player."),
"",
"DS");
1301 register_command(
"gold", &console_handler::do_gold,
_(
"Give gold to the current player."),
_(
"<amount>"),
"DS");
1302 register_command(
"throw", &console_handler::do_event,
_(
"Fire a game event."),
_(
"<event name>"),
"DS");
1303 register_alias(
"throw",
"fire");
1304 register_command(
"show_coordinates", &console_handler::do_toggle_draw_coordinates,
1305 _(
"Toggle overlaying of x,y coordinates on hexes."));
1306 register_alias(
"show_coordinates",
"sc");
1307 register_command(
"show_terrain_codes", &console_handler::do_toggle_draw_terrain_codes,
1308 _(
"Toggle overlaying of terrain codes on hexes."));
1309 register_alias(
"show_terrain_codes",
"tc");
1310 register_command(
"show_num_of_bitmaps", &console_handler::do_toggle_draw_num_of_bitmaps,
1311 _(
"Toggle overlaying of number of bitmaps on hexes."));
1312 register_alias(
"show_num_of_bitmaps",
"bn");
1313 register_command(
"whiteboard", &console_handler::do_toggle_whiteboard,
_(
"Toggle planning mode."));
1314 register_alias(
"whiteboard",
"wb");
1316 "whiteboard_options", &console_handler::do_whiteboard_options,
_(
"Access whiteboard options dialog."));
1317 register_alias(
"whiteboard_options",
"wbo");
1321 register_alias(
a.second,
a.first);
1331 void menu_handler::send_chat_message(
const std::string& message,
bool allies_only)
1335 cfg[
"message"] = message;
1336 const std::time_t time = ::std::time(
nullptr);
1337 std::stringstream ss;
1339 cfg[
"time"] = ss.str();
1341 const int side = board().
is_observer() ? 0 : gui_->viewing_side();
1342 if(!board().is_observer()) {
1349 if(board().is_observer()) {
1352 cfg[
"to_sides"] = pc_.get_teams()[gui_->viewing_team()].allied_human_teams();
1358 add_chat_message(time, cfg[
"id"], side, message,
1362 void menu_handler::do_search(
const std::string& new_search)
1364 if(new_search.empty() ==
false && new_search != last_search_)
1365 last_search_ = new_search;
1367 if(last_search_.empty())
1373 std::vector<std::string> args =
utils::split(last_search_,
',');
1374 if(args.size() == 2) {
1376 x = lexical_cast_default<int>(args[0], 0) - 1;
1377 y = lexical_cast_default<int>(args[1], 0) - 1;
1378 if(x >= 0 && x < pc_.get_map().w() && y >= 0 && y < pc_.get_map().h()) {
1384 if(loc.
valid() ==
false) {
1385 loc =
map_location(pc_.get_map().w() - 1, pc_.get_map().h() - 1);
1391 loc.
x = (loc.
x + 1) % pc_.get_map().w();
1393 loc.
y = (loc.
y + 1) % pc_.get_map().h();
1396 if(!gui_->shrouded(loc)) {
1399 std::string label_text =
label->text().str();
1400 if(std::search(label_text.begin(), label_text.end(), last_search_.begin(), last_search_.end(),
1402 != label_text.end()) {
1408 if(!gui_->fogged(loc)) {
1410 if(ui != pc_.get_units().end()) {
1411 const std::string name = ui->name();
1415 if(!pc_.get_teams()[gui_->viewing_team()].is_enemy(ui->side())
1416 || !ui->invisible(ui->get_location())) {
1428 last_search_hit_ = loc;
1430 gui_->highlight_hex(loc);
1435 symbols[
"search"] = last_search_;
1436 const std::string
msg =
VGETTEXT(
"Could not find label or unit "
1437 "containing the string ‘$search’.",
1443 void menu_handler::do_command(
const std::string& str)
1449 std::vector<std::string> menu_handler::get_commands_list()
1460 void console_handler::do_refresh()
1465 menu_handler_.gui_->create_buttons();
1466 menu_handler_.gui_->queue_rerender();
1469 void console_handler::do_droid()
1472 const std::string side_s = get_arg(1);
1473 std::string action = get_arg(2);
1474 std::transform(action.begin(), action.end(), action.begin(), tolower);
1476 const unsigned int side = side_s.empty() ? team_num_ : lexical_cast_default<unsigned int>(side_s);
1477 const bool is_your_turn = menu_handler_.pc_.current_side() ==
static_cast<int>(menu_handler_.gui_->viewing_side());
1480 symbols[
"side"] = std::to_string(side);
1482 if(side < 1 || side > menu_handler_.pc_.get_teams().size()) {
1483 command_failed(
VGETTEXT(
"Can't droid invalid side: '$side'.", symbols));
1485 }
else if(menu_handler_.board().get_team(side).is_network()) {
1486 command_failed(
VGETTEXT(
"Can't droid networked side: '$side'.", symbols));
1488 }
else if(menu_handler_.board().get_team(side).is_local()) {
1489 bool changed =
false;
1491 const bool is_human = menu_handler_.board().get_team(side).is_human();
1492 const bool is_droid = menu_handler_.board().get_team(side).is_droid();
1493 const bool is_proxy_human = menu_handler_.board().get_team(side).is_proxy_human();
1494 const bool is_ai = menu_handler_.board().get_team(side).is_ai();
1496 if(action ==
"on") {
1497 if(is_ai && !is_your_turn) {
1498 command_failed(
_(
"It is not allowed to change a side from AI to human control when it's not your turn."));
1501 if(!is_human || !is_droid) {
1502 menu_handler_.board().get_team(side).make_human();
1503 menu_handler_.board().get_team(side).make_droid();
1506 menu_handler_.pc_.send_to_wesnothd(
config {
"change_controller",
config {
"side", side,
"player",
preferences::login(),
"to", side_controller::human}});
1508 print(get_cmd(),
VGETTEXT(
"Side '$side' controller is now controlled by: AI.", symbols));
1510 print(get_cmd(),
VGETTEXT(
"Side '$side' is already droided.", symbols));
1512 }
else if(action ==
"off") {
1513 if(is_ai && !is_your_turn) {
1514 command_failed(
_(
"It is not allowed to change a side from AI to human control when it's not your turn."));
1517 if(!is_human || !is_proxy_human) {
1518 menu_handler_.board().get_team(side).make_human();
1519 menu_handler_.board().get_team(side).make_proxy_human();
1522 menu_handler_.pc_.send_to_wesnothd(
config {
"change_controller",
config {
"side", side,
"player",
preferences::login(),
"to", side_controller::human}});
1524 print(get_cmd(),
VGETTEXT(
"Side '$side' controller is now controlled by: human.", symbols));
1526 print(get_cmd(),
VGETTEXT(
"Side '$side' is already not droided.", symbols));
1528 }
else if(action ==
"full") {
1530 command_failed(
_(
"It is not allowed to change a side from human to AI control when it's not your turn."));
1533 if(!is_ai || !is_droid) {
1534 menu_handler_.board().get_team(side).make_ai();
1535 menu_handler_.board().get_team(side).make_droid();
1537 if(is_human || is_proxy_human) {
1538 menu_handler_.pc_.send_to_wesnothd(
config {
"change_controller",
config {
"side", side,
"player",
preferences::login(),
"to", side_controller::ai}});
1540 print(get_cmd(),
VGETTEXT(
"Side '$side' controller is now fully controlled by: AI.", symbols));
1542 print(get_cmd(),
VGETTEXT(
"Side '$side' is already fully AI controlled.", symbols));
1544 }
else if(action ==
"") {
1545 if(is_ai && !is_your_turn) {
1546 command_failed(
_(
"It is not allowed to change a side from AI to human control when it's not your turn."));
1549 if(is_ai || is_droid) {
1550 menu_handler_.board().get_team(side).make_human();
1551 menu_handler_.board().get_team(side).make_proxy_human();
1554 menu_handler_.pc_.send_to_wesnothd(
config {
"change_controller",
config {
"side", side,
"player",
preferences::login(),
"to", side_controller::human}});
1556 print(get_cmd(),
VGETTEXT(
"Side '$side' controller is now controlled by: human.", symbols));
1558 menu_handler_.board().get_team(side).make_human();
1559 menu_handler_.board().get_team(side).make_droid();
1562 menu_handler_.pc_.send_to_wesnothd(
config {
"change_controller",
config {
"side", side,
"player",
preferences::login(),
"to", side_controller::human}});
1564 print(get_cmd(),
VGETTEXT(
"Side '$side' controller is now controlled by: AI.", symbols));
1567 print(get_cmd(),
VGETTEXT(
"Invalid action provided for side '$side'. Valid actions are: on, off, full.", symbols));
1570 if(team_num_ == side && changed) {
1572 psc->set_player_type_changed();
1576 menu_handler_.textbox_info_.close();
1579 void console_handler::do_terrain()
1583 const std::string mode_str = get_arg(2);
1593 "mode_str", mode_str,
1598 void console_handler::do_idle()
1601 const std::string side_s = get_arg(1);
1602 const std::string action = get_arg(2);
1604 const unsigned int side = side_s.empty() ? team_num_ : lexical_cast_default<unsigned int>(side_s);
1606 if(side < 1 || side > menu_handler_.pc_.get_teams().size()) {
1608 symbols[
"side"] = side_s;
1609 command_failed(
VGETTEXT(
"Can't idle invalid side: '$side'.", symbols));
1611 }
else if(menu_handler_.board().get_team(side).is_network()) {
1613 symbols[
"side"] = std::to_string(side);
1614 command_failed(
VGETTEXT(
"Can't idle networked side: '$side'.", symbols));
1616 }
else if(menu_handler_.board().get_team(side).is_local_ai()) {
1618 symbols[
"side"] = std::to_string(side);
1619 command_failed(
VGETTEXT(
"Can't idle local ai side: '$side'.", symbols));
1621 }
else if(menu_handler_.board().get_team(side).is_local_human()) {
1622 if(menu_handler_.board().get_team(side).is_idle() ? action ==
" on" : action ==
" off") {
1626 menu_handler_.board().get_team(side).toggle_idle();
1627 if(team_num_ == side) {
1629 psc->set_player_type_changed();
1633 menu_handler_.textbox_info_.close();
1636 void console_handler::do_theme()
1650 return t.save_id() == save_id_;
1656 void console_handler::do_control()
1659 if(!menu_handler_.pc_.is_networked_mp()) {
1663 const std::string side = get_arg(1);
1664 const std::string player = get_arg(2);
1665 if(player.empty()) {
1666 command_failed_need_arg(2);
1670 unsigned int side_num;
1672 side_num = lexical_cast<unsigned int>(side);
1674 const auto& teams = menu_handler_.pc_.get_teams();
1675 const auto it_t = std::find_if(teams.begin(), teams.end(),
save_id_matches(side));
1677 if(it_t == teams.end()) {
1679 symbols[
"side"] = side;
1680 command_failed(
VGETTEXT(
"Can't change control of invalid side: '$side'.", symbols));
1683 side_num = it_t->side();
1687 if(side_num < 1 || side_num > menu_handler_.pc_.get_teams().size()) {
1689 symbols[
"side"] = side;
1690 command_failed(
VGETTEXT(
"Can't change control of out-of-bounds side: '$side'.", symbols));
1694 menu_handler_.request_control_change(side_num, player);
1695 menu_handler_.textbox_info_.close();
1698 void console_handler::do_controller()
1700 const std::string side = get_arg(1);
1701 unsigned int side_num;
1703 side_num = lexical_cast<unsigned int>(side);
1706 symbols[
"side"] = side;
1707 command_failed(
VGETTEXT(
"Can't query control of invalid side: '$side'.", symbols));
1711 if(side_num < 1 || side_num > menu_handler_.pc_.get_teams().size()) {
1713 symbols[
"side"] = side;
1714 command_failed(
VGETTEXT(
"Can't query control of out-of-bounds side: '$side'.", symbols));
1719 if(!menu_handler_.board().get_team(side_num).is_proxy_human()) {
1723 if(menu_handler_.board().get_team(side_num).is_network()) {
1724 report +=
" (networked)";
1727 print(get_cmd(), report);
1730 void console_handler::do_clear()
1732 menu_handler_.gui_->get_chat_manager().clear_chat_messages();
1735 void console_handler::do_foreground()
1738 menu_handler_.gui_->invalidate_all();
1741 void console_handler::do_layers()
1743 display& disp = *(menu_handler_.gui_);
1758 gui2::dialogs::terrain_layers::display(disp, loc);
1762 void console_handler::do_fps()
1767 void console_handler::do_benchmark()
1772 void console_handler::do_save()
1774 menu_handler_.pc_.do_consolesave(get_data());
1777 void console_handler::do_save_quit()
1783 void console_handler::do_quit()
1788 void console_handler::do_ignore_replay_errors()
1793 void console_handler::do_nosaves()
1798 void console_handler::do_next_level()
1803 void console_handler::do_choose_level()
1805 std::string tag = menu_handler_.pc_.get_classification().get_tagname();
1806 std::vector<std::string>
options;
1808 if(tag !=
"multiplayer") {
1810 const std::string&
id = sc[
"id"];
1812 if(
id == menu_handler_.gamedata().next_scenario()) {
1819 std::string scenario_id = menu_handler_.pc_.get_mp_settings().mp_scenario;
1820 if(
auto this_scenario = menu_handler_.game_config_.find_child(tag,
"id", scenario_id)) {
1821 std::string addon_id = this_scenario[
"addon_id"].str();
1823 if(sc[
"addon_id"] == addon_id) {
1824 std::string
id = sc[
"id"];
1826 if(
id == menu_handler_.gamedata().next_scenario()) {
1834 int choice = std::distance(
options.begin(), std::lower_bound(
options.begin(),
options.end(), next));
1846 if(std::size_t(choice) <
options.size()) {
1851 void console_handler::do_turn()
1853 tod_manager& tod_man = menu_handler_.gamestate().tod_manager_;
1855 int turn = tod_man.
turn() + 1;
1856 const std::string&
data = get_data();
1858 turn = lexical_cast_default<int>(
data, 1);
1863 void console_handler::do_turn_limit()
1865 int limit = get_data().empty() ? -1 : lexical_cast_default<int>(get_data(), 1);
1869 void console_handler::do_debug()
1872 print(get_cmd(),
_(
"Debug mode activated!"));
1875 command_failed(
_(
"Debug mode not available in network games"));
1879 void console_handler::do_nodebug()
1882 print(get_cmd(),
_(
"Debug mode deactivated!"));
1887 void console_handler::do_lua()
1889 if(!menu_handler_.gamestate().lua_kernel_) {
1896 void console_handler::do_unsafe_lua()
1898 if(!menu_handler_.gamestate().lua_kernel_) {
1903 _(
"Executing Lua code in in this manner opens your computer to potential security breaches from any "
1904 "malicious add-ons or other programs you may have installed.\n\n"
1908 print(get_cmd(),
_(
"Unsafe mode enabled!"));
1909 menu_handler_.gamestate().lua_kernel_->load_package();
1913 void console_handler::do_custom()
1918 void console_handler::do_set_alias()
1920 const std::string
data = get_data();
1921 const std::string::const_iterator j = std::find(
data.begin(),
data.end(),
'=');
1922 const std::string alias(
data.begin(), j);
1923 if(j !=
data.end()) {
1924 const std::string command(j + 1,
data.end());
1925 if(!command.empty()) {
1926 register_alias(command, alias);
1930 register_alias(alias, alias);
1938 const std::string command = chmap::get_actual_cmd(alias);
1939 print(get_cmd(),
"'" + alias +
"'" +
" = " +
"'" + command +
"'");
1943 void console_handler::do_set_var()
1945 const std::string
data = get_data();
1947 command_failed_need_arg(1);
1951 const std::string::const_iterator j = std::find(
data.begin(),
data.end(),
'=');
1952 if(j !=
data.end()) {
1953 const std::string name(
data.begin(), j);
1954 const std::string value(j + 1,
data.end());
1957 command_failed(
_(
"Variable not found"));
1961 void console_handler::do_show_var()
1966 void console_handler::do_inspect()
1969 gui2::dialogs::gamestate_inspector::display(
1973 void console_handler::do_control_dialog()
1975 gui2::dialogs::mp_change_control::display(menu_handler_);
1978 void console_handler::do_unit()
1986 if(
i == menu_handler_.pc_.get_units().end()) {
1988 symbols[
"unit"] = get_arg(1);
1990 "Debug command 'unit: $unit' failed: no unit selected or hovered over.",
1996 const std::string
data = get_data(1);
1998 if(parameters.size() < 2) {
2002 if(parameters[0] ==
"alignment") {
2006 symbols[
"alignment"] = get_arg(1);
2008 "Invalid alignment: '$alignment', needs to be one of lawful, neutral, chaotic, or liminal.",
2018 "name", parameters[0],
2019 "value", parameters[1],
2024 void console_handler::do_discover()
2026 for(
const unit_type_data::unit_type_map::value_type&
i :
unit_types.
types()) {
2031 void console_handler::do_undiscover()
2041 void console_handler::do_create()
2045 if(menu_handler_.pc_.get_map().on_board(loc)) {
2048 command_failed(
_(
"Invalid unit type"));
2053 create_and_place(*menu_handler_.gui_, menu_handler_.pc_.get_map(), menu_handler_.pc_.get_units(), loc, *ut);
2055 command_failed(
_(
"Invalid location"));
2059 void console_handler::do_fog()
2064 void console_handler::do_shroud()
2069 void console_handler::do_gold()
2074 void console_handler::do_event()
2079 void console_handler::do_toggle_draw_coordinates()
2082 menu_handler_.gui_->invalidate_all();
2084 void console_handler::do_toggle_draw_terrain_codes()
2087 menu_handler_.gui_->invalidate_all();
2090 void console_handler::do_toggle_draw_num_of_bitmaps()
2093 menu_handler_.gui_->invalidate_all();
2096 void console_handler::do_toggle_whiteboard()
2098 if(
const std::shared_ptr<wb::manager>& whiteb = menu_handler_.pc_.get_whiteboard()) {
2099 whiteb->set_active(!whiteb->is_active());
2100 if(whiteb->is_active()) {
2101 print(get_cmd(),
_(
"Planning mode activated!"));
2102 whiteb->print_help_once();
2104 print(get_cmd(),
_(
"Planning mode deactivated!"));
2109 void console_handler::do_whiteboard_options()
2111 if(menu_handler_.pc_.get_whiteboard()) {
2112 menu_handler_.pc_.get_whiteboard()->options_dlg();
2116 void menu_handler::do_ai_formula(
const std::string& str,
int side_num,
mouse_handler& )
2126 void menu_handler::user_command()
2131 void menu_handler::request_control_change(
int side_num,
const std::string& player)
2133 std::string side = std::to_string(side_num);
2140 pc_.send_to_wesnothd(
config {
"change_controller",
config {
"side", side,
"player", player}});
2147 do_command(command);
2151 void menu_handler::ai_formula()
2153 if(!pc_.is_networked_mp()) {
2158 void menu_handler::clear_messages()
2160 gui_->get_chat_manager().clear_chat_messages();
2165 pc_.send_to_wesnothd(cfg);
Various functions that implement attacks and attack calculations.
Various functions related to moving units.
Managing the AIs lifecycle - headers TODO: Refactor history handling and internal commands.
Definitions for the terrain builder.
static manager & get_singleton()
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
attribute_map::value_type attribute
Abstract class for exposing game data that doesn't depend on the GUI, however which for historical re...
const team & get_team(int side) const
This getter takes a 1-based side number, not a 0-based team number.
int village_owner(const map_location &loc) const
Given the location of a village, will return the 1-based number of the team that currently owns it,...
bool is_observer() const
Check if we are an observer in this game.
can_move_result unit_can_move(const unit &u) const
Work out what u can do - this does not check which player's turn is currently active,...
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
@ DEBUG_COORDINATES
Overlays x,y coords on tiles.
@ DEBUG_BENCHMARK
Toggle to continuously redraw the whole map.
@ DEBUG_NUM_BITMAPS
Overlays number of bitmaps on tiles.
@ DEBUG_FOREGROUND
Separates background and foreground terrain layers.
@ DEBUG_TERRAIN_CODES
Overlays terrain codes on tiles.
const gamemap & get_map() const
void queue_rerender()
Marks everything for rendering including all tiles and sidebar.
virtual std::string get_arg(unsigned i) const
std::string get_flags_description() const
virtual std::string get_cmd() const
console_handler(menu_handler &menu_handler)
void print(const std::string &title, const std::string &message)
virtual void register_alias(const std::string &to_cmd, const std::string &cmd)
bool is_enabled(const chmap::command &c) const
virtual std::string get_data(unsigned n=1) const
menu_handler & menu_handler_
std::string get_command_flags_description(const chmap::command &c) const
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="")
map_command_handler< console_handler > chmap
const unsigned int team_num_
std::vector< std::string > get_commands_list() const
void dispatch(std::string cmd)
game_board & board() const
gui::floating_textbox & get_textbox()
menu_handler(game_display *gui, play_controller &pc)
gui::floating_textbox textbox_info_
void show_statistics(int side_num)
void recruit(int side_num, const map_location &last_hex)
t_string can_recruit(const std::string &name, int side_num, map_location &target_hex, map_location &recruited_from)
game_state & gamestate() const
void disable_units_highlight()
Use this to disable hovering an unit from highlighting its movement range.
void set_current_paths(const pathfind::paths &new_paths)
map_location get_selected_hex() const
const map_location hovered_hex() const
Uses SDL and game_display::hex_clicked_on to fetch the hex the mouse is hovering, if applicable.
const map_location & get_last_hex() const
bool hex_hosts_unit(const map_location &hex) const
Unit exists on the hex, no matter if friend or foe.
void cycle_units(const bool browse, const bool reverse=false)
pathfind::marked_route get_route(const unit *un, map_location go_to, team &team) const
unit_map::iterator find_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false)
void scroll_to_leader(int side, SCROLL_TYPE scroll_type=ONSCREEN, bool force=true)
Scrolls to the leader of a certain side.
virtual const std::set< std::string > & observers() const override
bool on_board_with_border(const map_location &loc) const
Encapsulates the map of the game.
std::string write() const
file_dialog & set_extension(const std::string &value)
Sets the default file extension for file names in save mode.
file_dialog & set_path(const std::string &value)
Sets the initial file selection.
file_dialog & set_title(const std::string &value)
Sets the current dialog title text.
file_dialog & set_save_mode(bool value)
Sets the dialog's behavior on non-existent file name inputs.
std::string path() const
Gets the current file selection.
static bool execute(game_board &board, const int viewing_team, int &selected_side_number)
@ yes_no_buttons
Shows a yes and no button.
@ ok_cancel_buttons
Shows an ok and cancel button.
@ auto_close
Enables auto close.
bool show(const unsigned auto_close_time=0)
Shows the window.
A simple one-column listbox with OK and Cancel buttons.
int selected_index() const
Returns the selected item index after displaying.
void set_selected_index(int index)
Sets the initially selected item index (-1 by default).
This shows the debug-mode dialog to create new units on the map.
unit_race::GENDER gender()
Gender choice from the user.
bool no_choice() const
Whether the user actually chose a unit type or not.
std::string variation() const
Variation choice from the user.
const std::string & choice() const
Unit type choice from the user.
int get_selected_index() const
void show(gui::TEXTBOX_MODE mode, const std::string &label, const std::string &check_label, bool checked, game_display &gui)
std::vector< team > & get_teams()
void show_objectives() const
statistics_t & statistics()
events::mouse_handler & get_mouse_handler_base() override
Get a reference to a mouse handler member a derived class uses.
const gamemap & get_map() const
void refresh_objectives() const
Reevaluate [show_if] conditions and build a new objectives string.
void notify_event(const std::string &name, const config &data)
static plugins_manager * get()
bool empty() const
Is it empty?
static config get_recall(const std::string &unit_id, const map_location &loc, const map_location &from)
static config get_auto_shroud(bool turned_on)
Records that the player has toggled automatic shroud updates.
static config get_recruit(const std::string &type_id, const map_location &loc, const map_location &from)
static config get_update_shroud()
Records that the player has manually updated fog/shroud.
void add_rename(const std::string &name, const map_location &loc)
void add_label(const terrain_label *)
void speak(const config &cfg)
void clear_labels(const std::string &, bool)
static void ignore_error_function(const std::string &message)
A function to be passed to run_in_synced_context to ignore the error.
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)
static synced_state get_synced_state()
This class stores all the data for a single 'side' (in game nomenclature).
void set_action_bonus_count(const int count)
bool auto_shroud_updates() const
int action_bonus_count() const
static color_t get_side_color(int side)
recall_list_manager & recall_list()
const std::string & last_recruit() const
To store label data Class implements logic for rendering.
const t_string & text() const
Container associating units to locations.
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.
const unit_type_map & types() const
A single unit type that the player may recruit.
const std::string & id() const
The id for this unit_type.
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.
const t_string & type_name() const
The name of the unit in the current language setting.
This class represents a single unit of a specific type.
A variable-expanding proxy for the config class.
static vconfig empty_vconfig()
Various functions related to the creation of units (recruits, recalls, and placed units).
static void print(std::stringstream &sstr, const std::string &queue, const std::string &id)
Contains the exception interfaces used to signal completion of a scenario, campaign or turn.
void throw_quit_game_exception()
int dispatch(lua_State *L)
static std::string _(const char *str)
bool user_end_turn() const
Check whether the user ended their turn.
const std::string & id() const
Gets this unit's id.
int side() const
The side this unit belongs to.
const t_string & name() const
Gets this unit's translatable display name.
const map_location & get_location() const
The current map location this unit is at.
bool has_moved() const
Checks if this unit has moved.
void set_goto(const map_location &new_goto)
Sets this unit's long term destination.
int movement_left() const
Gets how far a unit can move, considering the incapacitated flag.
const map_location & get_goto() const
The map location to which this unit is moving over multiple turns, if any.
std::string label
What to show in the filter's drop-down list.
std::string id
Text to match against addon_info.tags()
Standard logging facilities (interface).
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.
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...
std::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.
game_events::pump_result_t 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.
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...
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.
EXIT_STATUS start(bool clear_id, const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.
Handling of system events.
static bfs::path get_dir(const bfs::path &dirpath)
std::string get_user_data_dir()
void write_file(const std::string &fname, const std::string &data, std::ios_base::openmode mode)
Throws io_exception if an error occurs.
const color_t LABEL_COLOR
std::string private_message
Game configuration data as global variables.
bool ignore_replay_errors
const std::string observer_team_name
observer team name used for observer team chat
void set_debug(bool new_debug)
void show_unit_list(display &gui)
void show_transient_error_message(const std::string &message, const std::string &image, const bool message_use_markup)
Shows a transient error message to the user.
void show_transient_message(const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup)
Shows a transient message to the user.
void show_message(const std::string &title, const std::string &msg, const std::string &button_caption, const bool auto_close, const bool message_use_markup, const bool title_use_markup)
Shows a message to the user.
retval
Default window/dialog return values.
@ OK
Dialog was closed with the OK button.
@ CANCEL
Dialog was closed with the CANCEL button.
void show_help(const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
void show_terrain_description(const terrain_type &t)
void show_unit_description(const unit &u)
void flush_cache()
Purges all image caches.
void send_to_server(const config &data)
Attempts to send given data to server if a connection is open.
bool logged_in_as_moderator()
Gets whether the currently logged-in user is a moderator.
void set_message_private(bool value)
void set_custom_command(const std::string &command)
void set_show_fps(bool value)
optional_const_config get_alias()
std::set< std::string > & encountered_units()
void add_alias(const std::string &alias, const std::string &command)
std::string custom_command()
void set_ellipses(bool ison)
game_events::manager * game_events
static std::string sgettext(const char *str)
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
@ STRIP_SPACES
REMOVE_EMPTY: remove empty elements.
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
std::string get_unknown_exception_type()
Utility function for finding the type of thing caught with catch(...).
bool chars_equal_insensitive(char a, char b)
std::string format_conjunct_list(const t_string &empty, const std::vector< t_string > &elems)
Format a conjunctive list.
std::map< std::string, t_string > string_map
std::vector< std::string > split(const config_attribute_value &val)
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
std::shared_ptr< const unit > unit_const_ptr
Define the game's event mechanism.
const std::string & gender_string(unit_race::GENDER gender)
This file contains the settings handling of the widget library.
Thrown when a lexical_cast fails.
The basic class for representing 8-bit RGB or RGBA colour values.
save_id_matches(const std::string &save_id)
bool operator()(const team &t) const
An exception object used when an IO error occurs.
Encapsulates the map of the game.
static const map_location & null_location()
Structure which holds a single route and marks for special events.
std::vector< map_location > & steps
Object which contains all the possible locations a unit can move to, with associated best routes to t...
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.
static constexpr std::optional< enum_type > get_enum(const std::string_view value)
Converts a string into its enum equivalent.
Object which temporarily resets a unit's movement.
ONLY IF whiteboard is currently active, applies the planned unit map for the duration of the struct's...
Applies the planned unit map for the duration of the struct's life.
const std::string & gamedata
static map_location::DIRECTION n
unit_type_data unit_types
Display units performing various actions: moving, attacking, and dying.
Various functions that implement the undoing (and redoing) of in-game commands.
Various functions implementing vision (through fog of war and shroud).