Reformat.

This commit is contained in:
Pcornat 2024-01-28 20:31:50 +01:00
parent 7d1a0473ff
commit 2755f4827e
Signed by: Pcornat
GPG Key ID: E0326CC678A00BDD
24 changed files with 6140 additions and 5829 deletions

View File

@ -14,7 +14,7 @@ set(PRECOMPILE_HEADERS
include/gui/gui.hpp include/gui/gui.hpp
include/gui/gui_data.hpp include/gui/gui_data.hpp
include/gui/window.hpp include/gui/window.hpp
) )
set(SOURCE_HEADERS set(SOURCE_HEADERS
include/imgui/imconfig.h include/imgui/imconfig.h
@ -42,7 +42,7 @@ set(SOURCE_HEADERS
include/characteristic/characteristic.hpp include/characteristic/characteristic.hpp
include/controller.hpp include/controller.hpp
include/gui_data_interface.hpp include/gui_data_interface.hpp
) )
set(SOURCE_FILES set(SOURCE_FILES
src/imgui/imgui.cpp src/imgui/imgui.cpp
@ -63,7 +63,7 @@ set(SOURCE_FILES
src/characteristic/chance.cpp src/characteristic/chance.cpp
src/gui/menu/menu.cpp src/gui/menu/menu.cpp
src/controller.cpp src/controller.cpp
) )
set(SOURCES set(SOURCES
${SOURCE_HEADERS} ${SOURCE_HEADERS}
@ -123,16 +123,16 @@ set(COMPILE_FLAGS
-funroll-loops -funroll-loops
-fdevirtualize-at-ltrans -fdevirtualize-at-ltrans
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
) )
set(LINKER_OPTIONS set(LINKER_OPTIONS
-Wl,--sort-common,--as-needed,--gc-sections,--strip-all -Wl,--sort-common,--as-needed,--gc-sections,--strip-all
-fuse-ld=gold -fuse-ld=gold
-fdevirtualize-at-ltrans -fdevirtualize-at-ltrans
) )
set(LINKER_FLAGS set(LINKER_FLAGS
jemalloc jemalloc
) )
option(ENABLE_COVERAGE "Enabling coverage" OFF) option(ENABLE_COVERAGE "Enabling coverage" OFF)
@ -155,7 +155,7 @@ set_target_properties(BillySheet spdlog PROPERTIES
CXX_EXTENSIONS OFF CXX_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON INTERPROCEDURAL_OPTIMIZATION ON
# UNITY_BUILD ON # UNITY_BUILD ON
) )
set_target_properties(spdlog PROPERTIES UNITY_BUILD ON) set_target_properties(spdlog PROPERTIES UNITY_BUILD ON)
@ -165,7 +165,7 @@ set_target_properties(glfw PROPERTIES
C_EXTENSIONS OFF C_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON INTERPROCEDURAL_OPTIMIZATION ON
UNITY_BUILD ON UNITY_BUILD ON
) )
set_target_properties(spdlog PROPERTIES UNITY_BUILD ON) set_target_properties(spdlog PROPERTIES UNITY_BUILD ON)

View File

@ -12,7 +12,7 @@ set_target_properties(Catch2 UnitTest PROPERTIES
CXX_EXTENSIONS OFF CXX_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON INTERPROCEDURAL_OPTIMIZATION ON
# UNITY_BUILD ON # UNITY_BUILD ON
) )
target_include_directories(UnitTest PRIVATE ${CMAKE_SOURCE_DIR}/include) target_include_directories(UnitTest PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_compile_definitions(UnitTest PRIVATE ${DEF_COMP}) target_compile_definitions(UnitTest PRIVATE ${DEF_COMP})
target_compile_options(UnitTest PRIVATE ${COMPILE_FLAGS}) target_compile_options(UnitTest PRIVATE ${COMPILE_FLAGS})

View File

@ -1,2 +1,3 @@
#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp> #include <catch2/catch.hpp>

View File

@ -12,7 +12,7 @@ namespace gui {
} }
namespace character { namespace character {
enum class classe : std::uint32_t { enum class classe : std::uint8_t {
Guerrier = 0, Guerrier = 0,
Prudent = 1, Prudent = 1,
Paysan = 2, Paysan = 2,
@ -51,6 +51,14 @@ namespace character {
public: public:
CharacterSheet() = default; CharacterSheet() = default;
CharacterSheet(const CharacterSheet &sheet) noexcept = default;
CharacterSheet(CharacterSheet &&sheet) noexcept = default;
CharacterSheet &operator=(const CharacterSheet &characterSheet) noexcept = default;
CharacterSheet &operator=(CharacterSheet &&characterSheet) noexcept = default;
~CharacterSheet() noexcept = default; ~CharacterSheet() noexcept = default;
[[nodiscard]] const std::string &get_caractere() const { return caractere; } [[nodiscard]] const std::string &get_caractere() const { return caractere; }

View File

@ -17,7 +17,10 @@ namespace character::characteristic {
public: public:
Characteristic() noexcept = default; Characteristic() noexcept = default;
Characteristic(const std::uint32_t base, const std::uint32_t carac, const std::uint32_t materiel, const std::uint32_t additional) noexcept: Characteristic(const std::uint32_t base,
const std::uint32_t carac,
const std::uint32_t materiel,
const std::uint32_t additional) noexcept:
base(base), carac(carac), materiel(materiel), additional(additional) {} base(base), carac(carac), materiel(materiel), additional(additional) {}
Characteristic(const Characteristic &charac) noexcept = default; Characteristic(const Characteristic &charac) noexcept = default;

View File

@ -17,13 +17,14 @@ private:
public: public:
Controller() = delete; Controller() = delete;
explicit Controller(character::CharacterSheet &sheet, gui::menu::MenuData &menuData) : sheet(sheet), menu_data(menuData) {} explicit Controller(character::CharacterSheet &sheet, gui::menu::MenuData &menuData) :
sheet(sheet), menu_data(menuData) {}
~Controller() noexcept = default; ~Controller() noexcept = default;
void control_menu() const noexcept; void control_menu() const noexcept;
void control_sheet()const noexcept; void control_sheet() const noexcept;
}; };

View File

@ -36,9 +36,11 @@ namespace gui::menu {
[[nodiscard]] bool is_edit_mode() const { return edit_mode; } [[nodiscard]] bool is_edit_mode() const { return edit_mode; }
void set_save_path([[maybe_unused]] const Controller &controller, const fs::path &savePath) const { save_path = savePath; } void set_save_path([[maybe_unused]] const Controller &controller,
const fs::path &savePath) const { save_path = savePath; }
void set_filename([[maybe_unused]] const Controller &controller, const std::string &fileName) const { filename = fileName; } void set_filename([[maybe_unused]] const Controller &controller,
const std::string &fileName) const { filename = fileName; }
}; };
} }

View File

@ -23,7 +23,8 @@ namespace gui {
~Window() noexcept = default; ~Window() noexcept = default;
[[nodiscard]] const std::unique_ptr<GLFWwindow, decltype(&delete_glfw_window)> &get_window() const { return wwindow; } [[nodiscard]] const std::unique_ptr<GLFWwindow, decltype(&delete_glfw_window)> &
get_window() const { return wwindow; }
[[nodiscard]] bool should_close() const noexcept; [[nodiscard]] bool should_close() const noexcept;

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,8 @@
#include "character_sheet.hpp" #include "character_sheet.hpp"
#include "controller.hpp" #include "controller.hpp"
gui::Gui::Gui(Window &window, GuiData &data, menu::MenuData &menuData) : data(data), menu(menuData), font("font/DejaVuSans.ttf") { gui::Gui::Gui(Window &window, GuiData &data, menu::MenuData &menuData) :
data(data), menu(menuData), font("font/DejaVuSans.ttf") {
SPDLOG_DEBUG("Creating GUI"); SPDLOG_DEBUG("Creating GUI");
(void) ImGui::CreateContext(); (void) ImGui::CreateContext();
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
@ -116,13 +117,16 @@ 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), true);
ImGui::Text("Habileté"); ImGui::Text("Habileté");
data.base.second = data.billy.get_habilete().get_base(); 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.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.second = data.billy.get_habilete().get_carac();
data.carac.first = ImGui::InputInt("Carac", reinterpret_cast<int *>(&data.carac.second)) ? characChanged::Habilete : characChanged::None; 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.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.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.second = data.billy.get_habilete().get_additional();
data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast<int *>(&data.additional.second)) ? data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast<int *>(&data.additional.second)) ?
@ -135,13 +139,16 @@ 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), true);
ImGui::Text("Adresse"); ImGui::Text("Adresse");
data.base.second = data.billy.get_adresse().get_base(); 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.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.second = data.billy.get_adresse().get_carac();
data.carac.first = ImGui::InputInt("Carac", reinterpret_cast<int *>(&data.carac.second)) ? characChanged::Adresse : characChanged::None; 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.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.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.second = data.billy.get_adresse().get_additional();
data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast<int *>(&data.additional.second)) ? data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast<int *>(&data.additional.second)) ?
@ -155,10 +162,12 @@ void gui::Gui::endurance_menu() noexcept {
ImGui::Text("Endurance"); ImGui::Text("Endurance");
data.base.second = data.billy.get_endurance().get_base(); 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.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.second = data.billy.get_endurance().get_carac();
data.carac.first = ImGui::InputInt("Carac", reinterpret_cast<int *>(&data.carac.second)) ? characChanged::Endurance : characChanged::None; 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.second = data.billy.get_endurance().get_materiel();
data.materiel.first = ImGui::InputInt("Matériel", reinterpret_cast<int *>(&data.materiel.second)) ? data.materiel.first = ImGui::InputInt("Matériel", reinterpret_cast<int *>(&data.materiel.second)) ?
@ -176,13 +185,16 @@ 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), true);
ImGui::Text("Chance"); ImGui::Text("Chance");
data.base.second = data.billy.get_chance().get_base(); 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.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.second = data.billy.get_chance().get_carac();
data.carac.first = ImGui::InputInt("Carac", reinterpret_cast<int *>(&data.carac.second)) ? characChanged::Chance : characChanged::None; 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.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.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.second = data.billy.get_chance().get_additional();
data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast<int *>(&data.additional.second)) ? data.additional.first = ImGui::InputInt("Additionnel", reinterpret_cast<int *>(&data.additional.second)) ?

View File

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

View File

@ -20,7 +20,11 @@ gui::Window::Window() {
} }
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
wwindow = std::unique_ptr<GLFWwindow, decltype(&delete_glfw_window)>(glfwCreateWindow(720, 1280, "Billy Sheet tracker", nullptr, nullptr), wwindow = std::unique_ptr<GLFWwindow, decltype(&delete_glfw_window)>(glfwCreateWindow(720,
1280,
"Billy Sheet tracker",
nullptr,
nullptr),
delete_glfw_window); delete_glfw_window);
if (!wwindow) { if (!wwindow) {
glfwTerminate(); glfwTerminate();