#include <controller_base.hpp>
Public Member Functions | |
controller_base (const config &game_config, CVideo &video) | |
virtual | ~controller_base () |
void | play_slice (bool is_delay_enabled=true) |
void | apply_keyboard_scroll (int x, int y) |
void | set_scroll_up (bool on) |
void | set_scroll_down (bool on) |
void | set_scroll_left (bool on) |
void | set_scroll_right (bool on) |
Public Member Functions inherited from events::sdl_handler | |
virtual void | process_event () |
virtual void | draw () |
virtual void | volatile_draw () |
virtual void | volatile_undraw () |
virtual bool | requires_event_focus (const SDL_Event *=nullptr) const |
virtual void | process_help_string (int, int) |
virtual void | process_tooltip_string (int, int) |
virtual void | join () |
virtual void | join (context &c) |
virtual void | join_same (sdl_handler *parent) |
virtual void | leave () |
virtual void | join_global () |
virtual void | leave_global () |
Static Public Member Functions | |
static const config & | get_theme (const config &game_config, std::string theme_name) |
Protected Member Functions | |
virtual bool | is_browsing () const |
virtual events::mouse_handler_base & | get_mouse_handler_base ()=0 |
Get a reference to a mouse handler member a derived class uses. More... | |
virtual display & | get_display ()=0 |
Get a reference to a display member a derived class uses. More... | |
virtual soundsource::manager * | get_soundsource_man () |
Get (optionally) a soundsources manager a derived class uses. More... | |
virtual plugins_context * | get_plugins_context () |
Get (optionally) a plugins context a derived class uses. More... | |
virtual hotkey::command_executor * | get_hotkey_command_executor () |
Get (optionally) a command executor to handle context menu events. More... | |
virtual bool | have_keyboard_focus () |
Derived classes should override this to return false when arrow keys should not scroll the map, hotkeys not processed etc, for example when a textbox is active. More... | |
virtual std::vector< std::string > | additional_actions_pressed () |
bool | handle_scroll (int mousex, int mousey, int mouse_flags, double joystickx, double joysticky) |
Handle scrolling by keyboard, joystick and moving mouse near map edges. More... | |
void | handle_event (const SDL_Event &event) |
Process mouse- and keypress-events from SDL. More... | |
void | handle_window_event (const SDL_Event &) |
virtual void | process_focus_keydown_event (const SDL_Event &event) |
Process keydown (only when the general map display does not have focus). More... | |
virtual void | process_keydown_event (const SDL_Event &event) |
Process keydown (always). More... | |
virtual void | process_keyup_event (const SDL_Event &event) |
Process keyup (always). More... | |
virtual void | show_menu (const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu, display &disp) |
virtual void | execute_action (const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu) |
virtual bool | in_context_menu (hotkey::HOTKEY_COMMAND command) const |
Protected Member Functions inherited from video2::draw_layering | |
draw_layering (const bool auto_join=true) | |
virtual | ~draw_layering () |
Protected Member Functions inherited from events::sdl_handler | |
sdl_handler (const bool auto_join=true) | |
virtual | ~sdl_handler () |
virtual std::vector < sdl_handler * > | handler_members () |
Protected Attributes | |
const config & | game_config_ |
CKey | key_ |
bool | scrolling_ |
bool | scroll_up_ |
bool | scroll_down_ |
bool | scroll_left_ |
bool | scroll_right_ |
joystick_manager | joystick_manager_ |
Definition at line 58 of file controller_base.hpp.
Definition at line 32 of file controller_base.cpp.
|
virtual |
Definition at line 45 of file controller_base.cpp.
|
inlineprotectedvirtual |
Reimplemented in editor::editor_controller.
Definition at line 108 of file controller_base.hpp.
Referenced by play_slice().
|
protectedvirtual |
Definition at line 314 of file controller_base.cpp.
References hotkey::command_executor::can_execute_command(), hotkey::command_executor::execute_action(), get_display(), hotkey::get_hotkey_command(), get_hotkey_command_executor(), and mp_ui_alerts::items.
Referenced by play_slice().
|
protectedpure virtual |
Get a reference to a display member a derived class uses.
Implemented in play_controller, and editor::editor_controller.
Referenced by execute_action(), handle_event(), handle_scroll(), and play_slice().
|
inlineprotectedvirtual |
Get (optionally) a command executor to handle context menu events.
Reimplemented in play_controller, and editor::editor_controller.
Definition at line 98 of file controller_base.hpp.
Referenced by execute_action(), handle_event(), and show_menu().
|
protectedpure virtual |
Get a reference to a mouse handler member a derived class uses.
Implemented in play_controller, and editor::editor_controller.
Referenced by handle_event(), handle_scroll(), and play_slice().
|
inlineprotectedvirtual |
Get (optionally) a plugins context a derived class uses.
Reimplemented in play_controller.
Definition at line 93 of file controller_base.hpp.
Referenced by play_slice().
|
inlineprotectedvirtual |
Get (optionally) a soundsources manager a derived class uses.
Reimplemented in play_controller.
Definition at line 88 of file controller_base.hpp.
Referenced by play_slice().
|
static |
Definition at line 341 of file controller_base.cpp.
References ERR_DP, config::find_child(), and preferences::theme().
Referenced by replay_controller::add_replay_theme(), play_controller::hotkey_handler::execute_command(), handle_event(), play_controller::init(), and replay_controller::rebuild_replay_theme().
|
protectedvirtual |
Process mouse- and keypress-events from SDL.
Calls various virtual function to allow specialized behavior of derived classes.
Implements events::sdl_handler.
Definition at line 49 of file controller_base.cpp.
References hotkey::execute_command(), hotkey::hotkey_command::get_command_by_command(), get_display(), get_hotkey_command_executor(), get_mouse_handler_base(), get_theme(), have_keyboard_focus(), hotkey::HOTKEY_QUIT_GAME, gui::in_dialog(), is_browsing(), mp_ui_alerts::items, hotkey::jbutton_event(), hotkey::jhat_event(), hotkey::key_event(), hotkey::mbutton_event(), events::mouse_handler_base::mouse_motion_event(), events::mouse_handler_base::mouse_press(), events::mouse_handler_base::mouse_wheel(), process_focus_keydown_event(), process_keydown_event(), process_keyup_event(), SDL_EVENTMASK, and show_menu().
|
protected |
Handle scrolling by keyboard, joystick and moving mouse near map edges.
Definition at line 136 of file controller_base.cpp.
References preferences::get(), get_display(), get_mouse_handler_base(), events::mouse_handler_base::get_scroll_start(), display::get_theme(), display::h(), display::map_outside_area(), theme::menus(), preferences::middle_click_scrolls(), preferences::mouse_scroll_enabled(), preferences::mouse_scroll_threshold(), sdl::point_in_rect(), round_double(), display::scroll(), scroll_down_, scroll_left_, scroll_right_, preferences::scroll_speed(), scroll_up_, SDL_APPMOUSEFOCUS, SDL_GetAppState, events::mouse_handler_base::set_scroll_start(), display::w(), map_location::x, and map_location::y.
Referenced by play_slice().
|
inlineprotectedvirtual |
Implements events::sdl_handler.
Definition at line 125 of file controller_base.hpp.
|
protectedvirtual |
Derived classes should override this to return false when arrow keys should not scroll the map, hotkeys not processed etc, for example when a textbox is active.
Reimplemented in play_controller.
Definition at line 119 of file controller_base.cpp.
Referenced by handle_event().
|
protectedvirtual |
Definition at line 336 of file controller_base.cpp.
Referenced by editor::editor_controller::show_menu(), play_controller::hotkey_handler::show_menu(), and show_menu().
|
inlineprotectedvirtual |
Reimplemented in play_controller.
Definition at line 74 of file controller_base.hpp.
Referenced by handle_event(), and play_slice().
void controller_base::play_slice | ( | bool | is_delay_enabled = true | ) |
Definition at line 203 of file controller_base.cpp.
References display::action_pressed(), additional_actions_pressed(), CVideo::delay(), display::draw(), execute_action(), get_display(), display::get_map(), get_mouse_handler_base(), get_plugins_context(), joystick_manager::get_scroll_axis_pair(), get_soundsource_man(), handle_scroll(), is_browsing(), theme::action::items(), theme::menu::items(), joystick_manager_, theme::object::location(), display::menu_pressed(), events::mouse_handler_base::mouse_motion(), events::mouse_handler_base::mouse_update(), display::mouseover_hex(), gamemap::on_board(), display::ONSCREEN_WARP, events::pump(), events::raise_draw_event(), events::raise_process_event(), screen_area(), display::scroll_to_tile(), scrolling_, SDL_APPACTIVE, SDL_GetAppState, show_menu(), and joystick_manager::update_highlighted_hex().
Referenced by playsingle_controller::handle_generic_event(), game_lua_kernel::intf_delay(), playsingle_controller::linger(), editor::editor_controller::main_loop(), playmp_controller::play_linger_turn(), replay_controller::play_side_impl(), play_controller::play_slice_catch(), unit_animator::wait_for_end(), wait_ingame(), and unit_animator::wait_until().
|
protectedvirtual |
Process keydown (only when the general map display does not have focus).
Reimplemented in play_controller.
Definition at line 124 of file controller_base.cpp.
Referenced by handle_event().
|
protectedvirtual |
Process keydown (always).
Overridden in derived classes
Reimplemented in play_controller.
Definition at line 128 of file controller_base.cpp.
Referenced by handle_event().
|
protectedvirtual |
Process keyup (always).
Overridden in derived classes
Reimplemented in play_controller, and editor::editor_controller.
Definition at line 132 of file controller_base.cpp.
Referenced by handle_event().
void controller_base::set_scroll_down | ( | bool | on | ) |
Definition at line 364 of file controller_base.cpp.
References preferences::editor::TransitionUpdateMode::on, and scroll_down_.
Referenced by editor::editor_controller::scroll_down().
void controller_base::set_scroll_left | ( | bool | on | ) |
Definition at line 369 of file controller_base.cpp.
References preferences::editor::TransitionUpdateMode::on, and scroll_left_.
Referenced by editor::editor_controller::scroll_left().
void controller_base::set_scroll_right | ( | bool | on | ) |
Definition at line 374 of file controller_base.cpp.
References preferences::editor::TransitionUpdateMode::on, and scroll_right_.
Referenced by editor::editor_controller::scroll_right().
void controller_base::set_scroll_up | ( | bool | on | ) |
Definition at line 359 of file controller_base.cpp.
References preferences::editor::TransitionUpdateMode::on, and scroll_up_.
Referenced by editor::editor_controller::scroll_up().
|
protectedvirtual |
Reimplemented in editor::editor_controller.
Definition at line 291 of file controller_base.cpp.
References hotkey::command_executor::can_execute_command(), hotkey::get_hotkey_command(), get_hotkey_command_executor(), i, hotkey::hotkey_command::id, in_context_menu(), mp_ui_alerts::items, and hotkey::command_executor::show_menu().
Referenced by play_controller::hotkey_handler::execute_command(), handle_event(), and play_slice().
|
protected |
Definition at line 149 of file controller_base.hpp.
Referenced by editor::editor_controller::editor_controller(), play_controller::init(), play_controller::load_game(), and editor::editor_controller::preferences().
|
protected |
Definition at line 156 of file controller_base.hpp.
Referenced by play_slice().
|
protected |
Definition at line 150 of file controller_base.hpp.
Referenced by editor::editor_controller::editor_controller().
|
protected |
Definition at line 153 of file controller_base.hpp.
Referenced by handle_scroll(), and set_scroll_down().
|
protected |
Definition at line 154 of file controller_base.hpp.
Referenced by handle_scroll(), and set_scroll_left().
|
protected |
Definition at line 155 of file controller_base.hpp.
Referenced by handle_scroll(), and set_scroll_right().
|
protected |
Definition at line 152 of file controller_base.hpp.
Referenced by handle_scroll(), and set_scroll_up().
|
protected |
Definition at line 151 of file controller_base.hpp.
Referenced by play_slice().