removing useless window owning in GuiData

This commit is contained in:
Pcornat 2022-02-09 23:43:49 +01:00
parent 9e4e6fa226
commit 420ad2c8d9
Signed by: Pcornat
GPG Key ID: 2F3932FF46D9ECA0
5 changed files with 8 additions and 14 deletions

View File

@ -12,6 +12,8 @@ namespace gui {
class GuiData; class GuiData;
class Window;
namespace menu { class MenuData; } namespace menu { class MenuData; }
class Gui final { class Gui final {
@ -43,7 +45,7 @@ namespace gui {
public: public:
Gui() = delete; Gui() = delete;
explicit Gui(GuiData &data, menu::MenuData &menuData); explicit Gui(Window &window, GuiData &data, menu::MenuData &menuData);
~Gui() noexcept; ~Gui() noexcept;

View File

@ -11,7 +11,6 @@ namespace character {
using namespace std::string_view_literals; using namespace std::string_view_literals;
namespace gui { namespace gui {
class Window;
enum class characChanged { enum class characChanged {
None, None,
@ -25,8 +24,6 @@ namespace gui {
private: private:
friend class Gui; friend class Gui;
Window &window;
character::CharacterSheet &billy; character::CharacterSheet &billy;
std::pair<characChanged, std::uint32_t> base{ characChanged::None, 0 }; std::pair<characChanged, std::uint32_t> base{ characChanged::None, 0 };
@ -47,12 +44,10 @@ namespace gui {
GuiData() = delete; GuiData() = delete;
explicit GuiData(Window &wwindow, character::CharacterSheet &billy) : window(wwindow), billy(billy) { SPDLOG_DEBUG("Creating GUI Data"); } explicit GuiData(character::CharacterSheet &billy) noexcept: billy(billy) { SPDLOG_DEBUG("Creating GUI Data"); }
~GuiData() noexcept = default; ~GuiData() noexcept = default;
[[nodiscard]] Window &get_window() const;
[[nodiscard]] const std::pair<characChanged, std::uint32_t> &get_base() const { return base; } [[nodiscard]] const std::pair<characChanged, std::uint32_t> &get_base() const { return base; }
[[nodiscard]] const std::pair<characChanged, std::uint32_t> &get_carac() const { return carac; } [[nodiscard]] const std::pair<characChanged, std::uint32_t> &get_carac() const { return carac; }

View File

@ -8,12 +8,12 @@
#include "character_sheet.hpp" #include "character_sheet.hpp"
#include "controller.hpp" #include "controller.hpp"
gui::Gui::Gui(GuiData &data, menu::MenuData &menuData) : data(data), menu(menuData), font("font/DejaVuSans.ttf") { gui::Gui::Gui(Window &window, GuiData &data, menu::MenuData &menuData) : data(data), menu(menuData), font("font/DejaVuSans.ttf") {
SPDLOG_DEBUG("Creating GUI"); SPDLOG_DEBUG("Creating GUI");
(void) ImGui::CreateContext(); (void) ImGui::CreateContext();
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
(void) ImGui::GetIO().Fonts->AddFontFromFileTTF(font.c_str(), 18.0f); (void) ImGui::GetIO().Fonts->AddFontFromFileTTF(font.c_str(), 18.0f);
(void) ImGui_ImplGlfw_InitForOpenGL(data.get_window().get_window().get(), true); (void) ImGui_ImplGlfw_InitForOpenGL(window.get_window().get(), true);
initialized = ImGui_ImplOpenGL3_Init("#version 130"); initialized = ImGui_ImplOpenGL3_Init("#version 130");
SPDLOG_DEBUG("Initialized: {}", initialized); SPDLOG_DEBUG("Initialized: {}", initialized);
} }

View File

@ -1,4 +1 @@
#include "gui/gui_data.hpp" #include "gui/gui_data.hpp"
#include "gui/window.hpp"
gui::Window &gui::GuiData::get_window() const { return window; }

View File

@ -14,10 +14,10 @@ int main() {
try { try {
gui::Window window; gui::Window window;
character::CharacterSheet billy; character::CharacterSheet billy;
gui::GuiData gui_data(window, billy); gui::GuiData gui_data(billy);
gui::menu::MenuData menu_data(billy); gui::menu::MenuData menu_data(billy);
Controller controller(billy, menu_data); Controller controller(billy, menu_data);
gui::Gui gui(gui_data, menu_data); gui::Gui gui(window, gui_data, menu_data);
while (!window.should_close()) { while (!window.should_close()) {
glfwPollEvents(); glfwPollEvents();