#ifndef ELEMENTS_H #define ELEMENTS_H #include "bindings/ruby.h" #include "localization/localization.h" #include "utils.h" #include "window/window.h" enum Type { IMAGE, TEXT, RECT, WORLD }; enum ClickMode { PASS, BLOCK, IGNORE }; namespace app { struct Element { Type type; Vec2 position = {0, 0}; float rotation = 0; Vec2 pivot = {0, 0}; Vec2 scale = {1, 1}; float alpha = 1.0f; float z = 0; ClickMode click_mode = ClickMode::BLOCK; Ruby::Block on_click; Element(Type type) : type(type) {} virtual ~Element() = default; virtual void render(uint64_t) = 0; virtual Vec2 size() = 0; void click(); }; struct EImage : Element { uint64_t animation_id = UINT64_MAX; EImage(uint64_t animation_id) : Element(Type::IMAGE), animation_id(animation_id) {} ~EImage(); Vec2 size() override; void render(uint64_t) override; }; struct EText : Element { Localization::Key key; uint64_t font_id = UINT64_MAX; Color color = {255, 255, 255}; std::unordered_map params; ~EText(); EText(Localization::Key key, uint64_t font_id, Color color, std::unordered_map params) : Element(Type::TEXT), key(key), font_id(font_id), color(color), params(params) {} Vec2 size() override; void reload_text(); void render(uint64_t) override; private: uint64_t text_id = UINT64_MAX; Color last_color = color; Localization::LanguageCode last_language = UINT32_MAX; Localization::Key last_key = UINT16_MAX; bool params_changed = true; }; struct ERect : Element { Color color = {255, 255, 255}; Vec2 shape = {0, 0}; Vec2 size() override; ERect(Vec2 shape, Color color) : Element(Type::RECT), shape(shape), color(color) {} void render(uint64_t) override; }; struct EWorld : Element { #warning need to implement ecs system first before implementing this uint64_t world_id = UINT64_MAX; EWorld(uint64_t world_id) : Element(Type::WORLD), world_id(world_id) {} Vec2 size() override; void render(uint64_t) override; }; inline Pool element_pool; } // namespace app #endif