90 #define ERR_NG LOG_STREAM(err, log_engine) 91 #define LOG_NG LOG_STREAM(info, log_engine) 141 gui2::dialogs::statistics_dialog::display(
board().get_team(side_num));
160 const std::string& input_name
179 symbols[
"msg"] = e.
what();
180 const std::string
msg =
VGETTEXT(
"Could not save the map: $msg", symbols);
187 gui2::dialogs::preferences_dialog::display();
195 c[
"name"] =
"prototype of chat log";
209 ?
board().is_observer()
210 ?
_(
"Send to observers only")
211 :
_(
"Send to allies only")
229 if(
board().is_observer()) {
245 std::map<const unit_type*, t_string> sample_units;
249 std::vector<t_string> unknown_units;
250 for(
const auto&
recruit : recruits) {
254 unknown_units.emplace_back(recruit);
262 if(!unknown_units.empty()) {
267 const auto message =
VNGETTEXT(
"Error: there’s an unknown unit type on your recruit list: $unknown_ids",
268 "Error: there are several unknown unit types on your recruit list: $unknown_ids",
269 unknown_units.size(),
274 if(sample_units.empty()) {
295 if(last_recruit.empty() ==
false) {
297 do_recruit(last_recruit, side_num, recruit_hex);
309 if(u_type ==
nullptr) {
310 return _(
"Internal error. Please report this as a bug! Details:\n")
311 +
"menu_handler::can_recruit: u_type == nullptr for " + name;
316 return VGETTEXT(
"You cannot recruit a $unit_type_name at this time.",
326 if(u_type->
cost() > current_team.
gold() - wb_gold)
330 return _(
"At this point in your plan, you will not have enough gold to recruit this unit.");
332 return _(
"You do not have enough gold to recruit this unit.");
352 const std::string res =
can_recruit(name, side_num, loc, recruited_from);
363 }
else if(res.empty()) {
381 std::vector<unit_const_ptr> recall_list_team;
389 DBG_WB <<
"menu_handler::recall: Contents of wb-modified recall list:";
396 _(
"There are no troops available to recall.\n(You must have veteran survivors from a previous scenario.)"));
399 if(recall_list_team.empty()) {
422 unit_cost = recall_list_team[res]->recall_cost();
426 if(current_team.
gold() - wb_gold < unit_cost) {
428 i18n_symbols[
"cost"] = std::to_string(unit_cost);
429 std::string
msg =
VNGETTEXT(
"You must have at least 1 gold piece to recall a unit.",
430 "You must have at least $cost gold pieces to recall this unit.", unit_cost, i18n_symbols);
435 LOG_NG <<
"recall index: " << res;
453 || !
pc_.
get_whiteboard()->save_recall(*recall_list_team[res].
get(), side_num, recall_location)) {
459 ERR_NG <<
"menu_handler::recall(): Unit does not exist in the recall list.";
476 bool invisible = u.invisible(u.get_location());
493 const bool selected_hex_has_unit = mh.
hex_hosts_unit(hex_under_mouse);
495 if(selected_hex_has_unit) {
526 bool units_alive(
int side_num,
const unit_map& units)
528 for(
auto&
unit : units) {
537 bool partmoved_units(
540 for(
auto&
unit : units) {
555 int side_num,
const unit_map& units,
const game_board& board,
const std::shared_ptr<wb::manager>& whiteb)
557 for(
auto&
unit : units) {
560 && (!whiteb || !whiteb->unit_has_actions(&
unit))) {
575 reason =
_(
"You cannot end your turn yet!");
581 std::size_t team_num =
static_cast<std::size_t
>(side_num - 1);
590 _(
"You have not started your turn yet. Do you really want to end your turn?"),
599 _(
"Some units have movement left. Do you really want to end your turn?"),
608 _(
"Some units have not moved. Do you really want to end your turn?"),
660 if(un->unrenamable()) {
664 std::string name = un->name();
665 const std::string title(
_(
"Rename Unit"));
666 const std::string
label(
_(
"Name:"));
668 if(gui2::dialogs::edit_text::execute(title, label, name)) {
692 typedef std::tuple<const unit_type*, unit_race::GENDER, std::string> type_gender_variation;
701 type_gender_variation choose_unit()
714 const std::string& ut_id = create_dlg.
choice();
717 ERR_NG <<
"Create unit dialog returned nonexistent or unusable unit_type id '" << ut_id <<
"'.";
730 return type_gender_variation(utp, gender, create_dlg.
variation());
743 const std::string& variation =
"")
751 "variation", variation,
766 assert(
gui_ !=
nullptr);
769 if(
const auto& [
type, gender, variation] = choose_unit();
type !=
nullptr) {
793 int side = i->side();
820 std::string
label = old_label ? old_label->
text() :
"";
822 if(gui2::dialogs::edit_label::execute(label, team_only)) {
823 std::string team_name;
843 _(
"Are you sure you want to clear map labels?"),
856 if(gui2::dialogs::label_settings::execute(
board())) {
870 move_unit_to_loc(i, i->get_interrupted_move(),
true, side_num, mousehandler);
883 if(route.steps.empty()) {
887 assert(route.steps.front() == ui->get_location());
893 LOG_NG <<
"move_unit_to_loc " << route.steps.front() <<
" to " << route.steps.back();
908 bool wait_blocker_move =
true;
909 std::set<map_location> fully_moved;
912 bool blocked_unit =
false;
915 blocked_unit =
false;
924 if(goto_loc == current_loc) {
934 if(fully_moved.count(current_loc)) {
940 if(route.
steps.size() <= 1) {
941 fully_moved.insert(current_loc);
947 pathfind::marked_route::mark_map::const_iterator
w = route.
marks.begin();
948 for(; w != route.
marks.end(); ++
w) {
949 if(w->second.turns == 1) {
950 next_stop = w->first;
955 if(next_stop == current_loc) {
956 fully_moved.insert(current_loc);
964 if(wait_blocker_move)
971 LOG_NG <<
"execute goto from " << route.
steps.front() <<
" to " << route.
steps.back();
978 wait_blocker_move =
true;
982 if(!change && wait_blocker_move) {
984 wait_blocker_move =
false;
987 }
while(change && blocked_unit);
1009 if(un !=
pc_.
get_units().
end() && un->side() == side_num && un->movement_left() >= 0) {
1010 un->toggle_hold_position();
1015 if(un->hold_position()) {
1024 if(un !=
pc_.
get_units().
end() && un->side() == side_num && un->movement_left() >= 0) {
1025 un->toggle_user_end_turn();
1030 if(un->user_end_turn()) {
1044 std::ostringstream
msg;
1062 const std::string& speaker,
1064 const std::string& message,
1088 , menu_handler_(menu_handler)
1089 , team_num_(menu_handler.
pc_.current_side())
1094 using chmap::get_commands_list;
1095 using chmap::command_failed;
1102 const std::string&
help =
"",
1103 const std::string& usage =
"",
1104 const std::string& flags =
"")
1106 chmap::register_command(cmd, h,
help, usage, flags +
"N");
1111 chmap::register_alias(to_cmd, cmd);
1116 return chmap::get_arg(i);
1121 return chmap::get_cmd();
1126 return chmap::get_data(
n);
1130 using chmap::register_command;
1131 using chmap::register_alias;
1133 using chmap::is_enabled;
1134 using chmap::command_failed_need_arg;
1142 void do_controller();
1144 void do_foreground();
1147 void do_benchmark();
1149 void do_save_quit();
1151 void do_ignore_replay_errors();
1153 void do_next_level();
1154 void do_choose_level();
1156 void do_turn_limit();
1160 void do_unsafe_lua();
1162 void do_set_alias();
1166 void do_control_dialog();
1171 void do_undiscover();
1177 void do_toggle_draw_coordinates();
1178 void do_toggle_draw_terrain_codes();
1179 void do_toggle_draw_num_of_bitmaps();
1180 void do_toggle_whiteboard();
1181 void do_whiteboard_options();
1185 return _(
"(D) — debug only, (N) — network only, (A) — admin only");
1191 std::string space(
" ");
1192 return (c.has_flag(
'D') ? space +
_(
"(debug command)") :
"")
1193 + (c.has_flag(
'N') ? space +
_(
"(network only)") :
"")
1194 + (c.has_flag(
'A') ? space +
_(
"(admin only)") :
"")
1195 + (c.has_flag(
'S') ? space +
_(
"(not during other events)") :
"");
1198 using map::is_enabled;
1202 || (c.has_flag(
'N') && !menu_handler_.pc_.is_networked_mp())
1207 void print(
const std::string& title,
const std::string& message)
1209 menu_handler_.add_chat_message(std::time(
nullptr), title, 0, message);
1216 chmap::get_command(
"log")->flags =
"";
1217 chmap::get_command(
"version")->flags =
"";
1218 chmap::get_command(
"ignore")->flags =
"";
1219 chmap::get_command(
"friend")->flags =
"";
1220 chmap::get_command(
"remove")->flags =
"";
1222 chmap::set_cmd_prefix(
":");
1223 chmap::set_cmd_flag(
true);
1230 _(
"[<side> [on/off/full]]\n“on” = enable but retain vision, “full” = as if it’s controlled by another player"));
1233 _(
"<terrain type> [both|base|overlay]"),
"DS");
1238 _(
"command_idle^[<side> [on/off]]"));
1241 _(
"Assign control of a side to a different player or observer."),
_(
"<side> <nickname>"),
"N");
1249 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_alias(
"save",
"w");
1254 register_alias(
"quit",
"q!");
1256 register_alias(
"save_quit",
"wq");
1260 _(
"Advance to the next scenario, or scenario identified by 'id'"),
_(
"<id>"),
"DS");
1261 register_alias(
"next_level",
"n");
1263 register_alias(
"choose_level",
"cl");
1265 _(
"Change turn number (and time of day), or increase by one if no number is specified."),
_(
"[turn]"),
1268 _(
"Change turn limit, or turn the turn limit off if no number is specified or it’s −1."),
_(
"[limit]"),
1277 _(
"<command>[;<command>...]"));
1279 _(
"Invoke a dialog allowing changing control of MP sides."),
"",
"N");
1288 _(
"Modify a unit variable. (Only top level keys are supported, and advances=<number>.)"),
1289 _(
"<var>=<value>"),
"DS");
1302 register_alias(
"throw",
"fire");
1304 _(
"Toggle overlaying of x,y coordinates on hexes."));
1305 register_alias(
"show_coordinates",
"sc");
1307 _(
"Toggle overlaying of terrain codes on hexes."));
1308 register_alias(
"show_terrain_codes",
"tc");
1310 _(
"Toggle overlaying of number of bitmaps on hexes."));
1311 register_alias(
"show_num_of_bitmaps",
"bn");
1313 register_alias(
"whiteboard",
"wb");
1316 register_alias(
"whiteboard_options",
"wbo");
1320 register_alias(
a.second,
a.first);
1334 cfg[
"message"] = message;
1335 const std::time_t time = ::std::time(
nullptr);
1336 std::stringstream ss;
1338 cfg[
"time"] = ss.str();
1341 if(!
board().is_observer()) {
1347 if(private_message) {
1348 if(
board().is_observer()) {
1363 if(new_search.empty() ==
false && new_search !=
last_search_)
1373 if(args.size() == 2) {
1375 x = lexical_cast_default<int>(args[0], 0) - 1;
1376 y = lexical_cast_default<int>(args[1], 0) - 1;
1383 if(loc.
valid() ==
false) {
1398 std::string label_text = label->
text().
str();
1401 != label_text.end()) {
1410 const std::string name = ui->name();
1415 || !ui->invisible(ui->get_location())) {
1435 const std::string
msg =
VGETTEXT(
"Could not find label or unit " 1436 "containing the string ‘$search’.",
1464 menu_handler_.gui_->create_buttons();
1465 menu_handler_.gui_->queue_rerender();
1471 const std::string side_s = get_arg(1);
1472 std::string action = get_arg(2);
1473 std::transform(action.begin(), action.end(), action.begin(), tolower);
1475 const unsigned int side = side_s.empty() ? team_num_ : lexical_cast_default<unsigned int>(side_s);
1476 const bool is_your_turn = menu_handler_.pc_.current_side() ==
static_cast<int>(menu_handler_.gui_->viewing_side());
1479 symbols[
"side"] = std::to_string(side);
1481 if(side < 1 || side > menu_handler_.pc_.get_teams().size()) {
1482 command_failed(
VGETTEXT(
"Can't droid invalid side: '$side'.", symbols));
1484 }
else if(menu_handler_.board().get_team(side).is_network()) {
1485 command_failed(
VGETTEXT(
"Can't droid networked side: '$side'.", symbols));
1487 }
else if(menu_handler_.board().get_team(side).is_local()) {
1488 bool changed =
false;
1490 const bool is_human = menu_handler_.board().get_team(side).is_human();
1491 const bool is_droid = menu_handler_.board().get_team(side).is_droid();
1492 const bool is_proxy_human = menu_handler_.board().get_team(side).is_proxy_human();
1493 const bool is_ai = menu_handler_.board().get_team(side).is_ai();
1495 if(action ==
"on") {
1496 if(is_ai && !is_your_turn) {
1497 command_failed(
_(
"It is not allowed to change a side from AI to human control when it's not your turn."));
1500 if(!is_human || !is_droid) {
1501 menu_handler_.board().get_team(side).make_human();
1502 menu_handler_.board().get_team(side).make_droid();
1505 menu_handler_.pc_.send_to_wesnothd(
config {
"change_controller",
config {
"side", side,
"player",
preferences::login(),
"to", side_controller::human}});
1507 print(get_cmd(),
VGETTEXT(
"Side '$side' controller is now controlled by: AI.", symbols));
1509 print(get_cmd(),
VGETTEXT(
"Side '$side' is already droided.", symbols));
1511 }
else if(action ==
"off") {
1512 if(is_ai && !is_your_turn) {
1513 command_failed(
_(
"It is not allowed to change a side from AI to human control when it's not your turn."));
1516 if(!is_human || !is_proxy_human) {
1517 menu_handler_.board().get_team(side).make_human();
1518 menu_handler_.board().get_team(side).make_proxy_human();
1521 menu_handler_.pc_.send_to_wesnothd(
config {
"change_controller",
config {
"side", side,
"player",
preferences::login(),
"to", side_controller::human}});
1523 print(get_cmd(),
VGETTEXT(
"Side '$side' controller is now controlled by: human.", symbols));
1525 print(get_cmd(),
VGETTEXT(
"Side '$side' is already not droided.", symbols));
1527 }
else if(action ==
"full") {
1529 command_failed(
_(
"It is not allowed to change a side from human to AI control when it's not your turn."));
1532 if(!is_ai || !is_droid) {
1533 menu_handler_.board().get_team(side).make_ai();
1534 menu_handler_.board().get_team(side).make_droid();
1536 if(is_human || is_proxy_human) {
1537 menu_handler_.pc_.send_to_wesnothd(
config {
"change_controller",
config {
"side", side,
"player",
preferences::login(),
"to", side_controller::ai}});
1539 print(get_cmd(),
VGETTEXT(
"Side '$side' controller is now fully controlled by: AI.", symbols));
1541 print(get_cmd(),
VGETTEXT(
"Side '$side' is already fully AI controlled.", symbols));
1543 }
else if(action ==
"") {
1544 if(is_ai && !is_your_turn) {
1545 command_failed(
_(
"It is not allowed to change a side from AI to human control when it's not your turn."));
1548 if(is_ai || is_droid) {
1549 menu_handler_.board().get_team(side).make_human();
1550 menu_handler_.board().get_team(side).make_proxy_human();
1553 menu_handler_.pc_.send_to_wesnothd(
config {
"change_controller",
config {
"side", side,
"player",
preferences::login(),
"to", side_controller::human}});
1555 print(get_cmd(),
VGETTEXT(
"Side '$side' controller is now controlled by: human.", symbols));
1557 menu_handler_.board().get_team(side).make_human();
1558 menu_handler_.board().get_team(side).make_droid();
1561 menu_handler_.pc_.send_to_wesnothd(
config {
"change_controller",
config {
"side", side,
"player",
preferences::login(),
"to", side_controller::human}});
1563 print(get_cmd(),
VGETTEXT(
"Side '$side' controller is now controlled by: AI.", symbols));
1566 print(get_cmd(),
VGETTEXT(
"Invalid action provided for side '$side'. Valid actions are: on, off, full.", symbols));
1569 if(team_num_ == side && changed) {
1571 psc->set_player_type_changed();
1575 menu_handler_.textbox_info_.close();
1582 const std::string mode_str = get_arg(2);
1591 "terrain_type", terrain_type,
1592 "mode_str", mode_str,
1600 const std::string side_s = get_arg(1);
1601 const std::string action = get_arg(2);
1603 const unsigned int side = side_s.empty() ? team_num_ : lexical_cast_default<unsigned int>(side_s);
1605 if(side < 1 || side > menu_handler_.pc_.get_teams().size()) {
1607 symbols[
"side"] = side_s;
1608 command_failed(
VGETTEXT(
"Can't idle invalid side: '$side'.", symbols));
1610 }
else if(menu_handler_.board().get_team(side).is_network()) {
1612 symbols[
"side"] = std::to_string(side);
1613 command_failed(
VGETTEXT(
"Can't idle networked side: '$side'.", symbols));
1615 }
else if(menu_handler_.board().get_team(side).is_local_ai()) {
1617 symbols[
"side"] = std::to_string(side);
1618 command_failed(
VGETTEXT(
"Can't idle local ai side: '$side'.", symbols));
1620 }
else if(menu_handler_.board().get_team(side).is_local_human()) {
1621 if(menu_handler_.board().get_team(side).is_idle() ? action ==
" on" : action ==
" off") {
1625 menu_handler_.board().get_team(side).toggle_idle();
1626 if(team_num_ == side) {
1628 psc->set_player_type_changed();
1632 menu_handler_.textbox_info_.close();
1649 return t.
save_id() == save_id_;
1658 if(!menu_handler_.pc_.is_networked_mp()) {
1662 const std::string side = get_arg(1);
1663 const std::string player = get_arg(2);
1664 if(player.empty()) {
1665 command_failed_need_arg(2);
1669 unsigned int side_num;
1673 const auto& teams = menu_handler_.pc_.get_teams();
1674 const auto it_t = std::find_if(teams.begin(), teams.end(),
save_id_matches(side));
1676 if(it_t == teams.end()) {
1678 symbols[
"side"] = side;
1679 command_failed(
VGETTEXT(
"Can't change control of invalid side: '$side'.", symbols));
1682 side_num = it_t->side();
1686 if(side_num < 1 || side_num > menu_handler_.pc_.get_teams().size()) {
1688 symbols[
"side"] = side;
1689 command_failed(
VGETTEXT(
"Can't change control of out-of-bounds side: '$side'.", symbols));
1693 menu_handler_.request_control_change(side_num, player);
1694 menu_handler_.textbox_info_.close();
1699 const std::string side = get_arg(1);
1700 unsigned int side_num;
1705 symbols[
"side"] = side;
1706 command_failed(
VGETTEXT(
"Can't query control of invalid side: '$side'.", symbols));
1710 if(side_num < 1 || side_num > menu_handler_.pc_.get_teams().size()) {
1712 symbols[
"side"] = side;
1713 command_failed(
VGETTEXT(
"Can't query control of out-of-bounds side: '$side'.", symbols));
1718 if(!menu_handler_.board().get_team(side_num).is_proxy_human()) {
1722 if(menu_handler_.board().get_team(side_num).is_network()) {
1723 report +=
" (networked)";
1726 print(get_cmd(), report);
1731 menu_handler_.gui_->get_chat_manager().clear_chat_messages();
1737 menu_handler_.gui_->invalidate_all();
1742 display& disp = *(menu_handler_.gui_);
1757 gui2::dialogs::terrain_layers::display(disp, loc);
1773 menu_handler_.pc_.do_consolesave(get_data());
1804 std::string tag = menu_handler_.pc_.get_classification().get_tagname();
1805 std::vector<std::string>
options;
1807 if(tag !=
"multiplayer") {
1809 const std::string&
id = sc[
"id"];
1810 options.push_back(
id);
1811 if(
id == menu_handler_.gamedata().next_scenario()) {
1818 std::string scenario_id = menu_handler_.pc_.get_mp_settings().mp_scenario;
1819 if(
const config& this_scenario = menu_handler_.game_config_.
find_child(tag,
"id", scenario_id)) {
1820 std::string addon_id = this_scenario[
"addon_id"].str();
1822 if(sc[
"addon_id"] == addon_id) {
1823 std::string
id = sc[
"id"];
1824 options.push_back(
id);
1825 if(
id == menu_handler_.gamedata().next_scenario()) {
1832 std::sort(options.begin(), options.end());
1833 int choice = std::distance(options.begin(), std::lower_bound(options.begin(), options.end(), next));
1845 if(std::size_t(choice) < options.size()) {
1852 tod_manager& tod_man = menu_handler_.gamestate().tod_manager_;
1854 int turn = tod_man.
turn() + 1;
1855 const std::string&
data = get_data();
1857 turn = lexical_cast_default<int>(
data, 1);
1864 int limit = get_data().empty() ? -1 : lexical_cast_default<int>(get_data(), 1);
1871 print(get_cmd(),
_(
"Debug mode activated!"));
1874 command_failed(
_(
"Debug mode not available in network games"));
1881 print(get_cmd(),
_(
"Debug mode deactivated!"));
1888 if(!menu_handler_.gamestate().lua_kernel_) {
1897 if(!menu_handler_.gamestate().lua_kernel_) {
1902 _(
"Executing Lua code in in this manner opens your computer to potential security breaches from any " 1903 "malicious add-ons or other programs you may have installed.\n\n" 1907 print(get_cmd(),
_(
"Unsafe mode enabled!"));
1908 menu_handler_.gamestate().lua_kernel_->load_package();
1919 const std::string
data = get_data();
1920 const std::string::const_iterator j = std::find(data.begin(), data.end(),
'=');
1921 const std::string alias(data.begin(), j);
1922 if(j != data.end()) {
1923 const std::string command(j + 1, data.end());
1924 if(!command.empty()) {
1925 register_alias(command, alias);
1929 register_alias(alias, alias);
1937 const std::string command = chmap::get_actual_cmd(alias);
1938 print(get_cmd(),
"'" + alias +
"'" +
" = " +
"'" + command +
"'");
1944 const std::string
data = get_data();
1946 command_failed_need_arg(1);
1950 const std::string::const_iterator j = std::find(data.begin(), data.end(),
'=');
1951 if(j != data.end()) {
1952 const std::string name(data.begin(), j);
1953 const std::string value(j + 1, data.end());
1956 command_failed(
_(
"Variable not found"));
1968 gui2::dialogs::gamestate_inspector::display(
1974 gui2::dialogs::mp_change_control::display(menu_handler_);
1985 if(i == menu_handler_.pc_.get_units().end()) {
1987 symbols[
"unit"] = get_arg(1);
1989 "Debug command 'unit: $unit' failed: no unit selected or hovered over.",
1995 const std::string
data = get_data(1);
1997 if(parameters.size() < 2) {
2001 if(parameters[0] ==
"alignment") {
2005 symbols[
"alignment"] = get_arg(1);
2007 "Invalid alignment: '$alignment', needs to be one of lawful, neutral, chaotic, or liminal.",
2017 "name", parameters[0],
2018 "value", parameters[1],
2025 for(
const unit_type_data::unit_type_map::value_type&
i :
unit_types.
types()) {
2044 if(menu_handler_.pc_.get_map().on_board(loc)) {
2047 command_failed(
_(
"Invalid unit type"));
2052 create_and_place(*menu_handler_.gui_, menu_handler_.pc_.get_map(), menu_handler_.pc_.get_units(), loc, *ut);
2054 command_failed(
_(
"Invalid location"));
2081 menu_handler_.gui_->invalidate_all();
2086 menu_handler_.gui_->invalidate_all();
2092 menu_handler_.gui_->invalidate_all();
2097 if(
const std::shared_ptr<wb::manager>& whiteb = menu_handler_.pc_.get_whiteboard()) {
2098 whiteb->set_active(!whiteb->is_active());
2099 if(whiteb->is_active()) {
2100 print(get_cmd(),
_(
"Planning mode activated!"));
2101 whiteb->print_help_once();
2103 print(get_cmd(),
_(
"Planning mode deactivated!"));
2110 if(menu_handler_.pc_.get_whiteboard()) {
2111 menu_handler_.pc_.get_whiteboard()->options_dlg();
2132 std::string side = std::to_string(side_num);
void label_terrain(mouse_handler &mousehandler, bool team_only)
pathfind::marked_route get_route(const unit *un, map_location go_to, team &team) const
int dispatch(lua_State *L)
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...
Dialog was closed with the CANCEL button.
menu_handler & menu_handler_
bool empty() const
Is it empty?
void do_search(const std::string &new_search)
void set_current_paths(const pathfind::paths &new_paths)
virtual replay_controller * get_replay_controller() const
static synced_state get_synced_state()
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.
void add_chat_message(const std::time_t &time, const std::string &speaker, int side, const std::string &message, events::chat_handler::MESSAGE_TYPE type=events::chat_handler::MESSAGE_PRIVATE) override
void goto_leader(int side_num)
std::string format_conjunct_list(const t_string &empty, const std::vector< t_string > &elems)
Format a conjunctive list.
void show_help(const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
void queue_rerender()
Marks everything for rendering including all tiles and sidebar.
const team & get_team(int side) 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.
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
std::map< std::string, t_string > string_map
void refresh_objectives() const
Reevaluate [show_if] conditions and build a new objectives string.
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
map_location last_search_hit_
file_dialog & set_extension(const std::string &value)
Sets the default file extension for file names in save mode.
This class represents a single unit of a specific type.
void show_terrain_description(const terrain_type &t)
const unit_map & get_units() const
Various functions implementing vision (through fog of war and shroud).
void send_chat_message(const std::string &message, bool allies_only=false) override
file_dialog & set_path(const std::string &value)
Sets the initial file selection.
void speak(const config &cfg)
static manager & get_singleton()
Various functions that implement attacks and attack calculations.
config & find_child(config_key_type key, const std::string &name, const std::string &value)
Returns the first child of tag key with a name attribute containing value.
map_command_handler< console_handler > chmap
unit_iterator find_leader(int side)
static config get_recall(const std::string &unit_id, const map_location &loc, const map_location &from)
std::vector< std::string > get_commands_list() const
void clear_chat_messages()
unit_race::GENDER gender()
Gender choice from the user.
const map_location hovered_hex() const
Uses SDL and game_display::hex_clicked_on to fetch the hex the mouse is hovering, if applicable...
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, the result is calculated assuming that the unit's owner is currently active.
Shows an ok and cancel button.
std::string private_message
const t_string & text() const
menu_handler(game_display *gui, play_controller &pc)
child_itors child_range(config_key_type key)
void show_unit_list(display &gui)
void do_command(const std::string &str)
const std::string & choice() const
Unit type choice from the user.
attribute_map::value_type attribute
gui::floating_textbox & get_textbox()
void request_control_change(int side_num, const std::string &player)
void invalidate_unit()
Function to invalidate that unit status displayed on the sidebar.
void do_whiteboard_options()
bool show_everything() const
virtual std::string get_cmd() const
const unit_type * get_selected_unit_type() const
static config get_auto_shroud(bool turned_on)
Records that the player has toggled automatic shroud updates.
const terrain_type & get_terrain_info(const t_translation::terrain_code &terrain) const
unit_type_data unit_types
void print(const std::string &title, const std::string &message)
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.
const std::string & save_id() const
const color_t LABEL_COLOR
file_dialog & set_save_mode(bool value)
Sets the dialog's behavior on non-existent file name inputs.
bool chars_equal_insensitive(char a, char b)
void update_shroud_now(int side_num)
const gamemap & get_map() const
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
std::string get_unknown_exception_type()
Utility function for finding the type of thing caught with catch(...).
bool do_recruit(const std::string &name, int side_num, map_location &target_hex)
virtual void clear_messages() override
int get_selected_index() const
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
static std::string _(const char *str)
Toggle to continuously redraw the whole map.
To lexical_cast(From value)
Lexical cast converts one type to another.
bool show(const unsigned auto_close_time=0)
Shows the window.
void create_unit(mouse_handler &mousehandler)
Creates a unit (in debug mode via hotkey or context menu).
const unit_type_map & types() const
save_id_matches(const std::string &save_id)
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...
static config get_update_shroud()
Records that the player has manually updated fog/shroud.
static bfs::path get_dir(const bfs::path &dirpath)
void show_statistics(int side_num)
A single unit type that the player may recruit.
void add_chat_message(const std::time_t &time, const std::string &speaker, int side, const std::string &msg, events::chat_handler::MESSAGE_TYPE type, bool bell)
void flush_cache()
Purges all image caches.
bool get_disallow_recall() const
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
void highlight_another_reach(const pathfind::paths &paths_list, const map_location &goal=map_location::null_location())
Add more paths to highlight.
std::string path() const
Gets the current file selection.
bool logged_in_as_moderator()
Gets whether the currently logged-in user is a moderator.
std::shared_ptr< const unit > unit_const_ptr
map_location get_selected_hex() const
Overlays x,y coords on tiles.
game_board & board() const
int action_bonus_count() const
const map_location & get_last_hex() const
std::string write() const
This class stores all the data for a single 'side' (in game nomenclature).
bool end_turn(int side_num)
console_handler(menu_handler &menu_handler)
virtual void register_alias(const std::string &to_cmd, const std::string &cmd)
void dispatch(std::string cmd)
void toggle_shroud_updates(int side_num)
void set_custom_command(const std::string &command)
virtual std::string get_arg(unsigned i) const
t_string can_recruit(const std::string &name, int side_num, map_location &target_hex, map_location &recruited_from)
void throw_quit_game_exception()
void do_ignore_replay_errors()
A simple one-column listbox with OK and Cancel buttons.
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 std::string & id() const
Gets this unit's id.
void scroll_to_leader(int side, SCROLL_TYPE scroll_type=ONSCREEN, bool force=true)
Scrolls to the leader of a certain side.
const t_string & cannot_end_turn_reason()
bool hex_hosts_unit(const map_location &hex) const
Unit exists on the hex, no matter if friend or foe.
void disable_units_highlight()
Use this to disable hovering an unit from highlighting its movement range.
std::string label
What to show in the filter's drop-down list.
int w() const
Effective map width.
bool is_enabled(const chmap::command &c) const
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...
This file contains the settings handling of the widget library.
EXIT_STATUS start(const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.
const terrain_label * set_label(const map_location &loc, const t_string &text, const int creator=-1, const std::string &team="", const color_t 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="")
void do_create()
Implements the (debug mode) console command that creates a unit.
const t_string & type_name() const
The name of the unit in the current language setting.
Applies the planned unit map for the duration of the struct's life.
static bool execute(game_board &board, const int viewing_team, int &selected_side_number)
std::string get_user_data_dir()
void clear(const std::string &, bool force)
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 do_toggle_draw_coordinates()
const std::unique_ptr< gui::button > & check() const
bool ignore_replay_errors
bool on_board_with_border(const map_location &loc) const
void recall(int side_num, const map_location &last_hex)
void end_unit_turn(mouse_handler &mousehandler, int side_num)
void set_show_fps(bool value)
Encapsulates the map of the game.
std::vector< team > & get_teams()
const t_string & name() const
Gets this unit's translatable display name.
The basic class for representing 8-bit RGB or RGBA colour values.
virtual const std::set< std::string > & observers() const override
void recruit(int side_num, const map_location &last_hex)
const std::string & last_recruit() const
REMOVE_EMPTY: remove empty elements.
void do_speak(const std::string &message, bool allies_only=false)
bool is_enemy(int n) const
const map_location & get_goto() const
The map location to which this unit is moving over multiple turns, if any.
Object which temporarily resets a unit's movement.
void add_rename(const std::string &name, const map_location &loc)
Shows a yes and no button.
const std::string & id() const
The id for this unit_type.
Managing the AIs lifecycle - headers TODO: Refactor history handling and internal commands...
std::size_t count(const map_location &loc) const
Separates background and foreground terrain layers.
Structure which holds a single route and marks for special events.
bool no_choice() const
Whether the user actually chose a unit type or not.
std::shared_ptr< wb::manager > get_whiteboard() const
const terrain_label * get_label(const map_location &loc, const std::string &team_name) const
const char * what() const noexcept
void invalidate_all()
Function to invalidate all tiles.
void set_message_private(bool value)
game_events::manager * game_events
void show_unit_description(const unit &u)
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
const std::string & gender_string(unit_race::GENDER gender)
Encapsulates the map of the game.
bool auto_shroud_updates() const
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
Various functions related to moving units.
bool user_end_turn() const
Check whether the user ended their turn.
unit_iterator find(std::size_t id)
game_state & gamestate() const
Various functions related to the creation of units (recruits, recalls, and placed units)...
actions::undo_list & get_undo_stack()
bool has_moved() const
Checks if this unit has moved.
std::string current_team_name() const
void recalculate_labels()
std::string id
Text to match against addon_info.tags()
void write_file(const std::string &fname, const std::string &data, std::ios_base::openmode mode)
Throws io_exception if an error occurs.
virtual bool is_networked_mp() const
void continue_move(mouse_handler &mousehandler, int side_num)
static void print(std::stringstream &sstr, const std::string &queue, const std::string &id)
void add_alias(const std::string &alias, const std::string &command)
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.
bool is_observer() const
Check if we are an observer in this game.
int selected_index() const
Returns the selected item index after displaying.
void execute_gotos(mouse_handler &mousehandler, int side_num)
virtual void highlight_hex(map_location hex) override
Function to highlight a location.
static constexpr std::optional< enum_type > get_enum(const std::string_view value)
Converts a string into its enum equivalent.
Game configuration data as global variables.
std::string get_command_flags_description(const chmap::command &c) const
void do_toggle_draw_num_of_bitmaps()
An exception object used when an IO error occurs.
void terrain_description(mouse_handler &mousehandler)
Define the game's event mechanism.
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.
ONLY IF whiteboard is currently active, applies the planned unit map for the duration of the struct's...
const display_context & get_disp_context() const
void unit_hold_position(mouse_handler &mousehandler, int side_num)
const std::string & team_name() const
bool on_board(const map_location &loc) const
Tell if a location is on the map.
void change_side(mouse_handler &mousehandler)
void(chat_command_handler ::* command_handler)()
std::set< std::string > & encountered_units()
static void ignore_error_function(const std::string &message)
A function to be passed to run_in_synced_context to ignore the error.
Definitions for the terrain builder.
void show(gui::TEXTBOX_MODE mode, const std::string &label, const std::string &check_label, bool checked, game_display &gui)
void set_goto(const map_location &new_goto)
Sets this unit's long term destination.
void set_ellipses(bool ison)
void cycle_units(const bool browse, const bool reverse=false)
void kill_unit(mouse_handler &mousehandler)
Handling of system events.
bool operator()(const team &t) const
display_chat_manager & get_chat_manager()
void do_toggle_whiteboard()
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 is_village(const map_location &loc) const
virtual std::string get_data(unsigned n=1) const
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.
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.
const gamemap & get_map() const
To store label data Class implements logic for rendering.
events::mouse_handler & get_mouse_handler_base() override
Get a reference to a mouse handler member a derived class uses.
Overlays number of bitmaps on tiles.
const std::unique_ptr< gui::textbox > & box() const
unit_map::iterator current_unit()
bool unhighlight_reach()
Reset highlighting of paths.
std::vector< std::string > split(const config_attribute_value &val)
void show_enemy_moves(bool ignore_units, int side_num)
const map_location & get_location() const
The current map location this unit is at.
static color_t get_side_color(int side)
void set_selected_index(int index)
Sets the initially selected item index (-1 by default).
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
A variable-expanding proxy for the config class.
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.
void set_action_bonus_count(const int count)
Standard logging facilities (interface).
static std::string sgettext(const char *str)
Object which contains all the possible locations a unit can move to, with associated best routes to t...
recall_list_manager & recall_list()
static const map_location & null_location()
Overlays terrain codes on tiles.
Container associating units to locations.
std::string get_command_flags_description(const map_command_handler< chat_command_handler >::command &c) const
std::string get_flags_description() const
static vconfig empty_vconfig()
static config get_recruit(const std::string &type_id, const map_location &loc, const map_location &from)
retval
Default window/dialog return values.
int side() const
The side this unit belongs to.
bool player_acted() const
Returns true if the player has performed any actions this turn.
Dialog was closed with the OK button.
gui::floating_textbox textbox_info_
void send_to_server(const config &cfg) override
A config object defines a single node in a WML file, with access to child nodes.
void notify_event(const std::string &name, const config &data)
const std::string & str() const
void do_toggle_draw_terrain_codes()
const config & get_alias()
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()
std::vector< std::string > get_commands_list()
static map_location::DIRECTION n
void repeat_recruit(int side_num, const map_location &last_hex)
int h() const
Effective map height.
void move_unit_to_loc(const unit_map::iterator &ui, const map_location &target, bool continue_move, int side_num, mouse_handler &mousehandler)
Thrown when a lexical_cast fails.
void clear_labels(const std::string &, bool)
This shows the debug-mode dialog to create new units on the map.
const unsigned int team_num_
int movement_left() const
Gets how far a unit can move, considering the incapacitated flag.
unit_map::iterator find_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false)
virtual void send_to_wesnothd(const config &, const std::string &="unknown") const
Display units performing various actions: moving, attacking, and dying.
std::string variation() const
Variation choice from the user.
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="")
std::vector< map_location > & steps
void set_debug(bool new_debug)
static plugins_manager * get()
void show_objectives() const
void add_label(const terrain_label *)
const std::string observer_team_name
observer team name used for observer team chat
void do_ai_formula(const std::string &str, int side_num, mouse_handler &mousehandler)
file_dialog & set_title(const std::string &value)
Sets the current dialog title text.
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.