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_ICMPOVERLAYRENDERER 19 : #define INCLUDED_ICMPOVERLAYRENDERER 20 : 21 : #include "simulation2/system/Interface.h" 22 : 23 : #include "lib/file/vfs/vfs_path.h" 24 : #include "maths/FixedVector2D.h" 25 : #include "maths/FixedVector3D.h" 26 : #include "simulation2/system/Component.h" 27 : 28 : #include <js/Value.h> 29 : #include <string> 30 : 31 : /** 32 : * Interface for rendering 'overlay' objects (typically sprites), automatically 33 : * positioned relative to the entity. 34 : * Usually driven by the StatusBars component. 35 : * 36 : * (TODO: maybe we should add a "category" argument to Reset/AddSprite/etc, 37 : * so different components can each maintain independent sets of overlays here?) 38 : */ 39 186 : class ICmpOverlayRenderer : public IComponent 40 : { 41 : public: 42 : /** 43 : * Delete all sprites that have been previously added. 44 : */ 45 : virtual void Reset() = 0; 46 : 47 : /** 48 : * Add a new textured billboard sprite to be rendered. 49 : * @param textureName filename of texture to render. 50 : * @param corner0,corner1 coordinates of sprite's corners, in world-space units oriented with the camera plane, 51 : * relative to the sprite position. 52 : * @param offset world-space offset of sprite position from the entity's base position. 53 : * @param color multiply color of texture 54 : */ 55 : virtual void AddSprite(const VfsPath& textureName, const CFixedVector2D& corner0, const CFixedVector2D& corner1, const CFixedVector3D& offset, const std::string& color = "255 255 255 255") = 0; 56 : 57 : DECLARE_INTERFACE_TYPE(OverlayRenderer) 58 : }; 59 : 60 : #endif // INCLUDED_ICMPOVERLAYRENDERER