39 : play_controller_(pc)
40 , menu_handler_(pc.get_menu_handler())
41 , mouse_handler_(pc.get_mouse_handler_base())
46 , last_context_menu_x_(0)
47 , last_context_menu_y_(0)
53 return &play_controller_.get_display();
57 return play_controller_.gamestate();
61 return play_controller_.gamestate();
87 play_controller_.save_game();
91 play_controller_.save_replay();
95 play_controller_.save_map();
99 play_controller_.load_game();
107 int x =
gui()->get_location_x(
gui()->mouseover_hex());
108 int y =
gui()->get_location_y(
gui()->mouseover_hex());
110 SDL_MouseButtonEvent
event;
116 event.state = SDL_PRESSED;
137 int x =
gui()->get_location_x(
gui()->mouseover_hex());
138 int y =
gui()->get_location_y(
gui()->mouseover_hex());
140 SDL_MouseButtonEvent
event;
146 event.state = SDL_PRESSED;
169 play_controller_.undo();
173 play_controller_.redo();
222 play_controller_.set_scroll_up(on);
227 play_controller_.set_scroll_down(on);
232 play_controller_.set_scroll_left(on);
237 play_controller_.set_scroll_right(on);
244 unsigned i =
static_cast<unsigned>(
index);
245 if(i < savenames_.size() && !savenames_[
i].empty()) {
247 load_autosave(savenames_[i]);
249 }
else if ( i < wml_commands_.size() && wml_commands_[
i] ) {
250 if (!wml_command_pager_->capture(*wml_commands_[i])) {
258 int prefixlen = wml_menu_hotkey_prefix.length();
273 unsigned i =
static_cast<unsigned>(
index);
274 if((i < savenames_.size() && !savenames_[
i].empty())
275 || (i < wml_commands_.size() && wml_commands_[
i])) {
336 return !
linger() && play_controller_.enemies_visible();
339 return !play_controller_.is_networked_mp();
345 return play_controller_.can_redo();
347 return play_controller_.can_undo();
369 if (newitems.size() > 5) {
370 std::vector<std::string> subitems;
371 subitems.push_back(newitems[0]);
372 subitems.push_back(newitems[1]);
373 subitems.push_back(newitems[newitems.size() / 3]);
374 subitems.push_back(newitems[newitems.size() * 2 / 3]);
375 subitems.push_back(newitems.back());
386 for (
unsigned int i = 0;
i < items.size(); ++
i) {
387 if (items[
i] ==
"AUTOSAVES") {
388 items.erase(items.begin() +
i);
389 std::vector<std::string> newitems;
390 std::vector<std::string> newsaves;
391 for (
unsigned int turn = play_controller_.turn();
turn != 0;
turn--) {
396 newitems.push_back(
_(
"Back to Turn ") + std::to_string(
turn));
404 newitems.push_back(
_(
"Back to Start"));
412 items.insert(items.begin()+
i, newitems.begin(), newitems.end());
413 savenames_.insert(savenames_.end(), newsaves.begin(), newsaves.end());
416 savenames_.push_back(
"");
422 wml_commands_.clear();
423 for (
unsigned int i = 0;
i < items.size(); ++
i) {
424 if (items[
i] ==
"wml") {
425 std::vector<std::string> newitems;
428 items.erase(items.begin() +
i);
429 wml_command_pager_->update_ref(&
gamestate().get_wml_menu_items());
432 wml_commands_, newitems);
433 items.insert(items.begin()+
i, newitems.begin(), newitems.end());
447 last_context_menu_x_ = xloc;
448 last_context_menu_y_ = yloc;
451 std::vector<std::string>
items = items_arg;
454 while(i != items.end()) {
455 if (*i ==
"AUTOSAVES") {
463 if(*i !=
"wml" && (!can_execute_command(*cmd) || (context_menu && !
in_context_menu(cmd->
id)))) {
471 expand_autosaves(items);
472 expand_wml_commands(items);
477 command_executor::show_menu(items, xloc, yloc, context_menu, disp);
489 const int viewing_side =
gui()->viewing_side();
493 if ( !play_controller_.get_map_const().is_keep(last_hex) &&
494 !play_controller_.get_map_const().is_castle(last_hex) )
508 if(index >= 0 && index < static_cast<int>(wml_commands_.size())) {
514 return command_executor::get_action_image(command, index);
static const config & get_theme(const config &game_config, std::string theme_name)
void set_turbo(bool ison)
void goto_leader(int side_num)
bool minimap_draw_units()
hotkey_handler(play_controller &, saved_game &)
virtual void scroll_up(bool on)
virtual void show_menu(const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu, display &disp)
void mouse_press(const SDL_MouseButtonEvent &event, const bool browse)
virtual void unit_description()
std::string label
Name of the game (e.g.
void expand_wml_commands(std::vector< std::string > &items)
Replaces "wml" in items with all active WML menu items for the current field.
events::mouse_handler mouse_handler_
virtual hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command, int index) const
virtual void deselect_hex()
virtual void show_chat_log()
bool fire_item(const std::string &id, const map_location &hex, game_data &gamedata, filter_context &fc, unit_map &units) const
Fires the menu item with the given id.
bool minimap_movement_coding()
virtual void scroll_left(bool on)
virtual void goto_leader()
virtual void status_table()
virtual void preferences()
Stores all information related to functions that can be bound to hotkeys.
virtual void move_action()
GLint GLint GLint GLint GLint GLint y
const std::vector< std::string > items
const map_location & get_last_hex() const
virtual std::string get_action_image(hotkey::HOTKEY_COMMAND, int index) const
This file implements all the hotkey handling and menu details for play controller.
const SDL_Color NORMAL_COLOR
void select_hex(const map_location &hex, const bool browse, const bool highlight=true, const bool fire_event=true)
void show_statistics(int side_num)
events::menu_handler menu_handler_
bool in_context_menu(hotkey::HOTKEY_COMMAND command) const
Determines whether the command should be in the context menu or not.
virtual void toggle_grid()
bool minimap_draw_villages()
virtual void scroll_down(bool on)
This class stores all the data for a single 'side' (in game nomenclature).
virtual void terrain_description()
static UNUSEDNOWARN std::string _(const char *str)
virtual void scroll_right(bool on)
std::map< std::string, t_string > string_map
bool side_can_recruit_on(int side, map_location loc) const
Checks if any of the sides leaders can recruit at a location.
virtual void select_and_action()
Applies the planned unit map for the duration of the struct's life.
void status_table(int selected=0)
static bool execute_command(std::string &command_line)
bool save_game_exists(const std::string &name, compression::format compressed)
Returns true if there is already a savegame with that name.
virtual void save_replay()
bool viewing_team_is_playing() const
void expand_autosaves(std::vector< std::string > &items)
virtual bool can_execute_command(const hotkey::hotkey_command &command, int index=-1) const
Check if a command can be executed.
static void trim_items(std::vector< std::string > &newitems)
const team & viewing_team() const
virtual void toggle_accelerated_speed()
static const std::string wml_menu_hotkey_prefix
virtual void show_enemy_moves(bool ignore_units)
Encapsulates the map of the game.
virtual void select_hex()
void cycle_back_units(const bool browse)
Declarations for a container for wml_menu_item.
Various functions related to the creation of units (recruits, recalls, and placed units)...
std::string format_extension(format compression_format)
virtual void toggle_ellipses()
virtual void load_autosave(const std::string &filename)
virtual void show_statistics()
const std::string command
The command is unique.
Exception used to signal that the user has decided to abort a game, and to load another game instead...
void terrain_description(mouse_handler &mousehandler)
GLint GLint GLint GLint GLint x
std::string get_names(std::string id)
Returns a comma-separated string of hotkey names.
void objectives(int side_num)
void cycle_units(const bool browse, const bool reverse=false)
void show_menu(const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu, display &disp)
GLuint const GLchar * name
compression::format save_compression_format()
unit_map::iterator current_unit()
bool minimap_draw_terrain()
const hotkey::HOTKEY_COMMAND id
the names are strange: the "hotkey::HOTKEY_COMMAND" is named id, and the string to identify the objec...
game_display * gui() const
game_classification & classification()
void show_enemy_moves(bool ignore_units, int side_num)
virtual void left_mouse_click()
virtual bool execute_command(const hotkey::hotkey_command &command, int index=-1, bool press=true)
virtual void cycle_back_units()
virtual void right_mouse_click()
const hotkey_command & get_hotkey_command(const std::string &command)
returns the hotkey_command with the given name
virtual void objectives()
GLsizei const GLcharARB ** string
virtual bool in_context_menu(hotkey::HOTKEY_COMMAND command) const
virtual void cycle_units()
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()
game_events::wmi_container & get_wml_menu_items()