LCOV - code coverage report
Current view: top level - source/tools/atlas/GameInterface - SharedTypes.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 15 0.0 %
Date: 2026-12-03 01:19:39 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2025 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_SHAREDTYPES
      19             : #define INCLUDED_SHAREDTYPES
      20             : 
      21             : #include "Shareable.h"
      22             : 
      23             : #include <string>
      24             : #include <vector>
      25             : 
      26             : class wxPoint;
      27             : class CVector3D;
      28             : 
      29             : namespace AtlasMessage
      30             : {
      31             : 
      32             : enum SELECTED_AXIS
      33             : {
      34             :     AXIS_INVALID = -1,
      35             :     AXIS_X = 1,
      36             :     AXIS_Y = 2,
      37             :     AXIS_Z = 4
      38             : };
      39             : 
      40             : // Represents a position in the game world, with an interface usable from the
      41             : // UI (which usually knows only about screen space). Typically constructed
      42             : // by the UI, then passed to the game which uses GetWorldSpace.
      43             : 
      44             : struct Position
      45             : {
      46             :     Position() : type(0) { type0.x = type0.y = type0.z = 0.f;  }
      47             : 
      48             :     // Constructs a position with specified world-space coordinates
      49             :     Position(float x, float y, float z) : type(0) { type0.x = x; type0.y = y; type0.z = z; }
      50             : 
      51             :     // Constructs a position on the terrain underneath the screen-space coordinates
      52             :     Position(const wxPoint& pt); // (implementation in ScenarioEditor.cpp)
      53             : 
      54             :     // Store all possible position representations in a union, instead of something
      55             :     // like inheritance and virtual functions, so we don't have to care about
      56             :     // dynamic memory allocation across DLLs.
      57             :     int type;
      58             :     union {
      59             :         struct { float x, y, z; } type0; // world-space coordinates
      60             :         struct { int x, y; } type1; // screen-space coordinates, to be projected onto terrain
      61             :         // type2: "same as previous" (e.g. for elevation-editing when the mouse hasn't moved)
      62             :     };
      63             : 
      64             :     // Constructs a position with the meaning "same as previous", which is handled
      65             :     // in unspecified (but usually obvious) ways by different message handlers.
      66             :     static Position Unchanged() { Position p; p.type = 2; return p; }
      67             : 
      68             :     // Only for use in the game, not the UI.
      69             :     // Implementations in Misc.cpp.
      70             :     CVector3D GetWorldSpace(bool floating = false) const;
      71             :     CVector3D GetWorldSpace(float h, bool floating = false) const;
      72             :     CVector3D GetWorldSpace(const CVector3D& prev, bool floating = false) const;
      73             :     void GetScreenSpace(float& x, float& y) const;
      74             : };
      75           0 : SHAREABLE_STRUCT(Position);
      76             : 
      77             : 
      78             : struct Color
      79             : {
      80           0 :     Color()
      81           0 :         : r(255), g(0), b(255)
      82             :     {
      83             :     }
      84             : 
      85           0 :     Color(unsigned char r, unsigned char g, unsigned char b)
      86             :         : r(r), g(g), b(b)
      87             :     {
      88             :     }
      89             : 
      90             :     unsigned char r, g, b;
      91             : };
      92           0 : SHAREABLE_STRUCT(Color);
      93             : 
      94             : 
      95             : typedef unsigned int ObjectID;
      96             : inline bool ObjectIDIsValid(ObjectID id) { return (id != 0); }
      97             : 
      98             : 
      99             : struct sCinemaSplineNode
     100             : {
     101             :     Shareable<float> px, py, pz, rx, ry, rz, t;
     102             : public:
     103             :     sCinemaSplineNode(float _px, float _py, float _pz, float _rx, float _ry, float _rz)
     104             :             : px(_px), py(_py), pz(_pz), rx(_rx), ry(_ry), rz(_rz), t(0.0f) {}
     105           0 :     sCinemaSplineNode() {}
     106             :     void SetTime(float _t) { t = _t; }
     107             : };
     108           0 : SHAREABLE_STRUCT(sCinemaSplineNode);
     109             : 
     110           0 : struct sCinemaPath
     111             : {
     112             :     Shareable<std::vector<AtlasMessage::sCinemaSplineNode> > nodes;
     113             :     Shareable<std::wstring> name;
     114             :     Shareable<float> duration, timescale;
     115             :     Shareable<int> mode, growth, change, style;   // change == switch point
     116             : 
     117             :     sCinemaPath(const std::wstring& _name) : name(_name), mode(0), style(0), change(0), growth(0), duration(0), timescale(1) {}
     118           0 :     sCinemaPath() : mode(0), style(0), change(0), growth(0), duration(0), timescale(1) {}
     119             : 
     120             :     /*AtlasMessage::sCinemaPath operator-(const AtlasMessage::sCinemaPath& path)
     121             :     {
     122             :         return AtlasMessage::sCinemaPath(x - path.x, y - path.y, z - path.z);
     123             :     }
     124             :     AtlasMessage::sCinemaPath operator+(const AtlasMessage::sCinemaPath& path)
     125             :     {
     126             :         return AtlasMessage::sCinemaPath(x + path.x, y + path.y, z + path.z);
     127             :     }*/
     128             : };
     129           0 : SHAREABLE_STRUCT(sCinemaPath);
     130             : 
     131           0 : struct sCinemaPathNode
     132             : {
     133             :     Shareable<std::wstring> name;
     134             :     Shareable<int> index;
     135             :     Shareable<bool> targetNode;
     136           0 :     sCinemaPathNode() : index(-1), targetNode(false) {}
     137             : };
     138           0 : SHAREABLE_STRUCT(sCinemaPathNode);
     139             : 
     140             : 
     141             : struct eCinemaEventMode { enum { SMOOTH, SELECT, IMMEDIATE_PATH, RESET }; };
     142           0 : struct sCameraInfo
     143             : {
     144             :     Shareable<float> pX, pY, pZ, rX, rY, rZ;  // position and rotation
     145             : };
     146           0 : SHAREABLE_STRUCT(sCameraInfo);
     147             : 
     148             : }
     149             : 
     150             : #endif // INCLUDED_SHAREDTYPES

Generated by: LCOV version 1.16