Working to save and select classes
This commit is contained in:
parent
8e6f0ccc1f
commit
acc2f0ca9d
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,4 +2,5 @@ cmake-*
|
|||||||
build/
|
build/
|
||||||
!.idea/cmake.xml
|
!.idea/cmake.xml
|
||||||
.idea/*
|
.idea/*
|
||||||
|
*.json
|
||||||
imgui.ini
|
imgui.ini
|
@ -12,9 +12,17 @@ namespace gui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace character {
|
namespace character {
|
||||||
|
enum class classe : std::uint32_t {
|
||||||
|
Guerrier = 0,
|
||||||
|
Prudent = 1,
|
||||||
|
Paysan = 2,
|
||||||
|
Debrouillard = 3,
|
||||||
|
};
|
||||||
|
|
||||||
class CharacterSheet final {
|
class CharacterSheet final {
|
||||||
private:
|
private:
|
||||||
friend gui::Gui;
|
friend gui::Gui;
|
||||||
|
|
||||||
friend class Controller;
|
friend class Controller;
|
||||||
|
|
||||||
std::mt19937_64 engine{ std::random_device{ "rdseed" }() };
|
std::mt19937_64 engine{ std::random_device{ "rdseed" }() };
|
||||||
@ -29,6 +37,8 @@ namespace character {
|
|||||||
|
|
||||||
characteristic::Habilete habilete;
|
characteristic::Habilete habilete;
|
||||||
|
|
||||||
|
classe current_class{ classe::Guerrier };
|
||||||
|
|
||||||
std::uint32_t health_point{ 0 };
|
std::uint32_t health_point{ 0 };
|
||||||
|
|
||||||
std::uint32_t armor{ 0 };
|
std::uint32_t armor{ 0 };
|
||||||
@ -53,6 +63,8 @@ namespace character {
|
|||||||
|
|
||||||
[[nodiscard]] const characteristic::Habilete &get_habilete() const { return habilete; }
|
[[nodiscard]] const characteristic::Habilete &get_habilete() const { return habilete; }
|
||||||
|
|
||||||
|
[[nodiscard]] classe get_current_class() const { return current_class; }
|
||||||
|
|
||||||
[[nodiscard]] std::uint32_t get_health_point() const { return health_point; }
|
[[nodiscard]] std::uint32_t get_health_point() const { return health_point; }
|
||||||
|
|
||||||
[[nodiscard]] std::uint32_t get_armor() const { return armor; }
|
[[nodiscard]] std::uint32_t get_armor() const { return armor; }
|
||||||
@ -69,6 +81,7 @@ namespace character {
|
|||||||
j.at("endurance").get_to(billy.endurance);
|
j.at("endurance").get_to(billy.endurance);
|
||||||
j.at("chance").get_to(billy.chance);
|
j.at("chance").get_to(billy.chance);
|
||||||
j.at("habilete").get_to(billy.habilete);
|
j.at("habilete").get_to(billy.habilete);
|
||||||
|
j.at("classe").get_to(billy.current_class);
|
||||||
j.at("health_point").get_to(billy.health_point);
|
j.at("health_point").get_to(billy.health_point);
|
||||||
j.at("armor").get_to(billy.armor);
|
j.at("armor").get_to(billy.armor);
|
||||||
j.at("damage").get_to(billy.damage);
|
j.at("damage").get_to(billy.damage);
|
||||||
@ -83,6 +96,7 @@ namespace character {
|
|||||||
j["endurance"] = billy.get_endurance();
|
j["endurance"] = billy.get_endurance();
|
||||||
j["chance"] = billy.get_chance();
|
j["chance"] = billy.get_chance();
|
||||||
j["habilete"] = billy.get_habilete();
|
j["habilete"] = billy.get_habilete();
|
||||||
|
j["classe"] = billy.get_current_class();
|
||||||
j["health_point"] = billy.get_health_point();
|
j["health_point"] = billy.get_health_point();
|
||||||
j["armor"] = billy.get_armor();
|
j["armor"] = billy.get_armor();
|
||||||
j["damage"] = billy.get_damage();
|
j["damage"] = billy.get_damage();
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
#ifndef BILLYSHEET_GUI_DATA_HPP
|
#ifndef BILLYSHEET_GUI_DATA_HPP
|
||||||
#define BILLYSHEET_GUI_DATA_HPP
|
#define BILLYSHEET_GUI_DATA_HPP
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
namespace character {
|
namespace character {
|
||||||
class CharacterSheet;
|
class CharacterSheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace std::string_view_literals;
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
class Window;
|
class Window;
|
||||||
|
|
||||||
@ -19,6 +22,13 @@ namespace gui {
|
|||||||
character::CharacterSheet &billy;
|
character::CharacterSheet &billy;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static constexpr std::array classes{
|
||||||
|
"Guerrier"sv,
|
||||||
|
"Prudent"sv,
|
||||||
|
"Paysan"sv,
|
||||||
|
"Débrouillard"sv
|
||||||
|
};
|
||||||
|
|
||||||
GuiData() = delete;
|
GuiData() = delete;
|
||||||
|
|
||||||
explicit GuiData(Window &wwindow, character::CharacterSheet &billy) : window(wwindow), billy(billy) { SPDLOG_DEBUG("Creating GUI Data"); }
|
explicit GuiData(Window &wwindow, character::CharacterSheet &billy) : window(wwindow), billy(billy) { SPDLOG_DEBUG("Creating GUI Data"); }
|
||||||
|
@ -42,6 +42,20 @@ void Controller::control_menu() const noexcept {
|
|||||||
void Controller::control_sheet() const noexcept {
|
void Controller::control_sheet() const noexcept {
|
||||||
if (menu_data.is_edit_mode()) {
|
if (menu_data.is_edit_mode()) {
|
||||||
// TODO
|
// TODO
|
||||||
|
switch (sheet.get_current_class()) {
|
||||||
|
case character::classe::Prudent:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
case character::classe::Guerrier:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
case character::classe::Paysan:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
case character::classe::Debrouillard:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,20 @@ void gui::Gui::render_gui(const Controller &controller) {
|
|||||||
(void) ImGui::Begin("Billy", nullptr, flags);
|
(void) ImGui::Begin("Billy", nullptr, flags);
|
||||||
menu.gui();
|
menu.gui();
|
||||||
|
|
||||||
|
if (ImGui::BeginCombo("Classe",
|
||||||
|
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 (ImGui::Selectable(GuiData::classes[i].data(), is_selected))
|
||||||
|
data.billy.current_class = static_cast<character::classe>(i);
|
||||||
|
|
||||||
|
if (is_selected)
|
||||||
|
ImGui::SetItemDefaultFocus();
|
||||||
|
}
|
||||||
|
ImGui::EndCombo();
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ImGui::BeginChild("carac", ImVec2(0, ImGui::GetWindowHeight() * 0.2f), true);
|
ImGui::BeginChild("carac", ImVec2(0, ImGui::GetWindowHeight() * 0.2f), true);
|
||||||
ImGui::Text("Caractère");
|
ImGui::Text("Caractère");
|
||||||
|
@ -21,7 +21,7 @@ int main() {
|
|||||||
|
|
||||||
while (!window.should_close()) {
|
while (!window.should_close()) {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
// controller.control();
|
controller.control_sheet();
|
||||||
|
|
||||||
gui.render_gui(controller);
|
gui.render_gui(controller);
|
||||||
gui.render_gpu();
|
gui.render_gpu();
|
||||||
|
Loading…
Reference in New Issue
Block a user