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

          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_VIEW
      19             : #define INCLUDED_VIEW
      20             : 
      21             : #include "graphics/Camera.h"
      22             : #include "maths/Rect.h"
      23             : #include "maths/Vector3D.h"
      24             : #include "simulation2/system/Entity.h"
      25             : #include "tools/atlas/GameInterface/SharedTypes.h"
      26             : 
      27             : #include <cstddef>
      28             : #include <map>
      29             : #include <string>
      30             : 
      31             : class AtlasViewActor;
      32             : class AtlasViewGame;
      33             : class CCanvas2D;
      34             : class CSimulation2;
      35             : 
      36             : namespace Renderer::Backend { class IDeviceCommandContext; }
      37             : 
      38             : /**
      39             :  * Superclass for all Atlas game views.
      40             :  */
      41           0 : class AtlasView
      42             : {
      43             : public:
      44             :     virtual ~AtlasView();
      45           0 :     virtual void Update(float /*realFrameLength*/) { };
      46           0 :     virtual void Render() { };
      47           0 :     virtual void DrawCinemaPathTool(Renderer::Backend::IDeviceCommandContext&) { };
      48           0 :     virtual void DrawOverlays(CCanvas2D& /*canvas*/) { };
      49             :     virtual const CCamera& GetCamera() const = 0;
      50             :     virtual void SetCamera(const CCamera& camera) = 0;
      51           0 :     virtual CSimulation2* GetSimulation2() { return NULL; }
      52           0 :     virtual entity_id_t GetEntityId(AtlasMessage::ObjectID obj) { return (entity_id_t)obj; }
      53           0 :     virtual bool GetSmoothFramerate() const { return false; }
      54           0 :     virtual void SetSmoothFramerate(const bool) {}
      55           0 :     virtual void SetEnabled(bool /*enabled*/) {}
      56             : 
      57             :     virtual void SetParam(const std::wstring& name, bool value);
      58             :     virtual void SetParam(const std::wstring& name, int value);
      59           0 :     virtual void SetParam(const std::wstring& /*name*/, float /*value*/) {}
      60             :     virtual void SetParam(const std::wstring& name, const AtlasMessage::Color& value);
      61             :     virtual void SetParam(const std::wstring& name, const std::wstring& value);
      62             : 
      63             :     // These always return a valid (not NULL) object
      64             :     static AtlasView* GetView(int /*eRenderView*/ view);
      65             :     static AtlasView* GetView_None();
      66             :     static AtlasViewGame* GetView_Game();
      67             :     static AtlasViewActor* GetView_Actor();
      68             : 
      69             :     // Invalidates any AtlasView objects previously returned by this class
      70             :     static void DestroyViews();
      71             : };
      72             : 
      73             : //////////////////////////////////////////////////////////////////////////
      74             : 
      75           0 : class AtlasViewNone : public AtlasView
      76             : {
      77             : public:
      78           0 :     virtual const CCamera& GetCamera() const { return m_DummyCamera; }
      79           0 :     virtual void SetCamera(const CCamera& camera) { m_DummyCamera = camera; }
      80             : private:
      81             :     CCamera m_DummyCamera;
      82             : };
      83             : 
      84             : //////////////////////////////////////////////////////////////////////////
      85             : 
      86             : class SimState;
      87             : 
      88             : /**
      89             :  * Main editor/game view of Atlas. Editing the world/scenario and simulation testing happens here.
      90             :  */
      91             : class AtlasViewGame : public AtlasView
      92             : {
      93             : public:
      94             :     AtlasViewGame();
      95             :     virtual ~AtlasViewGame();
      96             :     virtual void Update(float realFrameLength);
      97             :     virtual void Render();
      98             :     virtual void DrawCinemaPathTool(Renderer::Backend::IDeviceCommandContext& deviceCommandContext);
      99             :     virtual void DrawOverlays(CCanvas2D& canvas);
     100             :     virtual const CCamera& GetCamera() const;
     101             :     virtual void SetCamera(const CCamera& camera);
     102             :     virtual CSimulation2* GetSimulation2();
     103             :     virtual bool GetSmoothFramerate() const;
     104             :     virtual void SetSmoothFramerate(const bool enabled);
     105             : 
     106             :     virtual void SetParam(const std::wstring& name, bool value);
     107             :     virtual void SetParam(const std::wstring& name, float value);
     108             :     virtual void SetParam(const std::wstring& name, const std::wstring& value);
     109             : 
     110             :     void SetSpeedMultiplier(float speedMultiplier);
     111             :     void SetTesting(bool testing);
     112             :     void SaveState(const std::wstring& label);
     113             :     void RestoreState(const std::wstring& label);
     114             :     std::wstring DumpState(bool binary);
     115             :     void SetBandbox(bool visible, float x0, float y0, float x1, float y1);
     116             : 
     117             : private:
     118             :     float m_SpeedMultiplier;
     119             :     bool m_IsTesting;
     120             :     bool m_SmoothFramerate{false};
     121             :     std::map<std::wstring, SimState*> m_SavedStates;
     122             :     std::string m_DisplayPassability;
     123             : 
     124             :     CRect m_Bandbox;
     125             :     bool m_DrawMoveTool;
     126             :     CVector3D m_MoveTool;
     127             : };
     128             : 
     129             : //////////////////////////////////////////////////////////////////////////
     130             : 
     131             : class ActorViewer;
     132             : 
     133             : /**
     134             :  * Actor Viewer window in Atlas. Dedicated view for examining a single actor/entity and its variations,
     135             :  * animations, etc. in more detail.
     136             :  */
     137             : class AtlasViewActor : public AtlasView
     138             : {
     139             : public:
     140             :     AtlasViewActor();
     141             :     ~AtlasViewActor();
     142             : 
     143             :     virtual void Update(float realFrameLength);
     144             :     virtual void Render();
     145             :     virtual const CCamera& GetCamera() const;
     146             :     virtual void SetCamera(const CCamera& camera);
     147             :     virtual CSimulation2* GetSimulation2();
     148             :     virtual entity_id_t GetEntityId(AtlasMessage::ObjectID obj);
     149             :     virtual bool GetSmoothFramerate() const;
     150             :     virtual void SetSmoothFramerate(const bool enabled);
     151             :     virtual void SetEnabled(bool enabled);
     152             : 
     153             :     virtual void SetParam(const std::wstring& name, bool value);
     154             :     virtual void SetParam(const std::wstring& name, int value);
     155             :     virtual void SetParam(const std::wstring& name, const AtlasMessage::Color& value);
     156             : 
     157             :     void SetSpeedMultiplier(float speedMultiplier);
     158             :     ActorViewer& GetActorViewer();
     159             : 
     160             : private:
     161             :     float m_SpeedMultiplier;
     162             :     bool m_SmoothFramerate{false};
     163             :     CCamera m_Camera;
     164             :     ActorViewer* m_ActorViewer;
     165             : };
     166             : 
     167             : #endif // INCLUDED_VIEW

Generated by: LCOV version 1.16