Refactored the maze functions to be a builder that can do different things to the maze. Also when I hit p in the game it'll save the map to a file. This was extremely hard for no reason.
This commit is contained in:
parent
20f03731e5
commit
5f1a453fb4
8 changed files with 270 additions and 254 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <codecvt>
|
||||
#include <iostream>
|
||||
#include <fmt/xchar.h>
|
||||
#include <fstream>
|
||||
|
||||
namespace gui {
|
||||
using namespace components;
|
||||
|
@ -58,6 +59,19 @@ namespace gui {
|
|||
// $gui.debug_layout(window);
|
||||
}
|
||||
|
||||
void MapViewUI::save_map(const std::string& outfile, int compass_dir) {
|
||||
std::wstring map_out = System::draw_map(
|
||||
$level, $level.map->width(), $level.map->height(), compass_dir);
|
||||
dbc::check(map_out.size() > 0, "WHAT? printed map has nothing in it.");
|
||||
|
||||
std::wofstream out(outfile, std::ios::binary);
|
||||
std::locale loc(std::locale::classic(), new std::codecvt_utf8<wchar_t>);
|
||||
out.imbue(loc);
|
||||
|
||||
out << map_out;
|
||||
dbc::check(out.good(), "failed to write map file");
|
||||
}
|
||||
|
||||
void MapViewUI::update() {
|
||||
if($gui.has<Textual>($log_to)) {
|
||||
auto& text = $gui.get<Textual>($log_to);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue