LCOV - code coverage report
Current view: top level - source/simulation2/components - ICmpSelectable.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 4 5 80.0 %
Date: 2023-01-19 00:18:29 Functions: 2 5 40.0 %

          Line data    Source code
       1             : /* Copyright (C) 2018 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 "simulation2/system/Interface.h"
      22             : 
      23             : struct CColor;
      24             : 
      25           0 : class ICmpSelectable : public IComponent
      26             : {
      27             : public:
      28             :     /**
      29             :      * Returns true if the entity is only selectable in Atlas editor, e.g. a decorative visual actor.
      30             :      */
      31             :     virtual bool IsEditorOnly() const = 0;
      32             : 
      33             :     /**
      34             :      * Sets the selection highlight state.
      35             :      * The highlight is typically a circle/square overlay around the unit.
      36             :      * @param color color and alpha of the selection highlight. Set color.a = 0 to hide the highlight.
      37             :      * @param selected whether the entity is selected; affects desaturation for always visible highlights.
      38             :      */
      39             :     virtual void SetSelectionHighlight(const CColor& color, bool selected) = 0;
      40             : 
      41             :     /**
      42             :      * Enables or disables rendering of an entity's selectable.
      43             :      * @param visible Whether the selectable should be visible.
      44             :      */
      45             :     virtual void SetVisibility(bool visible) = 0;
      46             : 
      47             :     /**
      48             :     * Enables or disables rendering of all entities selectable.
      49             :     * @param visible Whether the selectable should be visible.
      50             :     */
      51           2 :     static void SetOverrideVisibility(bool visible)
      52             :     {
      53           2 :         ICmpSelectable::m_OverrideVisible = visible;
      54           2 :     }
      55             : 
      56             :     /**
      57             :      * Updates the selection color to match the current owner.
      58             :      */
      59             :     virtual void UpdateColor() = 0;
      60             : 
      61             :     /**
      62             :      * Sets the alpha of the selection highlight. Set to 0 to hide the highlight.
      63             :      */
      64             :     virtual void SetSelectionHighlightAlpha(float alpha) = 0;
      65             : 
      66         116 :     DECLARE_INTERFACE_TYPE(Selectable)
      67             : 
      68             :     // TODO: this is slightly ugly design; it would be nice to change the component system to support per-component-type data
      69             :     // and methods, where we can keep settings like these. Note that any such data store would need to be per-component-manager
      70             :     // and not entirely global, to support multiple simulation instances.
      71             :     static bool ms_EnableDebugOverlays; // ms for member static
      72             : 
      73             : protected:
      74             :     static bool m_OverrideVisible;
      75             : };
      76             : 
      77             : #endif // INCLUDED_ICMPSELECTABLE

Generated by: LCOV version 1.13