The Battle for Wesnoth  1.15.2+dev
Public Member Functions | Private Attributes | List of all members
editor::mouse_action_unit Class Reference

Unit placement action class. More...

#include <mouse_action_unit.hpp>

Inheritance diagram for editor::mouse_action_unit:
Inheritance graph

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_actionclick_left (editor_display &disp, int x, int y)
 TODO. More...
 
editor_actionup_left (editor_display &disp, int x, int y)
 TODO. More...
 
editor_actiondrag_left (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
 Drag operation. More...
 
editor_actiondrag_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_actionclick_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_locationaffected_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_actiondrag_right (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
 Drag operation. More...
 
virtual editor_actiondrag_end_right (editor_display &disp, int x, int y)
 
virtual editor_actionup_right (editor_display &disp, int x, int y)
 
virtual editor_actionkey_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::menutoolbar_button () const
 Getter for the (possibly nullptr) associated menu/button. More...
 
common_paletteget_palette ()
 Getter for the associated palette. More...
 
virtual bool supports_brushes () const
 Whether we need the brush bar, is used to grey it out. More...
 

Private Attributes

bool click_
 
map_location start_hex_
 
unit_paletteunit_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::terrain_code &fg, const t_translation::terrain_code &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 CKeykey_
 Key presses, used for modifiers (alt, shift) in some operations. More...
 

Detailed Description

Unit placement action class.

Definition at line 27 of file mouse_action_unit.hpp.

Constructor & Destructor Documentation

◆ mouse_action_unit()

editor::mouse_action_unit::mouse_action_unit ( const CKey key,
unit_palette palette 
)
inline

Definition at line 30 of file mouse_action_unit.hpp.

Member Function Documentation

◆ click_left()

editor_action * editor::mouse_action_unit::click_left ( editor_display disp,
int  x,
int  y 
)
virtual

◆ click_right()

editor_action* editor::mouse_action_unit::click_right ( editor_display disp,
int  x,
int  y 
)
inlinevirtual

A click, possibly the beginning of a drag.

Must be overridden.

Implements editor::mouse_action.

Definition at line 62 of file mouse_action_unit.hpp.

References set_mouse_overlay(), and set_unit_mouse_overlay().

◆ drag_end_left()

editor_action * editor::mouse_action_unit::drag_end_left ( editor_display disp,
int  x,
int  y 
)
virtual

Drag end replaces the unit when clicked left, or adjusts the facing when clicked right.

Reimplemented from editor::mouse_action.

Definition at line 140 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(), and start_hex_.

Referenced by has_context_menu().

◆ drag_left()

editor_action * editor::mouse_action_unit::drag_left ( editor_display disp,
int  x,
int  y,
bool &  partial,
editor_action last_undo 
)
virtual

Drag operation.

A click should have occurred earlier. Defaults to no action.

Reimplemented from editor::mouse_action.

Definition at line 103 of file mouse_action_unit.cpp.

References click_, display::hex_clicked_on(), and start_hex_.

Referenced by has_context_menu().

◆ has_context_menu()

bool editor::mouse_action_unit::has_context_menu ( ) const
inlinevirtual

Reimplemented from editor::mouse_action.

Definition at line 38 of file mouse_action_unit.hpp.

References click_left(), drag_end_left(), drag_left(), move(), and up_left().

◆ move()

void editor::mouse_action_unit::move ( editor_display disp,
const map_location hex 
)
virtual

◆ set_mouse_overlay()

void editor::mouse_action_unit::set_mouse_overlay ( editor_display disp)
virtual

Set the mouse overlay for this action.

Defaults to an empty overlay.

Reimplemented from editor::mouse_action.

Definition at line 237 of file mouse_action_unit.cpp.

References editor::editor_palette< Item >::selected_fg_item(), set_unit_mouse_overlay(), and unit_palette_.

Referenced by click_right(), and move().

◆ set_unit_mouse_overlay()

void editor::mouse_action_unit::set_unit_mouse_overlay ( editor_display disp,
const unit_type u 
)

◆ up_left()

editor_action * editor::mouse_action_unit::up_left ( editor_display disp,
int  x,
int  y 
)
virtual

Member Data Documentation

◆ click_

bool editor::mouse_action_unit::click_
private

Definition at line 70 of file mouse_action_unit.hpp.

Referenced by click_left(), drag_end_left(), drag_left(), and up_left().

◆ start_hex_

map_location editor::mouse_action_unit::start_hex_
private

Definition at line 72 of file mouse_action_unit.hpp.

Referenced by click_left(), drag_end_left(), and drag_left().

◆ unit_palette_

unit_palette& editor::mouse_action_unit::unit_palette_
private

Definition at line 73 of file mouse_action_unit.hpp.

Referenced by set_mouse_overlay(), and up_left().


The documentation for this class was generated from the following files: