mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-01-16 23:12:05 -08:00
In-game message macros available immediately in active games (#5113)
* In-game message macros available immediately in active games * fix formatting * init sayMenu actions with sayMenu as parent
This commit is contained in:
@@ -1001,6 +1001,7 @@ void MessagesSettingsPage::storeSettings()
|
||||
SettingsCache::instance().messages().setCount(messageList->count());
|
||||
for (int i = 0; i < messageList->count(); i++)
|
||||
SettingsCache::instance().messages().setMessageAt(i, messageList->item(i)->text());
|
||||
emit SettingsCache::instance().messages().messageMacrosChanged();
|
||||
}
|
||||
|
||||
void MessagesSettingsPage::actAdd()
|
||||
|
||||
@@ -419,6 +419,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
|
||||
|
||||
if (local) {
|
||||
sayMenu = playerMenu->addMenu(QString());
|
||||
connect(&SettingsCache::instance().messages(), SIGNAL(messageMacrosChanged()), this, SLOT(initSayMenu()));
|
||||
initSayMenu();
|
||||
}
|
||||
|
||||
@@ -1036,7 +1037,7 @@ void Player::initSayMenu()
|
||||
sayMenu->setEnabled(count > 0);
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto *newAction = new QAction(SettingsCache::instance().messages().getMessageAt(i), this);
|
||||
auto *newAction = new QAction(SettingsCache::instance().messages().getMessageAt(i), sayMenu);
|
||||
if (i < 10) {
|
||||
newAction->setShortcut(QKeySequence("Ctrl+" + QString::number((i + 1) % 10)));
|
||||
}
|
||||
|
||||
@@ -224,6 +224,8 @@ private slots:
|
||||
void actReveal(QAction *action);
|
||||
void refreshShortcuts();
|
||||
|
||||
void initSayMenu();
|
||||
|
||||
private:
|
||||
TabGame *game;
|
||||
QMenu *sbMenu, *countersMenu, *sayMenu, *createPredefinedTokenMenu, *mRevealLibrary, *mLendLibrary, *mRevealTopCard,
|
||||
@@ -310,7 +312,6 @@ private:
|
||||
QMap<int, ArrowItem *> arrows;
|
||||
void rearrangeCounters();
|
||||
|
||||
void initSayMenu();
|
||||
void initContextualPlayersMenu(QMenu *menu);
|
||||
|
||||
// void eventConnectionStateChanged(const Event_ConnectionStateChanged &event);
|
||||
|
||||
@@ -15,6 +15,7 @@ public:
|
||||
void setCount(int count);
|
||||
void setMessageAt(int index, QString message);
|
||||
signals:
|
||||
void messageMacrosChanged();
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user