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(OpenGL REQUIRED)
|
||||||
find_package(GLEW 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
|
set(PRECOMPILE_HEADERS
|
||||||
include/gui/gui.hpp
|
include/gui/gui.hpp
|
||||||
include/gui/gui_data.hpp
|
include/gui/gui_data.hpp
|
||||||
@ -143,9 +148,11 @@ set_target_properties(glfw PROPERTIES
|
|||||||
C_STANDARD_REQUIRED ON
|
C_STANDARD_REQUIRED ON
|
||||||
C_EXTENSIONS OFF
|
C_EXTENSIONS OFF
|
||||||
INTERPROCEDURAL_OPTIMIZATION ON
|
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_precompile_headers(BillySheet PRIVATE ${PRECOMPILE_HEADERS})
|
||||||
target_compile_definitions(BillySheet PRIVATE
|
target_compile_definitions(BillySheet PRIVATE
|
||||||
$<$<CONFIG:Debug>:_GLIBCXX_DEBUG>
|
$<$<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(spdlog PRIVATE ${LINKER_FLAGS})
|
||||||
target_link_libraries(glfw 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;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
class Controller;
|
||||||
|
|
||||||
namespace character {
|
namespace character {
|
||||||
class CharacterSheet;
|
class CharacterSheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace gui::menu {
|
namespace gui::menu {
|
||||||
class MenuData final {
|
class MenuData final {
|
||||||
|
public:
|
||||||
|
static constexpr const char *const open_character_key{ "CharacterSheetOpen" };
|
||||||
|
|
||||||
|
static constexpr const char *const save_character_key{ "CharacterSheetSaveAs" };
|
||||||
private:
|
private:
|
||||||
friend class Menu;
|
friend class Menu;
|
||||||
|
|
||||||
const character::CharacterSheet &character_sheet;
|
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 };
|
bool edit_mode{ true };
|
||||||
public:
|
public:
|
||||||
@ -29,6 +35,10 @@ namespace gui::menu {
|
|||||||
~MenuData() noexcept = default;
|
~MenuData() noexcept = default;
|
||||||
|
|
||||||
[[nodiscard]] bool is_edit_mode() const { return edit_mode; }
|
[[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 "controller.hpp"
|
||||||
#include "gui/menu/menu_data.hpp"
|
#include "gui/menu/menu_data.hpp"
|
||||||
|
#include "ImFileDialog.h"
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
void Controller::control() noexcept {
|
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()) {
|
if (menu_data.is_edit_mode()) {
|
||||||
// TODO
|
// TODO
|
||||||
} else {
|
} else {
|
||||||
|
@ -60,7 +60,6 @@ void gui::Gui::render_gui() {
|
|||||||
ImGui::PushItemWidth(-1);
|
ImGui::PushItemWidth(-1);
|
||||||
ImGui::InputTextMultiline("Caractère", &data.billy.caractere);
|
ImGui::InputTextMultiline("Caractère", &data.billy.caractere);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGui::TreePop();
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -95,7 +94,7 @@ void gui::Gui::render_gui() {
|
|||||||
|
|
||||||
void gui::Gui::render_gpu() const {
|
void gui::Gui::render_gpu() const {
|
||||||
if (initialized) {
|
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());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,17 @@ gui::menu::Menu::Menu(gui::menu::MenuData &data) noexcept: data(data) {
|
|||||||
SPDLOG_DEBUG("Creating Menu");
|
SPDLOG_DEBUG("Creating Menu");
|
||||||
ifd::FileDialog::Instance().CreateTexture = [](uint8_t *data, int w, int h, char fmt) -> void * {
|
ifd::FileDialog::Instance().CreateTexture = [](uint8_t *data, int w, int h, char fmt) -> void * {
|
||||||
GLuint tex;
|
GLuint tex;
|
||||||
|
SPDLOG_DEBUG("Inside CreateTexture for file dialog.");
|
||||||
glGenTextures(1, &tex);
|
glGenTextures(1, &tex);
|
||||||
|
SPDLOG_DEBUG("texture generated");
|
||||||
glBindTexture(GL_TEXTURE_2D, tex);
|
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_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, 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);
|
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);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
@ -36,17 +39,23 @@ void gui::menu::Menu::gui() const noexcept {
|
|||||||
if (ImGui::BeginMenuBar()) {
|
if (ImGui::BeginMenuBar()) {
|
||||||
if (ImGui::BeginMenu("File")) {
|
if (ImGui::BeginMenu("File")) {
|
||||||
if (ImGui::MenuItem("Open 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")) {
|
if (ImGui::MenuItem("Save")) {
|
||||||
|
SPDLOG_DEBUG("Saving file with know path");
|
||||||
std::ofstream file{ data.save_path / data.filename };
|
std::ofstream file{ data.save_path / data.filename };
|
||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
j.emplace("character_sheet", data.character_sheet);
|
j.emplace("character_sheet", data.character_sheet);
|
||||||
|
file << j;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::MenuItem("Save as...")) {
|
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();
|
ImGui::EndMenu();
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <boost/stacktrace.hpp>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||||
#include "gui/window.hpp"
|
#include "gui/window.hpp"
|
||||||
@ -7,7 +8,15 @@
|
|||||||
#include "controller.hpp"
|
#include "controller.hpp"
|
||||||
#include "character_sheet.hpp"
|
#include "character_sheet.hpp"
|
||||||
|
|
||||||
|
void myTerminateHandler() {
|
||||||
|
try {
|
||||||
|
SPDLOG_CRITICAL(to_string(boost::stacktrace::stacktrace()));
|
||||||
|
} catch (...) {}
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
std::set_terminate(myTerminateHandler);
|
||||||
std::ios::sync_with_stdio(false);
|
std::ios::sync_with_stdio(false);
|
||||||
spdlog::set_default_logger(spdlog::stdout_color_st("console"));
|
spdlog::set_default_logger(spdlog::stdout_color_st("console"));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user