Better organization.

This commit is contained in:
Pcornat 2022-01-11 22:33:29 +01:00
parent c7b6b87005
commit 45c92db758
Signed by: Pcornat
GPG key ID: 2F3932FF46D9ECA0
8 changed files with 26 additions and 20 deletions

32
include/gui/gui.hpp Normal file
View file

@ -0,0 +1,32 @@
#ifndef BILLYSHEET_GUI_HPP
#define BILLYSHEET_GUI_HPP
#include <filesystem>
namespace fs = std::filesystem;
namespace gui {
class GuiData;
class Gui final {
private:
GuiData &data;
fs::path font;
bool initialized{ false };
public:
Gui() = delete;
explicit Gui(GuiData &data);
~Gui() noexcept;
void render_gui();
void render_gpu() const;
};
}
#endif //BILLYSHEET_GUI_HPP

34
include/gui/gui_data.hpp Normal file
View file

@ -0,0 +1,34 @@
#ifndef BILLYSHEET_GUI_DATA_HPP
#define BILLYSHEET_GUI_DATA_HPP
#include "character_sheet.hpp"
#include <filesystem>
#include <spdlog/spdlog.h>
namespace fs = std::filesystem;
namespace gui {
class Window;
class GuiData final {
private:
Window &window;
character::CharacterSheet billy;
fs::path save_path{ "./" };
std::string filename{ "character_sheet.json" };
public:
GuiData() = delete;
explicit GuiData(Window &wwindow) : window(wwindow) { SPDLOG_DEBUG("Creating GUI Data"); }
[[nodiscard]] Window &get_window() const;
~GuiData() noexcept = default;
};
}
#endif //BILLYSHEET_GUI_DATA_HPP

32
include/gui/window.hpp Normal file
View file

@ -0,0 +1,32 @@
#ifndef BILLYSHEET_WINDOW_HPP
#define BILLYSHEET_WINDOW_HPP
#include <memory>
#include "imgui_impl_opengl3_loader.h"
#include "GLFW/glfw3.h"
namespace gui {
class Window final {
private:
static void delete_glfw_window(GLFWwindow *glfWwindow) {
glfwDestroyWindow(glfWwindow);
glfwTerminate();
}
std::unique_ptr<GLFWwindow, decltype(&delete_glfw_window)> wwindow{ nullptr, delete_glfw_window };
public:
Window();
~Window() noexcept = default;
[[nodiscard]] const std::unique_ptr<GLFWwindow, decltype(&delete_glfw_window)> &get_window() const { return wwindow; }
[[nodiscard]] bool should_close() const noexcept;
void swap_buffers() const noexcept;
};
}
#endif //BILLYSHEET_WINDOW_HPP