Initial layout of an item inventory UI.

main
Zed A. Shaw 6 days ago
parent 3d461bce6d
commit d7353a02df
  1. 52
      gui.cpp
  2. 6
      gui.hpp

@ -12,6 +12,7 @@
#include <ftxui/screen/box.hpp> // for ftxui
#include <ftxui/component/loop.hpp>
#include <ftxui/screen/color.hpp>
#include <ftxui/dom/table.hpp>
#include <fmt/core.h>
#include "dbc.hpp"
@ -30,17 +31,48 @@ using namespace ftxui;
using namespace components;
void InventoryUI::create_render() {
auto cell = [](const char* t) { return text(t) | border; };
auto inventory_test = Renderer([cell] {
return hflow({
gridbox({
{cell("one"), cell("two"), cell("three")},
{cell("four"), cell("five"), cell("six")},
{cell("seven"), cell("eight"), cell("nine")},
}) | yflex_grow,
$inventory_list = {
"Sword (10)",
"Hat (1)",
"Fruit (4)",
"Dead Rabbit (1)"
};
$fake_text = R"(
Franzen kickstarter keffiyeh poutine actually master cleanse, irony butcher live-edge glossier stumptown organic PBR&B. Cloud bread cupping praxis hammock, offal tilde fam ennui vexillologist chartreuse chillwave. Chambray swag umami chartreuse cupping photo booth butcher fashion axe godard banh mi portland sartorial banjo shabby chic intelligentsia. Praxis synth helvetica 3 wolf moon raclette tousled. Tousled cliche jawn, coloring book meh pitchfork chartreuse. Kitsch try-hard poke celiac tote bag listicle photo booth.
)";
$inventory_table = Renderer([&]{
auto table = Table({
{"Version", "Marketing name", "Release date", "API level", "Runtime"},
{"2.3", "Gingerbread", "February 9 2011", "10", "Dalvik 1.4.0"},
{"4.0", "Ice Cream Sandwich", "October 19 2011", "15", "Dalvik"},
{"4.1", "Jelly Bean", "July 9 2012", "16", "Dalvik"},
{"4.2", "Jelly Bean", "November 13 2012", "17", "Dalvik"},
{"4.3", "Jelly Bean", "July 24 2013", "18", "Dalvik"},
{"4.4", "KitKat", "October 31 2013", "19", "Dalvik and ART"},
{"5.0", "Lollipop", "November 3 2014", "21", "ART"},
{"5.1", "Lollipop", "March 9 2015", "22", "ART"},
});
table.SelectAll().Border(LIGHT);
table.SelectRow(0).Border(DOUBLE);
return table.Render();
});
MenuOption option;
$inventory_box = Menu(&$inventory_list, &$selected, option);
auto inventory_test = Renderer([&] {
return hbox({
$inventory_box->Render() | frame | size(WIDTH, EQUAL, 35) | yflex_grow,
separator() | yflex_grow,
paragraph("Item UI Goes Here") | yflex_grow
}) | border | flex;
vflow({
paragraph($fake_text) | border,
$inventory_table->Render()
}) | flex
}) | border | flex;
});
set_renderer(inventory_test);

@ -50,6 +50,12 @@ struct UnDumbTSS {
class InventoryUI : public Panel {
public:
std::vector<string> $inventory_list;
int $selected = 0;
Component $inventory_box;
Component $inventory_table;
string $fake_text;
InventoryUI() : Panel(INVENTORY_PIXEL_X, INVENTORY_PIXEL_Y, INVENTORY_WIDTH, INVENTORY_HEIGHT) {}
void create_render();
};

Loading…
Cancel
Save