diff --git a/include/gui/gui.hpp b/include/gui/gui.hpp index e2d718e..60f8284 100644 --- a/include/gui/gui.hpp +++ b/include/gui/gui.hpp @@ -8,6 +8,10 @@ namespace fs = std::filesystem; class Controller; +namespace character::characteristic { + class Characteristic; +} + namespace gui { class GuiData; @@ -52,6 +56,8 @@ namespace gui { void render_gui(const Controller &controller); void render_gpu() const; + + static void characteristic_gui(const character::characteristic::Characteristic &characteristic) noexcept; }; } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 69745ca..62a65ae 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -8,6 +8,9 @@ #include "character_sheet.hpp" #include "controller.hpp" #include "billy_objects.hpp" +#include "characteristic/characteristic.hpp" + +using character::characteristic::Characteristic; gui::Gui::Gui(Window &window, GuiData &data, menu::MenuData &menuData) : data(data), menu(menuData), font("font/DejaVuSans.ttf") { @@ -112,27 +115,26 @@ void gui::Gui::render_gpu() const { } } +void gui::Gui::characteristic_gui(const Characteristic &characteristic) noexcept { + int base = static_cast(characteristic.get_base()); + (void) ImGui::InputInt("Base", &base, 1, 100, ImGuiInputTextFlags_ReadOnly); + + int carac = static_cast(characteristic.get_carac()); + (void) ImGui::InputInt("Carac", &carac, 1, 100, ImGuiInputTextFlags_ReadOnly); + + int materiel = static_cast(characteristic.get_materiel()); + (void) ImGui::InputInt("Matériel", &materiel, 1, 100, ImGuiInputTextFlags_ReadOnly); + + int additional = static_cast(characteristic.get_additional()); + (void) ImGui::InputInt("Additionnel", &additional, 1, 100, ImGuiInputTextFlags_ReadOnly); +} + void gui::Gui::habilete_menu() noexcept { ImGui::BeginChild("habilete", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), ImGuiChildFlags_Border); 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; + characteristic_gui(static_cast(data.billy.get_habilete())); ImGui::EndChild(); } @@ -141,22 +143,7 @@ void gui::Gui::adresse_menu() noexcept { ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), ImGuiChildFlags_Border); ImGui::Text("Adresse"); - 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; + characteristic_gui(static_cast(data.billy.get_adresse())); ImGui::EndChild(); } @@ -165,24 +152,7 @@ void gui::Gui::endurance_menu() noexcept { ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), ImGuiChildFlags_Border); ImGui::Text("Endurance"); - - 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; + characteristic_gui(static_cast(data.billy.get_endurance())); ImGui::EndChild(); } @@ -191,22 +161,7 @@ void gui::Gui::chance_menu() noexcept { ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), ImGuiChildFlags_Border); ImGui::Text("Chance"); - 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; + characteristic_gui(static_cast(data.billy.get_chance())); ImGui::EndChild(); }