Compare commits
5 Commits
bdc9adcf75
...
9d5971e23a
Author | SHA1 | Date | |
---|---|---|---|
9d5971e23a | |||
fd230e87e9 | |||
1d609f12d5 | |||
7d4981e02c | |||
60957902cb |
@ -64,9 +64,15 @@ namespace character {
|
||||
|
||||
static std::string_view billy_object_to_string(const billyObject &object) noexcept;
|
||||
|
||||
void add_object(const billyObject &object, CharacterSheet &sheet) noexcept;
|
||||
void push_object(const billyObject &object, CharacterSheet &sheet) noexcept;
|
||||
|
||||
void insert_weapon(weapons weapon, CharacterSheet &sheet) noexcept;
|
||||
void pop_object(CharacterSheet &sheet) noexcept;
|
||||
|
||||
[[nodiscard]] std::pair<const container &, std::int8_t> get_objects() const noexcept {
|
||||
return { objects, end_object };
|
||||
}
|
||||
|
||||
// void insert_weapon(weapons weapon, CharacterSheet &sheet) noexcept;
|
||||
|
||||
private:
|
||||
container objects;
|
||||
@ -74,8 +80,8 @@ namespace character {
|
||||
std::minus<std::uint32_t> minus;
|
||||
std::uint8_t end_object{ 0 };
|
||||
|
||||
static void change_carac_weapon(CharacterSheet &sheet,
|
||||
const weapons &arg,
|
||||
static void change_carac_weapon(const weapons &arg,
|
||||
CharacterSheet &sheet,
|
||||
characteristic::Characteristic &localHabilete,
|
||||
characteristic::Characteristic &localAdresse,
|
||||
characteristic::Characteristic &localEndurance,
|
||||
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,10 @@
|
||||
namespace character {
|
||||
using characteristic::Characteristic;
|
||||
|
||||
void BillyObjects::add_object(const billyObject &object, CharacterSheet &sheet) noexcept {
|
||||
void BillyObjects::push_object(const billyObject &object, CharacterSheet &sheet) noexcept {
|
||||
if (end_object < 3) {
|
||||
objects.at(end_object) = object;
|
||||
++end_object;
|
||||
|
||||
auto &local_habilete = static_cast<Characteristic &>(sheet.habilete);
|
||||
auto &local_adresse = static_cast<Characteristic &>(sheet.adresse);
|
||||
@ -20,7 +21,7 @@ namespace character {
|
||||
std::visit(overloaded{
|
||||
[&](const weapons &arg) {
|
||||
++sheet.nb_weapons;
|
||||
change_carac_weapon(sheet, arg, local_habilete, local_adresse, local_endurance, plus);
|
||||
change_carac_weapon(arg, sheet, local_habilete, local_adresse, local_endurance, plus);
|
||||
},
|
||||
[&](const equipments &arg) {
|
||||
++sheet.nb_equipments;
|
||||
@ -47,6 +48,46 @@ namespace character {
|
||||
}
|
||||
}
|
||||
|
||||
void BillyObjects::pop_object(CharacterSheet &sheet) noexcept {
|
||||
if (end_object > 0) {
|
||||
const auto &obj = objects.at(end_object - 1);
|
||||
--end_object;
|
||||
|
||||
auto &local_habilete = static_cast<Characteristic &>(sheet.habilete);
|
||||
auto &local_adresse = static_cast<Characteristic &>(sheet.adresse);
|
||||
auto &local_endurance = static_cast<Characteristic &>(sheet.endurance);
|
||||
auto &local_chance = static_cast<Characteristic &>(sheet.chance);
|
||||
|
||||
std::visit(overloaded{
|
||||
[&](const weapons &arg) {
|
||||
--sheet.nb_weapons;
|
||||
change_carac_weapon(arg, sheet, local_habilete, local_adresse, local_endurance, minus);
|
||||
},
|
||||
[&](const equipments &arg) {
|
||||
--sheet.nb_equipments;
|
||||
change_carac_equipment(arg,
|
||||
sheet,
|
||||
local_habilete,
|
||||
local_adresse,
|
||||
local_endurance,
|
||||
local_chance,
|
||||
minus,
|
||||
plus);
|
||||
},
|
||||
[&](const tools &arg) {
|
||||
--sheet.nb_tools;
|
||||
change_carac_tools(arg,
|
||||
sheet,
|
||||
local_habilete,
|
||||
local_adresse,
|
||||
local_endurance,
|
||||
local_chance,
|
||||
minus);
|
||||
}
|
||||
}, obj);
|
||||
}
|
||||
}
|
||||
|
||||
void BillyObjects::change_carac_tools(const tools &arg,
|
||||
CharacterSheet &sheet,
|
||||
Characteristic &localHabilete,
|
||||
@ -101,8 +142,8 @@ namespace character {
|
||||
}
|
||||
}
|
||||
|
||||
void BillyObjects::change_carac_weapon(CharacterSheet &sheet,
|
||||
const weapons &arg,
|
||||
void BillyObjects::change_carac_weapon(const weapons &arg,
|
||||
CharacterSheet &sheet,
|
||||
Characteristic &localHabilete,
|
||||
Characteristic &localAdresse,
|
||||
Characteristic &localEndurance,
|
||||
|
142
src/gui/gui.cpp
142
src/gui/gui.cpp
@ -7,6 +7,10 @@
|
||||
#include "gui/gui_data.hpp"
|
||||
#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") {
|
||||
@ -111,116 +115,106 @@ 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 {
|
||||
ImGui::BeginChild("habilete", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true);
|
||||
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<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;
|
||||
characteristic_gui(static_cast<const Characteristic &>(data.billy.get_habilete()));
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void gui::Gui::adresse_menu() noexcept {
|
||||
ImGui::BeginChild("adresse", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true);
|
||||
ImGui::BeginChild("adresse",
|
||||
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<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;
|
||||
characteristic_gui(static_cast<const Characteristic &>(data.billy.get_adresse()));
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void gui::Gui::endurance_menu() noexcept {
|
||||
ImGui::BeginChild("endurance", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true);
|
||||
ImGui::BeginChild("endurance",
|
||||
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<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;
|
||||
characteristic_gui(static_cast<const Characteristic &>(data.billy.get_endurance()));
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void gui::Gui::chance_menu() noexcept {
|
||||
ImGui::BeginChild("chance", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f), true);
|
||||
ImGui::BeginChild("chance",
|
||||
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<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;
|
||||
characteristic_gui(static_cast<const Characteristic&>(data.billy.get_chance()));
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void gui::Gui::stat_second_menu() noexcept {
|
||||
ImGui::BeginChild("stats secondaire", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.4f), true);
|
||||
ImGui::BeginChild("stats secondaire",
|
||||
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.4f),
|
||||
ImGuiChildFlags_Border);
|
||||
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::BeginChild("materiel",
|
||||
ImVec2(ImGui::GetWindowWidth() / 3, 0),
|
||||
ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeY);
|
||||
ImGui::Text("Matériel");
|
||||
|
||||
ImGui::BeginChild("weapons", ImVec2(0, 0), ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeY);
|
||||
ImGui::Text(character::BillyObjects::sword.data());
|
||||
ImGui::Text(character::BillyObjects::lance.data());
|
||||
ImGui::Text(character::BillyObjects::morgenstern.data());
|
||||
ImGui::Text(character::BillyObjects::bow.data());
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::BeginChild("equipments", ImVec2(0, 0), ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeY);
|
||||
ImGui::Text(character::BillyObjects::chainmail.data());
|
||||
ImGui::Text(character::BillyObjects::cooking_pot.data());
|
||||
ImGui::Text(character::BillyObjects::pamphlet_tourist.data());
|
||||
ImGui::Text(character::BillyObjects::medic_kit.data());
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::BeginChild("tools", ImVec2(0, 0), ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeY);
|
||||
ImGui::Text(character::BillyObjects::fourche.data());
|
||||
ImGui::Text(character::BillyObjects::dagger.data());
|
||||
ImGui::Text(character::BillyObjects::rock_climbing_kit.data());
|
||||
ImGui::Text(character::BillyObjects::sack_of_grain.data());
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void gui::Gui::gloire_menu() noexcept {
|
||||
ImGui::BeginChild("gloire", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.1f), true);
|
||||
ImGui::BeginChild("gloire",
|
||||
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.1f),
|
||||
ImGuiChildFlags_Border);
|
||||
ImGui::Text("Gloire");
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void gui::Gui::richesse_menu() noexcept {
|
||||
ImGui::BeginChild("richesse", ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.1f), true);
|
||||
ImGui::BeginChild("richesse",
|
||||
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.1f),
|
||||
ImGuiChildFlags_Border);
|
||||
ImGui::Text("Richesse");
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user