Better displaying characteristics

This commit is contained in:
Pcornat 2024-02-26 23:40:46 +01:00
parent 7d4981e02c
commit 1d609f12d5
Signed by: Pcornat
GPG Key ID: E0326CC678A00BDD
2 changed files with 27 additions and 66 deletions

View File

@ -8,6 +8,10 @@ namespace fs = std::filesystem;
class Controller; class Controller;
namespace character::characteristic {
class Characteristic;
}
namespace gui { namespace gui {
class GuiData; class GuiData;
@ -52,6 +56,8 @@ namespace gui {
void render_gui(const Controller &controller); void render_gui(const Controller &controller);
void render_gpu() const; void render_gpu() const;
static void characteristic_gui(const character::characteristic::Characteristic &characteristic) noexcept;
}; };
} }

View File

@ -8,6 +8,9 @@
#include "character_sheet.hpp" #include "character_sheet.hpp"
#include "controller.hpp" #include "controller.hpp"
#include "billy_objects.hpp" #include "billy_objects.hpp"
#include "characteristic/characteristic.hpp"
using character::characteristic::Characteristic;
gui::Gui::Gui(Window &window, GuiData &data, menu::MenuData &menuData) : gui::Gui::Gui(Window &window, GuiData &data, menu::MenuData &menuData) :
data(data), menu(menuData), font("font/DejaVuSans.ttf") { 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<int>(characteristic.get_base());
(void) ImGui::InputInt("Base", &base, 1, 100, ImGuiInputTextFlags_ReadOnly);
int carac = static_cast<int>(characteristic.get_carac());
(void) ImGui::InputInt("Carac", &carac, 1, 100, ImGuiInputTextFlags_ReadOnly);
int materiel = static_cast<int>(characteristic.get_materiel());
(void) ImGui::InputInt("Matériel", &materiel, 1, 100, ImGuiInputTextFlags_ReadOnly);
int additional = static_cast<int>(characteristic.get_additional());
(void) ImGui::InputInt("Additionnel", &additional, 1, 100, ImGuiInputTextFlags_ReadOnly);
}
void gui::Gui::habilete_menu() noexcept { void gui::Gui::habilete_menu() noexcept {
ImGui::BeginChild("habilete", ImGui::BeginChild("habilete",
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f),
ImGuiChildFlags_Border); ImGuiChildFlags_Border);
ImGui::Text("Habileté"); ImGui::Text("Habileté");
data.base.second = data.billy.get_habilete().get_base(); characteristic_gui(static_cast<const Characteristic &>(data.billy.get_habilete()));
data.base.first = ImGui::InputInt("Base", reinterpret_cast<int *>(&data.base.second)) ? characChanged::Habilete
: characChanged::None;
data.carac.second = data.billy.get_habilete().get_carac();
data.carac.first = ImGui::InputInt("Carac", reinterpret_cast<int *>(&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<int *>(&data.materiel.second))
? characChanged::Habilete : characChanged::None;
data.additional.second = data.billy.get_habilete().get_additional();
data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast<int *>(&data.additional.second)) ?
characChanged::Habilete :
characChanged::None;
ImGui::EndChild(); ImGui::EndChild();
} }
@ -141,22 +143,7 @@ void gui::Gui::adresse_menu() noexcept {
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f),
ImGuiChildFlags_Border); ImGuiChildFlags_Border);
ImGui::Text("Adresse"); ImGui::Text("Adresse");
data.base.second = data.billy.get_adresse().get_base(); characteristic_gui(static_cast<const Characteristic &>(data.billy.get_adresse()));
data.base.first = ImGui::InputInt("Base", reinterpret_cast<int *>(&data.base.second)) ? characChanged::Adresse
: characChanged::None;
data.carac.second = data.billy.get_adresse().get_carac();
data.carac.first = ImGui::InputInt("Carac", reinterpret_cast<int *>(&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<int *>(&data.materiel.second))
? characChanged::Adresse : characChanged::None;
data.additional.second = data.billy.get_adresse().get_additional();
data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast<int *>(&data.additional.second)) ?
characChanged::Adresse :
characChanged::None;
ImGui::EndChild(); ImGui::EndChild();
} }
@ -165,24 +152,7 @@ void gui::Gui::endurance_menu() noexcept {
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f),
ImGuiChildFlags_Border); ImGuiChildFlags_Border);
ImGui::Text("Endurance"); ImGui::Text("Endurance");
characteristic_gui(static_cast<const Characteristic &>(data.billy.get_endurance()));
data.base.second = data.billy.get_endurance().get_base();
data.base.first = ImGui::InputInt("Base", reinterpret_cast<int *>(&data.base.second)) ? characChanged::Endurance
: characChanged::None;
data.carac.second = data.billy.get_endurance().get_carac();
data.carac.first = ImGui::InputInt("Carac", reinterpret_cast<int *>(&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<int *>(&data.materiel.second)) ?
characChanged::Endurance :
characChanged::None;
data.additional.second = data.billy.get_endurance().get_additional();
data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast<int *>(&data.additional.second)) ?
characChanged::Endurance :
characChanged::None;
ImGui::EndChild(); ImGui::EndChild();
} }
@ -191,22 +161,7 @@ void gui::Gui::chance_menu() noexcept {
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f),
ImGuiChildFlags_Border); ImGuiChildFlags_Border);
ImGui::Text("Chance"); ImGui::Text("Chance");
data.base.second = data.billy.get_chance().get_base(); characteristic_gui(static_cast<const Characteristic&>(data.billy.get_chance()));
data.base.first = ImGui::InputInt("Base", reinterpret_cast<int *>(&data.base.second)) ? characChanged::Chance
: characChanged::None;
data.carac.second = data.billy.get_chance().get_carac();
data.carac.first = ImGui::InputInt("Carac", reinterpret_cast<int *>(&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<int *>(&data.materiel.second))
? characChanged::Chance : characChanged::None;
data.additional.second = data.billy.get_chance().get_additional();
data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast<int *>(&data.additional.second)) ?
characChanged::Chance :
characChanged::None;
ImGui::EndChild(); ImGui::EndChild();
} }