mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 16:44:48 -07:00
Refactor player menus into helper classes (#6121)
* Refactor player menus into helper classes. Took 2 hours 6 minutes Took 11 minutes * Lint. Took 6 minutes Took 22 seconds * Refactor card and move menu. Took 1 hour 6 minutes Took 36 seconds Took 52 seconds * Set active shortcuts, move player info stuff to card menu. Took 25 minutes Took 18 seconds * Refactor say and utility menu. Took 54 minutes Took 2 minutes Took 5 minutes Took 11 minutes * Rename folder. Took 24 minutes Took 6 minutes * Refactor sideboard menu. Took 26 minutes * Remove unused variable in constructor. Took 42 seconds * Lint. Took 11 minutes * Nullptr check Took 8 minutes * Use localOrJudge check Took 6 minutes * Fix the build. Took 7 minutes Took 35 seconds * PlayerList things. Took 16 minutes * Retranslate and set shortcuts for everything. Took 10 minutes * Correctly nullptr out sayMenu if not local Took 3 minutes * Don't check playerInfo in sbMenu shortcutsActive Took 3 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
ff7ce39841
commit
fb23cc8c7a
30 changed files with 2242 additions and 1536 deletions
28
cockatrice/src/game/player/menu/say_menu.cpp
Normal file
28
cockatrice/src/game/player/menu/say_menu.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include "say_menu.h"
|
||||
|
||||
#include "../../../settings/cache_settings.h"
|
||||
#include "../player.h"
|
||||
#include "../player_actions.h"
|
||||
|
||||
SayMenu::SayMenu(Player *_player) : player(_player)
|
||||
{
|
||||
connect(&SettingsCache::instance().messages(), &MessageSettings::messageMacrosChanged, this, &SayMenu::initSayMenu);
|
||||
initSayMenu();
|
||||
}
|
||||
|
||||
void SayMenu::initSayMenu()
|
||||
{
|
||||
clear();
|
||||
|
||||
int count = SettingsCache::instance().messages().getCount();
|
||||
setEnabled(count > 0);
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto *newAction = new QAction(SettingsCache::instance().messages().getMessageAt(i), this);
|
||||
if (i < 10) {
|
||||
newAction->setShortcut(QKeySequence("Ctrl+" + QString::number((i + 1) % 10)));
|
||||
}
|
||||
connect(newAction, &QAction::triggered, player->getPlayerActions(), &PlayerActions::actSayMessage);
|
||||
addAction(newAction);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue