mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Merge b7b7a385ea into b1fe4c85d3
This commit is contained in:
commit
b473e0e943
4 changed files with 55 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../../../interface/widgets/tabs/tab_game.h"
|
||||
#include "../../board/card_item.h"
|
||||
#include "../../game_meta_info.h"
|
||||
#include "../../zones/hand_zone.h"
|
||||
#include "../../zones/pile_zone.h"
|
||||
#include "../../zones/table_zone.h"
|
||||
|
|
@ -48,6 +49,13 @@ PlayerMenu::PlayerMenu(Player *_player) : QObject(_player), player(_player)
|
|||
|
||||
connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
|
||||
&PlayerMenu::refreshShortcuts);
|
||||
|
||||
// Monitor game state to re-evaluate shortcuts when game starts/stops
|
||||
if (player->getGame() && player->getGame()->getGameMetaInfo()) {
|
||||
connect(player->getGame()->getGameMetaInfo(), &GameMetaInfo::startedChanged, this,
|
||||
&PlayerMenu::onGameStartedChanged);
|
||||
}
|
||||
|
||||
refreshShortcuts();
|
||||
|
||||
retranslateUi();
|
||||
|
|
@ -117,10 +125,40 @@ void PlayerMenu::refreshShortcuts()
|
|||
}
|
||||
}
|
||||
|
||||
void PlayerMenu::onGameStartedChanged(bool started)
|
||||
{
|
||||
Q_UNUSED(started);
|
||||
// Re-evaluate shortcuts when game state transitions
|
||||
if (shortcutsActive) {
|
||||
setShortcutsActive();
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerMenu::setShortcutsActive()
|
||||
{
|
||||
shortcutsActive = true;
|
||||
|
||||
// Null-safety checks
|
||||
if (!player->getGame() || !player->getGame()->getGameMetaInfo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player->getGame()->getGameMetaInfo()->started()) {
|
||||
for (auto *component : managedComponents) {
|
||||
component->setShortcutsInactive();
|
||||
}
|
||||
|
||||
QMapIterator<int, AbstractCounter *> counterIterator(player->getCounters());
|
||||
while (counterIterator.hasNext()) {
|
||||
counterIterator.next().value()->setShortcutsInactive();
|
||||
}
|
||||
|
||||
if (utilityMenu) {
|
||||
utilityMenu->setLobbyShortcutsActive();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto *component : managedComponents) {
|
||||
component->setShortcutsActive();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,10 +69,15 @@ public:
|
|||
}
|
||||
|
||||
/// Delegates to all managedComponents, plus counters separately.
|
||||
/// Stop full activation until game has started; only roll-die shortcut is active in lobby.
|
||||
void setShortcutsActive();
|
||||
/// Delegates to all managedComponents, plus counters separately.
|
||||
void setShortcutsInactive();
|
||||
|
||||
private slots:
|
||||
/// Re-evaluate shortcut state when game started/stopped state changes.
|
||||
void onGameStartedChanged(bool started);
|
||||
|
||||
private:
|
||||
Player *player;
|
||||
TearOffMenu *playerMenu;
|
||||
|
|
|
|||
|
|
@ -117,4 +117,14 @@ void UtilityMenu::setShortcutsInactive()
|
|||
aCreateAnotherToken->setShortcut(QKeySequence());
|
||||
aIncrementAllCardCounters->setShortcut(QKeySequence());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UtilityMenu::setLobbyShortcutsActive()
|
||||
{
|
||||
if (!player->getPlayerInfo()->getLocalOrJudge()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
|
||||
aRollDie->setShortcuts(shortcuts.getShortcut("Player/aRollDie"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public slots:
|
|||
|
||||
public:
|
||||
explicit UtilityMenu(Player *player, QMenu *playerMenu);
|
||||
void setLobbyShortcutsActive();
|
||||
|
||||
[[nodiscard]] bool createAnotherTokenActionExists() const
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue