Have a plan for the new inventory and looting system, now have to implement it. Temporarily you can't pick anything up, but it will go away.
This commit is contained in:
parent
b8d2d1870d
commit
ab391aaa97
9 changed files with 23 additions and 261 deletions
|
@ -1,6 +1,5 @@
|
|||
#include "gui/status_ui.hpp"
|
||||
#include "components.hpp"
|
||||
#include "inventory.hpp"
|
||||
#include <guecs/ui.hpp>
|
||||
#include "rand.hpp"
|
||||
#include <fmt/xchar.h>
|
||||
|
@ -14,12 +13,12 @@ namespace gui {
|
|||
{
|
||||
$gui.position(STATUS_UI_X, STATUS_UI_Y, STATUS_UI_WIDTH, STATUS_UI_HEIGHT);
|
||||
$gui.layout(
|
||||
"[ ritual_ui ]"
|
||||
"[inv_1|inv_2|inv_3]"
|
||||
"[inv_4|*%(200,300)character_view|_|inv_5]"
|
||||
"[inv_6|_|_ |inv_7]"
|
||||
"[inv_8|_|_ |inv_9]"
|
||||
"[inv_10|inv_11|inv_12]");
|
||||
"[ritual_ui]"
|
||||
"[earing|armor_head|amulet]"
|
||||
"[back|*%(200,300)character_view|_|armor_bdy]"
|
||||
"[hand_r|_|_ |hand_l]"
|
||||
"[ring_r|_|_ |ring_l]"
|
||||
"[pocket_r|armor_leg|pocket_l]");
|
||||
|
||||
size_t inv_id = 0;
|
||||
for(auto [name, entity] : $gui.$name_ents) {
|
||||
|
@ -36,7 +35,7 @@ namespace gui {
|
|||
if(name == "character_view") {
|
||||
auto char_view = $gui.entity(name);
|
||||
$gui.set<Rectangle>(char_view, {});
|
||||
$gui.set<Sprite>(char_view, {"peasant_girl"});
|
||||
$gui.set<Sprite>(char_view, {"armored_knight"});
|
||||
} else {
|
||||
auto button = $gui.entity(name);
|
||||
$gui.set<Rectangle>(button, {});
|
||||
|
@ -73,47 +72,14 @@ namespace gui {
|
|||
}
|
||||
|
||||
void StatusUI::select_slot(DinkyECS::Entity ent, any slot_name) {
|
||||
dbc::check(slot_name.has_value(), "passed select_slot an any without a value");
|
||||
|
||||
auto cn = $gui.get<CellName>(ent);
|
||||
auto world = $level.world;
|
||||
|
||||
if(world->has<components::Inventory>($level.player)) {
|
||||
auto& inventory = world->get<components::Inventory>($level.player);
|
||||
size_t inv_id = $slots[any_cast<string>(slot_name)];
|
||||
|
||||
if(inventory.has_item(inv_id)) {
|
||||
auto [used, name] = inventory.use($level, inv_id);
|
||||
}
|
||||
}
|
||||
(void)ent;
|
||||
(void)slot_name;
|
||||
dbc::log("REWRITE!");
|
||||
}
|
||||
|
||||
/* WARNING: This is really not the greatest way to do this. */
|
||||
void StatusUI::update() {
|
||||
auto world = $level.world;
|
||||
if(world->has<components::Inventory>($level.player)) {
|
||||
auto& inventory = world->get<components::Inventory>($level.player);
|
||||
|
||||
for(auto& [slot_name, inv_id] : $slots) {
|
||||
if(inventory.has_item(inv_id)) {
|
||||
auto slot = $gui.entity(slot_name);
|
||||
auto& item = inventory.get(inv_id);
|
||||
auto comp_sprite = components::get<components::Sprite>(item.data);
|
||||
$gui.set_init<guecs::Sprite>(slot, {comp_sprite.name});
|
||||
string count_label = fmt::format("{}", item.count);
|
||||
auto& label = $gui.get<Textual>(slot);
|
||||
label.text->setString(count_label);
|
||||
|
||||
auto& sprite = $gui.get<guecs::Sprite>(slot);
|
||||
|
||||
if(item.count == 0) {
|
||||
sprite.sprite->setColor({125, 125, 125});
|
||||
} else {
|
||||
sprite.sprite->setColor({255, 255, 255});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dbc::log("REWRITE ME!");
|
||||
}
|
||||
|
||||
void StatusUI::render(sf::RenderWindow &window) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue