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