Working on a better character view.

master
Zed A. Shaw 2 days ago
parent d6e64dd06b
commit 0eb245d113
  1. 2
      assets/config.json
  2. BIN
      assets/peasant_girl_2-256.png
  3. 2
      gui/fsm.hpp
  4. 2
      gui/ritual_ui.hpp
  5. 45
      gui/status_ui.cpp
  6. 3
      gui/status_ui.hpp
  7. 0
      simplefsm.hpp
  8. 2
      tests/battle.cpp
  9. 2
      tests/fsm.cpp
  10. 2
      tests/rituals.cpp

@ -86,7 +86,7 @@
"frame_height": 256
},
"peasant_girl":
{"path": "assets/undead_peasant-256.png",
{"path": "assets/peasant_girl_2-256.png",
"frame_width": 256,
"frame_height": 256
},

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

@ -1,7 +1,7 @@
#pragma once
#include "constants.hpp"
#include "levelmanager.hpp"
#include "../fsm.hpp"
#include "simplefsm.hpp"
#include "gui/debug_ui.hpp"
#include "gui/main_ui.hpp"
#include "gui/combat_ui.hpp"

@ -5,7 +5,7 @@
#include "textures.hpp"
#include <guecs/ui.hpp>
#include "rituals.hpp"
#include "fsm.hpp"
#include "simplefsm.hpp"
namespace gui {
namespace ritual {

@ -17,9 +17,9 @@ namespace gui {
"[ ritual_ui ]"
"[inv_slot1 | inv_slot2 | inv_slot3]"
"[inv_slot4 | inv_slot5 | inv_slot6]"
"[*%(100,300)log_view]"
"[_]"
"[_]");
"[*%(200,300)character_view|_|stat1]"
"[_|_|stat2]"
"[_|_|stat3]");
size_t inv_id = 0;
for(auto [name, entity] : $gui.$name_ents) {
@ -33,10 +33,14 @@ namespace gui {
$gui.set<Background>($gui.MAIN, {$gui.$parser});
for(auto& [name, cell] : $gui.cells()) {
if(name == "log_view") {
$log_to = $gui.entity("log_view");
$gui.set<Rectangle>($log_to, {});
$gui.set<Textual>($log_to, {L"Welcome to the Game!", 20});
if(name == "character_view") {
auto char_view = $gui.entity(name);
$gui.set<Rectangle>(char_view, {});
$gui.set<Sprite>(char_view, {"peasant_girl"});
} else if(name.starts_with("stat")) {
auto stat = $gui.entity(name);
$gui.set<Rectangle>(stat, {});
$gui.set<Label>(stat, {guecs::to_wstring(name)});
} else {
auto button = $gui.entity(name);
$gui.set<Rectangle>(button, {});
@ -84,30 +88,12 @@ namespace gui {
if(inventory.has_item(inv_id)) {
auto [used, name] = inventory.use($level, inv_id);
if(used) {
// log(fmt::format(L"Used item: {}", name));
log(fmt::format(L"Used item: {}", L"FIX ME ZED"));
} else {
// log(fmt::format(L"You are out of {}.", name));
log(fmt::format(L"Used item: {}", L"FIX ME ZED"));
}
}
}
}
/* WARNING: This is really not the greatest way to do this. */
void StatusUI::update() {
if($gui.has<Textual>($log_to)) {
auto& text = $gui.get<Textual>($log_to);
//BUG: I'm calling this what it is, fix it
wstring log_garbage;
for(auto msg : $messages) {
log_garbage += msg + L"\n";
}
text.update(log_garbage);
}
auto world = $level.world;
if(world->has<components::Inventory>($level.player)) {
auto& inventory = world->get<components::Inventory>($level.player);
@ -136,17 +122,10 @@ namespace gui {
void StatusUI::render(sf::RenderWindow &window) {
$gui.render(window);
// $gui.debug_layout(window);
$ritual_ui.render(window);
}
void StatusUI::log(wstring msg) {
$messages.push_front(msg);
if($messages.size() > MAX_LOG_MESSAGES) {
$messages.pop_back();
}
update();
}
void StatusUI::update_level(GameLevel &level) {
$level = level;
init();

@ -10,9 +10,7 @@ namespace gui {
class StatusUI {
public:
guecs::UI $gui;
DinkyECS::Entity $log_to;
std::map<std::string, size_t> $slots;
std::deque<std::wstring> $messages;
GameLevel $level;
ritual::UI $ritual_ui;
@ -21,7 +19,6 @@ namespace gui {
void select_ritual();
void update_level(GameLevel &level);
bool mouse(float x, float y, bool hover);
void log(std::wstring msg);
void init();
void render(sf::RenderWindow &window);
void update();

@ -2,7 +2,7 @@
#include <iostream>
#include "rituals.hpp"
#include "battle.hpp"
#include "fsm.hpp"
#include "simplefsm.hpp"
#include "dinkyecs.hpp"
using namespace combat;

@ -1,7 +1,7 @@
#include <catch2/catch_test_macros.hpp>
#include <fmt/core.h>
#include <string>
#include "../fsm.hpp"
#include "simplefsm.hpp"
using namespace fmt;
using std::string;

@ -1,7 +1,7 @@
#include <catch2/catch_test_macros.hpp>
#include <iostream>
#include "rituals.hpp"
#include "fsm.hpp"
#include "simplefsm.hpp"
#include "dinkyecs.hpp"
#include "levelmanager.hpp"
#include "ai_debug.hpp"

Loading…
Cancel
Save