mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 02:53:56 -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
93
cockatrice/src/game/player/menu/player_menu.h
Normal file
93
cockatrice/src/game/player/menu/player_menu.h
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
#ifndef COCKATRICE_PLAYER_MENU_H
|
||||
#define COCKATRICE_PLAYER_MENU_H
|
||||
|
||||
#include "../../../client/tearoff_menu.h"
|
||||
#include "../player.h"
|
||||
#include "custom_zone_menu.h"
|
||||
#include "grave_menu.h"
|
||||
#include "hand_menu.h"
|
||||
#include "library_menu.h"
|
||||
#include "rfg_menu.h"
|
||||
#include "say_menu.h"
|
||||
#include "sideboard_menu.h"
|
||||
#include "utility_menu.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QObject>
|
||||
|
||||
class CardItem;
|
||||
class PlayerMenu : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void cardMenuUpdated(QMenu *cardMenu);
|
||||
|
||||
public slots:
|
||||
void setMenusForGraphicItems();
|
||||
|
||||
private slots:
|
||||
void addPlayer(Player *playerToAdd);
|
||||
void removePlayer(Player *playerToRemove);
|
||||
void playerListActionTriggered();
|
||||
void onNewPlayerListActionCreated(QAction *action);
|
||||
void refreshShortcuts();
|
||||
|
||||
public:
|
||||
PlayerMenu(Player *player);
|
||||
void retranslateUi();
|
||||
|
||||
void addPlayerToList(QMenu *playerList, Player *playerToAdd);
|
||||
static void removePlayerFromList(QMenu *playerList, Player *player);
|
||||
|
||||
QMenu *updateCardMenu(const CardItem *card);
|
||||
|
||||
[[nodiscard]] QMenu *getPlayerMenu() const
|
||||
{
|
||||
return playerMenu;
|
||||
}
|
||||
|
||||
[[nodiscard]] QMenu *getCountersMenu()
|
||||
{
|
||||
return countersMenu;
|
||||
}
|
||||
|
||||
[[nodiscard]] LibraryMenu *getLibraryMenu() const
|
||||
{
|
||||
return libraryMenu;
|
||||
}
|
||||
|
||||
[[nodiscard]] UtilityMenu *getUtilityMenu() const
|
||||
{
|
||||
return utilityMenu;
|
||||
}
|
||||
|
||||
bool getShortcutsActive() const
|
||||
{
|
||||
return shortcutsActive;
|
||||
}
|
||||
|
||||
void setShortcutsActive();
|
||||
void setShortcutsInactive();
|
||||
|
||||
private:
|
||||
Player *player;
|
||||
TearOffMenu *playerMenu;
|
||||
QMenu *countersMenu;
|
||||
HandMenu *handMenu;
|
||||
LibraryMenu *libraryMenu;
|
||||
SideboardMenu *sideboardMenu;
|
||||
GraveyardMenu *graveMenu;
|
||||
RfgMenu *rfgMenu;
|
||||
UtilityMenu *utilityMenu;
|
||||
SayMenu *sayMenu;
|
||||
CustomZoneMenu *customZonesMenu;
|
||||
QList<QMenu *> playerLists;
|
||||
QList<QAction *> allPlayersActions;
|
||||
|
||||
bool shortcutsActive;
|
||||
|
||||
void initSayMenu();
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_PLAYER_MENU_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue