119 lines
3.5 KiB
C++
119 lines
3.5 KiB
C++
#ifndef GAMEWIDGET_H
|
|
#define GAMEWIDGET_H
|
|
|
|
#include <QWidget>
|
|
#include <QGraphicsScene>
|
|
#include <QGraphicsView>
|
|
#include <QJsonObject>
|
|
#include <QJsonArray>
|
|
#include <QMap>
|
|
|
|
class SceneCardItem;
|
|
class CardWidget;
|
|
class CardInfoPopup;
|
|
class ChoiceOverlay;
|
|
class SettlementOverlay;
|
|
class PlayerSeatWidget;
|
|
class ElaPushButton;
|
|
class QLabel;
|
|
class QListWidget;
|
|
class QGraphicsPixmapItem;
|
|
class QGraphicsTextItem;
|
|
class ElaLineEdit;
|
|
|
|
class GameWidget : public QWidget {
|
|
Q_OBJECT
|
|
public:
|
|
explicit GameWidget(QWidget* parent = nullptr);
|
|
|
|
void onGameStart(const QJsonObject& config);
|
|
void onSnapshot(const QJsonObject& snapshot);
|
|
void resetGame();
|
|
|
|
signals:
|
|
void gameFinished();
|
|
|
|
protected:
|
|
void resizeEvent(QResizeEvent* event) override;
|
|
bool eventFilter(QObject* obj, QEvent* event) override;
|
|
void keyPressEvent(QKeyEvent* event) override;
|
|
void keyReleaseEvent(QKeyEvent* event) override;
|
|
void mousePressEvent(QMouseEvent* event) override;
|
|
void mouseMoveEvent(QMouseEvent* event) override;
|
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
|
|
|
private:
|
|
void initScene();
|
|
void initFloatingUI();
|
|
void layoutFloatingUI();
|
|
void layoutPlayerSeats();
|
|
void updateHandCards(const QJsonArray& cards);
|
|
void updateHarmonyZone(const QJsonArray& cards);
|
|
void addLog(const QString& text);
|
|
void setActionsEnabled(bool s, bool h, bool c);
|
|
|
|
void onSceneCardClicked(const QString& uid);
|
|
void onSceneCardHover(const QString& typeId);
|
|
void onSceneCardHoverOut();
|
|
void onSkill();
|
|
void onHarmony();
|
|
void onChallenge();
|
|
void onPlayerSeatClicked(const QString& playerId);
|
|
void onEffectResponse(const QJsonObject& resp);
|
|
void handleEffectState(const QJsonObject& info);
|
|
void showSettlement(const QJsonObject& data);
|
|
void showCardZoom(const QString& typeId);
|
|
void showPlayAnimation(const QString& typeId, const QString& actionName);
|
|
void animateCardToPos(SceneCardItem* card, const QPointF& target, int duration = 400);
|
|
void onSendChat();
|
|
void toggleChat();
|
|
QRect gameArea() const;
|
|
|
|
enum class Phase { Idle, SelectCard, SelectAction, SelectTarget, WaitResponse, Watching };
|
|
Phase _phase = Phase::Idle;
|
|
QString _localPlayerId;
|
|
QString _selectedCardUid;
|
|
int _harmonyTarget = 0;
|
|
|
|
QGraphicsScene* _scene = nullptr;
|
|
QGraphicsView* _view = nullptr;
|
|
QGraphicsPixmapItem* _corpseItem = nullptr;
|
|
QGraphicsTextItem* _harmonyLabel = nullptr;
|
|
|
|
QVector<SceneCardItem*> _handCards;
|
|
QVector<SceneCardItem*> _harmonyCards;
|
|
QMap<QString, PlayerSeatWidget*> _seats;
|
|
QVector<QString> _playerOrder;
|
|
|
|
QWidget* _topBar = nullptr;
|
|
QLabel* _turnLabel = nullptr;
|
|
QLabel* _targetLabel = nullptr;
|
|
|
|
QWidget* _actionBar = nullptr;
|
|
ElaPushButton* _skillBtn = nullptr;
|
|
ElaPushButton* _harmonyBtn = nullptr;
|
|
ElaPushButton* _challengeBtn = nullptr;
|
|
|
|
QWidget* _logPanel = nullptr;
|
|
QListWidget* _logList = nullptr;
|
|
|
|
QWidget* _chatPanel = nullptr;
|
|
QListWidget* _chatList = nullptr;
|
|
ElaLineEdit* _chatInput = nullptr;
|
|
ElaPushButton* _chatToggle = nullptr;
|
|
bool _chatVisible = false;
|
|
int _logWidth = 220;
|
|
bool _draggingLog = false;
|
|
|
|
CardInfoPopup* _cardInfoPopup = nullptr;
|
|
ChoiceOverlay* _choiceOverlay = nullptr;
|
|
SettlementOverlay* _settlementOverlay = nullptr;
|
|
QWidget* _zoomOverlay = nullptr;
|
|
CardWidget* _zoomCard = nullptr;
|
|
QWidget* _playAnimWidget = nullptr;
|
|
CardWidget* _playAnimCard = nullptr;
|
|
QLabel* _playAnimLabel = nullptr;
|
|
};
|
|
|
|
#endif
|