38 #define ERR_G LOG_STREAM(err, lg::general())
39 #define WRN_G LOG_STREAM(warn, lg::general())
40 #define LOG_G LOG_STREAM(info, lg::general())
41 #define DBG_G LOG_STREAM(debug, lg::general())
42 #define ERR_CF LOG_STREAM(err, log_config)
51 template<
typename TFunc>
61 const bool res = func(filename, video);
66 _(
"Screenshot creation failed.\n\n"
67 "Make sure there is enough space on the drive holding Wesnoth’s player resource files and that file permissions are set up correctly."));
363 std::vector<std::string>
items = items_arg;
364 if (items.empty())
return;
372 res = mmenu.
show(xloc, yloc);
374 if (res < 0 ||
size_t(res) >= items.size())
return;
379 SDL_GetMouseState(&x,&y);
390 std::vector<std::string>
items = items_arg;
396 while(i != items.end()) {
408 const std::string base_image_name =
"icons/action/" + command +
"_25.png";
409 const std::string pressed_image_name =
"icons/action/" + command +
"_25-pressed.png";
416 return "icons/arrows/short_arrow_right_25.png~CROP(3,3,18,18)";
423 return pressed_image_name +
"~CROP(3,3,18,18)";
425 return base_image_name +
"~CROP(3,3,18,18)";
443 std::vector<std::string>
result;
444 bool has_image =
false;
446 for (
size_t i = 0;
i < items.size(); ++
i) {
450 std::stringstream str;
453 if (img.empty() ==
false) {
461 str << menu->
title();
467 str << menu->
title();
480 result.push_back(str.str());
497 switch (event.type) {
505 }
else if (
exec_ !=
nullptr) {
509 case SDL_JOYBUTTONDOWN:
510 case SDL_JOYBUTTONUP:
513 }
else if (
exec_ !=
nullptr) {
517 case SDL_MOUSEBUTTONDOWN:
518 case SDL_MOUSEBUTTONUP:
521 }
else if (
exec_ !=
nullptr) {
545 if (!executor)
return;
551 if (!executor)
return;
553 if (!hk->active() || hk->is_disabled()) {
557 bool press =
event.type == SDL_KEYDOWN ||
event.type == SDL_JOYBUTTONDOWN ||
event.type == SDL_MOUSEBUTTONDOWN;
565 if (executor !=
nullptr) {
576 switch (command.
id) {
602 make_screenshot(
_(
"Screenshot"), executor->
get_video(), &::screenshot);
613 static struct before_muted_s
615 bool playing_sound,playing_music;
616 before_muted_s() : playing_sound(
false),playing_music(
false){}
635 DBG_G <<
"command_executor: unknown command number " << command.
id <<
", ignoring.\n";
646 if (!button)
continue;
657 button->enable(enabled);
663 if (!button)
continue;
666 for (
const std::string& command : action.items()) {
671 button->set_overlay(
"icons/action/" + command);
672 if (!tooltip.empty())
673 button->set_tooltip_string(tooltip);
677 if (!can_execute)
continue;
684 button->set_check(
true);
688 button->set_check(
false);
698 button->enable(enabled);
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
bool set_sound(bool ison)
virtual void toggle_shroud_updates()
void show_error_message(CVideo &video, const std::string &message, bool message_use_markup)
Shows an error message to the user.
virtual ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND, int) const
std::string get_next_filename(const std::string &name, const std::string &extension)
Get the next free filename using "name + number (3 digits) + extension" maximum 1000 files then start...
GLenum GLsizei const GLuint GLboolean enabled
virtual void stop_network()
virtual void repeat_recruit()
static void display(CVideo &video, lua_kernel_base *lk)
Display a new console, using given video and lua kernel.
virtual void lua_console()
static void quit_to_title()
void handle_event(const SDL_Event &event)
virtual void save_replay()
virtual void create_unit()
virtual void goto_leader()
void set_default_zoom()
Sets the zoom amount to the default.
virtual void toggle_ellipses()
std::string selected_menu
void enable_mouse_scroll(bool value)
virtual void clear_labels()
virtual void play_replay()
virtual void ai_formula()
Stores all information related to functions that can be bound to hotkeys.
virtual void terrain_description()
std::string get_screenshot_dir()
virtual void show_chat_log()
virtual void select_hex()
const std::vector< menu > & menus() const
void mbutton_event(const SDL_Event &event, command_executor *executor)
virtual void clear_messages()
virtual void move_action()
std::string unchecked_menu
GLint GLint GLint GLint GLint GLint y
const std::vector< std::string > items
virtual void recalculate_minimap()
int show(int xloc, int yloc)
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
virtual void select_and_action()
virtual void whiteboard_execute_action()
virtual void scroll_up(bool)
virtual void preferences()
virtual void toggle_grid()
static void event_execute(const SDL_Event &event, command_executor *executor)
virtual void replay_show_each()
virtual CVideo & get_video()=0
Keyboard shortcuts for game actions.
virtual void stop_replay()
virtual void whiteboard_delete_action()
virtual bool can_execute_command(const hotkey_command &command, int index=-1) const =0
virtual void reset_replay()
bool save_image(const locator &i_locator, const std::string &filename)
virtual void whiteboard_bump_up_action()
virtual void label_terrain(bool)
virtual void deselect_hex()
std::vector< std::string > get_menu_images(display &, const std::vector< std::string > &items_arg)
static lg::log_domain log_config("config")
GLdouble GLdouble GLdouble b
virtual void replay_next_move()
virtual void show_statistics()
static const int zoom_amount
virtual void label_settings()
static UNUSEDNOWARN std::string _(const char *str)
std::string deselected_menu
virtual display & get_display()=0
void execute_command(const hotkey_command &command, command_executor *executor, int index, bool press)
virtual void replay_show_team1()
void jbutton_event(const SDL_Event &event, command_executor *executor)
void toggle_minimap_draw_units()
virtual void continue_move()
const hotkey_ptr get_hotkey(const SDL_Event &event)
Iterate through the list of hotkeys and return a hotkey that matches the SDL_Event and the current ke...
virtual void unit_hold_position()
void recalculate_minimap()
Schedule the minimap for recalculation.
virtual void scroll_right(bool)
virtual void end_unit_turn()
void set_menu(menu *const m)
virtual void user_command()
virtual void show_enemy_moves(bool)
const menu * get_menu_item(const std::string &key) const
void toggle_minimap_draw_terrain()
map_display and display: classes which take care of displaying the map and game-data on the screen...
static const style hotkeys_style
void set_animate_map(bool value)
void jhat_event(const SDL_Event &event, command_executor *executor)
void toggle_minimap_draw_villages()
const std::string & title() const
virtual void start_network()
static void quit_to_desktop()
virtual void status_table()
const std::vector< action > & actions() const
virtual void scroll_left(bool)
virtual void update_shroud_now()
void toggle_minimap_terrain_coding()
void execute_action(const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu, display &gui)
virtual void replay_show_everything()
std::string get_menu_image(display &disp, const std::string &command, int index=-1) const
virtual void scroll_down(bool)
GLint GLint GLint GLint GLint x
void toggle_minimap_movement_coding()
void set_fullscreen(bool ison)
Declarations for File-IO.
std::string get_names(std::string id)
Returns a comma-separated string of hotkey names.
virtual void whiteboard_suppose_dead()
virtual void replay_next_turn()
void key_event(const SDL_Event &event, command_executor *executor)
const action * get_action_item(const std::string &key) const
const std::string & get_description(const std::string &command)
virtual void whiteboard_bump_down_action()
virtual bool execute_command(const hotkey_command &command, int index=-1, bool press=true)
GLuint const GLchar * name
bool mouse_scroll_enabled()
virtual void change_side()
char const COLUMN_SEPARATOR
virtual void replay_next_side()
const hotkey::HOTKEY_COMMAND id
the names are strange: the "hotkey::HOTKEY_COMMAND" is named id, and the string to identify the objec...
virtual void whiteboard_execute_all_actions()
virtual void objectives()
virtual void show_menu(const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu, display &gui)
virtual void rename_unit()
virtual void set_button_state()
bool set_music(bool ison)
Standard logging facilities (interface).
CVideo & video()
Gets the underlying screen object.
virtual std::string get_action_image(hotkey::HOTKEY_COMMAND, int) const
virtual void cycle_units()
virtual void cycle_back_units()
virtual void map_screenshot()
void recalculate_minimap()
const hotkey_command & get_hotkey_command(const std::string &command)
returns the hotkey_command with the given name
virtual void replay_exit()
bool file_exists(const std::string &name)
Returns true if a file or directory with such name already exists.
GLsizei const GLcharARB ** string
virtual void zoom_default()
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
HOTKEY_COMMAND get_id(const std::string &command)
returns get_hotkey_command(command).id
virtual void replay_skip_animation()
virtual void change_language()
virtual void whiteboard_toggle()
bool set_zoom(int amount, bool absolute=false)
Zooms the display by the specified amount.
static void display(const std::string &path, CVideo &video)
The display function.
basic_handler(command_executor *exec)
virtual void toggle_accelerated_speed()
bool screenshot(const std::string &filename, bool map_screenshot=false)
Save a (map-)screenshot and return whether the operation succeeded.
virtual void unit_description()
virtual void custom_command()