From 367d030ff11cfd7e116c8dd4aa1d3b3c97831ed4 Mon Sep 17 00:00:00 2001 From: Pcornat Date: Mon, 31 Jan 2022 20:37:35 +0100 Subject: [PATCH] Display and control characteristics --- include/gui/gui.hpp | 6 +++ include/gui/gui_data.hpp | 24 ++++++++++ src/gui/gui.cpp | 96 +++++++++++++++++++++++++++++++++++----- 3 files changed, 114 insertions(+), 12 deletions(-) diff --git a/include/gui/gui.hpp b/include/gui/gui.hpp index 3772008..0be67d1 100644 --- a/include/gui/gui.hpp +++ b/include/gui/gui.hpp @@ -34,6 +34,12 @@ namespace gui { void stat_second_menu() noexcept; + void materiel_menu() noexcept; + + void gloire_menu() noexcept; + + void richesse_menu() noexcept; + public: Gui() = delete; diff --git a/include/gui/gui_data.hpp b/include/gui/gui_data.hpp index 7b1aedc..6c4e574 100644 --- a/include/gui/gui_data.hpp +++ b/include/gui/gui_data.hpp @@ -13,6 +13,14 @@ using namespace std::string_view_literals; namespace gui { class Window; + enum class characChanged { + None, + Adresse, + Endurance, + Chance, + Habilete + }; + class GuiData final { private: friend class Gui; @@ -21,6 +29,14 @@ namespace gui { character::CharacterSheet &billy; + std::pair base{ characChanged::None, 0 }; + + std::pair carac{ characChanged::None, 0 }; + + std::pair materiel{ characChanged::None, 0 }; + + std::pair additional{ characChanged::None, 0 }; + public: static constexpr std::array classes{ "Guerrier"sv, @@ -36,6 +52,14 @@ namespace gui { ~GuiData() noexcept = default; [[nodiscard]] Window &get_window() const; + + [[nodiscard]] const std::pair &get_base() const { return base; } + + [[nodiscard]] const std::pair &get_carac() const { return carac; } + + [[nodiscard]] const std::pair &get_materiel() const { return materiel; } + + [[nodiscard]] const std::pair &get_additional() const { return additional; } }; } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index bb09274..6ee6208 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -87,6 +87,17 @@ void gui::Gui::render_gui(const Controller &controller) { stat_second_menu(); + materiel_menu(); + + ImGui::SameLine(); + + ImGui::BeginGroup(); + gloire_menu(); + + richesse_menu(); + ImGui::EndGroup(); + + ImGui::End(); controller.control_menu(); @@ -105,36 +116,79 @@ void gui::Gui::render_gpu() const { void gui::Gui::habilete_menu() noexcept { ImGui::BeginChild("habilete", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true); ImGui::Text("Habileté"); + data.base.second = data.billy.get_habilete().get_base(); + data.base.first = ImGui::InputInt("Base", reinterpret_cast(&data.base.second)) ? characChanged::Habilete : characChanged::None; + + data.carac.second = data.billy.get_habilete().get_carac(); + data.carac.first = ImGui::InputInt("Carac", reinterpret_cast(&data.carac.second)) ? characChanged::Habilete : characChanged::None; + + data.materiel.second = data.billy.get_habilete().get_materiel(); + data.materiel.first = ImGui::InputInt("Matériel", reinterpret_cast(&data.materiel.second)) ? characChanged::Habilete : characChanged::None; + + data.additional.second = data.billy.get_habilete().get_additional(); + data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast(&data.additional.second)) ? + characChanged::Habilete : + characChanged::None; ImGui::EndChild(); } void gui::Gui::adresse_menu() noexcept { ImGui::BeginChild("adresse", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true); ImGui::Text("Adresse"); - ImGui::Text("Bottom pane1"); - ImGui::Text("Bottom pane2"); - ImGui::Text("Bottom pane3"); - ImGui::Text("Bottom pane4"); + data.base.second = data.billy.get_adresse().get_base(); + data.base.first = ImGui::InputInt("Base", reinterpret_cast(&data.base.second)) ? characChanged::Adresse : characChanged::None; + + data.carac.second = data.billy.get_adresse().get_carac(); + data.carac.first = ImGui::InputInt("Carac", reinterpret_cast(&data.carac.second)) ? characChanged::Adresse : characChanged::None; + + data.materiel.second = data.billy.get_adresse().get_materiel(); + data.materiel.first = ImGui::InputInt("Matériel", reinterpret_cast(&data.materiel.second)) ? characChanged::Adresse : characChanged::None; + + data.additional.second = data.billy.get_adresse().get_additional(); + data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast(&data.additional.second)) ? + characChanged::Adresse : + characChanged::None; ImGui::EndChild(); } void gui::Gui::endurance_menu() noexcept { ImGui::BeginChild("endurance", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true); ImGui::Text("Endurance"); - ImGui::Text("Bottom pane1"); - ImGui::Text("Bottom pane2"); - ImGui::Text("Bottom pane3"); - ImGui::Text("Bottom pane4"); + + data.base.second = data.billy.get_endurance().get_base(); + data.base.first = ImGui::InputInt("Base", reinterpret_cast(&data.base.second)) ? characChanged::Endurance : characChanged::None; + + data.carac.second = data.billy.get_endurance().get_carac(); + data.carac.first = ImGui::InputInt("Carac", reinterpret_cast(&data.carac.second)) ? characChanged::Endurance : characChanged::None; + + data.materiel.second = data.billy.get_endurance().get_materiel(); + data.materiel.first = ImGui::InputInt("Matériel", reinterpret_cast(&data.materiel.second)) ? + characChanged::Endurance : + characChanged::None; + + data.additional.second = data.billy.get_endurance().get_additional(); + data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast(&data.additional.second)) ? + characChanged::Endurance : + characChanged::None; ImGui::EndChild(); } void gui::Gui::chance_menu() noexcept { ImGui::BeginChild("chance", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true); ImGui::Text("Chance"); - ImGui::Text("Bottom pane1"); - ImGui::Text("Bottom pane2"); - ImGui::Text("Bottom pane3"); - ImGui::Text("Bottom pane4"); + data.base.second = data.billy.get_chance().get_base(); + data.base.first = ImGui::InputInt("Base", reinterpret_cast(&data.base.second)) ? characChanged::Chance : characChanged::None; + + data.carac.second = data.billy.get_chance().get_carac(); + data.carac.first = ImGui::InputInt("Carac", reinterpret_cast(&data.carac.second)) ? characChanged::Chance : characChanged::None; + + data.materiel.second = data.billy.get_chance().get_materiel(); + data.materiel.first = ImGui::InputInt("Matériel", reinterpret_cast(&data.materiel.second)) ? characChanged::Chance : characChanged::None; + + data.additional.second = data.billy.get_chance().get_additional(); + data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast(&data.additional.second)) ? + characChanged::Chance : + characChanged::None; ImGui::EndChild(); } @@ -143,3 +197,21 @@ void gui::Gui::stat_second_menu() noexcept { ImGui::Text("STAT. SECONDAIRES"); ImGui::EndChild(); } + +void gui::Gui::materiel_menu() noexcept { + ImGui::BeginChild("materiel", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true); + ImGui::Text("Matériel"); + ImGui::EndChild(); +} + +void gui::Gui::gloire_menu() noexcept { + ImGui::BeginChild("gloire", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.1f), true); + ImGui::Text("Gloire"); + ImGui::EndChild(); +} + +void gui::Gui::richesse_menu() noexcept { + ImGui::BeginChild("richesse", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.1f), true); + ImGui::Text("Richesse"); + ImGui::EndChild(); +}