38 #include <boost/algorithm/string/predicate.hpp>
40 namespace balg = boost::algorithm;
44 , playsingle_controller_(pc)
45 , whiteboard_manager_(pc.get_whiteboard())
82 playsingle_controller_.end_turn();
153 symbols[
"hotkey"] = hk;
187 const unit* curr_unit;
210 int prefixlen = wml_menu_hotkey_prefix.length();
215 if(cmd.
id.compare(0, prefixlen, wml_menu_hotkey_prefix) == 0) {
220 return !item->is_synced() || play_controller_.can_use_synced_wml_menu();
240 && (
gui()->viewing_team().uses_fog() ||
gui()->viewing_team().uses_shroud())
241 &&
gui()->viewing_team_is_playing()
242 &&
gui()->viewing_team().is_local_human()
246 &&
gui()->viewing_team_is_playing()
247 &&
gui()->viewing_team().is_local_human()
249 &&
gui()->viewing_team().auto_shroud_updates() ==
false;
278 if (!
i.valid())
return false;
279 return i->move_interrupted();
308 return playsingle_controller_.get_replay_controller() && playsingle_controller_.get_replay_controller()->can_execute_command(cmd);
310 return playsingle_controller_.is_replay() && (!playsingle_controller_.is_networked_mp() ||
resources::recorder->
at_end());
322 auto invalid_save_file = [
this,
filename](
const std::string&
msg){
323 if(playsingle_controller_.is_networked_mp()) {
334 std::string error_log;
337 if(!error_log.empty()) {
338 invalid_save_file(
_(
"The file you have tried to load is corrupt: '") + error_log);
341 if(
savegame.child_or_empty(
"snapshot")[
"replay_pos"].to_int(-1) < 0 ) {
342 invalid_save_file(
_(
"The file you have tried to load has no replay information. "));
345 if(!playsingle_controller_.get_saved_game().get_replay().is_ancestor(
savegame.child_or_empty(
"replay"))) {
346 invalid_save_file(
_(
"The file you have tried to load is not from the current session."));
350 auto res = std::make_shared<config>(
savegame.child_or_empty(
"snapshot"));
351 auto stats = std::make_shared<config>(
savegame.child_or_empty(
"statistics"));
357 if(!playsingle_controller_.is_networked_mp()) {
360 playsingle_controller_.set_player_type_changed();
A config object defines a single node in a WML file, with access to child nodes.
void label_terrain(mouse_handler &mousehandler, bool team_only)
void update_shroud_now(int side_num)
virtual void clear_messages() override
void recall(int side_num, const map_location &last_hex)
void create_unit(mouse_handler &mousehandler)
Creates a unit (in debug mode via hotkey or context menu).
void unit_hold_position(mouse_handler &mousehandler, int side_num)
void end_unit_turn(mouse_handler &mousehandler, int side_num)
void change_side(mouse_handler &mousehandler)
void toggle_shroud_updates(int side_num)
void recruit(int side_num, const map_location &last_hex)
void continue_move(mouse_handler &mousehandler, int side_num)
void repeat_recruit(int side_num, const map_location &last_hex)
void kill_unit(mouse_handler &mousehandler)
unit_map::iterator current_unit()
map_location get_selected_hex() const
const map_location & get_last_hex() const
std::shared_ptr< wml_menu_item > item_ptr
wml_menu_item pointers
item_ptr get_item(const std::string &id) const
Gets the menu item with the specified ID.
game_events::wmi_manager & get_wml_menu_items()
@ yes_no_buttons
Shows a yes and no button.
virtual hotkey::action_state get_action_state(const hotkey::ui_command &) const override
virtual void load_autosave(const std::string &filename, bool start_replay=false)
virtual bool can_execute_command(const hotkey::ui_command &command) const override
Check if a command can be executed.
events::menu_handler menu_handler_
events::mouse_handler mouse_handler_
std::shared_ptr< wb::manager > whiteboard_manager_
virtual void select_teleport() override
virtual void continue_move() override
virtual void toggle_shroud_updates() override
virtual void end_turn() override
virtual void update_shroud_now() override
virtual void clear_labels() override
virtual void whiteboard_suppose_dead() override
virtual void end_unit_turn() override
virtual void clear_messages() override
virtual void custom_command() override
hotkey_handler(playsingle_controller &, saved_game &)
virtual void unit_hold_position() override
virtual hotkey::action_state get_action_state(const hotkey::ui_command &) const override
virtual bool can_execute_command(const hotkey::ui_command &cmd) const override
Check if a command can be executed.
virtual void recall() override
virtual void recruit() override
virtual void whiteboard_delete_action() override
virtual void change_side() override
virtual void whiteboard_execute_action() override
virtual void kill_unit() override
virtual void create_unit() override
virtual void label_terrain(bool) override
virtual void ai_formula() override
virtual void load_autosave(const std::string &filename, bool start_replay=false) override
virtual void replay_exit() override
virtual void label_settings() override
virtual void rename_unit() override
virtual void user_command() override
virtual void whiteboard_bump_up_action() override
virtual void whiteboard_toggle() override
virtual void whiteboard_bump_down_action() override
virtual void whiteboard_execute_all_actions() override
virtual void repeat_recruit() override
void delete_upcoming_commands()
To store label data Class implements logic for rendering.
This class represents a single unit of a specific type.
Declarations for File-IO.
static std::string _(const char *str)
const map_location & get_location() const
The current map location this unit is at.
std::string label
What to show in the filter's drop-down list.
An extension of play_controller::hotkey_handler, which has support for SP wesnoth features like white...
std::string get_saves_dir()
const color_t NORMAL_COLOR
void show_error_message(const std::string &msg, bool message_use_markup)
Shows an error 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.
@ CANCEL
Dialog was closed with the CANCEL button.
std::string get_names(const std::string &id)
Returns a comma-separated string of hotkey names.
action_state on_if(bool condition)
Returns action_state::on if condition is true, else action_state::off.
@ HOTKEY_WB_EXECUTE_ALL_ACTIONS
@ HOTKEY_LABEL_TEAM_TERRAIN
@ HOTKEY_UNIT_HOLD_POSITION
@ HOTKEY_REPLAY_NEXT_TURN
@ HOTKEY_REPLAY_SHOW_EVERYTHING
@ HOTKEY_REPLAY_SHOW_TEAM1
@ HOTKEY_WB_EXECUTE_ACTION
@ HOTKEY_WB_BUMP_UP_ACTION
@ HOTKEY_REPLAY_NEXT_SIDE
@ HOTKEY_REPLAY_NEXT_MOVE
@ HOTKEY_REPLAY_SKIP_ANIMATION
@ HOTKEY_WB_BUMP_DOWN_ACTION
@ HOTKEY_REPLAY_SHOW_EACH
@ HOTKEY_WB_DELETE_ACTION
void read_save_file(const std::string &dir, const std::string &name, config &cfg, std::string *error_log)
Read the complete config information out of a savefile.
std::map< std::string, t_string > string_map
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
std::string filename
Filename.
static const hotkey_command & get_command_by_command(HOTKEY_COMMAND command)
the execute_command argument was changed from HOTKEY_COMMAND to hotkey_command, to be able to call it...
Used as the main parameter for can_execute_command/do_execute_command These functions are used to exe...
hotkey::HOTKEY_COMMAND hotkey_command
The hotkey::HOTKEY_COMMAND associated with this action, HOTKEY_NULL for actions that don't allow hotk...
std::string id
The string command, never empty, describes the action uniquely.
Encapsulates the map of the game.
Applies the planned unit map for the duration of the struct's life.
Declarations for a container for wml_menu_item.