The log is now moved to the map, but changing StatusUI caused a weird compiler error so need to remove logs from that separate.

master
Zed A. Shaw 1 day ago
parent a2246d2b71
commit d6e64dd06b
  1. 2
      autowalker.cpp
  2. 19
      gui/fsm.cpp
  3. 1
      gui/fsm.hpp
  4. 42
      gui/map_view.cpp
  5. 5
      gui/map_view.hpp

@ -42,7 +42,7 @@ Pathing compute_paths(gui::FSM& fsm) {
}
void Autowalker::log(std::wstring msg) {
fsm.$status_ui.log(msg);
fsm.$map_ui.log(msg);
}
void Autowalker::status(std::wstring msg) {

@ -58,12 +58,12 @@ namespace gui {
$combat_ui.init();
$status_ui.init();
$status_ui.log(L"Welcome to the game!");
$boss_fight_ui = $levels.create_bossfight($level.world);
$boss_fight_ui->init();
$map_ui.init();
$map_ui.log(L"Welcome to the game!");
$mini_map.init($main_ui.$overlay_ui.$gui);
run_systems();
@ -397,15 +397,15 @@ namespace gui {
auto &damage = std::any_cast<Events::Combat&>(data);
if(damage.enemy_did > 0) {
$status_ui.log(fmt::format(L"Enemy HIT YOU for {} damage!", damage.enemy_did));
$map_ui.log(fmt::format(L"Enemy HIT YOU for {} damage!", damage.enemy_did));
} else {
$status_ui.log(L"Enemy MISSED YOU.");
$map_ui.log(L"Enemy MISSED YOU.");
}
if(damage.player_did > 0) {
$status_ui.log(fmt::format(L"You HIT enemy for {} damage!", damage.player_did));
$map_ui.log(fmt::format(L"You HIT enemy for {} damage!", damage.player_did));
} else {
$status_ui.log(L"You MISSED the enemy.");
$map_ui.log(L"You MISSED the enemy.");
}
}
break;
@ -425,10 +425,7 @@ namespace gui {
event(Event::LOOT_OPEN);
break;
case eGUI::LOOT: {
// auto &item = std::any_cast<InventoryItem&>(data);
// $status_ui.log(fmt::format("You picked up a {}.",
// std::string(item.data["name"])));
$status_ui.log(L"You picked up an item.");
$map_ui.log(L"You picked up an item.");
} break;
case eGUI::HP_STATUS:
System::player_status($level);
@ -456,11 +453,11 @@ namespace gui {
case eGUI::NOOP: {
if(data.type() == typeid(std::string)) {
auto name = std::any_cast<std::string>(data);
$status_ui.log(fmt::format(L"NOOP EVENT! {},{}", evt, entity));
$map_ui.log(fmt::format(L"NOOP EVENT! {},{}", evt, entity));
}
} break;
default:
$status_ui.log(fmt::format(L"INVALID EVENT! {},{}", evt, entity));
$map_ui.log(fmt::format(L"INVALID EVENT! {},{}", evt, entity));
}
}
}

@ -1,6 +1,5 @@
#pragma once
#include "constants.hpp"
#include "stats.hpp"
#include "levelmanager.hpp"
#include "../fsm.hpp"
#include "gui/debug_ui.hpp"

@ -13,6 +13,7 @@
namespace gui {
using namespace components;
using namespace guecs;
MapViewUI::MapViewUI(GameLevel &level) :
$level(level),
@ -29,16 +30,15 @@ namespace gui {
//auto cell = overlay.cell_for(top_right);
$gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
$gui.layout(
"[status| *%(200)map_grid | _ ]"
"[log_view| *%(200)map_grid | _ ]"
);
auto grid = $gui.entity("map_grid");
$gui.set<guecs::Textual>(grid,
$gui.set<Textual>(grid,
{L"Loading...", 65, {27, 26, 23, 150}, 10});
auto status = $gui.entity("status");
$gui.set<guecs::Textual>(status,
{L"Loading...", 25, {37, 36, 33}, 25});
$log_to = $gui.entity("log_view");
$gui.set<Textual>($log_to, {L"Welcome to the Game!", 25, {37, 36, 33}, 25});
$paper.sprite->setPosition({0, 0});
$gui.init();
@ -48,23 +48,33 @@ namespace gui {
window.draw(*$paper.sprite);
auto grid = $gui.entity("map_grid");
auto status = $gui.entity("status");
std::wstring map_out = System::draw_map($level, 23, 9, compass_dir);
auto& map_text = $gui.get<guecs::Textual>(grid);
auto& map_text = $gui.get<Textual>(grid);
map_text.update(map_out);
auto& status_text = $gui.get<guecs::Textual>(status);
std::wstring status_out = fmt::format(
L"Level: {}\n"
L"Enemies Killed: A Lot\n",
$level.index + 1);
status_text.update(status_out);
$gui.render(window);
// $gui.debug_layout(window);
}
void MapViewUI::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);
}
}
void MapViewUI::log(wstring msg) {
$messages.push_front(msg);
if($messages.size() > MAX_LOG_MESSAGES) {
$messages.pop_back();
}
update();
}
}

@ -3,17 +3,22 @@
#include "textures.hpp"
#include <guecs/ui.hpp>
#include "tilemap.hpp"
#include <string>
namespace gui {
class MapViewUI {
public:
guecs::UI $gui;
GameLevel $level;
DinkyECS::Entity $log_to;
textures::SpriteTexture $paper;
std::deque<std::wstring> $messages;
MapViewUI(GameLevel &level);
void init();
void render(sf::RenderWindow &window, int compass_dir);
void update_level(GameLevel &level);
void log(std::wstring msg);
void update();
};
}

Loading…
Cancel
Save