mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-05 13:03:55 -07:00
Add menu option and shortcut to auto increment counters (#6055)
* Add method to increment all counters on cards on table * add keyboard shortcut * register action for menu * register action for menu * Change menu text * Move to Counters submenu * Change function name * Change menu, update function to handle selected vs non selected cards * Use getShortcut instead of getSingleShortcut Co-authored-by: RickyRister <42636155+RickyRister@users.noreply.github.com> --------- Co-authored-by: Paul Carroll <paul.x.carroll@questdiagnostics.com> Co-authored-by: RickyRister <42636155+RickyRister@users.noreply.github.com> Co-authored-by: Zach H <zahalpern+github@gmail.com>
This commit is contained in:
parent
04be0fe634
commit
d6243a2dd2
3 changed files with 58 additions and 1 deletions
|
|
@ -417,6 +417,9 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
|
||||||
connect(aCreateAnotherToken, &QAction::triggered, this, &Player::actCreateAnotherToken);
|
connect(aCreateAnotherToken, &QAction::triggered, this, &Player::actCreateAnotherToken);
|
||||||
aCreateAnotherToken->setEnabled(false);
|
aCreateAnotherToken->setEnabled(false);
|
||||||
|
|
||||||
|
aIncrementAllCardCounters = new QAction(this);
|
||||||
|
connect(aIncrementAllCardCounters, &QAction::triggered, this, &Player::incrementAllCardCounters);
|
||||||
|
|
||||||
createPredefinedTokenMenu = new QMenu(QString());
|
createPredefinedTokenMenu = new QMenu(QString());
|
||||||
createPredefinedTokenMenu->setEnabled(false);
|
createPredefinedTokenMenu->setEnabled(false);
|
||||||
|
|
||||||
|
|
@ -424,6 +427,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
|
||||||
|
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
countersMenu = playerMenu->addMenu(QString());
|
countersMenu = playerMenu->addMenu(QString());
|
||||||
|
playerMenu->addAction(aIncrementAllCardCounters);
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
playerMenu->addAction(aUntapAll);
|
playerMenu->addAction(aUntapAll);
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
|
|
@ -910,6 +914,7 @@ void Player::retranslateUi()
|
||||||
aSetCounter[i]->setText(tr("&Set counters (%1)...").arg(cardCounterSettings.displayName(i)));
|
aSetCounter[i]->setText(tr("&Set counters (%1)...").arg(cardCounterSettings.displayName(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aIncrementAllCardCounters->setText(tr("Increment all card counters"));
|
||||||
aMoveToTopLibrary->setText(tr("&Top of library in random order"));
|
aMoveToTopLibrary->setText(tr("&Top of library in random order"));
|
||||||
aMoveToXfromTopOfLibrary->setText(tr("X cards from the top of library..."));
|
aMoveToXfromTopOfLibrary->setText(tr("X cards from the top of library..."));
|
||||||
aMoveToBottomLibrary->setText(tr("&Bottom of library in random order"));
|
aMoveToBottomLibrary->setText(tr("&Bottom of library in random order"));
|
||||||
|
|
@ -971,6 +976,7 @@ void Player::setShortcutsActive()
|
||||||
counterIterator.next().value()->setShortcutsActive();
|
counterIterator.next().value()->setShortcutsActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aIncrementAllCardCounters->setShortcuts(shortcuts.getShortcut("Player/aIncrementAllCardCounters"));
|
||||||
aViewSideboard->setShortcuts(shortcuts.getShortcut("Player/aViewSideboard"));
|
aViewSideboard->setShortcuts(shortcuts.getShortcut("Player/aViewSideboard"));
|
||||||
aViewLibrary->setShortcuts(shortcuts.getShortcut("Player/aViewLibrary"));
|
aViewLibrary->setShortcuts(shortcuts.getShortcut("Player/aViewLibrary"));
|
||||||
aViewHand->setShortcuts(shortcuts.getShortcut("Player/aViewHand"));
|
aViewHand->setShortcuts(shortcuts.getShortcut("Player/aViewHand"));
|
||||||
|
|
@ -1057,6 +1063,7 @@ void Player::setShortcutsInactive()
|
||||||
aMoveBottomCardsToGraveyard->setShortcut(QKeySequence());
|
aMoveBottomCardsToGraveyard->setShortcut(QKeySequence());
|
||||||
aMoveBottomCardToExile->setShortcut(QKeySequence());
|
aMoveBottomCardToExile->setShortcut(QKeySequence());
|
||||||
aMoveBottomCardsToExile->setShortcut(QKeySequence());
|
aMoveBottomCardsToExile->setShortcut(QKeySequence());
|
||||||
|
aIncrementAllCardCounters->setShortcut(QKeySequence());
|
||||||
|
|
||||||
QMapIterator<int, AbstractCounter *> counterIterator(counters);
|
QMapIterator<int, AbstractCounter *> counterIterator(counters);
|
||||||
while (counterIterator.hasNext()) {
|
while (counterIterator.hasNext()) {
|
||||||
|
|
@ -3011,6 +3018,51 @@ void Player::clearCounters()
|
||||||
counters.clear();
|
counters.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::incrementAllCardCounters()
|
||||||
|
{
|
||||||
|
QList<CardItem *> cardsToUpdate;
|
||||||
|
|
||||||
|
auto selectedItems = scene()->selectedItems();
|
||||||
|
if (!selectedItems.isEmpty()) {
|
||||||
|
// If cards are selected, only update those
|
||||||
|
for (const auto &item : selectedItems) {
|
||||||
|
auto *card = static_cast<CardItem *>(item);
|
||||||
|
cardsToUpdate.append(card);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If no cards selected, update all cards on table
|
||||||
|
const CardList &tableCards = table->getCards();
|
||||||
|
cardsToUpdate = tableCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<const ::google::protobuf::Message *> commandList;
|
||||||
|
|
||||||
|
for (const auto *card : cardsToUpdate) {
|
||||||
|
const auto &cardCounters = card->getCounters();
|
||||||
|
|
||||||
|
QMapIterator<int, int> counterIterator(cardCounters);
|
||||||
|
while (counterIterator.hasNext()) {
|
||||||
|
counterIterator.next();
|
||||||
|
int counterId = counterIterator.key();
|
||||||
|
int currentValue = counterIterator.value();
|
||||||
|
if (currentValue >= MAX_COUNTERS_ON_CARD) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto cmd = std::make_unique<Command_SetCardCounter>();
|
||||||
|
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||||
|
cmd->set_card_id(card->getId());
|
||||||
|
cmd->set_counter_id(counterId);
|
||||||
|
cmd->set_counter_value(currentValue + 1);
|
||||||
|
commandList.append(cmd.release());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!commandList.isEmpty()) {
|
||||||
|
sendGameCommand(prepareGameCommand(commandList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ArrowItem *Player::addArrow(const ServerInfo_Arrow &arrow)
|
ArrowItem *Player::addArrow(const ServerInfo_Arrow &arrow)
|
||||||
{
|
{
|
||||||
const QMap<int, Player *> &playerList = game->getPlayers();
|
const QMap<int, Player *> &playerList = game->getPlayers();
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,7 @@ private:
|
||||||
QAction *aPlay, *aPlayFacedown, *aHide, *aTap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aResetPT,
|
QAction *aPlay, *aPlayFacedown, *aHide, *aTap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aResetPT,
|
||||||
*aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aFlowP, *aFlowT, *aSetAnnotation, *aFlip, *aPeek, *aClone,
|
*aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aFlowP, *aFlowT, *aSetAnnotation, *aFlip, *aPeek, *aClone,
|
||||||
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile,
|
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile,
|
||||||
*aMoveToXfromTopOfLibrary, *aSelectAll, *aSelectRow, *aSelectColumn;
|
*aMoveToXfromTopOfLibrary, *aSelectAll, *aSelectRow, *aSelectColumn, *aIncrementAllCardCounters;
|
||||||
|
|
||||||
bool movingCardsUntil;
|
bool movingCardsUntil;
|
||||||
QTimer *moveTopCardTimer;
|
QTimer *moveTopCardTimer;
|
||||||
|
|
@ -420,6 +420,7 @@ public:
|
||||||
AbstractCounter *addCounter(int counterId, const QString &name, QColor color, int radius, int value);
|
AbstractCounter *addCounter(int counterId, const QString &name, QColor color, int radius, int value);
|
||||||
void delCounter(int counterId);
|
void delCounter(int counterId);
|
||||||
void clearCounters();
|
void clearCounters();
|
||||||
|
void incrementAllCardCounters();
|
||||||
|
|
||||||
ArrowItem *addArrow(const ServerInfo_Arrow &arrow);
|
ArrowItem *addArrow(const ServerInfo_Arrow &arrow);
|
||||||
ArrowItem *addArrow(int arrowId, CardItem *startCard, ArrowTarget *targetItem, const QColor &color);
|
ArrowItem *addArrow(int arrowId, CardItem *startCard, ArrowTarget *targetItem, const QColor &color);
|
||||||
|
|
|
||||||
|
|
@ -413,6 +413,10 @@ private:
|
||||||
{"Player/aSetCounter_storm", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Set Other Counters..."),
|
{"Player/aSetCounter_storm", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Set Other Counters..."),
|
||||||
parseSequenceString("Ctrl+\\"),
|
parseSequenceString("Ctrl+\\"),
|
||||||
ShortcutGroup::Player_Counters)},
|
ShortcutGroup::Player_Counters)},
|
||||||
|
{"Player/aIncrementAllCardCounters",
|
||||||
|
ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Increment all card counters"),
|
||||||
|
parseSequenceString("Ctrl+Shift+A"),
|
||||||
|
ShortcutGroup::Playing_Area)},
|
||||||
{"Player/aIncP", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Add Power (+1/+0)"),
|
{"Player/aIncP", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Add Power (+1/+0)"),
|
||||||
parseSequenceString("Ctrl++;Ctrl+="),
|
parseSequenceString("Ctrl++;Ctrl+="),
|
||||||
ShortcutGroup::Power_Toughness)},
|
ShortcutGroup::Power_Toughness)},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue