From e8933c5029cf3fdb72394228bc14a03943cce8bf Mon Sep 17 00:00:00 2001 From: Pcornat Date: Fri, 6 Feb 2026 19:17:23 +0100 Subject: [PATCH] Adding objects correctly --- app_win_2_back.cpp | 38 ++++++++++++++------------------------ app_win_2_back.hpp | 3 +-- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/app_win_2_back.cpp b/app_win_2_back.cpp index e8e5271..db940e3 100644 --- a/app_win_2_back.cpp +++ b/app_win_2_back.cpp @@ -44,29 +44,19 @@ namespace gui_to_app { void AppWin2Back::SwitchSignalHelper::signal_handler() noexcept { if (switch_ != nullptr && !on_stack) { - if (!switch_->get_inconsistent()) { - if (switch_->get_active()) { - if (!app.insert_obj(obj)) { - on_stack = true; - switch_->set_active(false); - ranges::for_each( - app.selection_buttons | views::filter([](const buttons_obj_container::value_type a) { - return !a->get_active() && !a->get_inconsistent(); - }), - [](const buttons_obj_container::value_type a) { a->set_inconsistent(); }); - } - } else { - const bool was_full = character::BillyObjects::is_full(app.sheet); - if (!app.erase_obj(obj)) { - on_stack = true; - switch_->set_active(true); - } else if (!character::BillyObjects::is_full(app.sheet) && was_full) { - ranges::for_each( - app.selection_buttons | views::filter([](const buttons_obj_container::value_type a) { - return a->get_inconsistent(); - }), - [](const buttons_obj_container::value_type a) { a->set_inconsistent(false); }); - } + if (switch_->get_active()) { + if (!app.insert_obj(obj)) { + on_stack = true; + switch_->set_active(false); + } + } else { + if (!app.erase_obj(obj)) { + on_stack = true; + switch_->set_active(true); + spdlog::warn( + "Erasing object {} was not successful", + character::BillyObjects::billy_object_to_string(obj).data() + ); } } } @@ -116,7 +106,7 @@ namespace gui_to_app { on_quit(); return true; } - // TODO: interaction avec la CharacterSheet + ranges::for_each(views::zip(std::array{ sword_switch, lance_switch, diff --git a/app_win_2_back.hpp b/app_win_2_back.hpp index 2b6d61f..2f8bc52 100644 --- a/app_win_2_back.hpp +++ b/app_win_2_back.hpp @@ -5,11 +5,10 @@ #include #include +#include #include #include -// #include -#include namespace learn_gtkmm4 { class HelloWorld;