Writing is working.
This commit is contained in:
parent
3c1ce804a0
commit
2023360149
5 changed files with 31 additions and 9 deletions
|
@ -1,7 +1,10 @@
|
|||
#include "controller.hpp"
|
||||
#include "gui/menu/menu_data.hpp"
|
||||
#include "ImFileDialog.h"
|
||||
#include <fstream>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "ImFileDialog.h"
|
||||
#include "gui/menu/menu_data.hpp"
|
||||
#include "character_sheet.hpp"
|
||||
|
||||
void Controller::control_menu() const noexcept {
|
||||
if (ifd::FileDialog::Instance().IsDone(menu_data.open_character_key)) {
|
||||
|
@ -13,8 +16,16 @@ void Controller::control_menu() const noexcept {
|
|||
}
|
||||
if (ifd::FileDialog::Instance().IsDone(menu_data.save_character_key)) {
|
||||
if (ifd::FileDialog::Instance().HasResult()) {
|
||||
const fs::path str = ifd::FileDialog::Instance().GetResult();
|
||||
fs::path str = ifd::FileDialog::Instance().GetResult();
|
||||
SPDLOG_DEBUG("path saving: {}", str.string());
|
||||
const auto filename = str.filename();
|
||||
const auto save_path = str.remove_filename();
|
||||
menu_data.set_filename(*this, filename);
|
||||
menu_data.set_save_path(*this, save_path);
|
||||
std::ofstream file{ save_path / filename };
|
||||
json j;
|
||||
j.emplace("character_sheet", sheet);
|
||||
file << j.dump(4);
|
||||
}
|
||||
ifd::FileDialog::Instance().Close();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue