2024-07-12 19:48:34 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <pd/Color.hpp>
|
|
|
|
#include <pd/Font.hpp>
|
|
|
|
#include <pd/Image.hpp>
|
2024-08-02 13:50:36 +02:00
|
|
|
#include <pd/LI7.hpp>
|
2024-07-12 19:48:34 +02:00
|
|
|
#include <pd/NVec.hpp>
|
|
|
|
#include <pd/Sprite.hpp>
|
|
|
|
#include <pd/smart_ctor.hpp>
|
|
|
|
|
|
|
|
enum R2Screen {
|
|
|
|
R2Screen_Bottom,
|
|
|
|
R2Screen_Top,
|
|
|
|
// TopRight,
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace Palladium {
|
|
|
|
class R2 {
|
|
|
|
public:
|
|
|
|
struct R2Cmd {
|
2024-08-02 13:50:36 +02:00
|
|
|
NVec2 pos; //< Position
|
|
|
|
NVec2 pszs; //< Position or (TextBox) Size
|
|
|
|
NVec2 ap; //< Additional Pos
|
2024-07-12 19:48:34 +02:00
|
|
|
unsigned int clr; //< Color
|
|
|
|
bool Screen; //< TopScreen
|
|
|
|
Image::Ref img; //< Image Reference
|
|
|
|
Sprite::Ref spr; //< Sprite Reference
|
|
|
|
// 0 = skip, 1 = rect, 2 = tri, 3 = text,
|
|
|
|
// 4 = image, 5 = sprite, 6 = Line
|
|
|
|
int type; //< Command Type
|
|
|
|
bool lined = false; //< Draw Lined Rect/Tri
|
|
|
|
// Text Specific
|
|
|
|
PDTextFlags flags; // Text Flags
|
2024-08-02 13:50:36 +02:00
|
|
|
std::string text; // Text
|
2024-07-12 19:48:34 +02:00
|
|
|
PD_SMART_CTOR(R2Cmd)
|
|
|
|
};
|
|
|
|
R2() = default;
|
|
|
|
~R2() = default;
|
|
|
|
|
|
|
|
static void Init();
|
|
|
|
|
|
|
|
// Settings
|
|
|
|
static void SetFont(Font::Ref fnt);
|
|
|
|
static Font::Ref GetFont();
|
|
|
|
static void DefaultFont();
|
|
|
|
static void DrawNextLined();
|
|
|
|
static void OnScreen(R2Screen screen);
|
|
|
|
static R2Screen GetCurrentScreen();
|
|
|
|
static void SetTextSize(float szs);
|
|
|
|
static void DefaultTextSize();
|
|
|
|
static float GetTextSize();
|
|
|
|
static NVec2 GetCurrentScreenSize();
|
|
|
|
// Processing
|
|
|
|
static void Process();
|
|
|
|
static NVec2 GetTextDimensions(const std::string& text);
|
|
|
|
static std::string WrapText(const std ::string& in, int maxlen);
|
|
|
|
static std::string ShortText(const std::string& in, int maxlen);
|
|
|
|
// Draw Functions
|
|
|
|
static void AddRect(NVec2 pos, NVec2 size, PDColor clr);
|
|
|
|
static void AddRect(NVec2 pos, NVec2 size, unsigned int clr);
|
|
|
|
static void AddTriangle(NVec2 pos0, NVec2 pos1, NVec2 pos2, PDColor clr);
|
2024-08-02 13:50:36 +02:00
|
|
|
static void AddTriangle(NVec2 pos0, NVec2 pos1, NVec2 pos2, unsigned int clr);
|
2024-07-12 19:48:34 +02:00
|
|
|
static void AddText(NVec2 pos, const std::string& text, PDColor clr,
|
|
|
|
PDTextFlags flags = 0, NVec2 tmb = NVec2());
|
|
|
|
static void AddText(NVec2 pos, const std::string& text, unsigned int clr,
|
|
|
|
PDTextFlags flags = 0, NVec2 tmb = NVec2());
|
|
|
|
static void AddImage(NVec2 pos, Image::Ref img);
|
|
|
|
static void AddSprite(Sprite::Ref spr);
|
|
|
|
static void AddLine(NVec2 pos_a, NVec2 pos_b, PDColor clr, int t = 1);
|
|
|
|
static void AddLine(NVec2 pos_a, NVec2 pos_b, unsigned int clr, int t = 1);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const float default_text_size;
|
|
|
|
static float text_size;
|
|
|
|
static Font::Ref font;
|
|
|
|
static std::map<std::string, float> ts;
|
|
|
|
static std::map<std::string, int> mln;
|
|
|
|
static bool next_lined;
|
|
|
|
static std::vector<R2Cmd::Ref> commands;
|
|
|
|
static R2Screen current_screen;
|
|
|
|
};
|
|
|
|
} // namespace Palladium
|