Pyrogenesis  trunk
ICmpSelectable.h
Go to the documentation of this file.
1 /* Copyright (C) 2017 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_ICMPSELECTABLE
19 #define INCLUDED_ICMPSELECTABLE
20 
21 #include "ps/CStrIntern.h"
23 
24 struct CColor;
25 
26 class ICmpSelectable : public IComponent
27 {
28 public:
29 
30  enum EOverlayType {
31  /// A single textured quad overlay, intended for entities that move around much, like units (e.g. foot soldiers, etc).
33  /// A more complex textured line overlay, composed of several textured line segments. Intended for entities that do not
34  /// move often, such as buildings (structures).
36  };
37 
39  {
46 
47  SOverlayDescriptor() : m_LineThickness(0) { }
48  };
49 
50  /**
51  * Returns true if the entity is only selectable in Atlas editor, e.g. a decorative visual actor.
52  */
53  virtual bool IsEditorOnly() const = 0;
54 
55  /**
56  * Set the selection highlight state.
57  * The highlight is typically a circle/square overlay around the unit.
58  * @param color color and alpha of the selection highlight. Set color.a = 0 to hide the highlight.
59  * @param selected whether the entity is selected; affects desaturation for always visible highlights.
60  */
61  virtual void SetSelectionHighlight(const CColor& color, bool selected) = 0;
62 
63  /**
64  * Enables or disables rendering of an entity's selectable.
65  * @param visible Whether the selectable should be visible.
66  */
67  virtual void SetVisibility(bool visible) = 0;
68 
69  /**
70  * Enables or disables rendering of all entities selectable.
71  * @param visible Whether the selectable should be visible.
72  */
73  static void SetOverrideVisibility(bool visible)
74  {
76  }
77 
78  /**
79  * Set the alpha of the selection highlight. Set to 0 to hide the highlight.
80  */
81  virtual void SetSelectionHighlightAlpha(float alpha) = 0;
82 
83  DECLARE_INTERFACE_TYPE(Selectable)
84 
85  // TODO: this is slightly ugly design; it would be nice to change the component system to support per-component-type data
86  // and methods, where we can keep settings like these. Note that any such data store would need to be per-component-manager
87  // and not entirely global, to support multiple simulation instances.
88  static bool ms_EnableDebugOverlays; // ms for member static
89 
90 protected:
91  static bool m_OverrideVisible;
92 };
93 
94 #endif // INCLUDED_ICMPSELECTABLE
Definition: IComponent.h:33
A single textured quad overlay, intended for entities that move around much, like units (e...
Definition: ICmpSelectable.h:32
static bool ms_EnableDebugOverlays
Definition: ICmpSelectable.h:88
static void SetOverrideVisibility(bool visible)
Enables or disables rendering of all entities selectable.
Definition: ICmpSelectable.h:73
SOverlayDescriptor()
Definition: ICmpSelectable.h:47
float m_LineThickness
Definition: ICmpSelectable.h:45
Definition: Shapes.h:36
Definition: ICmpSelectable.h:26
Definition: ICmpSelectable.h:38
static bool m_OverrideVisible
Definition: ICmpSelectable.h:91
EOverlayType
Definition: ICmpSelectable.h:30
Interned 8-bit strings.
Definition: CStrIntern.h:37
CStrIntern m_QuadTexture
Definition: ICmpSelectable.h:41
#define DECLARE_INTERFACE_TYPE(iname)
Definition: Interface.h:23
CStrIntern m_LineTexture
Definition: ICmpSelectable.h:43
CStrIntern m_QuadTextureMask
Definition: ICmpSelectable.h:42
A more complex textured line overlay, composed of several textured line segments. ...
Definition: ICmpSelectable.h:35
CStrIntern m_LineTextureMask
Definition: ICmpSelectable.h:44
virtual void SetVisibility(bool visible)=0
Enables or disables rendering of an entity&#39;s selectable.
virtual void SetSelectionHighlight(const CColor &color, bool selected)=0
Set the selection highlight state.
virtual bool IsEditorOnly() const =0
Returns true if the entity is only selectable in Atlas editor, e.g.
virtual void SetSelectionHighlightAlpha(float alpha)=0
Set the alpha of the selection highlight.
EOverlayType m_Type
Definition: ICmpSelectable.h:40