Not working anymore. Issue opened.

This commit is contained in:
Pcornat 2022-01-17 23:36:12 +01:00
parent b759836989
commit 1266628646
Signed by: Pcornat
GPG key ID: 2F3932FF46D9ECA0
6 changed files with 65 additions and 9 deletions

View file

@ -1,7 +1,29 @@
#include "controller.hpp"
#include "gui/menu/menu_data.hpp"
#include "ImFileDialog.h"
#include <spdlog/spdlog.h>
void Controller::control() noexcept {
SPDLOG_DEBUG("Check \"open character\" task");
if (ifd::FileDialog::Instance().IsDone(gui::menu::MenuData::open_character_key)) {
SPDLOG_DEBUG("Task done");
if (ifd::FileDialog::Instance().HasResult()) {
SPDLOG_DEBUG("Has Result");
fs::path str = ifd::FileDialog::Instance().GetResult();
SPDLOG_DEBUG("path opening: {}", str.string());
}
ifd::FileDialog::Instance().Close();
}
SPDLOG_DEBUG("Check \"saving character\" task");
if (ifd::FileDialog::Instance().IsDone(gui::menu::MenuData::save_character_key)) {
SPDLOG_DEBUG("Task done");
if (ifd::FileDialog::Instance().HasResult()) {
SPDLOG_DEBUG("Has Result");
const fs::path str = ifd::FileDialog::Instance().GetResult();
SPDLOG_DEBUG("path saving: {}", str.string());
}
ifd::FileDialog::Instance().Close();
}
if (menu_data.is_edit_mode()) {
// TODO
} else {

View file

@ -60,7 +60,6 @@ void gui::Gui::render_gui() {
ImGui::PushItemWidth(-1);
ImGui::InputTextMultiline("Caractère", &data.billy.caractere);
ImGui::PopItemWidth();
ImGui::TreePop();
ImGui::EndChild();
}
ImGui::SameLine();
@ -95,7 +94,7 @@ void gui::Gui::render_gui() {
void gui::Gui::render_gpu() const {
if (initialized) {
glClear(GL_COLOR_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
}
}

View file

@ -12,14 +12,17 @@ gui::menu::Menu::Menu(gui::menu::MenuData &data) noexcept: data(data) {
SPDLOG_DEBUG("Creating Menu");
ifd::FileDialog::Instance().CreateTexture = [](uint8_t *data, int w, int h, char fmt) -> void * {
GLuint tex;
SPDLOG_DEBUG("Inside CreateTexture for file dialog.");
glGenTextures(1, &tex);
SPDLOG_DEBUG("texture generated");
glBindTexture(GL_TEXTURE_2D, tex);
SPDLOG_DEBUG("Texture binded");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, (fmt == 0) ? GL_BGRA : GL_RGBA, GL_UNSIGNED_BYTE, data);
SPDLOG_DEBUG("Before mipmap");
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
@ -36,17 +39,23 @@ void gui::menu::Menu::gui() const noexcept {
if (ImGui::BeginMenuBar()) {
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("Open file")) {
// TODO
SPDLOG_DEBUG("Opening file");
ifd::FileDialog::Instance().Open(MenuData::open_character_key, "Open a character sheet", "Character sheet (*.json){.json},.*");
SPDLOG_DEBUG("File opened");
}
if (ImGui::MenuItem("Save")) {
SPDLOG_DEBUG("Saving file with know path");
std::ofstream file{ data.save_path / data.filename };
nlohmann::json j;
j.emplace("character_sheet", data.character_sheet);
file << j;
}
if (ImGui::MenuItem("Save as...")) {
// TODO
SPDLOG_DEBUG("Saving with file dialog");
ifd::FileDialog::Instance().Save(MenuData::save_character_key, "Save character sheet as...", "*.json {.json}");
SPDLOG_DEBUG("File saved with dialog");
}
ImGui::EndMenu();

View file

@ -1,3 +1,4 @@
#include <boost/stacktrace.hpp>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include "gui/window.hpp"
@ -7,7 +8,15 @@
#include "controller.hpp"
#include "character_sheet.hpp"
void myTerminateHandler() {
try {
SPDLOG_CRITICAL(to_string(boost::stacktrace::stacktrace()));
} catch (...) {}
std::abort();
}
int main() {
std::set_terminate(myTerminateHandler);
std::ios::sync_with_stdio(false);
spdlog::set_default_logger(spdlog::stdout_color_st("console"));