Compare commits
No commits in common. "a84cace7b62f3bd569445347614e0eb5b940d9e4" and "8a91b471528339c447150a6128ce2a39cf57d427" have entirely different histories.
a84cace7b6
...
8a91b47152
5 changed files with 34 additions and 79 deletions
|
|
@ -1,12 +1,10 @@
|
||||||
cmake_minimum_required(VERSION 3.30)
|
cmake_minimum_required(VERSION 3.30)
|
||||||
project(BillyGui LANGUAGES C CXX)
|
project(BillyGui LANGUAGES CXX)
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(GTKMM4 REQUIRED IMPORTED_TARGET gtkmm-4.0)
|
pkg_check_modules(GTKMM4 REQUIRED IMPORTED_TARGET gtkmm-4.0)
|
||||||
|
|
||||||
find_program(GLIB_COMPILE_RESOURCES NAMES glib-compile-resources REQUIRED)
|
|
||||||
|
|
||||||
fetchcontent_declare(BillySheet
|
fetchcontent_declare(BillySheet
|
||||||
GIT_REPOSITORY https://gitea.pcornatcloud.fr/Pcornat/BillySheet.git
|
GIT_REPOSITORY https://gitea.pcornatcloud.fr/Pcornat/BillySheet.git
|
||||||
GIT_TAG main
|
GIT_TAG main
|
||||||
|
|
@ -75,41 +73,13 @@ set(SPDLOG_NO_TLS ON)
|
||||||
set(SPDLOG_NO_ATOMIC_LEVELS ON)
|
set(SPDLOG_NO_ATOMIC_LEVELS ON)
|
||||||
fetchcontent_makeavailable(spdlog)
|
fetchcontent_makeavailable(spdlog)
|
||||||
|
|
||||||
set(GRESOURCE_C resources.c)
|
|
||||||
set(GRESOURCE_XML billy_gui.gresource.xml)
|
|
||||||
|
|
||||||
# Step 2:
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${GRESOURCE_C}
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
COMMAND ${GLIB_COMPILE_RESOURCES}
|
|
||||||
ARGS
|
|
||||||
--target=${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C} ${GRESOURCE_XML} --generate-source
|
|
||||||
VERBATIM
|
|
||||||
MAIN_DEPENDENCY ${GRESOURCE_XML}
|
|
||||||
DEPENDS window_ui.ui menu_bar.ui
|
|
||||||
)
|
|
||||||
|
|
||||||
# Step 3:
|
|
||||||
add_custom_target(
|
|
||||||
dummy-resource
|
|
||||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} main.cpp
|
add_executable(${PROJECT_NAME} main.cpp
|
||||||
hello_world.cpp
|
hello_world.cpp
|
||||||
hello_world.hpp
|
hello_world.hpp
|
||||||
app_win_2_back.cpp
|
app_win_2_back.cpp
|
||||||
app_win_2_back.hpp
|
app_win_2_back.hpp
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set_source_files_properties(
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
|
|
||||||
PROPERTIES GENERATED TRUE
|
|
||||||
)
|
|
||||||
add_dependencies(${PROJECT_NAME} dummy-resource)
|
|
||||||
|
|
||||||
set_target_properties(${PROJECT_NAME} spdlog_header_only PROPERTIES
|
set_target_properties(${PROJECT_NAME} spdlog_header_only PROPERTIES
|
||||||
CXX_STANDARD 23
|
CXX_STANDARD 23
|
||||||
CXX_STANDARD_REQUIRED ON
|
CXX_STANDARD_REQUIRED ON
|
||||||
|
|
|
||||||
|
|
@ -16,22 +16,16 @@ namespace gui_to_app {
|
||||||
namespace views = std::views;
|
namespace views = std::views;
|
||||||
|
|
||||||
AppWin2Back::AppWin2Back() : Gtk::Application("org.billy_adventures.character_sheet", Flags::HANDLES_OPEN) {
|
AppWin2Back::AppWin2Back() : Gtk::Application("org.billy_adventures.character_sheet", Flags::HANDLES_OPEN) {
|
||||||
signal_window_removed().connect([](const Gtk::Window *window) { delete window; });
|
|
||||||
Glib::set_application_name("Billy's character sheet");
|
Glib::set_application_name("Billy's character sheet");
|
||||||
selection_buttons.reserve(signal_handlers.size());
|
selection_buttons.reserve(signal_handlers.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppWin2Back::on_startup() {
|
void AppWin2Back::on_startup() {
|
||||||
Application::on_startup();
|
Application::on_startup();
|
||||||
const auto menu_bar = [this]() -> Glib::RefPtr<Gio::Menu> {
|
const auto menu_bar = []() -> Glib::RefPtr<Gio::Menu> {
|
||||||
try {
|
try {
|
||||||
menu_builder = Gtk::Builder::create_from_resource("/org/gtkmm/billy_gui/menu_bar.ui");
|
const auto builder = Gtk::Builder::create_from_file("menu_bar.ui");
|
||||||
if (menu_builder != nullptr) {
|
return builder->get_object<Gio::Menu>("menu");
|
||||||
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;
|
||||||
|
|
@ -78,18 +72,18 @@ namespace gui_to_app {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppWin2Back::switches_procedure() {
|
bool AppWin2Back::switches_procedure() {
|
||||||
sword_switch = window_builder->get_widget<selection_button>("sword_button");
|
sword_switch = app_builder->get_widget<selection_button>("sword_button");
|
||||||
lance_switch = window_builder->get_widget<selection_button>("lance_button");
|
lance_switch = app_builder->get_widget<selection_button>("lance_button");
|
||||||
morgen_switch = window_builder->get_widget<selection_button>("morgenstern_button");
|
morgen_switch = app_builder->get_widget<selection_button>("morgenstern_button");
|
||||||
bow_switch = window_builder->get_widget<selection_button>("arc_button");
|
bow_switch = app_builder->get_widget<selection_button>("arc_button");
|
||||||
chainmail_switch = window_builder->get_widget<selection_button>("chainmail_button");
|
chainmail_switch = app_builder->get_widget<selection_button>("chainmail_button");
|
||||||
cookpot_switch = window_builder->get_widget<selection_button>("cookingpot_button");
|
cookpot_switch = app_builder->get_widget<selection_button>("cookingpot_button");
|
||||||
pamphlet_switch = window_builder->get_widget<selection_button>("pamphlet_tourist_button");
|
pamphlet_switch = app_builder->get_widget<selection_button>("pamphlet_tourist_button");
|
||||||
medkit_switch = window_builder->get_widget<selection_button>("medkit_button");
|
medkit_switch = app_builder->get_widget<selection_button>("medkit_button");
|
||||||
fourche_switch = window_builder->get_widget<selection_button>("fourche_button");
|
fourche_switch = app_builder->get_widget<selection_button>("fourche_button");
|
||||||
dagger_switch = window_builder->get_widget<selection_button>("dagger_button");
|
dagger_switch = app_builder->get_widget<selection_button>("dagger_button");
|
||||||
rock_kit_switch = window_builder->get_widget<selection_button>("rock_kit_button");
|
rock_kit_switch = app_builder->get_widget<selection_button>("rock_kit_button");
|
||||||
sack_switch = window_builder->get_widget<selection_button>("sack_button");
|
sack_switch = app_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{
|
||||||
|
|
@ -148,24 +142,24 @@ namespace gui_to_app {
|
||||||
void AppWin2Back::on_activate() {
|
void AppWin2Back::on_activate() {
|
||||||
Application::on_activate();
|
Application::on_activate();
|
||||||
|
|
||||||
window_builder = [] -> Glib::RefPtr<Gtk::Builder> {
|
app_builder = [] -> Glib::RefPtr<Gtk::Builder> {
|
||||||
try {
|
try {
|
||||||
return Gtk::Builder::create_from_resource("/org/gtkmm/billy_gui/window_ui.ui");
|
return Gtk::Builder::create_from_file("window_ui.ui");
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
spdlog::critical("Error occurred while loading Window's UI: {}", e.what());
|
spdlog::critical("Error occurred while loading Window's UI: {}", e.what());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
if (!window_builder) {
|
if (!app_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>(window_builder, "main_window");
|
main_window = Gtk::Builder::get_widget_derived<learn_gtkmm4::HelloWorld>(app_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->present();
|
main_window->set_visible(true);
|
||||||
} else {
|
} else {
|
||||||
spdlog::critical("Error while getting window from builder");
|
spdlog::critical("Error while getting window from builder");
|
||||||
on_quit();
|
on_quit();
|
||||||
|
|
@ -174,7 +168,7 @@ namespace gui_to_app {
|
||||||
if (switches_procedure()) {
|
if (switches_procedure()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
debug_button = window_builder->get_widget<Gtk::Button>("debug_button");
|
debug_button = app_builder->get_widget<Gtk::Button>("debug_button");
|
||||||
hab_labels = CaracInterface<Gtk::Label>{
|
hab_labels = CaracInterface<Gtk::Label>{
|
||||||
{
|
{
|
||||||
"habilete_label_base",
|
"habilete_label_base",
|
||||||
|
|
@ -182,7 +176,7 @@ namespace gui_to_app {
|
||||||
"habilete_label_materiel",
|
"habilete_label_materiel",
|
||||||
"habilete_label_total"
|
"habilete_label_total"
|
||||||
},
|
},
|
||||||
window_builder
|
app_builder
|
||||||
};
|
};
|
||||||
endu_labels = CaracInterface<Gtk::Label>{
|
endu_labels = CaracInterface<Gtk::Label>{
|
||||||
{
|
{
|
||||||
|
|
@ -191,7 +185,7 @@ namespace gui_to_app {
|
||||||
"endurance_label_materiel",
|
"endurance_label_materiel",
|
||||||
"endurance_label_total"
|
"endurance_label_total"
|
||||||
},
|
},
|
||||||
window_builder
|
app_builder
|
||||||
};
|
};
|
||||||
addr_labels = CaracInterface<Gtk::Label>{
|
addr_labels = CaracInterface<Gtk::Label>{
|
||||||
{
|
{
|
||||||
|
|
@ -200,7 +194,7 @@ namespace gui_to_app {
|
||||||
"adresse_label_materiel",
|
"adresse_label_materiel",
|
||||||
"adresse_label_total"
|
"adresse_label_total"
|
||||||
},
|
},
|
||||||
window_builder
|
app_builder
|
||||||
};
|
};
|
||||||
luck_labels = CaracInterface<Gtk::Label>{
|
luck_labels = CaracInterface<Gtk::Label>{
|
||||||
{
|
{
|
||||||
|
|
@ -209,20 +203,21 @@ namespace gui_to_app {
|
||||||
"chance_label_materiel",
|
"chance_label_materiel",
|
||||||
"chance_label_total"
|
"chance_label_total"
|
||||||
},
|
},
|
||||||
window_builder
|
app_builder
|
||||||
};
|
};
|
||||||
|
|
||||||
damage_label = window_builder->get_widget<Gtk::Label>("label_degat");
|
damage_label = app_builder->get_widget<Gtk::Label>("label_degat");
|
||||||
armor_label = window_builder->get_widget<Gtk::Label>("label_armure");
|
armor_label = app_builder->get_widget<Gtk::Label>("label_armure");
|
||||||
critic_label = window_builder->get_widget<Gtk::Label>("label_critique");
|
critic_label = app_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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppWin2Back::on_quit() noexcept {
|
void AppWin2Back::on_quit() noexcept {
|
||||||
ranges::for_each(get_windows() | views::filter([](const auto windows) { return windows != nullptr; }),
|
ranges::for_each(get_windows() | views::filter([](const auto windows) { return windows != nullptr; }),
|
||||||
[this](auto *window) {
|
[](auto *window) {
|
||||||
remove_window(*window);
|
window->set_visible(false);
|
||||||
|
delete window;
|
||||||
});
|
});
|
||||||
quit();
|
quit();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,7 @@ namespace gui_to_app {
|
||||||
|
|
||||||
bool erase_obj(const character::billyEnums &obj) noexcept;
|
bool erase_obj(const character::billyEnums &obj) noexcept;
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::Builder> window_builder;
|
Glib::RefPtr<Gtk::Builder> app_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 };
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<gresources>
|
|
||||||
<gresource prefix="/org/gtkmm/billy_gui">
|
|
||||||
<file preprocess="xml-stripblanks">window_ui.ui</file>
|
|
||||||
<file preprocess="xml-stripblanks">menu_bar.ui</file>
|
|
||||||
</gresource>
|
|
||||||
</gresources>
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- Created with Cambalache 0.96.3 -->
|
|
||||||
<interface>
|
<interface>
|
||||||
<!-- interface-name menu_bar.ui -->
|
|
||||||
<requires lib="gio" version="2.0"/>
|
<requires lib="gio" version="2.0"/>
|
||||||
<menu id="menu">
|
<menu id="menu">
|
||||||
<submenu id="file_submenu">
|
<submenu id="file_submenu">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue