The Battle for Wesnoth  1.19.0-dev
mouse_action_unit.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
3  by Fabian Mueller <fabianmueller5@gmx.de>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
20 
21 class CKey;
22 
23 namespace editor {
24 
25 /**
26  * Unit placement action class
27  */
29 {
30 public:
32  : mouse_action(palette, key)
33  , click_(false)
34  , start_hex_()
36  {
37  }
38 
39  bool has_context_menu() const override {
40  return true;
41  }
42 
43  void move(editor_display& disp, const map_location& hex) override;
44 
45  /**
46  * TODO
47  */
48  std::unique_ptr<editor_action> click_left(editor_display& disp, int x, int y) override;
49 
50  /**
51  * TODO
52  */
53  std::unique_ptr<editor_action> up_left(editor_display& disp, int x, int y) override;
54 
55  std::unique_ptr<editor_action> drag_left(editor_display& disp, int x, int y, bool& partial, editor_action* last_undo) override;
56 
57  /**
58  * Drag end replaces the unit when clicked left, or adjusts
59  * the facing when clicked right.
60  */
61  std::unique_ptr<editor_action> drag_end_left(editor_display& disp, int x, int y) override;
62 
63  std::unique_ptr<editor_action> click_right(editor_display& /*disp*/, int /*x*/, int /*y*/) override {
64  return nullptr;
65  }
66 
67  virtual void set_mouse_overlay(editor_display& disp) override;
68  void set_unit_mouse_overlay(editor_display& disp, const unit_type& u);
69 
70 private:
71  bool click_;
72 
75 };
76 
77 
78 } //end namespace editor
Class that keeps track of all the keys on the keyboard.
Definition: key.hpp:29
Base class for all editor actions.
Definition: action_base.hpp:42
Unit placement action class.
virtual void set_mouse_overlay(editor_display &disp) override
Set the mouse overlay for this action.
std::unique_ptr< editor_action > click_left(editor_display &disp, int x, int y) override
TODO.
std::unique_ptr< editor_action > drag_left(editor_display &disp, int x, int y, bool &partial, editor_action *last_undo) override
Drag operation.
bool has_context_menu() const override
mouse_action_unit(const CKey &key, unit_palette &palette)
std::unique_ptr< editor_action > click_right(editor_display &, int, int) override
A click, possibly the beginning of a drag.
std::unique_ptr< editor_action > up_left(editor_display &disp, int x, int y) override
TODO.
std::unique_ptr< editor_action > drag_end_left(editor_display &disp, int x, int y) override
Drag end replaces the unit when clicked left, or adjusts the facing when clicked right.
void set_unit_mouse_overlay(editor_display &disp, const unit_type &u)
void move(editor_display &disp, const map_location &hex) override
Mouse move (not a drag).
A mouse action receives events from the controller, and responds to them by creating an appropriate e...
Palette where the terrain to be drawn can be selected.
A single unit type that the player may recruit.
Definition: types.hpp:43
std::vector< color_t > palette(const color_range &cr)
Creates a reference color palette from a color range.
Definition: color_range.cpp:84
Manage the empty-palette in the editor.
Definition: action.cpp:31
Encapsulates the map of the game.
Definition: location.hpp:38