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 18 0.0 %
Date: 2023-01-19 00:18:29 Functions: 0 30 0.0 %

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

Generated by: LCOV version 1.13