mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-06 21:43:55 -07:00
[Game] Use in-game menu for tally setting
This commit is contained in:
parent
c5b37cdffe
commit
ce53e03d42
10 changed files with 98 additions and 19 deletions
49
cockatrice/src/game_graphics/player/menu/tally_menu.cpp
Normal file
49
cockatrice/src/game_graphics/player/menu/tally_menu.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include "tally_menu.h"
|
||||
|
||||
#include "../../client/settings/cache_settings.h"
|
||||
|
||||
TallyMenu::TallyMenu()
|
||||
{
|
||||
aTallyNone = createTallyAction(TallyType::None);
|
||||
aTallySubtype = createTallyAction(TallyType::Subtypes);
|
||||
|
||||
addAction(aTallyNone);
|
||||
addSeparator();
|
||||
addAction(aTallySubtype);
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
QAction *TallyMenu::createTallyAction(TallyType tallyType)
|
||||
{
|
||||
TallyType currentType = SettingsCache::instance().getTallyType();
|
||||
|
||||
QAction *action = new QAction(this);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(tallyType == currentType);
|
||||
|
||||
connect(action, &QAction::triggered, &SettingsCache::instance(),
|
||||
[tallyType] { SettingsCache::instance().setTallyType(tallyType); });
|
||||
connect(&SettingsCache::instance(), &SettingsCache::tallyTypeChanged, action,
|
||||
[action, tallyType](TallyType type) { action->setChecked(type == tallyType); });
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
void TallyMenu::setShortcutsActive()
|
||||
{
|
||||
// no-op because we haven't decided if we're adding shortcuts for tally types
|
||||
}
|
||||
|
||||
void TallyMenu::setShortcutsInactive()
|
||||
{
|
||||
// no-op because we haven't decided if we're adding shortcuts for tally types
|
||||
}
|
||||
|
||||
void TallyMenu::retranslateUi()
|
||||
{
|
||||
setTitle(tr("Tally"));
|
||||
|
||||
aTallyNone->setText(tr("None"));
|
||||
aTallySubtype->setText(tr("Subtype"));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue