mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-25 08:03:54 -07:00
Non-QObject polymorphic interface with setShortcutsActive(), setShortcutsInactive(), and retranslateUi(). Uses regular multiple inheritance to avoid diamond inheritance with Qt's MOC. All zone menus, SayMenu, and AbstractCounter implement this interface. PlayerMenu manages them via a managedComponents list with two template helpers (addManagedMenu/registerManagedComponent), replacing individual if-guarded lifecycle calls with a single polymorphic loop. SayMenu now owns its shortcut and translation lifecycle instead of having PlayerMenu manage its title and shortcuts externally. Counters are iterated via Player::getCounters() rather than managedComponents to avoid duplicating the authoritative owner's map.
117 lines
3.4 KiB
C++
117 lines
3.4 KiB
C++
/**
|
|
* @file library_menu.h
|
|
* @ingroup GameMenusZones
|
|
* @brief TODO: Document this.
|
|
*/
|
|
|
|
#ifndef COCKATRICE_LIBRARY_MENU_H
|
|
#define COCKATRICE_LIBRARY_MENU_H
|
|
|
|
#include "../../../interface/widgets/menus/tearoff_menu.h"
|
|
#include "abstract_player_component.h"
|
|
|
|
#include <QAction>
|
|
#include <QMenu>
|
|
|
|
class Player;
|
|
class PlayerActions;
|
|
|
|
class LibraryMenu : public TearOffMenu, public AbstractPlayerComponent
|
|
{
|
|
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() override;
|
|
void populateRevealLibraryMenuWithActivePlayers();
|
|
void populateLendLibraryMenuWithActivePlayers();
|
|
void populateRevealTopCardMenuWithActivePlayers();
|
|
void onRevealLibraryTriggered();
|
|
void onLendLibraryTriggered();
|
|
void onRevealTopCardTriggered();
|
|
void setShortcutsActive() override;
|
|
void setShortcutsInactive() override;
|
|
|
|
[[nodiscard]] bool isAlwaysRevealTopCardChecked() const
|
|
{
|
|
return aAlwaysRevealTopCard->isChecked();
|
|
}
|
|
|
|
[[nodiscard]] bool isAlwaysLookAtTopCardChecked() const
|
|
{
|
|
return aAlwaysLookAtTopCard->isChecked();
|
|
}
|
|
|
|
// expose useful actions/menus if PlayerMenu needs them
|
|
[[nodiscard]] QMenu *revealLibrary() const
|
|
{
|
|
return mRevealLibrary;
|
|
}
|
|
[[nodiscard]] QMenu *lendLibraryMenu() const
|
|
{
|
|
return mLendLibrary;
|
|
}
|
|
[[nodiscard]] 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 *aMoveTopCardsToGraveyardFaceDown = nullptr;
|
|
QAction *aMoveTopCardsToExile = nullptr;
|
|
QAction *aMoveTopCardsToExileFaceDown = 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 *aMoveBottomCardsToGraveyardFaceDown = nullptr;
|
|
QAction *aMoveBottomCardsToExile = nullptr;
|
|
QAction *aMoveBottomCardsToExileFaceDown = nullptr;
|
|
QAction *aShuffleBottomCards = nullptr;
|
|
|
|
int defaultNumberTopCards = 1;
|
|
|
|
private:
|
|
Player *player;
|
|
};
|
|
|
|
#endif // COCKATRICE_LIBRARY_MENU_H
|