The Battle for Wesnoth  1.19.13+dev
Public Member Functions | Public Attributes | List of all members
hotkey::ui_command Struct Reference

Used as the main parameter for can_execute_command/do_execute_command These functions are used to execute hotkeys but also to execute menu items, (Most menu items point to the same action as a hotkey but not all) More...

#include <command_executor.hpp>

Public Member Functions

 ui_command (hotkey::HOTKEY_COMMAND hotkey_command, std::string_view id, int index=-1)
 
 ui_command (const hotkey::hotkey_command &cmd, int index=-1)
 
 ui_command (std::string_view id, int index=-1)
 

Public Attributes

hotkey::HOTKEY_COMMAND hotkey_command
 The hotkey::HOTKEY_COMMAND associated with this action, HOTKEY_NULL for actions that don't allow hotkey binding. More...
 
std::string id
 The string command, never empty, describes the action uniquely. More...
 
int index
 When this action was the result of a menu click, this is the index of the clicked item in the menu. More...
 

Detailed Description

Used as the main parameter for can_execute_command/do_execute_command These functions are used to execute hotkeys but also to execute menu items, (Most menu items point to the same action as a hotkey but not all)

Definition at line 43 of file command_executor.hpp.

Constructor & Destructor Documentation

◆ ui_command() [1/3]

hotkey::ui_command::ui_command ( hotkey::HOTKEY_COMMAND  hotkey_command,
std::string_view  id,
int  index = -1 
)
inline

Definition at line 56 of file command_executor.hpp.

◆ ui_command() [2/3]

hotkey::ui_command::ui_command ( const hotkey::hotkey_command cmd,
int  index = -1 
)
inlineexplicit

Definition at line 62 of file command_executor.hpp.

◆ ui_command() [3/3]

hotkey::ui_command::ui_command ( std::string_view  id,
int  index = -1 
)
inlineexplicit

Definition at line 67 of file command_executor.hpp.

Member Data Documentation

◆ hotkey_command

hotkey::HOTKEY_COMMAND hotkey::ui_command::hotkey_command

The hotkey::HOTKEY_COMMAND associated with this action, HOTKEY_NULL for actions that don't allow hotkey binding.

different actions of the ame type might have the same HOTKEY_COMMAND (like different wml menu items that allow hotkey bindings.). This is preferred to be used for comparision over id (for example being an enum makes it impossible to make typos in the id and its faster, plus c++ unfortunately doesn't allow switch statements with strings)

Definition at line 50 of file command_executor.hpp.

Referenced by replay_controller::can_execute_command(), playsingle_controller::hotkey_handler::can_execute_command(), editor::editor_controller::can_execute_command(), play_controller::hotkey_handler::can_execute_command(), playmp_controller::hotkey_handler::can_execute_command(), hotkey::command_executor::do_execute_command(), editor::editor_controller::do_execute_command(), play_controller::hotkey_handler::get_action_state(), playsingle_controller::hotkey_handler::get_action_state(), editor::editor_controller::get_action_state(), and play_controller::hotkey_handler::in_context_menu().

◆ id

std::string hotkey::ui_command::id

The string command, never empty, describes the action uniquely.

when the action is the result of a menu click this matches the id element of the clicked item (the id parameter of show_menu)

Definition at line 53 of file command_executor.hpp.

Referenced by playsingle_controller::hotkey_handler::can_execute_command(), and play_controller::hotkey_handler::do_execute_command().

◆ index

int hotkey::ui_command::index

When this action was the result of a menu click, this is the index of the clicked item in the menu.

Definition at line 55 of file command_executor.hpp.

Referenced by editor::editor_controller::can_execute_command(), editor::editor_controller::do_execute_command(), and editor::editor_controller::get_action_state().


The documentation for this struct was generated from the following file: