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
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue