Worked out the status UI more, setup the color scheme, and fixed various small problems with looting causing a crash.

This commit is contained in:
Zed A. Shaw 2026-03-29 13:15:39 -04:00
parent db60f75bd9
commit 36a49ef768
6 changed files with 48 additions and 40 deletions

View file

@ -5,17 +5,17 @@
}, },
"gui/theme": { "gui/theme": {
"black": [0, 0, 0, 255], "black": [0, 0, 0, 255],
"dark_dark": [10, 10, 10, 255], "dark_dark": [22, 10, 7, 255],
"dark_mid": [30, 30, 30, 255], "dark_mid": [53, 25, 18, 255],
"dark_light": [60, 60, 60, 255], "dark_light": [91, 42, 31, 255],
"mid": [100, 100, 100, 255], "mid": [142, 65, 48, 255],
"light_dark": [150, 150, 150, 255], "light_dark": [193, 89, 65, 255],
"light_mid": [200, 200, 200, 255], "light_mid": [255, 117, 86, 255],
"light_light": [230, 230, 230, 255], "light_light": [255, 194, 181, 255],
"white": [255, 255, 255, 255], "white": [255, 255, 255, 255],
"fill_color": "gui/theme:dark_mid", "fill_color": [28, 29, 33, 255],
"text_color": "gui/theme:light_light", "text_color": [209, 209, 209, 255],
"bg_color": "gui/theme:mid", "bg_color": "gui/theme:dark_light",
"border_color": "gui/theme:dark_dark", "border_color": "gui/theme:dark_dark",
"bg_color_dark": "gui/theme:black" "bg_color_dark": "gui/theme:black"
}, },

View file

@ -167,15 +167,14 @@ void System::distribute_loot(Position target_pos) {
auto loot_entity = world.entity(); auto loot_entity = world.entity();
if(inventory_count > 0) { if(inventory_count > 0) {
auto& entity_data = config.devices["DEAD_BODY_LOOTABLE"]; dbc::log("!!!!!!!!!!!!!!!! ============= LOOTING BODIES NOT READY");
components::configure_entity(world, loot_entity, entity_data["components"]); }
// BUG: inventory_count here isn't really used to remove it
world.set<InventoryItem>(loot_entity, {inventory_count, entity_data}); // NOTE: refer to the code in raycaster for this
} else {
// this creates a dead body on the ground // this creates a dead body on the ground
auto& entity_data = config.devices["DEAD_BODY"]; auto& entity_data = config.devices["DEAD_BODY"];
components::configure_entity(world, loot_entity, entity_data["components"]); components::configure_entity(world, loot_entity, entity_data["components"]);
}
set_position(world, *level.collision, loot_entity, target_pos); set_position(world, *level.collision, loot_entity, target_pos);
level.world->send<game::Event>(game::Event::ENTITY_SPAWN, loot_entity, {}); level.world->send<game::Event>(game::Event::ENTITY_SPAWN, loot_entity, {});

View file

@ -78,6 +78,7 @@ namespace gui {
dbc::check(world->has<components::Sprite>(item), dbc::check(world->has<components::Sprite>(item),
"item in inventory UI doesn't exist in world. New level?"); "item in inventory UI doesn't exist in world. New level?");
auto& sprite = world->get<components::Sprite>(item); auto& sprite = world->get<components::Sprite>(item);
fmt::println("!!!!!!!!!!! trying to load {}", sprite.name);
$gui.set_init<guecs::Icon>(id, {sprite.name}); $gui.set_init<guecs::Icon>(id, {sprite.name});
guecs::GrabSource grabber{ guecs::GrabSource grabber{

View file

@ -18,12 +18,13 @@ namespace gui {
$gui.init(); $gui.init();
} }
inline void make_clickable_area(guecs::UI &gui, const std::string &name) { inline void make_clickable_area(guecs::UI &gui, const std::string name) {
auto area = gui.entity(name); auto area = gui.entity(name);
gui.set<Clickable>(area, { gui.set<Clickable>(area, {
[&](auto) { [=](auto) {
auto world = GameDB::current_world(); auto world = GameDB::current_world();
fmt::println("CLICK {}", name);
world->send<game::Event>(game::Event::AIM_CLICK, area, {}); world->send<game::Event>(game::Event::AIM_CLICK, area, {});
} }
}); });

View file

@ -16,8 +16,16 @@ namespace gui {
{ {
$gui.position(x, y, width, height); $gui.position(x, y, width, height);
$gui.layout( $gui.layout(
"[=slot1]" "[=body_head]"
"[=slot2]" "[=body_chest]"
"[=body_right_arm]"
"[=body_left_arm]"
"[=body_stomach]"
"[=body_left_leg]"
"[=body_right_leg]"
"[=inv0|=inv1|=inv2]"
"[=inv3|=inv4|=inv5]"
"[=inv6|=inv7|=inv8]"
"[=hand_r]" "[=hand_r]"
"[=pocket_l]"); "[=pocket_l]");
} }
@ -28,9 +36,13 @@ namespace gui {
for(auto& [name, cell] : $gui.cells()) { for(auto& [name, cell] : $gui.cells()) {
auto gui_id = $gui.entity(name); auto gui_id = $gui.entity(name);
$gui.set<Rectangle>(gui_id, {});
$gui.set<Text>(gui_id, {guecs::to_wstring(name)}); $gui.set<Text>(gui_id, {guecs::to_wstring(name)});
if(name.starts_with("body_")) {
$gui.set<Meter>(gui_id, {});
} else {
$gui.set<Rectangle>(gui_id, {});
$gui.set<Clickable>(gui_id, { $gui.set<Clickable>(gui_id, {
guecs::make_action(gui_id, game::Event::INV_SELECT, {gui_id}) guecs::make_action(gui_id, game::Event::INV_SELECT, {gui_id})
}); });
@ -40,6 +52,7 @@ namespace gui {
} }
}); });
} }
}
$gui.init(); $gui.init();
update(); update();

View file

@ -11,14 +11,8 @@ TEST_CASE("color palette test", "[color-palette]") {
// confirm it's idempotent // confirm it's idempotent
palette::init(); palette::init();
sf::Color expect{10, 10, 10, 255};
auto gui_text = palette::get("gui/theme:dark_dark"); auto gui_text = palette::get("gui/theme:dark_dark");
REQUIRE(gui_text == expect); REQUIRE(gui_text.r > 0);
REQUIRE(gui_text.g > 0);
gui_text = palette::get("gui/theme", "mid"); REQUIRE(gui_text.b > 0);
REQUIRE(gui_text != expect);
expect = {100, 100, 100, 255};
REQUIRE(gui_text == expect);
} }