Add animations toggles for the life counter and battlefield

The blanket animations switch plus per-effect toggles: a life-counter
flash on loss and a crimson battlefield shimmer on damage.

Took 2 minutes
This commit is contained in:
Lukas Brübach 2026-08-11 01:42:59 +02:00
parent a5f43c08fa
commit c7ad813619
5 changed files with 83 additions and 1 deletions

View file

@ -116,8 +116,37 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
connect(&tapAnimationCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().cardsDisplay(), connect(&tapAnimationCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().cardsDisplay(),
&CardsDisplaySettings::setTapAnimation); &CardsDisplaySettings::setTapAnimation);
animationsEnabledCheckBox.setChecked(SettingsCache::instance().userInterface().getAnimationsEnabled());
connect(&animationsEnabledCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().userInterface(),
&InterfaceSettings::setAnimationsEnabled);
lifeCounterAnimationsCheckBox.setChecked(
SettingsCache::instance().userInterface().getLifeCounterAnimationsEnabled());
connect(&lifeCounterAnimationsCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().userInterface(),
&InterfaceSettings::setLifeCounterAnimationsEnabled);
battlefieldFlashCheckBox.setChecked(SettingsCache::instance().userInterface().getBattlefieldFlashEnabled());
connect(&battlefieldFlashCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().userInterface(),
&InterfaceSettings::setBattlefieldFlashEnabled);
auto *animationGrid = new QGridLayout; auto *animationGrid = new QGridLayout;
animationGrid->addWidget(&tapAnimationCheckBox, 0, 0); animationGrid->addWidget(&animationsEnabledCheckBox, 0, 0);
animationGrid->addWidget(&tapAnimationCheckBox, 1, 0);
// Subgroup for per-effect toggles, active only while the blanket "enable all" is on.
auto *animationDetailGrid = new QGridLayout;
animationDetailGrid->addWidget(&lifeCounterAnimationsCheckBox, 0, 0);
animationDetailGrid->addWidget(&battlefieldFlashCheckBox, 1, 0);
animationDetailGroupBox = new QGroupBox;
animationDetailGroupBox->setLayout(animationDetailGrid);
animationGrid->addWidget(animationDetailGroupBox, 2, 0);
const auto syncAnimationDetailEnabled = [this] {
animationDetailGroupBox->setEnabled(SettingsCache::instance().userInterface().getAnimationsEnabled());
};
syncAnimationDetailEnabled();
connect(&SettingsCache::instance().userInterface(), &InterfaceSettings::animationsEnabledChanged, this,
syncAnimationDetailEnabled);
animationGroupBox = new QGroupBox; animationGroupBox = new QGroupBox;
animationGroupBox->setLayout(animationGrid); animationGroupBox->setLayout(animationGrid);
@ -310,7 +339,11 @@ void UserInterfaceSettingsPage::retranslateUi()
specNotificationsEnabledCheckBox.setText(tr("Notify in the taskbar for game events while you are spectating")); specNotificationsEnabledCheckBox.setText(tr("Notify in the taskbar for game events while you are spectating"));
buddyConnectNotificationsEnabledCheckBox.setText(tr("Notify in the taskbar when users in your buddy list connect")); buddyConnectNotificationsEnabledCheckBox.setText(tr("Notify in the taskbar when users in your buddy list connect"));
animationGroupBox->setTitle(tr("Animation settings")); animationGroupBox->setTitle(tr("Animation settings"));
animationsEnabledCheckBox.setText(tr("Enable game &animations"));
tapAnimationCheckBox.setText(tr("&Tap/untap animation")); tapAnimationCheckBox.setText(tr("&Tap/untap animation"));
animationDetailGroupBox->setTitle(tr("Individual animations"));
lifeCounterAnimationsCheckBox.setText(tr("Life counter flash"));
battlefieldFlashCheckBox.setText(tr("Battlefield flash on damage"));
deckEditorGroupBox->setTitle(tr("Deck editor/storage settings")); deckEditorGroupBox->setTitle(tr("Deck editor/storage settings"));
openDeckInNewTabCheckBox.setText(tr("Open deck in new tab by default")); openDeckInNewTabCheckBox.setText(tr("Open deck in new tab by default"));
visualDeckStorageInGameCheckBox.setText(tr("Use visual deck storage in game lobby")); visualDeckStorageInGameCheckBox.setText(tr("Use visual deck storage in game lobby"));

View file

@ -35,6 +35,9 @@ private:
QCheckBox useTearOffMenusCheckBox; QCheckBox useTearOffMenusCheckBox;
QCheckBox keepGameChatFocusCheckBox; QCheckBox keepGameChatFocusCheckBox;
QCheckBox tapAnimationCheckBox; QCheckBox tapAnimationCheckBox;
QCheckBox animationsEnabledCheckBox;
QCheckBox lifeCounterAnimationsCheckBox;
QCheckBox battlefieldFlashCheckBox;
QCheckBox openDeckInNewTabCheckBox; QCheckBox openDeckInNewTabCheckBox;
QLabel visualDeckStoragePromptForConversionLabel; QLabel visualDeckStoragePromptForConversionLabel;
QComboBox visualDeckStoragePromptForConversionSelector; QComboBox visualDeckStoragePromptForConversionSelector;
@ -52,6 +55,7 @@ private:
QGroupBox *generalGroupBox; QGroupBox *generalGroupBox;
QGroupBox *notificationsGroupBox; QGroupBox *notificationsGroupBox;
QGroupBox *animationGroupBox; QGroupBox *animationGroupBox;
QGroupBox *animationDetailGroupBox;
QGroupBox *deckEditorGroupBox; QGroupBox *deckEditorGroupBox;
QGroupBox *replayGroupBox; QGroupBox *replayGroupBox;

View file

@ -39,6 +39,9 @@ public:
[[nodiscard]] virtual bool getShowStatusBar() const = 0; [[nodiscard]] virtual bool getShowStatusBar() const = 0;
[[nodiscard]] virtual bool getShowShortcuts() const = 0; [[nodiscard]] virtual bool getShowShortcuts() const = 0;
[[nodiscard]] virtual bool getShowGameSelectorFilterToolbar() const = 0; [[nodiscard]] virtual bool getShowGameSelectorFilterToolbar() const = 0;
[[nodiscard]] virtual bool getAnimationsEnabled() const = 0;
[[nodiscard]] virtual bool getLifeCounterAnimationsEnabled() const = 0;
[[nodiscard]] virtual bool getBattlefieldFlashEnabled() const = 0;
}; };
#endif // COCKATRICE_INTERFACE_INTERFACE_SETTINGS_PROVIDER_H #endif // COCKATRICE_INTERFACE_INTERFACE_SETTINGS_PROVIDER_H

View file

@ -160,6 +160,21 @@ bool InterfaceSettings::getShowGameSelectorFilterToolbar() const
return getValue("showGameSelectorFilterToolbar", QString(), QString(), true).toBool(); return getValue("showGameSelectorFilterToolbar", QString(), QString(), true).toBool();
} }
bool InterfaceSettings::getAnimationsEnabled() const
{
return getValue("animationsEnabled", QString(), QString(), true).toBool();
}
bool InterfaceSettings::getLifeCounterAnimationsEnabled() const
{
return getValue("lifeCounterAnimationsEnabled", QString(), QString(), true).toBool();
}
bool InterfaceSettings::getBattlefieldFlashEnabled() const
{
return getValue("battlefieldFlashEnabled", QString(), QString(), true).toBool();
}
void InterfaceSettings::setUseTearOffMenus(bool _useTearOffMenus) void InterfaceSettings::setUseTearOffMenus(bool _useTearOffMenus)
{ {
setValue(_useTearOffMenus, "useTearOffMenus"); setValue(_useTearOffMenus, "useTearOffMenus");
@ -326,3 +341,21 @@ void InterfaceSettings::setShowGameSelectorFilterToolbar(bool _showGameSelectorF
setValue(_showGameSelectorFilterToolbar, "showGameSelectorFilterToolbar"); setValue(_showGameSelectorFilterToolbar, "showGameSelectorFilterToolbar");
emit showGameSelectorFilterToolbarChanged(_showGameSelectorFilterToolbar); emit showGameSelectorFilterToolbarChanged(_showGameSelectorFilterToolbar);
} }
void InterfaceSettings::setAnimationsEnabled(bool _animationsEnabled)
{
setValue(_animationsEnabled, "animationsEnabled");
emit animationsEnabledChanged(_animationsEnabled);
}
void InterfaceSettings::setLifeCounterAnimationsEnabled(bool _lifeCounterAnimationsEnabled)
{
setValue(_lifeCounterAnimationsEnabled, "lifeCounterAnimationsEnabled");
emit lifeCounterAnimationsEnabledChanged(_lifeCounterAnimationsEnabled);
}
void InterfaceSettings::setBattlefieldFlashEnabled(bool _battlefieldFlashEnabled)
{
setValue(_battlefieldFlashEnabled, "battlefieldFlashEnabled");
emit battlefieldFlashEnabledChanged(_battlefieldFlashEnabled);
}

View file

@ -42,6 +42,9 @@ public:
[[nodiscard]] bool getShowStatusBar() const override; [[nodiscard]] bool getShowStatusBar() const override;
[[nodiscard]] bool getShowShortcuts() const override; [[nodiscard]] bool getShowShortcuts() const override;
[[nodiscard]] bool getShowGameSelectorFilterToolbar() const override; [[nodiscard]] bool getShowGameSelectorFilterToolbar() const override;
[[nodiscard]] bool getAnimationsEnabled() const override;
[[nodiscard]] bool getLifeCounterAnimationsEnabled() const override;
[[nodiscard]] bool getBattlefieldFlashEnabled() const override;
void setUseTearOffMenus(bool _useTearOffMenus); void setUseTearOffMenus(bool _useTearOffMenus);
void setCardViewInitialRowsMax(int _cardViewInitialRowsMax); void setCardViewInitialRowsMax(int _cardViewInitialRowsMax);
@ -74,6 +77,9 @@ public:
void setShowStatusBar(bool _showStatusBar); void setShowStatusBar(bool _showStatusBar);
void setShowShortcuts(bool _showShortcuts); void setShowShortcuts(bool _showShortcuts);
void setShowGameSelectorFilterToolbar(bool _showGameSelectorFilterToolbar); void setShowGameSelectorFilterToolbar(bool _showGameSelectorFilterToolbar);
void setAnimationsEnabled(bool _animationsEnabled);
void setLifeCounterAnimationsEnabled(bool _lifeCounterAnimationsEnabled);
void setBattlefieldFlashEnabled(bool _battlefieldFlashEnabled);
signals: signals:
void useTearOffMenusChanged(bool state); void useTearOffMenusChanged(bool state);
@ -85,6 +91,9 @@ signals:
void tallyTypeChanged(int type); void tallyTypeChanged(int type);
void showStatusBarChanged(bool state); void showStatusBarChanged(bool state);
void showGameSelectorFilterToolbarChanged(bool state); void showGameSelectorFilterToolbarChanged(bool state);
void animationsEnabledChanged(bool state);
void lifeCounterAnimationsEnabledChanged(bool state);
void battlefieldFlashEnabledChanged(bool state);
public: public:
explicit InterfaceSettings(const QString &settingPath, QObject *parent = nullptr); explicit InterfaceSettings(const QString &settingPath, QObject *parent = nullptr);