Status UI now fakes a kind of 'hot bar' inventory display.

master
Zed A. Shaw 2 months ago
parent f10498425e
commit 6447f86954
  1. 11
      status_ui.cpp
  2. 2
      texture.cpp

@ -2,6 +2,7 @@
#include "components.hpp"
#include "color.hpp"
#include "guecs.hpp"
#include "rand.hpp"
namespace gui {
using namespace guecs;
@ -23,6 +24,10 @@ namespace gui {
void StatusUI::render(TexturePack &textures) {
auto& world = $gui.world();
std::vector<std::string> fake_items{
"cinqueda", "healing_potion_small",
"torch_crappy", "barrel_small"};
for(auto& [name, cell] : $gui.cells()) {
if(name == "log_view") {
$log_to = $gui.entity("log_view");
@ -30,10 +35,14 @@ namespace gui {
world.set<Rectangle>($log_to, {});
world.set<Textual>($log_to, {"Welcome to the Game!", 20});
} else {
size_t selected_item = Random::uniform<size_t>(0, fake_items.size() - 1);
fmt::println("fake items {} but size {}", selected_item, fake_items.size());
auto& fake_item = fake_items[selected_item];
auto button = $gui.entity(name);
world.set<lel::Cell>(button, cell);
world.set<Rectangle>(button, {});
world.set<Label>(button, {name});
world.set<Sprite>(button, {fake_item});
world.set<Clickable>(button,
guecs::make_action(*$level.world, Events::GUI::NOOP));
}

@ -66,5 +66,7 @@ matrix::Matrix TexturePack::convert_char_to_texture(matrix::Matrix &tile_ids) {
}
SpriteTexture TexturePack::get(std::string name) {
dbc::check(sprite_textures.contains(name),
fmt::format("!!!!! texture pack does not contain {} sprite", name));
return sprite_textures.at(name);
}

Loading…
Cancel
Save