Converted almost everything to use wstring so that it works better with SFML and the unicode/utf8 usage in the system.

This commit is contained in:
Zed A. Shaw 2025-03-28 12:40:46 -04:00
parent 47c6bfd531
commit 72951f308f
17 changed files with 156 additions and 162 deletions

View file

@ -4,6 +4,7 @@
#include "color.hpp"
#include "guecs.hpp"
#include "rand.hpp"
#include <fmt/xchar.h>
namespace gui {
using namespace guecs;
@ -36,11 +37,11 @@ namespace gui {
if(name == "log_view") {
$log_to = $gui.entity("log_view");
$gui.set<Rectangle>($log_to, {});
$gui.set<Textual>($log_to, {"Welcome to the Game!", 20});
$gui.set<Textual>($log_to, {L"Welcome to the Game!", 20});
} else {
auto button = $gui.entity(name);
$gui.set<Rectangle>(button, {});
$gui.set<Textual>(button, {""});
$gui.set<Textual>(button, {L""});
$gui.set<ActionData>(button, {make_any<string>(name)});
if(name == "ritual_ui") {
@ -85,9 +86,11 @@ namespace gui {
auto [used, name] = inventory.use($level, inv_id);
if(used) {
log(fmt::format("Used item: {}", name));
// log(fmt::format(L"Used item: {}", name));
log(fmt::format(L"Used item: {}", L"FIX ME ZED"));
} else {
log(fmt::format("You are out of {}.", name));
// log(fmt::format(L"You are out of {}.", name));
log(fmt::format(L"Used item: {}", L"FIX ME ZED"));
}
}
}
@ -97,11 +100,12 @@ namespace gui {
void StatusUI::update() {
if($gui.has<Textual>($log_to)) {
auto& text = $gui.get<Textual>($log_to);
string log;
//BUG: I'm calling this what it is, fix it
wstring log_garbage;
for(auto msg : $messages) {
log += msg + "\n";
log_garbage += msg + L"\n";
}
text.update(log);
text.update(log_garbage);
}
auto world = $level.world;
@ -135,7 +139,7 @@ namespace gui {
$ritual_ui.render(window);
}
void StatusUI::log(string msg) {
void StatusUI::log(wstring msg) {
$messages.push_front(msg);
if($messages.size() > MAX_LOG_MESSAGES) {
$messages.pop_back();