Not working anymore. Issue opened.
This commit is contained in:
parent
b759836989
commit
1266628646
@ -5,6 +5,11 @@ project(BillySheet LANGUAGES CXX C)
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(GLEW REQUIRED)
|
||||
|
||||
# see https://cmake.org/cmake/help/latest/module/FindBoost.html
|
||||
find_package(Boost REQUIRED COMPONENTS stacktrace_addr2line)
|
||||
|
||||
include_directories(${Boost_INCLUDE_DIR})
|
||||
|
||||
set(PRECOMPILE_HEADERS
|
||||
include/gui/gui.hpp
|
||||
include/gui/gui_data.hpp
|
||||
@ -143,9 +148,11 @@ set_target_properties(glfw PROPERTIES
|
||||
C_STANDARD_REQUIRED ON
|
||||
C_EXTENSIONS OFF
|
||||
INTERPROCEDURAL_OPTIMIZATION ON
|
||||
# UNITY_BUILD ON
|
||||
UNITY_BUILD ON
|
||||
)
|
||||
|
||||
set_target_properties(spdlog PROPERTIES UNITY_BUILD ON)
|
||||
|
||||
#target_precompile_headers(BillySheet PRIVATE ${PRECOMPILE_HEADERS})
|
||||
target_compile_definitions(BillySheet PRIVATE
|
||||
$<$<CONFIG:Debug>:_GLIBCXX_DEBUG>
|
||||
@ -162,4 +169,4 @@ target_link_options(BillySheet PRIVATE ${LINKER_OPTIONS})
|
||||
|
||||
target_link_libraries(spdlog PRIVATE ${LINKER_FLAGS})
|
||||
target_link_libraries(glfw PRIVATE ${LINKER_FLAGS})
|
||||
target_link_libraries(BillySheet glfw spdlog OpenGL::OpenGL GLEW::GLEW nlohmann_json::nlohmann_json ${LINKER_FLAGS})
|
||||
target_link_libraries(BillySheet glfw spdlog OpenGL::OpenGL GLEW::GLEW nlohmann_json::nlohmann_json ${Boost_LIBRARIES} ${LINKER_FLAGS})
|
||||
|
@ -5,20 +5,26 @@
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class Controller;
|
||||
|
||||
namespace character {
|
||||
class CharacterSheet;
|
||||
}
|
||||
|
||||
namespace gui::menu {
|
||||
class MenuData final {
|
||||
public:
|
||||
static constexpr const char *const open_character_key{ "CharacterSheetOpen" };
|
||||
|
||||
static constexpr const char *const save_character_key{ "CharacterSheetSaveAs" };
|
||||
private:
|
||||
friend class Menu;
|
||||
|
||||
const character::CharacterSheet &character_sheet;
|
||||
|
||||
fs::path save_path{ "./" };
|
||||
mutable fs::path save_path{ "./" };
|
||||
|
||||
std::string filename{ "character_sheet.json" };
|
||||
mutable std::string filename{ "character_sheet.json" };
|
||||
|
||||
bool edit_mode{ true };
|
||||
public:
|
||||
@ -29,6 +35,10 @@ namespace gui::menu {
|
||||
~MenuData() noexcept = default;
|
||||
|
||||
[[nodiscard]] bool is_edit_mode() const { return edit_mode; }
|
||||
|
||||
void set_save_path(const fs::path &savePath) const { save_path = savePath; }
|
||||
|
||||
void set_filename(const std::string &fileName) const { filename = fileName; }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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"));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user