Almost working save sytem but the data I store is totally wrong. I need to also save the entity IDs being used and map them to the components.
This commit is contained in:
parent
babc190525
commit
d113dba42f
15 changed files with 213 additions and 64 deletions
11
gui.cpp
11
gui.cpp
|
@ -24,7 +24,7 @@ using std::string;
|
|||
using namespace fmt;
|
||||
using namespace std::chrono_literals;
|
||||
using namespace ftxui;
|
||||
using namespace Components;
|
||||
using namespace components;
|
||||
|
||||
|
||||
GUI::GUI(DinkyECS::World &world, Map& game_map) :
|
||||
|
@ -56,6 +56,13 @@ void GUI::resize_map(int new_size) {
|
|||
}
|
||||
}
|
||||
|
||||
void GUI::save_world() {
|
||||
tser::BinaryArchive archive;
|
||||
archive.save($world);
|
||||
std::string_view archive_view = archive.get_buffer();
|
||||
$log.log(format("Game saved! {} bytes.", archive_view.size()));
|
||||
}
|
||||
|
||||
void GUI::create_renderer() {
|
||||
Terminal::SetColorSupport(Terminal::Color::TrueColor);
|
||||
auto player = $world.get_the<Player>();
|
||||
|
@ -151,6 +158,8 @@ bool GUI::handle_ui_events() {
|
|||
resize_map(map_font_size + 10);
|
||||
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Hyphen)) {
|
||||
resize_map(map_font_size - 10);
|
||||
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) {
|
||||
save_world();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue