#include <controller_base.hpp>
Classes | |
class | keyup_listener |
Public Member Functions | |
controller_base () | |
virtual | ~controller_base () |
virtual void | play_slice () |
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) |
virtual hotkey::command_executor * | get_hotkey_command_executor () |
Optionally get a command executor to handle context menu events. More... | |
Public Member Functions inherited from events::sdl_handler | |
virtual void | handle_window_event (const SDL_Event &) |
virtual void | process_event () |
virtual bool | requires_event_focus (const SDL_Event *=nullptr) const |
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 () |
virtual bool | has_joined () |
virtual bool | has_joined_global () |
sdl_handler & | operator= (sdl_handler &&)=delete |
Moving would require two instances' context membership to be handled, it's simpler to delete these and require the two instances to be separately constructed / destructed. More... | |
sdl_handler (sdl_handler &&)=delete | |
Public Member Functions inherited from events::pump_monitor | |
pump_monitor () | |
virtual | ~pump_monitor () |
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 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) |
Handle scrolling by keyboard, joystick and moving mouse near map edges. More... | |
void | handle_event (const SDL_Event &event) override |
Process mouse- and keypress-events from SDL. More... | |
virtual void | process_focus_keydown_event (const SDL_Event &) |
Process keydown (only when the general map display does not have focus). More... | |
virtual void | process () override |
virtual void | process_keydown_event (const SDL_Event &) |
Process keydown (always). More... | |
virtual void | process_keyup_event (const SDL_Event &) |
Process keyup (always). More... | |
virtual void | show_menu (const std::vector< config > &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 (const hotkey::ui_command &cmd) const |
void | long_touch_callback (int x, int y) |
Protected Member Functions inherited from events::sdl_handler | |
sdl_handler (const bool auto_join=true) | |
sdl_handler (const sdl_handler &) | |
sdl_handler & | operator= (const sdl_handler &) |
virtual | ~sdl_handler () |
virtual std::vector< sdl_handler * > | handler_members () |
Protected Attributes | |
const game_config_view & | game_config_ |
CKey | key_ |
bool | scrolling_ |
bool | scroll_up_ |
bool | scroll_down_ |
bool | scroll_left_ |
bool | scroll_right_ |
std::chrono::steady_clock::time_point | last_scroll_tick_ |
double | scroll_carry_x_ |
double | scroll_carry_y_ |
Private Attributes | |
keyup_listener | key_release_listener_ |
bool | last_mouse_is_touch_ |
size_t | long_touch_timer_ |
Context menu timer. More... | |
Definition at line 66 of file controller_base.hpp.
controller_base::controller_base | ( | ) |
Definition at line 39 of file controller_base.cpp.
|
virtual |
Definition at line 56 of file controller_base.cpp.
References long_touch_timer_, and gui2::remove_timer().
|
inlineprotectedvirtual |
Reimplemented in editor::editor_controller.
Definition at line 134 of file controller_base.hpp.
Referenced by play_slice().
void controller_base::apply_keyboard_scroll | ( | int | x, |
int | y | ||
) |
|
protectedvirtual |
Definition at line 488 of file controller_base.cpp.
References hotkey::command_executor::can_execute_command(), hotkey::command_executor::execute_action(), get_display(), and get_hotkey_command_executor().
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(), long_touch_callback(), and play_slice().
|
inlinevirtual |
Optionally get a command executor to handle context menu events.
Reimplemented in play_controller, and editor::editor_controller.
Definition at line 97 of file controller_base.hpp.
Referenced by execute_action(), handle_event(), controller_base::keyup_listener::handle_event(), process(), 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(), long_touch_callback(), and play_slice().
|
inlineprotectedvirtual |
Get (optionally) a plugins context a derived class uses.
Reimplemented in play_controller.
Definition at line 121 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 115 of file controller_base.hpp.
Referenced by play_slice().
|
overrideprotectedvirtual |
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 98 of file controller_base.cpp.
References gui2::add_timer(), rect::contains(), theme::context_menu(), DOUBLE_CLICK_EVENT, hotkey::command_executor::execute_quit_command(), gui2::execute_timer(), get_display(), get_hotkey_command_executor(), get_mouse_handler_base(), events::mouse_handler_base::get_show_menu(), display::get_theme(), have_keyboard_focus(), is_browsing(), gui2::is_in_dialog(), hotkey::jbutton_event(), hotkey::jhat_event(), hotkey::key_event(), last_mouse_is_touch_, long_touch_callback(), long_touch_duration, long_touch_timer_, display::map_area(), 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(), gui2::remove_timer(), show_menu(), TIMER_EVENT, and events::mouse_handler_base::touch_motion_event().
|
protected |
Handle scrolling by keyboard, joystick and moving mouse near map edges.
Definition at line 298 of file controller_base.cpp.
References utils::contains(), video::game_canvas_size(), prefs::get(), get_display(), get_mouse_handler_base(), events::mouse_handler_base::get_scroll_start(), prefs::get_scroll_when_mouse_outside(), last_scroll_tick_, prefs::mouse_scroll_threshold(), display::scroll(), scroll_carry_x_, scroll_carry_y_, scroll_down_, scroll_left_, scroll_right_, prefs::scroll_speed(), events::mouse_handler_base::scroll_started(), scroll_up_, scrolling_, events::mouse_handler_base::set_scroll_start(), and video::window_has_mouse_focus().
Referenced by play_slice().
|
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 293 of file controller_base.cpp.
Referenced by handle_event().
|
protectedvirtual |
Definition at line 510 of file controller_base.cpp.
Referenced by show_menu(), editor::editor_controller::show_menu(), and play_controller::hotkey_handler::show_menu().
|
inlineprotectedvirtual |
Reimplemented in play_controller.
Definition at line 103 of file controller_base.hpp.
Referenced by handle_event(), and play_slice().
|
protected |
Definition at line 64 of file controller_base.cpp.
References utils::contains(), theme::context_menu(), events::mouse_handler_base::drag_threshold(), get_display(), get_mouse_handler_base(), sdl::get_mouse_state(), display::get_theme(), events::mouse_handler_base::gui(), long_touch_timer_, and show_menu().
Referenced by handle_event().
|
virtual |
Reimplemented in playmp_controller.
Definition at line 409 of file controller_base.cpp.
References display::action_pressed(), additional_actions_pressed(), events::draw(), execute_action(), video::game_canvas(), get_display(), get_mouse_handler_base(), sdl::get_mouse_state(), get_plugins_context(), get_soundsource_man(), handle_scroll(), is_browsing(), theme::action::items(), theme::menu::items(), theme::action::location(), theme::menu::location(), display::menu_pressed(), events::mouse_handler_base::mouse_update(), display::mouseover_hex(), events::pump(), events::raise_process_event(), scrolling_, and show_menu().
Referenced by synced_context::ask_server_choice(), playsingle_controller::handle_generic_event(), game_lua_kernel::impl_run_animation(), game_lua_kernel::intf_delay(), playsingle_controller::linger(), editor::editor_controller::main_loop(), replay_controller::play_side_impl(), playmp_controller::play_slice(), play_controller::play_slice_catch(), unit_animator::wait_for_end(), wait_ingame(), and unit_animator::wait_until().
|
overrideprotectedvirtual |
Implements events::pump_monitor.
Definition at line 277 of file controller_base.cpp.
References get_hotkey_command_executor(), gui2::is_in_dialog(), and hotkey::run_events().
|
inlineprotectedvirtual |
Process keydown (only when the general map display does not have focus).
Reimplemented in play_controller.
Definition at line 154 of file controller_base.hpp.
Referenced by handle_event().
|
inlineprotectedvirtual |
Process keydown (always).
Overridden in derived classes
Reimplemented in play_controller.
Definition at line 162 of file controller_base.hpp.
Referenced by handle_event().
|
inlineprotectedvirtual |
Process keyup (always).
Reimplemented in play_controller, and editor::editor_controller.
Definition at line 168 of file controller_base.hpp.
Referenced by handle_event().
|
inline |
Definition at line 81 of file controller_base.hpp.
References scroll_down_.
Referenced by editor::editor_controller::scroll_down().
|
inline |
Definition at line 86 of file controller_base.hpp.
References scroll_left_.
Referenced by editor::editor_controller::scroll_left().
|
inline |
Definition at line 91 of file controller_base.hpp.
References scroll_right_.
Referenced by editor::editor_controller::scroll_right().
|
inline |
Definition at line 76 of file controller_base.hpp.
References scroll_up_.
Referenced by editor::editor_controller::scroll_up().
|
protectedvirtual |
Reimplemented in editor::editor_controller.
Definition at line 463 of file controller_base.cpp.
References c, hotkey::command_executor::can_execute_command(), get_hotkey_command_executor(), in_context_menu(), and hotkey::command_executor::show_menu().
Referenced by handle_event(), long_touch_callback(), and play_slice().
|
protected |
Definition at line 180 of file controller_base.hpp.
Referenced by play_controller::check_next_scenario_is_known(), editor::editor_controller::editor_controller(), and editor::editor_controller::unit_editor_dialog().
|
protected |
Definition at line 182 of file controller_base.hpp.
Referenced by editor::editor_controller::editor_controller().
|
private |
Definition at line 216 of file controller_base.hpp.
|
private |
Definition at line 218 of file controller_base.hpp.
Referenced by handle_event().
|
protected |
Definition at line 190 of file controller_base.hpp.
Referenced by handle_scroll().
|
private |
Context menu timer.
Definition at line 220 of file controller_base.hpp.
Referenced by handle_event(), long_touch_callback(), and ~controller_base().
|
protected |
Definition at line 193 of file controller_base.hpp.
Referenced by handle_scroll().
|
protected |
Definition at line 194 of file controller_base.hpp.
Referenced by handle_scroll().
|
protected |
Definition at line 186 of file controller_base.hpp.
Referenced by handle_scroll(), and set_scroll_down().
|
protected |
Definition at line 187 of file controller_base.hpp.
Referenced by handle_scroll(), and set_scroll_left().
|
protected |
Definition at line 188 of file controller_base.hpp.
Referenced by handle_scroll(), and set_scroll_right().
|
protected |
Definition at line 185 of file controller_base.hpp.
Referenced by handle_scroll(), and set_scroll_up().
|
protected |
Definition at line 184 of file controller_base.hpp.
Referenced by handle_scroll(), and play_slice().