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