Keeping both builders, renaming them.
This commit is contained in:
parent
bae36631d2
commit
0b38380437
2 changed files with 34 additions and 28 deletions
|
|
@ -23,10 +23,15 @@ namespace gui_to_app {
|
||||||
|
|
||||||
void AppWin2Back::on_startup() {
|
void AppWin2Back::on_startup() {
|
||||||
Application::on_startup();
|
Application::on_startup();
|
||||||
const auto menu_bar = []() -> Glib::RefPtr<Gio::Menu> {
|
const auto menu_bar = [this]() -> Glib::RefPtr<Gio::Menu> {
|
||||||
try {
|
try {
|
||||||
const auto builder = Gtk::Builder::create_from_file("menu_bar.ui");
|
menu_builder = Gtk::Builder::create_from_file("menu_bar.ui");
|
||||||
return builder->get_object<Gio::Menu>("menu");
|
if (menu_builder != nullptr) {
|
||||||
|
return menu_builder->get_object<Gio::Menu>("menu");
|
||||||
|
} else {
|
||||||
|
spdlog::error("Error while loading menu bar UI");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
spdlog::error("Error occurred while loader menu bar: {}", e.what());
|
spdlog::error("Error occurred while loader menu bar: {}", e.what());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -73,18 +78,18 @@ namespace gui_to_app {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppWin2Back::switches_procedure() {
|
bool AppWin2Back::switches_procedure() {
|
||||||
sword_switch = app_builder->get_widget<selection_button>("sword_button");
|
sword_switch = window_builder->get_widget<selection_button>("sword_button");
|
||||||
lance_switch = app_builder->get_widget<selection_button>("lance_button");
|
lance_switch = window_builder->get_widget<selection_button>("lance_button");
|
||||||
morgen_switch = app_builder->get_widget<selection_button>("morgenstern_button");
|
morgen_switch = window_builder->get_widget<selection_button>("morgenstern_button");
|
||||||
bow_switch = app_builder->get_widget<selection_button>("arc_button");
|
bow_switch = window_builder->get_widget<selection_button>("arc_button");
|
||||||
chainmail_switch = app_builder->get_widget<selection_button>("chainmail_button");
|
chainmail_switch = window_builder->get_widget<selection_button>("chainmail_button");
|
||||||
cookpot_switch = app_builder->get_widget<selection_button>("cookingpot_button");
|
cookpot_switch = window_builder->get_widget<selection_button>("cookingpot_button");
|
||||||
pamphlet_switch = app_builder->get_widget<selection_button>("pamphlet_tourist_button");
|
pamphlet_switch = window_builder->get_widget<selection_button>("pamphlet_tourist_button");
|
||||||
medkit_switch = app_builder->get_widget<selection_button>("medkit_button");
|
medkit_switch = window_builder->get_widget<selection_button>("medkit_button");
|
||||||
fourche_switch = app_builder->get_widget<selection_button>("fourche_button");
|
fourche_switch = window_builder->get_widget<selection_button>("fourche_button");
|
||||||
dagger_switch = app_builder->get_widget<selection_button>("dagger_button");
|
dagger_switch = window_builder->get_widget<selection_button>("dagger_button");
|
||||||
rock_kit_switch = app_builder->get_widget<selection_button>("rock_kit_button");
|
rock_kit_switch = window_builder->get_widget<selection_button>("rock_kit_button");
|
||||||
sack_switch = app_builder->get_widget<selection_button>("sack_button");
|
sack_switch = window_builder->get_widget<selection_button>("sack_button");
|
||||||
|
|
||||||
const auto test_result = ranges::to<std::vector<const char *> >(
|
const auto test_result = ranges::to<std::vector<const char *> >(
|
||||||
std::array{
|
std::array{
|
||||||
|
|
@ -143,7 +148,7 @@ namespace gui_to_app {
|
||||||
void AppWin2Back::on_activate() {
|
void AppWin2Back::on_activate() {
|
||||||
Application::on_activate();
|
Application::on_activate();
|
||||||
|
|
||||||
app_builder = [] -> Glib::RefPtr<Gtk::Builder> {
|
window_builder = [] -> Glib::RefPtr<Gtk::Builder> {
|
||||||
try {
|
try {
|
||||||
return Gtk::Builder::create_from_file("window_ui.ui");
|
return Gtk::Builder::create_from_file("window_ui.ui");
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
|
|
@ -151,16 +156,16 @@ namespace gui_to_app {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
if (!app_builder) {
|
if (!window_builder) {
|
||||||
spdlog::critical("Error while loading UI");
|
spdlog::critical("Error while loading UI");
|
||||||
quit();
|
quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
main_window = Gtk::Builder::get_widget_derived<learn_gtkmm4::HelloWorld>(app_builder, "main_window");
|
main_window = Gtk::Builder::get_widget_derived<learn_gtkmm4::HelloWorld>(window_builder, "main_window");
|
||||||
if (main_window != nullptr) {
|
if (main_window != nullptr) {
|
||||||
add_window(*main_window);
|
add_window(*main_window);
|
||||||
main_window->set_show_menubar(true);
|
main_window->set_show_menubar(true);
|
||||||
main_window->set_visible(true);
|
main_window->present();
|
||||||
} else {
|
} else {
|
||||||
spdlog::critical("Error while getting window from builder");
|
spdlog::critical("Error while getting window from builder");
|
||||||
on_quit();
|
on_quit();
|
||||||
|
|
@ -169,7 +174,7 @@ namespace gui_to_app {
|
||||||
if (switches_procedure()) {
|
if (switches_procedure()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
debug_button = app_builder->get_widget<Gtk::Button>("debug_button");
|
debug_button = window_builder->get_widget<Gtk::Button>("debug_button");
|
||||||
hab_labels = CaracInterface<Gtk::Label>{
|
hab_labels = CaracInterface<Gtk::Label>{
|
||||||
{
|
{
|
||||||
"habilete_label_base",
|
"habilete_label_base",
|
||||||
|
|
@ -177,7 +182,7 @@ namespace gui_to_app {
|
||||||
"habilete_label_materiel",
|
"habilete_label_materiel",
|
||||||
"habilete_label_total"
|
"habilete_label_total"
|
||||||
},
|
},
|
||||||
app_builder
|
window_builder
|
||||||
};
|
};
|
||||||
endu_labels = CaracInterface<Gtk::Label>{
|
endu_labels = CaracInterface<Gtk::Label>{
|
||||||
{
|
{
|
||||||
|
|
@ -186,7 +191,7 @@ namespace gui_to_app {
|
||||||
"endurance_label_materiel",
|
"endurance_label_materiel",
|
||||||
"endurance_label_total"
|
"endurance_label_total"
|
||||||
},
|
},
|
||||||
app_builder
|
window_builder
|
||||||
};
|
};
|
||||||
addr_labels = CaracInterface<Gtk::Label>{
|
addr_labels = CaracInterface<Gtk::Label>{
|
||||||
{
|
{
|
||||||
|
|
@ -195,7 +200,7 @@ namespace gui_to_app {
|
||||||
"adresse_label_materiel",
|
"adresse_label_materiel",
|
||||||
"adresse_label_total"
|
"adresse_label_total"
|
||||||
},
|
},
|
||||||
app_builder
|
window_builder
|
||||||
};
|
};
|
||||||
luck_labels = CaracInterface<Gtk::Label>{
|
luck_labels = CaracInterface<Gtk::Label>{
|
||||||
{
|
{
|
||||||
|
|
@ -204,12 +209,12 @@ namespace gui_to_app {
|
||||||
"chance_label_materiel",
|
"chance_label_materiel",
|
||||||
"chance_label_total"
|
"chance_label_total"
|
||||||
},
|
},
|
||||||
app_builder
|
window_builder
|
||||||
};
|
};
|
||||||
|
|
||||||
damage_label = app_builder->get_widget<Gtk::Label>("label_degat");
|
damage_label = window_builder->get_widget<Gtk::Label>("label_degat");
|
||||||
armor_label = app_builder->get_widget<Gtk::Label>("label_armure");
|
armor_label = window_builder->get_widget<Gtk::Label>("label_armure");
|
||||||
critic_label = app_builder->get_widget<Gtk::Label>("label_critique");
|
critic_label = window_builder->get_widget<Gtk::Label>("label_critique");
|
||||||
|
|
||||||
debug_button->signal_clicked().connect(sigc::mem_fun(*this, &AppWin2Back::debug_button_clicked), false);
|
debug_button->signal_clicked().connect(sigc::mem_fun(*this, &AppWin2Back::debug_button_clicked), false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,8 @@ namespace gui_to_app {
|
||||||
|
|
||||||
bool erase_obj(const character::billyEnums &obj) noexcept;
|
bool erase_obj(const character::billyEnums &obj) noexcept;
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::Builder> app_builder;
|
Glib::RefPtr<Gtk::Builder> window_builder;
|
||||||
|
Glib::RefPtr<Gtk::Builder> menu_builder;
|
||||||
learn_gtkmm4::HelloWorld *main_window{ nullptr };
|
learn_gtkmm4::HelloWorld *main_window{ nullptr };
|
||||||
selection_button *sword_switch{ nullptr };
|
selection_button *sword_switch{ nullptr };
|
||||||
selection_button *lance_switch{ nullptr };
|
selection_button *lance_switch{ nullptr };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue