mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-26 00:23:55 -07:00
[Game][Counters] Split counters into AbstractCounter (graphics) and CounterState (logic) (#6917)
* [Counters] Split counters into graphics and logic states Took 22 minutes * Don't have widget hold pointer to state -> Copy what we need and subscribe to changes. Took 12 minutes Took 5 seconds * Sync value too. Took 3 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
0549892092
commit
bddf9bd818
17 changed files with 273 additions and 199 deletions
|
|
@ -97,10 +97,7 @@ void PlayerMenu::retranslateUi()
|
|||
countersMenu->setTitle(tr("&Counters"));
|
||||
}
|
||||
|
||||
QMapIterator<int, AbstractCounter *> counterIterator(player->getCounters());
|
||||
while (counterIterator.hasNext()) {
|
||||
counterIterator.next().value()->retranslateUi();
|
||||
}
|
||||
emit retranslateRequested();
|
||||
}
|
||||
|
||||
void PlayerMenu::refreshShortcuts()
|
||||
|
|
@ -120,30 +117,17 @@ void PlayerMenu::refreshShortcuts()
|
|||
void PlayerMenu::setShortcutsActive()
|
||||
{
|
||||
shortcutsActive = true;
|
||||
|
||||
for (auto *component : managedComponents) {
|
||||
component->setShortcutsActive();
|
||||
}
|
||||
|
||||
// Counters implement AbstractPlayerComponent but are iterated via Player::counters
|
||||
// (the authoritative source) rather than managedComponents to avoid a redundant
|
||||
// list that must stay in sync with the map.
|
||||
QMapIterator<int, AbstractCounter *> counterIterator(player->getCounters());
|
||||
while (counterIterator.hasNext()) {
|
||||
counterIterator.next().value()->setShortcutsActive();
|
||||
for (auto *c : managedComponents) {
|
||||
c->setShortcutsActive();
|
||||
}
|
||||
emit shortcutsActivated();
|
||||
}
|
||||
|
||||
void PlayerMenu::setShortcutsInactive()
|
||||
{
|
||||
shortcutsActive = false;
|
||||
|
||||
for (auto *component : managedComponents) {
|
||||
component->setShortcutsInactive();
|
||||
}
|
||||
|
||||
QMapIterator<int, AbstractCounter *> counterIterator(player->getCounters());
|
||||
while (counterIterator.hasNext()) {
|
||||
counterIterator.next().value()->setShortcutsInactive();
|
||||
for (auto *c : managedComponents) {
|
||||
c->setShortcutsInactive();
|
||||
}
|
||||
emit shortcutsDeactivated();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue