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:
BruebachL 2025-09-12 19:52:05 +02:00 committed by GitHub
parent ff7ce39841
commit fb23cc8c7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 2242 additions and 1536 deletions

View file

@ -0,0 +1,98 @@
#ifndef COCKATRICE_LIBRARY_MENU_H
#define COCKATRICE_LIBRARY_MENU_H
#include "../../../client/tearoff_menu.h"
#include <QAction>
#include <QMenu>
class Player;
class PlayerActions;
class LibraryMenu : public TearOffMenu
{
Q_OBJECT
public slots:
void enableOpenInDeckEditorAction() const;
void resetTopCardMenuActions();
public:
LibraryMenu(Player *player, QWidget *parent = nullptr);
void createDrawActions();
void createShuffleActions();
void createMoveActions();
void createViewActions();
void retranslateUi();
void setShortcutsActive();
void setShortcutsInactive();
[[nodiscard]] bool isAlwaysRevealTopCardChecked() const
{
return aAlwaysRevealTopCard->isChecked();
}
[[nodiscard]] bool isAlwaysLookAtTopCardChecked() const
{
return aAlwaysLookAtTopCard->isChecked();
}
// expose useful actions/menus if PlayerMenu needs them
QMenu *revealLibrary() const
{
return mRevealLibrary;
}
QMenu *lendLibraryMenu() const
{
return mLendLibrary;
}
QMenu *revealTopCardMenu() const
{
return mRevealTopCard;
}
QMenu *topLibraryMenu = nullptr;
QMenu *bottomLibraryMenu = nullptr;
// Expose submenus that PlayerMenu tracks in its lists
QMenu *mRevealLibrary = nullptr;
QMenu *mLendLibrary = nullptr;
QMenu *mRevealTopCard = nullptr;
QAction *aDrawCard = nullptr;
QAction *aDrawCards = nullptr;
QAction *aUndoDraw = nullptr;
QAction *aShuffle = nullptr;
QAction *aViewLibrary = nullptr;
QAction *aViewTopCards = nullptr;
QAction *aViewBottomCards = nullptr;
QAction *aAlwaysRevealTopCard = nullptr;
QAction *aAlwaysLookAtTopCard = nullptr;
QAction *aOpenDeckInDeckEditor = nullptr;
QAction *aMoveTopToPlay = nullptr;
QAction *aMoveTopToPlayFaceDown = nullptr;
QAction *aMoveTopCardToBottom = nullptr;
QAction *aMoveTopCardToGraveyard = nullptr;
QAction *aMoveTopCardToExile = nullptr;
QAction *aMoveTopCardsToGraveyard = nullptr;
QAction *aMoveTopCardsToExile = nullptr;
QAction *aMoveTopCardsUntil = nullptr;
QAction *aShuffleTopCards = nullptr;
QAction *aDrawBottomCard = nullptr;
QAction *aDrawBottomCards = nullptr;
QAction *aMoveBottomToPlay = nullptr;
QAction *aMoveBottomToPlayFaceDown = nullptr;
QAction *aMoveBottomCardToTop = nullptr;
QAction *aMoveBottomCardToGraveyard = nullptr;
QAction *aMoveBottomCardToExile = nullptr;
QAction *aMoveBottomCardsToGraveyard = nullptr;
QAction *aMoveBottomCardsToExile = nullptr;
QAction *aShuffleBottomCards = nullptr;
private:
Player *player;
};
#endif // COCKATRICE_LIBRARY_MENU_H