The log is now moved to the map, but changing StatusUI caused a weird compiler error so need to remove logs from that separate.
This commit is contained in:
parent
a2246d2b71
commit
d6e64dd06b
5 changed files with 40 additions and 29 deletions
|
@ -42,7 +42,7 @@ Pathing compute_paths(gui::FSM& fsm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Autowalker::log(std::wstring msg) {
|
void Autowalker::log(std::wstring msg) {
|
||||||
fsm.$status_ui.log(msg);
|
fsm.$map_ui.log(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Autowalker::status(std::wstring msg) {
|
void Autowalker::status(std::wstring msg) {
|
||||||
|
|
19
gui/fsm.cpp
19
gui/fsm.cpp
|
@ -58,12 +58,12 @@ namespace gui {
|
||||||
$combat_ui.init();
|
$combat_ui.init();
|
||||||
$status_ui.init();
|
$status_ui.init();
|
||||||
|
|
||||||
$status_ui.log(L"Welcome to the game!");
|
|
||||||
|
|
||||||
$boss_fight_ui = $levels.create_bossfight($level.world);
|
$boss_fight_ui = $levels.create_bossfight($level.world);
|
||||||
$boss_fight_ui->init();
|
$boss_fight_ui->init();
|
||||||
|
|
||||||
$map_ui.init();
|
$map_ui.init();
|
||||||
|
$map_ui.log(L"Welcome to the game!");
|
||||||
$mini_map.init($main_ui.$overlay_ui.$gui);
|
$mini_map.init($main_ui.$overlay_ui.$gui);
|
||||||
|
|
||||||
run_systems();
|
run_systems();
|
||||||
|
@ -397,15 +397,15 @@ namespace gui {
|
||||||
auto &damage = std::any_cast<Events::Combat&>(data);
|
auto &damage = std::any_cast<Events::Combat&>(data);
|
||||||
|
|
||||||
if(damage.enemy_did > 0) {
|
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 {
|
} else {
|
||||||
$status_ui.log(L"Enemy MISSED YOU.");
|
$map_ui.log(L"Enemy MISSED YOU.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(damage.player_did > 0) {
|
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 {
|
} else {
|
||||||
$status_ui.log(L"You MISSED the enemy.");
|
$map_ui.log(L"You MISSED the enemy.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -425,10 +425,7 @@ namespace gui {
|
||||||
event(Event::LOOT_OPEN);
|
event(Event::LOOT_OPEN);
|
||||||
break;
|
break;
|
||||||
case eGUI::LOOT: {
|
case eGUI::LOOT: {
|
||||||
// auto &item = std::any_cast<InventoryItem&>(data);
|
$map_ui.log(L"You picked up an item.");
|
||||||
// $status_ui.log(fmt::format("You picked up a {}.",
|
|
||||||
// std::string(item.data["name"])));
|
|
||||||
$status_ui.log(L"You picked up an item.");
|
|
||||||
} break;
|
} break;
|
||||||
case eGUI::HP_STATUS:
|
case eGUI::HP_STATUS:
|
||||||
System::player_status($level);
|
System::player_status($level);
|
||||||
|
@ -456,11 +453,11 @@ namespace gui {
|
||||||
case eGUI::NOOP: {
|
case eGUI::NOOP: {
|
||||||
if(data.type() == typeid(std::string)) {
|
if(data.type() == typeid(std::string)) {
|
||||||
auto name = std::any_cast<std::string>(data);
|
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;
|
} break;
|
||||||
default:
|
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
|
#pragma once
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include "stats.hpp"
|
|
||||||
#include "levelmanager.hpp"
|
#include "levelmanager.hpp"
|
||||||
#include "../fsm.hpp"
|
#include "../fsm.hpp"
|
||||||
#include "gui/debug_ui.hpp"
|
#include "gui/debug_ui.hpp"
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
using namespace components;
|
using namespace components;
|
||||||
|
using namespace guecs;
|
||||||
|
|
||||||
MapViewUI::MapViewUI(GameLevel &level) :
|
MapViewUI::MapViewUI(GameLevel &level) :
|
||||||
$level(level),
|
$level(level),
|
||||||
|
@ -29,16 +30,15 @@ namespace gui {
|
||||||
//auto cell = overlay.cell_for(top_right);
|
//auto cell = overlay.cell_for(top_right);
|
||||||
$gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
$gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||||
$gui.layout(
|
$gui.layout(
|
||||||
"[status| *%(200)map_grid | _ ]"
|
"[log_view| *%(200)map_grid | _ ]"
|
||||||
);
|
);
|
||||||
|
|
||||||
auto grid = $gui.entity("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});
|
{L"Loading...", 65, {27, 26, 23, 150}, 10});
|
||||||
|
|
||||||
auto status = $gui.entity("status");
|
$log_to = $gui.entity("log_view");
|
||||||
$gui.set<guecs::Textual>(status,
|
$gui.set<Textual>($log_to, {L"Welcome to the Game!", 25, {37, 36, 33}, 25});
|
||||||
{L"Loading...", 25, {37, 36, 33}, 25});
|
|
||||||
|
|
||||||
$paper.sprite->setPosition({0, 0});
|
$paper.sprite->setPosition({0, 0});
|
||||||
$gui.init();
|
$gui.init();
|
||||||
|
@ -48,23 +48,33 @@ namespace gui {
|
||||||
window.draw(*$paper.sprite);
|
window.draw(*$paper.sprite);
|
||||||
|
|
||||||
auto grid = $gui.entity("map_grid");
|
auto grid = $gui.entity("map_grid");
|
||||||
auto status = $gui.entity("status");
|
|
||||||
|
|
||||||
std::wstring map_out = System::draw_map($level, 23, 9, compass_dir);
|
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);
|
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.render(window);
|
||||||
// $gui.debug_layout(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 "textures.hpp"
|
||||||
#include <guecs/ui.hpp>
|
#include <guecs/ui.hpp>
|
||||||
#include "tilemap.hpp"
|
#include "tilemap.hpp"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
class MapViewUI {
|
class MapViewUI {
|
||||||
public:
|
public:
|
||||||
guecs::UI $gui;
|
guecs::UI $gui;
|
||||||
GameLevel $level;
|
GameLevel $level;
|
||||||
|
DinkyECS::Entity $log_to;
|
||||||
textures::SpriteTexture $paper;
|
textures::SpriteTexture $paper;
|
||||||
|
std::deque<std::wstring> $messages;
|
||||||
|
|
||||||
MapViewUI(GameLevel &level);
|
MapViewUI(GameLevel &level);
|
||||||
void init();
|
void init();
|
||||||
void render(sf::RenderWindow &window, int compass_dir);
|
void render(sf::RenderWindow &window, int compass_dir);
|
||||||
void update_level(GameLevel &level);
|
void update_level(GameLevel &level);
|
||||||
|
void log(std::wstring msg);
|
||||||
|
void update();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue