diff --git a/panel.cpp b/panel.cpp index 9b8d6cd..14f2f33 100644 --- a/panel.cpp +++ b/panel.cpp @@ -16,7 +16,7 @@ void Panel::add(Component child) { void Panel::render() { $dirty = true; - if($must_clear) $screen.Clear(); + if(must_clear) $screen.Clear(); Render($screen, $component->Render()); } diff --git a/panel.hpp b/panel.hpp index 3a578d1..4cf784f 100644 --- a/panel.hpp +++ b/panel.hpp @@ -6,9 +6,12 @@ #include #include #include +#include #include #include +const int UI_PANEL_BORDER_PX=5; + using ftxui::Renderer, ftxui::Component, ftxui::Element, ftxui::Screen; struct Panel { @@ -16,20 +19,25 @@ struct Panel { int y; int width; int height; - std::wstring $screenout; + bool has_border = false; + bool must_clear = true; + sf::Color default_bg = sf::Color(0,0,0); + sf::Color border_color = sf::Color::Red; + int border_px = UI_PANEL_BORDER_PX; + bool $dirty = true; Component $component; Screen $screen; - bool $must_clear = true; std::wstring_convert> $converter; + std::wstring $screenout; Panel(int width, int height, int x, int y, bool must_clear=true) : x(x), y(y), width(width), height(height), - $screen(Screen(width, height)), - $must_clear(must_clear) + must_clear(must_clear), + $screen(Screen(width, height)) { }; diff --git a/render.cpp b/render.cpp index 4f19f41..0d19413 100644 --- a/render.cpp +++ b/render.cpp @@ -216,18 +216,16 @@ void SFMLRender::render_text(const std::wstring &text, float start_x, float star } } -void SFMLRender::draw_text(Panel &panel, bool with_border) { - int border_px = with_border ? UI_PANEL_BORDER_PX : 0; - +void SFMLRender::draw_text(Panel &panel) { sf::RectangleShape backing( - sf::Vector2f($ui_bounds.width * panel.width + border_px, - $ui_bounds.height * panel.height + border_px)); + sf::Vector2f($ui_bounds.width * panel.width + panel.border_px, + $ui_bounds.height * panel.height + panel.border_px)); - backing.setFillColor(sf::Color(0, 0, 0)); + backing.setFillColor(panel.default_bg); - if(with_border) { - backing.setOutlineColor(color(Value::MID)); - backing.setOutlineThickness(border_px); + if(panel.has_border) { + backing.setOutlineColor(panel.border_color); + backing.setOutlineThickness(panel.border_px); } backing.setPosition(panel.x, panel.y); diff --git a/render.hpp b/render.hpp index ee76288..9c2dfd1 100644 --- a/render.hpp +++ b/render.hpp @@ -23,7 +23,6 @@ const int BASE_MAP_FONT_SIZE=90; const wchar_t BG_TILE = L'█'; const wchar_t UI_BASE_CHAR = L'█'; const int BG_BOX_OFFSET=5; -const int UI_PANEL_BORDER_PX=5; enum class Value { BLACK=0, DARK_DARK, DARK_MID, @@ -59,7 +58,7 @@ struct SFMLRender { bool resize_map(int new_size, Point &view_port); void render_grid(const std::wstring &text, float x, float y); void render_text(const std::wstring &text, float x, float y); - void draw_text(Panel &panel, bool with_border=false); + void draw_text(Panel &panel); void draw_grid(Panel &panel, float map_off_x=0.0f, float map_off_y=0.0f); bool poll_event(sf::Event &event) { diff --git a/status.txt b/status.txt index f8c3888..18a377b 100644 --- a/status.txt +++ b/status.txt @@ -1,8 +1,13 @@ TODAY'S GOAL: -TODO: +* Clean up renderer. * panels and everything except renderer should use character coodinates * panels should know if they're text vs. grid rendered +* Image -> Text converter. + + +TODO: +* Keep panel unified by implementing border and backing on grids too. * Can std::any be defaulted to a noop in the events? * Save file isn't saving gold. * Inventory needs to be better, but need some kinds of "weapons" or other loot to get and not just gold.