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

@ -40,12 +40,11 @@ Pathing compute_paths(gui::FSM& fsm) {
return paths;
}
void Autowalker::log(std::string msg) {
dbc::log(fmt::format(">>> AUTOWALK: {}", msg));
void Autowalker::log(std::wstring msg) {
fsm.$status_ui.log(msg);
}
void Autowalker::status(std::string msg) {
void Autowalker::status(std::wstring msg) {
fsm.$main_ui.$overlay_ui.show_text("bottom", msg);
}
@ -71,12 +70,12 @@ void Autowalker::handle_window_events() {
[&](const sf::Event::KeyPressed &) {
fsm.autowalking = false;
close_status();
log("Aborting autowalk.");
log(L"Aborting autowalk.");
},
[&](const sf::Event::MouseButtonPressed &) {
fsm.autowalking = false;
close_status();
log("Aborting autowalk.");
log(L"Aborting autowalk.");
}
);
}
@ -99,8 +98,8 @@ Point Autowalker::get_current_position() {
}
void Autowalker::path_fail(Matrix& bad_paths, Point pos) {
status("PATH FAIL");
log("Autowalk failed to find a path.");
status(L"PATH FAIL");
log(L"Autowalk failed to find a path.");
matrix::dump("MOVE FAIL PATHS", bad_paths, pos.x, pos.y);
send_event(gui::Event::STAIRS_DOWN);
}
@ -225,12 +224,12 @@ void Autowalker::handle_player_walk(ai::State& start, ai::State& goal) {
if(action.name == "find_enemy") {
// this is where to test if enemy found and update state
status("FINDING ENEMY");
status(L"FINDING ENEMY");
auto paths = path_to_enemies();
process_move(paths);
send_event(gui::Event::ATTACK);
} else if(action.name == "kill_enemy") {
status("KILLING ENEMY");
status(L"KILLING ENEMY");
// TODO: find the enemy and then rotate toward them
Point current = get_current_position();
@ -241,17 +240,18 @@ void Autowalker::handle_player_walk(ai::State& start, ai::State& goal) {
process_combat();
} else if(action.name == "use_healing") {
status("USING HEALING");
status(L"USING HEALING");
player_use_healing();
} else if(action.name == "collect_items") {
status("COLLECTING ITEMS");
status(L"COLLECTING ITEMS");
auto paths = path_to_items();
process_move(paths);
// path to the items and get them all
} else if(action == ai::FINAL_ACTION) {
close_status();
log("Autowalk done, nothing left to do.");
send_event(gui::Event::STAIRS_DOWN);
log(L"FINAL ACTION! Autowalk done.");
fsm.autowalking = false;
ai::dump_script("AUTOWALK", start, a_plan.script);
} else {
close_status();
dbc::log(fmt::format("Unknown action: {}", action.name));
@ -287,7 +287,7 @@ void Autowalker::process_move(Pathing& paths) {
if(!path_player(paths, target)) {
close_status();
log("No paths found, aborting autowalk.");
log(L"No paths found, aborting autowalk.");
return;
}