#pragma once
#include "../../Backend/Globalincludes.h"
#include "../../Backend/Misc/Fonts/FontManager.h"
#include "../../Frontend/Framework/MenuFramework.h"
#include <memory>

enum circle_type { FULL, HALF, QUARTER };
enum text_alignment { LEFT, CENTER, RIGHT };

// Convenience: FontManager-backed font accessors (replaces old Fonts:: namespace)
#define FM_Verdana()       FontManager::GetInstance().GetFont("Verdana")
#define FM_Tahombd()       FontManager::GetInstance().GetFont("Tahombd")
#define FM_SmallFont()     FontManager::GetInstance().GetFont("SmallFont")
#define FM_TabIcons()      FontManager::GetInstance().GetFont("TabIcons")
#define FM_LegitTabIcons() FontManager::GetInstance().GetFont("LegitTabIcons")

namespace Render 
{
    using GamesenseMenuFramework::Vec2;

    class CDraw
    {
    public:
        struct sScreen
        {
            float Width;        // Overlay full width (physical pixels)
            float Height;       // Overlay full height
            float x_center;
            float y_center;
            float RenderWidth;  // Renderable area width (excludes taskbar)
            float RenderHeight; // Renderable area height
        } Screen;

        void Sprite(RLTexture2D Texture, Vec2 Pos, Vec2 Size, RLColor Color);

        void Line(Vec2 Pos, Vec2 Pos2, RLColor Color);
        void Rect(Vec2 Pos, Vec2 Size, float linewidth, RLColor Color, bool Antialias = false);
        void FilledRect(Vec2 Pos, Vec2 Size, RLColor color, bool Antialias = false);
        void BorderedRect(Vec2 Pos, Vec2 Size, float BorderWidth, RLColor Color, RLColor BorderColor);
        void Gradient(Vec2 Pos, Vec2 Size, RLColor LColor, RLColor ROtherColor, bool Vertical = false, bool Antialias = false);
        void Triangle(Vec2 Top, Vec2 Left, Vec2 Right, RLColor Color, bool antialias = false);
        void Text(const char* Text, float X, float Y, int Orientation, RLFont Font, bool Bordered, RLColor Color, Vec2 MaxSize = Vec2(0, 0));

        void Init();
        void SetDpiScale(float dpiScale);
        void CreateObjects();
        void ReleaseObjects();
        void Reset();

        RLTexture2D GetBgTexture();
        Vec2      GetTextSize(RLFont Font, const char* Text);

    private:
        RLTexture2D  m_BgTexture;
        float        m_CurrentDpiScale = 1.0f;

        bool Initialized = false;
    };

    extern std::unique_ptr<CDraw> Draw;
}