#pragma once #include #include #include #include "3DRenderer.hpp" class UI { public: virtual ~UI() = 0; const sf::Vector2f& GetRTSize() const noexcept { return mRTSize; } void SetRTSize(unsigned int w, unsigned int h, bool recreateCanvas = false); virtual void Update() = 0; virtual inline void Draw(std::shared_ptr& c) { DrawUIOnRenderWindow(c); } protected: UI(unsigned int w, unsigned int h) : mRTSize(sf::Vector2f(w, h)) {} UI(sf::Vector2f size) : mRTSize(size) {} sf::Vector2f mRTSize; sf::RenderTexture mUIRender; // The screen to draw onto void CreateDefaultRenderWindow(); void DrawUIOnRenderWindow(std::shared_ptr& context, float& viewX, float& viewY); inline void DrawUIOnRenderWindow(std::shared_ptr& context) { DrawUIOnRenderWindow(context, mRTSize); } inline void DrawUIOnRenderWindow(std::shared_ptr& context, sf::Vector2f& view) { DrawUIOnRenderWindow(context, view.x, view.y); } }; inline UI::~UI() {} class CockpitUI final : public UI { public: CockpitUI(unsigned int w, unsigned int h); ~CockpitUI() {} CockpitUI(CockpitUI&&) = default; CockpitUI& operator= (CockpitUI&&) = default; CockpitUI(CockpitUI const&) = delete; CockpitUI& operator= (CockpitUI const&) = delete; void Update() override; void Draw(std::shared_ptr&) override; private: sf::Texture mStaticCockpitTexture; }; class WorldUI final : public UI { public: WorldUI(unsigned int w, unsigned int h, std::shared_ptr& engineInstance); ~WorldUI() {} WorldUI(WorldUI&&) = default; WorldUI& operator= (WorldUI&&) = default; WorldUI(WorldUI const&) = delete; WorldUI& operator= (WorldUI const&) = delete; void Update() override; void Draw(std::shared_ptr&) override; private: std::shared_ptr mWorld3D; };