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() {
|
||||
Application::on_startup();
|
||||
const auto menu_bar = []() -> Glib::RefPtr<Gio::Menu> {
|
||||
const auto menu_bar = [this]() -> Glib::RefPtr<Gio::Menu> {
|
||||
try {
|
||||
const auto builder = Gtk::Builder::create_from_file("menu_bar.ui");
|
||||
return builder->get_object<Gio::Menu>("menu");
|
||||
menu_builder = Gtk::Builder::create_from_file("menu_bar.ui");
|
||||
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) {
|
||||
spdlog::error("Error occurred while loader menu bar: {}", e.what());
|
||||
return nullptr;
|
||||
|
|
@ -73,18 +78,18 @@ namespace gui_to_app {
|
|||
}
|
||||
|
||||
bool AppWin2Back::switches_procedure() {
|
||||
sword_switch = app_builder->get_widget<selection_button>("sword_button");
|
||||
lance_switch = app_builder->get_widget<selection_button>("lance_button");
|
||||
morgen_switch = app_builder->get_widget<selection_button>("morgenstern_button");
|
||||
bow_switch = app_builder->get_widget<selection_button>("arc_button");
|
||||
chainmail_switch = app_builder->get_widget<selection_button>("chainmail_button");
|
||||
cookpot_switch = app_builder->get_widget<selection_button>("cookingpot_button");
|
||||
pamphlet_switch = app_builder->get_widget<selection_button>("pamphlet_tourist_button");
|
||||
medkit_switch = app_builder->get_widget<selection_button>("medkit_button");
|
||||
fourche_switch = app_builder->get_widget<selection_button>("fourche_button");
|
||||
dagger_switch = app_builder->get_widget<selection_button>("dagger_button");
|
||||
rock_kit_switch = app_builder->get_widget<selection_button>("rock_kit_button");
|
||||
sack_switch = app_builder->get_widget<selection_button>("sack_button");
|
||||
sword_switch = window_builder->get_widget<selection_button>("sword_button");
|
||||
lance_switch = window_builder->get_widget<selection_button>("lance_button");
|
||||
morgen_switch = window_builder->get_widget<selection_button>("morgenstern_button");
|
||||
bow_switch = window_builder->get_widget<selection_button>("arc_button");
|
||||
chainmail_switch = window_builder->get_widget<selection_button>("chainmail_button");
|
||||
cookpot_switch = window_builder->get_widget<selection_button>("cookingpot_button");
|
||||
pamphlet_switch = window_builder->get_widget<selection_button>("pamphlet_tourist_button");
|
||||
medkit_switch = window_builder->get_widget<selection_button>("medkit_button");
|
||||
fourche_switch = window_builder->get_widget<selection_button>("fourche_button");
|
||||
dagger_switch = window_builder->get_widget<selection_button>("dagger_button");
|
||||
rock_kit_switch = window_builder->get_widget<selection_button>("rock_kit_button");
|
||||
sack_switch = window_builder->get_widget<selection_button>("sack_button");
|
||||
|
||||
const auto test_result = ranges::to<std::vector<const char *> >(
|
||||
std::array{
|
||||
|
|
@ -143,7 +148,7 @@ namespace gui_to_app {
|
|||
void AppWin2Back::on_activate() {
|
||||
Application::on_activate();
|
||||
|
||||
app_builder = [] -> Glib::RefPtr<Gtk::Builder> {
|
||||
window_builder = [] -> Glib::RefPtr<Gtk::Builder> {
|
||||
try {
|
||||
return Gtk::Builder::create_from_file("window_ui.ui");
|
||||
} catch (const std::exception &e) {
|
||||
|
|
@ -151,16 +156,16 @@ namespace gui_to_app {
|
|||
return nullptr;
|
||||
}
|
||||
}();
|
||||
if (!app_builder) {
|
||||
if (!window_builder) {
|
||||
spdlog::critical("Error while loading UI");
|
||||
quit();
|
||||
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) {
|
||||
add_window(*main_window);
|
||||
main_window->set_show_menubar(true);
|
||||
main_window->set_visible(true);
|
||||
main_window->present();
|
||||
} else {
|
||||
spdlog::critical("Error while getting window from builder");
|
||||
on_quit();
|
||||
|
|
@ -169,7 +174,7 @@ namespace gui_to_app {
|
|||
if (switches_procedure()) {
|
||||
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>{
|
||||
{
|
||||
"habilete_label_base",
|
||||
|
|
@ -177,7 +182,7 @@ namespace gui_to_app {
|
|||
"habilete_label_materiel",
|
||||
"habilete_label_total"
|
||||
},
|
||||
app_builder
|
||||
window_builder
|
||||
};
|
||||
endu_labels = CaracInterface<Gtk::Label>{
|
||||
{
|
||||
|
|
@ -186,7 +191,7 @@ namespace gui_to_app {
|
|||
"endurance_label_materiel",
|
||||
"endurance_label_total"
|
||||
},
|
||||
app_builder
|
||||
window_builder
|
||||
};
|
||||
addr_labels = CaracInterface<Gtk::Label>{
|
||||
{
|
||||
|
|
@ -195,7 +200,7 @@ namespace gui_to_app {
|
|||
"adresse_label_materiel",
|
||||
"adresse_label_total"
|
||||
},
|
||||
app_builder
|
||||
window_builder
|
||||
};
|
||||
luck_labels = CaracInterface<Gtk::Label>{
|
||||
{
|
||||
|
|
@ -204,12 +209,12 @@ namespace gui_to_app {
|
|||
"chance_label_materiel",
|
||||
"chance_label_total"
|
||||
},
|
||||
app_builder
|
||||
window_builder
|
||||
};
|
||||
|
||||
damage_label = app_builder->get_widget<Gtk::Label>("label_degat");
|
||||
armor_label = app_builder->get_widget<Gtk::Label>("label_armure");
|
||||
critic_label = app_builder->get_widget<Gtk::Label>("label_critique");
|
||||
damage_label = window_builder->get_widget<Gtk::Label>("label_degat");
|
||||
armor_label = window_builder->get_widget<Gtk::Label>("label_armure");
|
||||
critic_label = window_builder->get_widget<Gtk::Label>("label_critique");
|
||||
|
||||
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;
|
||||
|
||||
Glib::RefPtr<Gtk::Builder> app_builder;
|
||||
Glib::RefPtr<Gtk::Builder> window_builder;
|
||||
Glib::RefPtr<Gtk::Builder> menu_builder;
|
||||
learn_gtkmm4::HelloWorld *main_window{ nullptr };
|
||||
selection_button *sword_switch{ nullptr };
|
||||
selection_button *lance_switch{ nullptr };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue