Reformat
This commit is contained in:
Pcornat 2024-02-29 12:04:09 +01:00
parent 371fbcb04d
commit 7ee5899e31
Signed by: Pcornat
GPG key ID: E0326CC678A00BDD
9 changed files with 111 additions and 108 deletions

View file

@ -26,23 +26,23 @@ namespace character {
[&](const equipments &arg) {
++sheet.nb_equipments;
change_carac_equipment(arg,
sheet,
local_habilete,
local_adresse,
local_endurance,
local_chance,
plus,
minus);
sheet,
local_habilete,
local_adresse,
local_endurance,
local_chance,
plus,
minus);
},
[&](const tools &arg) {
++sheet.nb_tools;
change_carac_tools(arg,
sheet,
local_habilete,
local_adresse,
local_endurance,
local_chance,
plus);
sheet,
local_habilete,
local_adresse,
local_endurance,
local_chance,
plus);
},
}, object);
}
@ -66,36 +66,35 @@ namespace character {
[&](const equipments &arg) {
--sheet.nb_equipments;
change_carac_equipment(arg,
sheet,
local_habilete,
local_adresse,
local_endurance,
local_chance,
minus,
plus);
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);
sheet,
local_habilete,
local_adresse,
local_endurance,
local_chance,
minus);
}
}, obj);
}
}
void BillyObjects::change_carac_tools(const tools &arg,
CharacterSheet &sheet,
Characteristic &localHabilete,
Characteristic &localAdresse,
Characteristic &localEndurance,
Characteristic &localChance,
const std::function<std::uint32_t(std::uint32_t,
std::uint32_t)> &operation) noexcept {
CharacterSheet &sheet,
Characteristic &localHabilete,
Characteristic &localAdresse,
Characteristic &localEndurance,
Characteristic &localChance,
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &operation) noexcept {
switch (arg) {
case tools::Fourche:
localHabilete.materiel = operation(localHabilete.materiel, 1);
@ -114,14 +113,14 @@ namespace character {
}
void BillyObjects::change_carac_equipment(const equipments &arg,
CharacterSheet &sheet,
Characteristic &localHabilete,
Characteristic &localAdresse,
Characteristic &localEndurance,
Characteristic &localChance,
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &primary,
const std::function<std::uint32_t(std::uint32_t,
std::uint32_t)> &complement) noexcept {
CharacterSheet &sheet,
Characteristic &localHabilete,
Characteristic &localAdresse,
Characteristic &localEndurance,
Characteristic &localChance,
const std::function<std::uint32_t(std::uint32_t, std::uint32_t)> &primary,
const std::function<std::uint32_t(std::uint32_t,
std::uint32_t)> &complement) noexcept {
switch (arg) {
case equipments::Chainmail:
localHabilete.materiel = complement(localHabilete.materiel, 1);
@ -143,12 +142,12 @@ namespace character {
}
void BillyObjects::change_carac_weapon(const weapons &arg,
CharacterSheet &sheet,
Characteristic &localHabilete,
Characteristic &localAdresse,
Characteristic &localEndurance,
const std::function<std::uint32_t(std::uint32_t,
std::uint32_t)> &operation) noexcept {
CharacterSheet &sheet,
Characteristic &localHabilete,
Characteristic &localAdresse,
Characteristic &localEndurance,
const std::function<std::uint32_t(std::uint32_t,
std::uint32_t)> &operation) noexcept {
switch (arg) {
case weapons::Sword:
localHabilete.materiel = operation(localHabilete.materiel, 4);

View file

@ -53,13 +53,14 @@ void gui::Gui::render_gui(const Controller &controller) {
menu.gui();
if (ImGui::BeginCombo("Classe",
GuiData::classes[static_cast<std::uint32_t>(data.billy.get_current_class())].data(),
ImGuiComboFlags_PopupAlignLeft)) {
GuiData::classes[static_cast<std::uint32_t>(data.billy.get_current_class())].data(),
ImGuiComboFlags_PopupAlignLeft)) {
for (std::size_t i = 0; i < GuiData::classes.size(); ++i) {
const bool is_selected = (data.billy.get_current_class() == static_cast<character::classe>(i));
if (is_selected)
if (is_selected) {
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
@ -131,8 +132,8 @@ void gui::Gui::characteristic_gui(const Characteristic &characteristic) noexcept
void gui::Gui::habilete_menu() noexcept {
ImGui::BeginChild("habilete",
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f),
ImGuiChildFlags_Border);
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f),
ImGuiChildFlags_Border);
ImGui::Text("Habileté");
characteristic_gui(static_cast<const Characteristic &>(data.billy.get_habilete()));
ImGui::EndChild();
@ -140,8 +141,8 @@ void gui::Gui::habilete_menu() noexcept {
void gui::Gui::adresse_menu() noexcept {
ImGui::BeginChild("adresse",
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f),
ImGuiChildFlags_Border);
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f),
ImGuiChildFlags_Border);
ImGui::Text("Adresse");
characteristic_gui(static_cast<const Characteristic &>(data.billy.get_adresse()));
ImGui::EndChild();
@ -149,8 +150,8 @@ void gui::Gui::adresse_menu() noexcept {
void gui::Gui::endurance_menu() noexcept {
ImGui::BeginChild("endurance",
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f),
ImGuiChildFlags_Border);
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f),
ImGuiChildFlags_Border);
ImGui::Text("Endurance");
characteristic_gui(static_cast<const Characteristic &>(data.billy.get_endurance()));
ImGui::EndChild();
@ -158,25 +159,25 @@ void gui::Gui::endurance_menu() noexcept {
void gui::Gui::chance_menu() noexcept {
ImGui::BeginChild("chance",
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f),
ImGuiChildFlags_Border);
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.2f),
ImGuiChildFlags_Border);
ImGui::Text("Chance");
characteristic_gui(static_cast<const Characteristic&>(data.billy.get_chance()));
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),
ImGuiChildFlags_Border);
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, 0),
ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeY);
ImVec2(ImGui::GetWindowWidth() / 3, 0),
ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeY);
ImGui::Text("Matériel");
ImGui::BeginChild("weapons", ImVec2(0, 0), ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeY);
@ -205,16 +206,16 @@ void gui::Gui::materiel_menu() noexcept {
void gui::Gui::gloire_menu() noexcept {
ImGui::BeginChild("gloire",
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.1f),
ImGuiChildFlags_Border);
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),
ImGuiChildFlags_Border);
ImVec2(ImGui::GetWindowWidth() / 3, ImGui::GetWindowHeight() * 0.1f),
ImGuiChildFlags_Border);
ImGui::Text("Richesse");
ImGui::EndChild();
}

View file

@ -41,8 +41,8 @@ void gui::menu::Menu::gui() const noexcept {
if (ImGui::MenuItem("Open file")) {
SPDLOG_DEBUG("Opening file");
ifd::FileDialog::Instance().Open(data.open_character_key,
"Open a character sheet",
"Character sheet (*.json){.json},.*");
"Open a character sheet",
"Character sheet (*.json){.json},.*");
SPDLOG_DEBUG("File opened");
}
@ -57,8 +57,8 @@ void gui::menu::Menu::gui() const noexcept {
if (ImGui::MenuItem("Save as...")) {
SPDLOG_DEBUG("Saving with file dialog");
ifd::FileDialog::Instance().Save(data.save_character_key,
"Save character sheet as...",
"*.json {.json}");
"Save character sheet as...",
"*.json {.json}");
SPDLOG_DEBUG("File saved with dialog");
}

View file

@ -21,11 +21,11 @@ gui::Window::Window() {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
wwindow = std::unique_ptr<GLFWwindow, decltype(&delete_glfw_window)>(glfwCreateWindow(720,
1280,
"Billy Sheet tracker",
nullptr,
nullptr),
delete_glfw_window);
1280,
"Billy Sheet tracker",
nullptr,
nullptr),
delete_glfw_window);
if (!wwindow) {
glfwTerminate();
SPDLOG_CRITICAL("No GLFW window created, nullptr.");