113 lines
3.6 KiB
C++
113 lines
3.6 KiB
C++
#ifndef LEARNGTK4_APP_WIN_2_BACK_HPP
|
|
#define LEARNGTK4_APP_WIN_2_BACK_HPP
|
|
|
|
#include <array>
|
|
|
|
#include <glibmm/refptr.h>
|
|
#include <gtkmm/application.h>
|
|
|
|
#include <billy_objects.hpp>
|
|
#include <character_sheet.hpp>
|
|
// #include <gtkmm/label.h>
|
|
#include <gtkmm/checkbutton.h>
|
|
|
|
namespace learn_gtkmm4 {
|
|
class HelloWorld;
|
|
}
|
|
|
|
namespace Gtk {
|
|
class Builder;
|
|
class Label;
|
|
}
|
|
|
|
namespace gui_to_app {
|
|
class AppWin2Back final : public Gtk::Application {
|
|
public:
|
|
~AppWin2Back() noexcept final = default;
|
|
|
|
static Glib::RefPtr<AppWin2Back> create();
|
|
|
|
protected:
|
|
AppWin2Back();
|
|
|
|
void on_startup() final;
|
|
|
|
void on_activate() final;
|
|
|
|
private:
|
|
using selection_button = Gtk::CheckButton;
|
|
using buttons_obj_container = std::unordered_set<selection_button *>;
|
|
|
|
|
|
struct SwitchSignalHelper {
|
|
AppWin2Back &app;
|
|
const character::billyEnums obj;
|
|
selection_button *switch_{ nullptr };
|
|
bool on_stack{ false };
|
|
|
|
void signal_handler() noexcept;
|
|
};
|
|
|
|
friend struct SwitchSignalHelper;
|
|
|
|
/*!
|
|
*
|
|
* @return true: failed, false: success
|
|
*/
|
|
bool switches_procedure();
|
|
|
|
void on_quit() noexcept;
|
|
|
|
bool switch_signal_handler(bool flag, const character::billyEnums &obj) noexcept;
|
|
|
|
bool insert_obj(const character::billyEnums &obj) noexcept;
|
|
|
|
bool erase_obj(const character::billyEnums &obj) noexcept;
|
|
|
|
Glib::RefPtr<Gtk::Builder> app_builder;
|
|
learn_gtkmm4::HelloWorld *main_window{ nullptr };
|
|
selection_button *sword_switch{ nullptr };
|
|
selection_button *lance_switch{ nullptr };
|
|
selection_button *morgen_switch{ nullptr };
|
|
selection_button *bow_switch{ nullptr };
|
|
|
|
selection_button *chainmail_switch{ nullptr };
|
|
selection_button *cookpot_switch{ nullptr };
|
|
selection_button *pamphlet_switch{ nullptr };
|
|
selection_button *medkit_switch{ nullptr };
|
|
|
|
selection_button *fourche_switch{ nullptr };
|
|
selection_button *dagger_switch{ nullptr };
|
|
selection_button *rock_kit_switch{ nullptr };
|
|
selection_button *sack_switch{ nullptr };
|
|
|
|
Gtk::Label *hab_base{ nullptr };
|
|
Gtk::Label *hab_carac{ nullptr };
|
|
Gtk::Label *hab_mat{ nullptr };
|
|
Gtk::Label *hab_total{ nullptr };
|
|
|
|
std::array<SwitchSignalHelper, 12> signal_handlers{
|
|
SwitchSignalHelper{ .app = *this, .obj = character::weapons::Sword },
|
|
SwitchSignalHelper{ .app = *this, .obj = character::weapons::Lance },
|
|
SwitchSignalHelper{ .app = *this, .obj = character::weapons::Morgenstern },
|
|
SwitchSignalHelper{ .app = *this, .obj = character::weapons::Bow },
|
|
|
|
SwitchSignalHelper{ .app = *this, .obj = character::equipments::Chainmail },
|
|
SwitchSignalHelper{ .app = *this, .obj = character::equipments::CookingPot },
|
|
SwitchSignalHelper{ .app = *this, .obj = character::equipments::PamphletTourist },
|
|
SwitchSignalHelper{ .app = *this, .obj = character::equipments::MedicKit },
|
|
|
|
SwitchSignalHelper{ .app = *this, .obj = character::tools::Fourche },
|
|
SwitchSignalHelper{ .app = *this, .obj = character::tools::Dagger },
|
|
SwitchSignalHelper{ .app = *this, .obj = character::tools::RockClimbingKit },
|
|
SwitchSignalHelper{ .app = *this, .obj = character::tools::SackOfGrain },
|
|
};
|
|
|
|
buttons_obj_container selection_buttons;
|
|
|
|
character::BillyObjects gestionnaire{};
|
|
character::CharacterSheet sheet{};
|
|
};
|
|
} // gui_to_app
|
|
|
|
#endif //LEARNGTK4_APP_WIN_2_BACK_HPP
|