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