|
|
@ -31,51 +31,44 @@ using namespace ftxui; |
|
|
|
using namespace components; |
|
|
|
using namespace components; |
|
|
|
|
|
|
|
|
|
|
|
void InventoryUI::create_render() { |
|
|
|
void InventoryUI::create_render() { |
|
|
|
$inventory_list = { |
|
|
|
auto inventory_render = Renderer([&] { |
|
|
|
"Sword (10)", |
|
|
|
auto &player = $world.get_the<Player>(); |
|
|
|
"Hat (1)", |
|
|
|
auto &inventory = $world.get<Inventory>(player.entity); |
|
|
|
"Fruit (4)", |
|
|
|
update_menu_list(inventory); |
|
|
|
"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; |
|
|
|
MenuOption option; |
|
|
|
$inventory_box = Menu(&$inventory_list, &$selected, option); |
|
|
|
$inventory_box = Menu(&$menu_list, &$selected, option); |
|
|
|
|
|
|
|
|
|
|
|
auto inventory_test = Renderer([&] { |
|
|
|
|
|
|
|
return hbox({ |
|
|
|
return hbox({ |
|
|
|
$inventory_box->Render() | frame | size(WIDTH, EQUAL, 35) | yflex_grow, |
|
|
|
$inventory_box->Render() | frame | size(WIDTH, EQUAL, 35) | yflex_grow, |
|
|
|
separator() | yflex_grow, |
|
|
|
separator() | yflex_grow, |
|
|
|
vflow({ |
|
|
|
vflow({ |
|
|
|
paragraph($fake_text) | border, |
|
|
|
paragraph($item_text) | border |
|
|
|
$inventory_table->Render() |
|
|
|
|
|
|
|
}) | flex |
|
|
|
}) | flex |
|
|
|
}) | border | flex; |
|
|
|
}) | border | flex; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
set_renderer(inventory_test); |
|
|
|
set_renderer(inventory_render); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InventoryUI::update_menu_list(Inventory& inventory) { |
|
|
|
|
|
|
|
// BUG: probably need to have a dirty marker on inventory
|
|
|
|
|
|
|
|
// so we don't update this all the damn time
|
|
|
|
|
|
|
|
$menu_list.clear(); |
|
|
|
|
|
|
|
int i = 0; // SOOOOO BADDDDD
|
|
|
|
|
|
|
|
for(auto& [key, val] : inventory.items) { |
|
|
|
|
|
|
|
$menu_list.push_back(fmt::format("{} {} ({})", |
|
|
|
|
|
|
|
string(val.data["display"]), |
|
|
|
|
|
|
|
string(val.data["name"]), |
|
|
|
|
|
|
|
val.count)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GARBAGE HOT
|
|
|
|
|
|
|
|
if($selected == i) { |
|
|
|
|
|
|
|
$item_text = val.data["description"]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void StatusUI::create_render() { |
|
|
|
void StatusUI::create_render() { |
|
|
@ -177,6 +170,7 @@ GUI::GUI(DinkyECS::World &world, Map& game_map) : |
|
|
|
$status_ui(world), |
|
|
|
$status_ui(world), |
|
|
|
$lights(game_map.width(), game_map.height()), |
|
|
|
$lights(game_map.width(), game_map.height()), |
|
|
|
$map_view($world, $lights, $game_map), |
|
|
|
$map_view($world, $lights, $game_map), |
|
|
|
|
|
|
|
$inventory_ui(world), |
|
|
|
$sounds("./assets") |
|
|
|
$sounds("./assets") |
|
|
|
{ |
|
|
|
{ |
|
|
|
// this needs a config file soon
|
|
|
|
// this needs a config file soon
|
|
|
@ -212,8 +206,6 @@ void GUI::create_renderer() { |
|
|
|
|
|
|
|
|
|
|
|
void GUI::handle_world_events() { |
|
|
|
void GUI::handle_world_events() { |
|
|
|
using eGUI = Events::GUI; |
|
|
|
using eGUI = Events::GUI; |
|
|
|
auto player = $world.get_the<Player>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while($world.has_event<eGUI>()) { |
|
|
|
while($world.has_event<eGUI>()) { |
|
|
|
auto [evt, entity, data] = $world.recv<eGUI>(); |
|
|
|
auto [evt, entity, data] = $world.recv<eGUI>(); |
|
|
|
|
|
|
|
|
|
|
@ -241,9 +233,9 @@ void GUI::handle_world_events() { |
|
|
|
} break; |
|
|
|
} break; |
|
|
|
case eGUI::LOOT: { |
|
|
|
case eGUI::LOOT: { |
|
|
|
auto &item = std::any_cast<InventoryItem&>(data); |
|
|
|
auto &item = std::any_cast<InventoryItem&>(data); |
|
|
|
auto &inventory = $world.get<Inventory>(player.entity); |
|
|
|
|
|
|
|
fmt::println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!! UPDATE INVENTORY HERE."); |
|
|
|
|
|
|
|
$sounds.play("loot_gold"); |
|
|
|
$sounds.play("loot_gold"); |
|
|
|
|
|
|
|
$status_ui.log(fmt::format("You picked up a {}.", |
|
|
|
|
|
|
|
std::string(item.data["name"]))); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|