#pragma once #include #include "guecs/lel.hpp" #include #include #include #include #include "guecs/theme.hpp" namespace guecs { using std::shared_ptr, std::wstring, std::string; struct Textual { std::wstring content; unsigned int size = THEME.TEXT_SIZE; sf::Color color = THEME.TEXT_COLOR; int padding = THEME.PADDING; bool centered = false; shared_ptr font = nullptr; shared_ptr text = nullptr; void init(lel::Cell &cell, shared_ptr font_ptr); void update(const std::wstring& new_content); }; struct Label : public Textual { template Label(Args... args) : Textual(args...) { centered = true; size = THEME.LABEL_SIZE; } Label() { centered = true; }; }; struct Sprite { // either you set a filename here, // or some kind of config, // or a callback that does the loading, // or a virtual function and you subclass // or there's a static config function you call once, // that's passed an object with all the necessary gear string name; int padding = THEME.PADDING; std::shared_ptr sprite = nullptr; void init(lel::Cell &cell); void update(const string& new_name); }; struct Rectangle { int padding = THEME.PADDING; sf::Color color = THEME.FILL_COLOR; sf::Color border_color = THEME.BORDER_COLOR; int border_px = THEME.BORDER_PX; shared_ptr shape = nullptr; void init(lel::Cell& cell); }; struct Meter { float percent = 1.0f; sf::Color color = THEME.BG_COLOR_DARK; Rectangle bar; void init(lel::Cell& cell); void render(lel::Cell& cell); }; struct Effect { float duration = 0.1f; string name{"ui_shader"}; float $u_time_end = 0.0; bool $active = false; std::shared_ptr $clock = nullptr; std::shared_ptr $shader = nullptr; int $shader_version = 0; void init(lel::Cell &cell); void run(); void stop(); void step(); shared_ptr checkout_ptr(); }; struct Sound { string on_click{"ui_click"}; void play(bool hover); void stop(bool hover); }; struct Background { float x = 0.0f; float y = 0.0f; float w = 0.0f; float h = 0.0f; sf::Color color = THEME.BG_COLOR; shared_ptr shape = nullptr; Background(lel::Parser& parser, sf::Color bg_color=THEME.BG_COLOR) : x(parser.grid_x), y(parser.grid_y), w(parser.grid_w), h(parser.grid_h), color(bg_color) {} Background() {} void init(); }; }