mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-06 13:33: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
|
|
@ -97,6 +97,7 @@ set(cockatrice_SOURCES
|
|||
src/game_graphics/player/menu/rfg_menu.cpp
|
||||
src/game_graphics/player/menu/say_menu.cpp
|
||||
src/game_graphics/player/menu/sideboard_menu.cpp
|
||||
src/game_graphics/player/menu/tally_menu.cpp
|
||||
src/game_graphics/player/menu/utility_menu.cpp
|
||||
src/game_graphics/tally/subtype_tally.cpp
|
||||
src/game_graphics/tally/tally.cpp
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ SettingsCache::SettingsCache()
|
|||
|
||||
showDragSelectionCount = settings->value("interface/showlassoselectioncount", true).toBool();
|
||||
showTotalSelectionCount = settings->value("interface/showpersistentselectioncount", true).toBool();
|
||||
showSubtypeSelectionTally = settings->value("interface/showsubtypeselectiontally", true).toBool();
|
||||
tallyType = settings->value("interface/tallyType", 0).toInt();
|
||||
|
||||
showShortcuts = settings->value("menu/showshortcuts", true).toBool();
|
||||
showGameSelectorFilterToolbar = settings->value("menu/showgameselectorfiltertoolbar", true).toBool();
|
||||
|
|
@ -1396,10 +1396,11 @@ void SettingsCache::setShowTotalSelectionCount(QT_STATE_CHANGED_T _showTotalSele
|
|||
settings->setValue("interface/showpersistentselectioncount", showTotalSelectionCount);
|
||||
}
|
||||
|
||||
void SettingsCache::setShowSubtypeSelectionTally(QT_STATE_CHANGED_T _showSubtypeSelectionTally)
|
||||
void SettingsCache::setTallyType(TallyType value)
|
||||
{
|
||||
showSubtypeSelectionTally = static_cast<bool>(_showSubtypeSelectionTally);
|
||||
settings->setValue("interface/showsubtypeselectiontally", showSubtypeSelectionTally);
|
||||
tallyType = static_cast<int>(value);
|
||||
settings->setValue("interface/tallyType", tallyType);
|
||||
emit tallyTypeChanged(value);
|
||||
}
|
||||
|
||||
void SettingsCache::loadPaths()
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef SETTINGSCACHE_H
|
||||
#define SETTINGSCACHE_H
|
||||
|
||||
#include "../../game_graphics/tally/tally.h"
|
||||
#include "../../interface/card_picture_loader/card_picture_loader_cache_method.h"
|
||||
#include "../../interface/card_picture_loader/card_picture_loader_local_schemes.h"
|
||||
#include "shortcuts_settings.h"
|
||||
|
|
@ -197,6 +198,7 @@ signals:
|
|||
void useTearOffMenusChanged(bool state);
|
||||
void roundCardCornersChanged(bool roundCardCorners);
|
||||
void keepGameChatFocusChanged(bool value);
|
||||
void tallyTypeChanged(TallyType type);
|
||||
|
||||
private:
|
||||
QSettings *settings;
|
||||
|
|
@ -355,7 +357,7 @@ private:
|
|||
bool showStatusBar;
|
||||
bool showDragSelectionCount;
|
||||
bool showTotalSelectionCount;
|
||||
bool showSubtypeSelectionTally;
|
||||
int tallyType;
|
||||
|
||||
public:
|
||||
SettingsCache();
|
||||
|
|
@ -479,9 +481,9 @@ public:
|
|||
{
|
||||
return showTotalSelectionCount;
|
||||
}
|
||||
[[nodiscard]] bool getShowSubtypeSelectionTally() const
|
||||
[[nodiscard]] TallyType getTallyType() const
|
||||
{
|
||||
return showSubtypeSelectionTally;
|
||||
return static_cast<TallyType>(tallyType);
|
||||
}
|
||||
[[nodiscard]] bool getNotificationsEnabled() const
|
||||
{
|
||||
|
|
@ -1181,6 +1183,6 @@ public slots:
|
|||
void setRoundCardCorners(bool _roundCardCorners);
|
||||
void setShowDragSelectionCount(QT_STATE_CHANGED_T _showDragSelectionCount);
|
||||
void setShowTotalSelectionCount(QT_STATE_CHANGED_T _showTotalSelectionCount);
|
||||
void setShowSubtypeSelectionTally(QT_STATE_CHANGED_T _showSubtypeSelectionTally);
|
||||
void setTallyType(TallyType value);
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ GameView::GameView(GameScene *scene, QWidget *parent) : QGraphicsView(scene, par
|
|||
connect(scene, &GameScene::sigResizeRubberBand, this, &GameView::resizeRubberBand);
|
||||
connect(scene, &GameScene::sigStopRubberBand, this, &GameView::stopRubberBand);
|
||||
connect(scene, &QGraphicsScene::selectionChanged, this, [this]() { updateTotalSelectionCount(); });
|
||||
connect(&SettingsCache::instance(), &SettingsCache::tallyTypeChanged, this,
|
||||
[this] { updateTotalSelectionCount(); });
|
||||
|
||||
setFocusDisabled(SettingsCache::instance().getKeepGameChatFocus());
|
||||
connect(&SettingsCache::instance(), &SettingsCache::keepGameChatFocusChanged, this, &GameView::setFocusDisabled);
|
||||
|
|
@ -246,8 +248,7 @@ void GameView::updateTotalSelectionCount(const QSize &viewSize)
|
|||
totalCountLabel->show();
|
||||
}
|
||||
|
||||
TallyType tallyType =
|
||||
SettingsCache::instance().getShowSubtypeSelectionTally() ? TallyType::Subtypes : TallyType::None;
|
||||
TallyType tallyType = SettingsCache::instance().getTallyType();
|
||||
|
||||
GameScene *gameScene = static_cast<GameScene *>(scene());
|
||||
QList<TallyRow> entries = Tally::compute(gameScene->selectedCards(), tallyType);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_
|
|||
utilityMenu = nullptr;
|
||||
}
|
||||
|
||||
tallyMenu = addManagedMenu<TallyMenu>();
|
||||
|
||||
if (player->getLogic()->getPlayerInfo()->getLocal()) {
|
||||
sayMenu = addManagedMenu<SayMenu>(player);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "rfg_menu.h"
|
||||
#include "say_menu.h"
|
||||
#include "sideboard_menu.h"
|
||||
#include "tally_menu.h"
|
||||
#include "utility_menu.h"
|
||||
|
||||
#include <QList>
|
||||
|
|
@ -87,6 +88,7 @@ private:
|
|||
GraveyardMenu *graveMenu;
|
||||
RfgMenu *rfgMenu;
|
||||
UtilityMenu *utilityMenu;
|
||||
TallyMenu *tallyMenu;
|
||||
SayMenu *sayMenu;
|
||||
CustomZoneMenu *customZonesMenu;
|
||||
|
||||
|
|
|
|||
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"));
|
||||
}
|
||||
28
cockatrice/src/game_graphics/player/menu/tally_menu.h
Normal file
28
cockatrice/src/game_graphics/player/menu/tally_menu.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef COCKATRICE_TALLY_MENU_H
|
||||
#define COCKATRICE_TALLY_MENU_H
|
||||
|
||||
#include "../../../interface/widgets/menus/tearoff_menu.h"
|
||||
#include "../../tally/tally.h"
|
||||
#include "abstract_player_component.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
class TallyMenu : public TearOffMenu, public AbstractPlayerComponent
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TallyMenu();
|
||||
|
||||
void setShortcutsActive() override;
|
||||
void setShortcutsInactive() override;
|
||||
void retranslateUi() override;
|
||||
|
||||
private:
|
||||
QAction *aTallyNone = nullptr;
|
||||
QAction *aTallySubtype = nullptr;
|
||||
|
||||
QAction *createTallyAction(TallyType tallyType);
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_TALLY_MENU_H
|
||||
|
|
@ -68,10 +68,6 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
connect(&showTotalSelectionCountCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
|
||||
&SettingsCache::setShowTotalSelectionCount);
|
||||
|
||||
showSubtypeSelectionTallyCheckBox.setChecked(SettingsCache::instance().getShowSubtypeSelectionTally());
|
||||
connect(&showSubtypeSelectionTallyCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
|
||||
&SettingsCache::setShowSubtypeSelectionTally);
|
||||
|
||||
useTearOffMenusCheckBox.setChecked(SettingsCache::instance().getUseTearOffMenus());
|
||||
connect(&useTearOffMenusCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
|
||||
[](const QT_STATE_CHANGED_T state) { SettingsCache::instance().setUseTearOffMenus(state == Qt::Checked); });
|
||||
|
|
@ -90,9 +86,8 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
generalGrid->addWidget(&annotateTokensCheckBox, 6, 0);
|
||||
generalGrid->addWidget(&showDragSelectionCountCheckBox, 7, 0);
|
||||
generalGrid->addWidget(&showTotalSelectionCountCheckBox, 8, 0);
|
||||
generalGrid->addWidget(&showSubtypeSelectionTallyCheckBox, 9, 0);
|
||||
generalGrid->addWidget(&useTearOffMenusCheckBox, 10, 0);
|
||||
generalGrid->addWidget(&keepGameChatFocusCheckBox, 11, 0);
|
||||
generalGrid->addWidget(&useTearOffMenusCheckBox, 9, 0);
|
||||
generalGrid->addWidget(&keepGameChatFocusCheckBox, 10, 0);
|
||||
|
||||
generalGroupBox = new QGroupBox;
|
||||
generalGroupBox->setLayout(generalGrid);
|
||||
|
|
@ -216,7 +211,6 @@ void UserInterfaceSettingsPage::retranslateUi()
|
|||
annotateTokensCheckBox.setText(tr("Annotate card text on tokens"));
|
||||
showDragSelectionCountCheckBox.setText(tr("Show selection count during drag selection"));
|
||||
showTotalSelectionCountCheckBox.setText(tr("Show total selection count"));
|
||||
showSubtypeSelectionTallyCheckBox.setText(tr("Show subtype breakdown in selection tally"));
|
||||
useTearOffMenusCheckBox.setText(tr("Use tear-off menus, allowing right click menus to persist on screen"));
|
||||
keepGameChatFocusCheckBox.setText(
|
||||
tr("Keep game chat focused when clicking in game (Note: disables card view search bar)"));
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ private:
|
|||
QCheckBox annotateTokensCheckBox;
|
||||
QCheckBox showDragSelectionCountCheckBox;
|
||||
QCheckBox showTotalSelectionCountCheckBox;
|
||||
QCheckBox showSubtypeSelectionTallyCheckBox;
|
||||
QCheckBox useTearOffMenusCheckBox;
|
||||
QCheckBox keepGameChatFocusCheckBox;
|
||||
QCheckBox tapAnimationCheckBox;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue