41 : play_controller_(pc)
42 , menu_handler_(pc.get_menu_handler())
43 , mouse_handler_(pc.get_mouse_handler_base())
47 , last_context_menu_x_(0)
48 , last_context_menu_y_(0)
111 SDL_MouseButtonEvent event;
117 event.state = SDL_PRESSED;
146 SDL_MouseButtonEvent event;
152 event.state = SDL_PRESSED;
257 unsigned i =
static_cast<unsigned>(
index);
270 std::string name = cmd.
id.substr(prefixlen);
276 return command_executor::do_execute_command(cmd, index, press, release);
282 unsigned i =
static_cast<unsigned>(
index);
343 std::size_t humans_notme_cnt = 0;
345 if(
t.is_network_human()) {
395 if(newitems.size() > 5) {
396 std::vector<T> subitems;
397 subitems.push_back(std::move(newitems[0]));
398 subitems.push_back(std::move(newitems[1]));
399 subitems.push_back(std::move(newitems[newitems.size() / 3]));
400 subitems.push_back(std::move(newitems[newitems.size() * 2 / 3]));
401 subitems.push_back(std::move(newitems.back()));
412 auto pos = items.erase(items.begin() +
i);
413 std::vector<config> newitems;
414 std::vector<std::string> newsaves;
427 newitems.emplace_back(
"label",
_(
"Back to Turn ") + std::to_string(
turn));
433 newitems.emplace_back(
"label",
_(
"Back to Start"));
440 items.insert(pos, newitems.begin(), newitems.end());
449 auto pos = items.erase(items.begin() +
i);
450 std::vector<config> newitems;
456 items.insert(pos, newitems.begin(), newitems.end());
466 std::vector<config>
items;
467 for(
const auto&
item : items_arg) {
468 const std::string&
id =
item[
"id"];
472 items.emplace_back(
"id",
id);
481 for(
int i = items.size() - 1;
i >= 0;
i--) {
482 if(items[
i][
"id"] ==
"AUTOSAVES") {
484 }
else if(items[
i][
"id"] ==
"wml") {
524 if(index >= 0 && index < static_cast<int>(
wml_commands_.size())) {
530 return command_executor::get_action_image(command, index);
virtual void search() override
virtual void toggle_accelerated_speed() override
const map_location & mouseover_hex() const
void set_turbo(bool ison)
const team & viewing_team() const
bool is_keep(const map_location &loc) const
bool discard_previous
An announcement according these options should replace the previous announce (typical of fast announc...
void set_scroll_up(bool on)
virtual void toggle_grid() override
void goto_leader(int side_num)
void set_scroll_down(bool on)
bool minimap_draw_units()
Class for start-of-scenario saves.
hotkey_handler(play_controller &, saved_game &)
virtual void unit_list() override
std::map< std::string, t_string > string_map
void expand_autosaves(std::vector< config > &items, int i)
void show_menu(const std::vector< config > &items_arg, int xloc, int yloc, bool context_menu, display &disp) override
bool is_castle(const map_location &loc) const
const unit_map & get_units() const
game_events::wmi_manager & get_wml_menu_items()
virtual void show_chat_log() override
virtual void select_hex() override
game_display & get_display() override
Get a reference to a display member a derived class uses.
static std::shared_ptr< save_index_class > default_saves_dir()
Returns an instance for managing saves in filesystem::get_saves_dir()
bool minimap_movement_coding()
virtual void load_game() override
virtual void select_and_action() override
bool enemies_visible() const
Stores all information related to functions that can be bound to hotkeys.
const std::vector< std::string > items
const gamemap & get_map() const
HOTKEY_COMMAND command
The command associated with this hotkey.
std::string id
The unique ID.
static std::string _(const char *str)
This file implements all the hotkey handling and menu details for play controller.
void select_hex(const map_location &hex, const bool browse, const bool highlight=true, const bool fire_event=true)
virtual bool can_execute_command(const hotkey::hotkey_command &command, int index=-1) const override
Check if a command can be executed.
bool fire_item(const std::string &id, const map_location &hex, game_data &gamedata, filter_context &fc, unit_map &units, bool is_key_hold_repeat=false) const
Fires the menu item with the given id.
play_controller & play_controller_
References to parent object / constituents.
void show_statistics(int side_num)
virtual void move_action() override
virtual void objectives() override
void touch_action(const map_location hex, bool browse)
std::vector< std::string > savenames_
virtual void mouse_press(const SDL_MouseButtonEvent &event, const bool browse)
void expand_wml_commands(std::vector< config > &items, int i)
Replaces "wml" in items with all active WML menu items for the current field.
virtual void deselect_hex() override
bool is_lingering() const
virtual void show_enemy_moves(bool ignore_units) override
bool minimap_draw_villages()
std::string get_names(const std::string &id)
Returns a comma-separated string of hotkey names.
const map_location & get_last_hex() const
This class stores all the data for a single 'side' (in game nomenclature).
virtual void show_statistics() override
virtual void terrain_description() override
virtual void save_replay() override
virtual void undo() override
virtual void preferences() override
virtual void speak() override
bool is_linger_mode() const
virtual void save_game() override
Applies the planned unit map for the duration of the struct's life.
bool in_context_menu(hotkey::HOTKEY_COMMAND command) const
Determines whether the command should be in the context menu or not.
events::menu_handler & menu_handler_
std::string create_filename() const
Build the filename according to the specific savegame's needs.
std::vector< team > & get_teams()
std::shared_ptr< const game_events::wml_menu_item > const_item_ptr
A smart pointer used when retrieving menu items.
virtual void right_mouse_click() override
int show_menu(lua_State *L)
Displays a popup menu at the current mouse position Best used from a [set_menu_item], to show a submenu.
virtual void unit_description() override
virtual void scroll_up(bool on) override
Declarations for a container for wml_menu_item.
static const std::string wml_menu_hotkey_prefix
bool is_browsing() const override
const color_t NORMAL_COLOR
Encapsulates the map of the game.
bool auto_shroud_updates() const
void cycle_back_units(const bool browse)
Various functions related to the creation of units (recruits, recalls, and placed units)...
std::string format_extension(format compression_format)
virtual void left_mouse_click() override
virtual void scroll_left(bool on) override
Exception used to signal that the user has decided to abortt a game, and to load another game instead...
virtual bool do_execute_command(const hotkey::hotkey_command &command, int index=-1, bool press=true, bool release=false) override
virtual bool is_networked_mp() const
virtual void load_autosave(const std::string &filename)
virtual void cycle_units() override
void announce(const std::string &msg, const color_t &color=font::GOOD_COLOR, const announce_options &options=announce_options())
Announce a message prominently.
Holds options for calls to function 'announce' (announce).
virtual void redo() override
std::size_t playing_team() const
The playing team is the team whose turn it is.
void terrain_description(mouse_handler &mousehandler)
int get_location_y(const map_location &loc) const
void set_scroll_right(bool on)
events::mouse_handler & mouse_handler_
virtual void scroll_down(bool on) override
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
virtual void status_table() override
void cycle_units(const bool browse, const bool reverse=false)
void get_items(const map_location &hex, std::vector< std::shared_ptr< const wml_menu_item >> &items, std::vector< config > &descriptions, filter_context &fc, game_data &gamedata, unit_map &units) const
Returns the menu items that can be shown for the given location.
compression::format save_compression_format()
void set_scroll_left(bool on)
bool side_can_recruit_on(int side, map_location loc) const
Checks if any of the sides leaders can recruit at a location.
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
virtual void goto_leader() override
unit_map::iterator current_unit()
std::vector< const_item_ptr > wml_commands_
bool minimap_draw_terrain()
void show_enemy_moves(bool ignore_units, int side_num)
virtual hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command, int index) const override
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
virtual void cycle_back_units() override
virtual std::string get_action_image(hotkey::HOTKEY_COMMAND, int index) const override
int current_side() const
Returns the number of the side whose turn it is.
game_display * gui() const
virtual void scroll_right(bool on) override
virtual void touch_hex() override
bool save_game_exists(std::string name, compression::format compressed)
Returns true if there is already a savegame with this name, looking only in the default save director...
virtual void toggle_ellipses() override
const hotkey_command & get_hotkey_command(const std::string &command)
returns the hotkey_command with the given name
virtual void save_map() override
static void trim_items(std::vector< T > &newitems)
virtual void show_help() override
std::pair< std::string, unsigned > item
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...
void move_action(bool browse)
Overridden in derived class.
void select_or_action(bool browse)
bool minimap_terrain_coding()
bool viewing_team_is_playing() const