Unit placement action class. More...
#include <mouse_action_unit.hpp>
Public Member Functions | |
mouse_action_unit (const CKey &key, unit_palette &palette) | |
bool | has_context_menu () const |
void | move (editor_display &disp, const map_location &hex) |
Mouse move (not a drag). More... | |
editor_action * | click_left (editor_display &disp, int x, int y) |
TODO. More... | |
editor_action * | up_left (editor_display &disp, int x, int y) |
TODO. More... | |
editor_action * | drag_left (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo) |
Drag operation. More... | |
editor_action * | drag_end_left (editor_display &disp, int x, int y) |
Drag end replaces the unit when clicked left, or adjusts the facing when clicked right. More... | |
editor_action * | click_right (editor_display &, int, int) |
A click, possibly the beginning of a drag. More... | |
virtual void | set_mouse_overlay (editor_display &disp) |
Set the mouse overlay for this action. More... | |
void | set_unit_mouse_overlay (editor_display &disp, const unit_type &u) |
Public Member Functions inherited from editor::mouse_action | |
mouse_action (common_palette &palette, const CKey &key) | |
virtual | ~mouse_action () |
void | update_brush_highlights (editor_display &disp, const map_location &hex) |
Unconditionally update the brush highlights for the current tool when hex is the center location. More... | |
virtual std::set< map_location > | affected_hexes (editor_display &disp, const map_location &hex) |
Locations that would be affected by a click, used by move to update highlights. More... | |
virtual editor_action * | drag_right (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo) |
Drag operation. More... | |
virtual editor_action * | drag_end_right (editor_display &disp, int x, int y) |
virtual editor_action * | up_right (editor_display &disp, int x, int y) |
virtual editor_action * | key_event (editor_display &disp, const SDL_Event &e) |
Function called by the controller on a key event for the current mouse action. More... | |
void | set_toolbar_button (const theme::menu *value) |
Helper variable setter - pointer to a toolbar menu/button used for highlighting the current action. More... | |
const theme::menu * | toolbar_button () const |
Getter for the (possibly nullptr) associated menu/button. More... | |
common_palette & | get_palette () |
Getter for the associated palette. More... | |
virtual bool | supports_brushes () |
Whether we need the brush bar, is used to grey it out. More... | |
Private Attributes | |
bool | click_ |
map_location | start_hex_ |
unit_palette & | unit_palette_ |
Additional Inherited Members | |
Protected Member Functions inherited from editor::mouse_action | |
bool | has_alt_modifier () const |
bool | has_shift_modifier () const |
bool | has_ctrl_modifier () const |
void | set_terrain_mouse_overlay (editor_display &disp, const t_translation::t_terrain &fg, const t_translation::t_terrain &bg) |
Helper function for derived classes that need a active-terrain mouse overlay. More... | |
Protected Attributes inherited from editor::mouse_action | |
map_location | previous_move_hex_ |
The hex previously used in move operations. More... | |
const CKey & | key_ |
Key presses, used for modifiers (alt, shift) in some operations. More... | |
Unit placement action class.
Definition at line 28 of file mouse_action_unit.hpp.
|
inline |
Definition at line 31 of file mouse_action_unit.hpp.
|
virtual |
TODO.
Implements editor::mouse_action.
Definition at line 76 of file mouse_action_unit.cpp.
References click_, unit_map::end(), unit_map::find(), display::get_map(), display::get_units(), display::hex_clicked_on(), gamemap::on_board(), set_unit_mouse_overlay(), start_hex_, and resources::units.
|
inlinevirtual |
A click, possibly the beginning of a drag.
Must be overridden.
Implements editor::mouse_action.
Definition at line 63 of file mouse_action_unit.hpp.
|
virtual |
Drag end replaces the unit when clicked left, or adjusts the facing when clicked right.
Reimplemented from editor::mouse_action.
Definition at line 129 of file mouse_action_unit.cpp.
References click_, unit_map::end(), unit_map::find(), display::get_map(), display::get_units(), display::hex_clicked_on(), gamemap::on_board(), start_hex_, and resources::units.
|
virtual |
Drag operation.
A click should have occurred earlier. Defaults to no action.
Reimplemented from editor::mouse_action.
Definition at line 92 of file mouse_action_unit.cpp.
References click_, display::hex_clicked_on(), and start_hex_.
|
inlinevirtual |
Reimplemented from editor::mouse_action.
Definition at line 39 of file mouse_action_unit.hpp.
|
virtual |
Mouse move (not a drag).
Never changes anything (other than temporary highlights and similar)
Reimplemented from editor::mouse_action.
Definition at line 33 of file mouse_action_unit.cpp.
References tooltips::add_tooltip(), tooltips::clear_tooltips(), unit_map::end(), unit_map::find(), get_adjacent_tiles(), display::get_location_x(), display::get_location_y(), display::get_units(), display::hex_size(), i, display::invalidate(), utils::join(), N_, editor::mouse_action::previous_move_hex_, set_mouse_overlay(), display::set_mouseover_hex_overlay(), resources::units, and editor::mouse_action::update_brush_highlights().
|
virtual |
Set the mouse overlay for this action.
Defaults to an empty overlay.
Reimplemented from editor::mouse_action.
Definition at line 226 of file mouse_action_unit.cpp.
References editor::editor_palette< Item >::selected_fg_item(), set_unit_mouse_overlay(), and unit_palette_.
Referenced by move().
void editor::mouse_action_unit::set_unit_mouse_overlay | ( | editor_display & | disp, |
const unit_type & | u | ||
) |
Definition at line 232 of file mouse_action_unit.cpp.
References adjust_surface_alpha(), unit_type::flag_rgb(), image::get_image(), team::get_side_color_index(), display::get_zoom_factor(), unit_type::image(), scale_surface(), display::set_mouseover_hex_overlay(), and display::viewing_side().
Referenced by click_left(), and set_mouse_overlay().
|
virtual |
TODO.
Reimplemented from editor::mouse_action.
Definition at line 99 of file mouse_action_unit.cpp.
References click_, ERR_ED, unit_type_data::find(), unit_type::genders(), display::get_map(), display::hex_clicked_on(), unit_type::id(), gamemap::on_board(), editor::editor_palette< Item >::selected_fg_item(), unit_palette_, unit_types, and display::viewing_side().
|
private |
Definition at line 71 of file mouse_action_unit.hpp.
Referenced by click_left(), drag_end_left(), drag_left(), and up_left().
|
private |
Definition at line 73 of file mouse_action_unit.hpp.
Referenced by click_left(), drag_end_left(), and drag_left().
|
private |
Definition at line 74 of file mouse_action_unit.hpp.
Referenced by set_mouse_overlay(), and up_left().