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 {
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue