Adding objects correctly
This commit is contained in:
parent
f4cbc2558b
commit
e8933c5029
2 changed files with 15 additions and 26 deletions
|
|
@ -44,29 +44,19 @@ namespace gui_to_app {
|
||||||
|
|
||||||
void AppWin2Back::SwitchSignalHelper::signal_handler() noexcept {
|
void AppWin2Back::SwitchSignalHelper::signal_handler() noexcept {
|
||||||
if (switch_ != nullptr && !on_stack) {
|
if (switch_ != nullptr && !on_stack) {
|
||||||
if (!switch_->get_inconsistent()) {
|
|
||||||
if (switch_->get_active()) {
|
if (switch_->get_active()) {
|
||||||
if (!app.insert_obj(obj)) {
|
if (!app.insert_obj(obj)) {
|
||||||
on_stack = true;
|
on_stack = true;
|
||||||
switch_->set_active(false);
|
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 {
|
} else {
|
||||||
const bool was_full = character::BillyObjects::is_full(app.sheet);
|
|
||||||
if (!app.erase_obj(obj)) {
|
if (!app.erase_obj(obj)) {
|
||||||
on_stack = true;
|
on_stack = true;
|
||||||
switch_->set_active(true);
|
switch_->set_active(true);
|
||||||
} else if (!character::BillyObjects::is_full(app.sheet) && was_full) {
|
spdlog::warn(
|
||||||
ranges::for_each(
|
"Erasing object {} was not successful",
|
||||||
app.selection_buttons | views::filter([](const buttons_obj_container::value_type a) {
|
character::BillyObjects::billy_object_to_string(obj).data()
|
||||||
return a->get_inconsistent();
|
);
|
||||||
}),
|
|
||||||
[](const buttons_obj_container::value_type a) { a->set_inconsistent(false); });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +106,7 @@ namespace gui_to_app {
|
||||||
on_quit();
|
on_quit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// TODO: interaction avec la CharacterSheet
|
|
||||||
ranges::for_each(views::zip(std::array{
|
ranges::for_each(views::zip(std::array{
|
||||||
sword_switch,
|
sword_switch,
|
||||||
lance_switch,
|
lance_switch,
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,10 @@
|
||||||
|
|
||||||
#include <glibmm/refptr.h>
|
#include <glibmm/refptr.h>
|
||||||
#include <gtkmm/application.h>
|
#include <gtkmm/application.h>
|
||||||
|
#include <gtkmm/checkbutton.h>
|
||||||
|
|
||||||
#include <billy_objects.hpp>
|
#include <billy_objects.hpp>
|
||||||
#include <character_sheet.hpp>
|
#include <character_sheet.hpp>
|
||||||
// #include <gtkmm/label.h>
|
|
||||||
#include <gtkmm/checkbutton.h>
|
|
||||||
|
|
||||||
namespace learn_gtkmm4 {
|
namespace learn_gtkmm4 {
|
||||||
class HelloWorld;
|
class HelloWorld;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue