|
|
|
@ -73,18 +73,21 @@ void GUI::create_renderer() { |
|
|
|
|
|
|
|
|
|
$document = Renderer([&, player]{ |
|
|
|
|
const auto& player_combat = $world.get<Combat>(player.entity); |
|
|
|
|
const auto& inventory = $world.get<Inventory>(player.entity); |
|
|
|
|
$status_text = player_combat.hp > 0 ? "NOT DEAD" : "DEAD!!!!!!"; |
|
|
|
|
|
|
|
|
|
std::vector<Element> log_list; |
|
|
|
|
for(auto msg : $log.messages) { |
|
|
|
|
log_list.push_back(text(msg)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
auto log_box = vbox(log_list) | yflex_grow | border; |
|
|
|
|
|
|
|
|
|
return hbox({ |
|
|
|
|
hflow( |
|
|
|
|
vbox( |
|
|
|
|
text(format("HP: {: >3}", player_combat.hp)) | border, |
|
|
|
|
text(format("HP: {: >3} GOLD: {: >3}", |
|
|
|
|
player_combat.hp, inventory.gold)) | border, |
|
|
|
|
text($status_text) | border, |
|
|
|
|
separator(), |
|
|
|
|
log_box |
|
|
|
@ -126,7 +129,9 @@ void GUI::handle_world_events() { |
|
|
|
|
break; |
|
|
|
|
case eGUI::LOOT: { |
|
|
|
|
auto loot = $world.get<Loot>(entity); |
|
|
|
|
$log.log(format("You found {} gold.", loot.amount)); |
|
|
|
|
auto inventory = $world.get<Inventory>(player.entity); |
|
|
|
|
$log.log(format("You found {} gold. You have {} now.", |
|
|
|
|
loot.amount, inventory.gold)); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|