mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-29 10:03:55 -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.
71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
/**
|
|
* @file hand_menu.h
|
|
* @ingroup GameMenusZones
|
|
* @brief TODO: Document this.
|
|
*/
|
|
|
|
#ifndef COCKATRICE_HAND_MENU_H
|
|
#define COCKATRICE_HAND_MENU_H
|
|
|
|
#include "../../../interface/widgets/menus/tearoff_menu.h"
|
|
#include "abstract_player_component.h"
|
|
|
|
#include <QAction>
|
|
#include <QMenu>
|
|
|
|
class Player;
|
|
class PlayerActions;
|
|
|
|
class HandMenu : public TearOffMenu, public AbstractPlayerComponent
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
HandMenu(Player *player, PlayerActions *actions, QWidget *parent = nullptr);
|
|
|
|
QMenu *revealHandMenu() const
|
|
{
|
|
return mRevealHand;
|
|
}
|
|
QMenu *revealRandomHandCardMenu() const
|
|
{
|
|
return mRevealRandomHandCard;
|
|
}
|
|
|
|
void retranslateUi() override;
|
|
void setShortcutsActive() override;
|
|
void setShortcutsInactive() override;
|
|
|
|
private slots:
|
|
void populateRevealHandMenuWithActivePlayers();
|
|
void populateRevealRandomHandCardMenuWithActivePlayers();
|
|
void onRevealHandTriggered();
|
|
void onRevealRandomHandCardTriggered();
|
|
|
|
private:
|
|
Player *player;
|
|
|
|
QAction *aViewHand = nullptr;
|
|
QAction *aMulligan = nullptr;
|
|
QAction *aMulliganSame = nullptr;
|
|
QAction *aMulliganMinusOne = nullptr;
|
|
|
|
QMenu *mSortHand = nullptr;
|
|
QAction *aSortHandByName = nullptr;
|
|
QAction *aSortHandByType = nullptr;
|
|
QAction *aSortHandByManaValue = nullptr;
|
|
|
|
QMenu *mRevealHand = nullptr;
|
|
QAction *aRevealHandToAll = nullptr;
|
|
|
|
QMenu *mRevealRandomHandCard = nullptr;
|
|
QAction *aRevealRandomHandCardToAll = nullptr;
|
|
|
|
QMenu *mMoveHandMenu = nullptr;
|
|
QAction *aMoveHandToTopLibrary = nullptr;
|
|
QAction *aMoveHandToBottomLibrary = nullptr;
|
|
QAction *aMoveHandToGrave = nullptr;
|
|
QAction *aMoveHandToRfg = nullptr;
|
|
};
|
|
|
|
#endif // COCKATRICE_HAND_MENU_H
|