mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-05 13:03:55 -07:00
[Game][Player] Pull out graphics_items out of player_logic
Took 25 seconds Took 9 minutes
This commit is contained in:
parent
cbfd286908
commit
7070269a86
8 changed files with 15 additions and 22 deletions
|
|
@ -3,7 +3,7 @@
|
|||
#include "../interface/widgets/tabs/tab_game.h"
|
||||
#include "player/player_logic.h"
|
||||
|
||||
AbstractGame::AbstractGame(TabGame *_tab) : QObject(_tab), tab(_tab)
|
||||
AbstractGame::AbstractGame(QObject *_parent) : QObject(_parent)
|
||||
{
|
||||
gameMetaInfo = new GameMetaInfo(this);
|
||||
gameEventHandler = new GameEventHandler(this);
|
||||
|
|
|
|||
|
|
@ -16,26 +16,19 @@
|
|||
#include <libcockatrice/protocol/pb/game_replay.pb.h>
|
||||
|
||||
class CardItem;
|
||||
class TabGame;
|
||||
class AbstractGame : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AbstractGame(TabGame *tab);
|
||||
explicit AbstractGame(QObject *parent);
|
||||
|
||||
TabGame *tab;
|
||||
GameMetaInfo *gameMetaInfo;
|
||||
GameState *gameState;
|
||||
GameEventHandler *gameEventHandler;
|
||||
PlayerManager *playerManager;
|
||||
CardItem *activeCard;
|
||||
|
||||
TabGame *getTab() const
|
||||
{
|
||||
return tab;
|
||||
}
|
||||
|
||||
GameMetaInfo *getGameMetaInfo()
|
||||
{
|
||||
return gameMetaInfo;
|
||||
|
|
|
|||
|
|
@ -482,8 +482,7 @@ void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
(!SettingsCache::instance().getDoubleClickToPlay())) {
|
||||
handleClickedToPlay(event->modifiers().testFlag(Qt::ShiftModifier));
|
||||
}
|
||||
|
||||
if (owner != nullptr) { // cards without owner will be deleted
|
||||
if (owner != nullptr) {
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
}
|
||||
AbstractCardItem::mouseReleaseEvent(event);
|
||||
|
|
@ -539,4 +538,4 @@ QVariant CardItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
|||
}
|
||||
|
||||
return AbstractCardItem::itemChange(change, value);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
#include <libcockatrice/protocol/pb/event_game_joined.pb.h>
|
||||
|
||||
Game::Game(TabGame *_tab,
|
||||
Game::Game(QObject *_parent,
|
||||
bool isLocalGame,
|
||||
QList<AbstractClient *> &_clients,
|
||||
const Event_GameJoined &event,
|
||||
const QMap<int, QString> &_roomGameTypes)
|
||||
: AbstractGame(_tab)
|
||||
: AbstractGame(_parent)
|
||||
{
|
||||
gameMetaInfo->setFromProto(event.game_info());
|
||||
gameMetaInfo->setRoomGameTypes(_roomGameTypes);
|
||||
gameState = new GameState(this, 0, event.host_id(), tab->getTabSupervisor()->getIsLocalGame(), _clients, false,
|
||||
event.resuming(), -1, false);
|
||||
gameState = new GameState(this, 0, event.host_id(), isLocalGame, _clients, false, event.resuming(), -1, false);
|
||||
connect(gameMetaInfo, &GameMetaInfo::startedChanged, gameState, &GameState::onStartedChanged);
|
||||
playerManager = new PlayerManager(this, event.player_id(), event.judge(), event.spectator());
|
||||
gameMetaInfo->setStarted(false);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ class Game : public AbstractGame
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Game(TabGame *tab,
|
||||
Game(QObject *parent,
|
||||
bool isLocalGame,
|
||||
QList<AbstractClient *> &_clients,
|
||||
const Event_GameJoined &event,
|
||||
const QMap<int, QString> &_roomGameTypes);
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
#include "../interface/widgets/tabs/tab_game.h"
|
||||
|
||||
Replay::Replay(TabGame *_tab, GameReplay *_replay) : AbstractGame(_tab)
|
||||
Replay::Replay(QObject *_parent, GameReplay *_replay, bool isLocalGame) : AbstractGame(_parent)
|
||||
{
|
||||
gameState = new GameState(this, 0, -1, tab->getTabSupervisor()->getIsLocalGame(), {}, false, false, -1, false);
|
||||
gameState = new GameState(this, 0, -1, isLocalGame, {}, false, false, -1, false);
|
||||
connect(gameMetaInfo, &GameMetaInfo::startedChanged, gameState, &GameState::onStartedChanged);
|
||||
playerManager = new PlayerManager(this, -1, false, true);
|
||||
loadReplay(_replay);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Replay : public AbstractGame
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Replay(TabGame *_tab, GameReplay *_replay);
|
||||
explicit Replay(QObject *_parent, GameReplay *_replay, bool isLocalGame);
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_REPLAY_H
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
|
|||
: Tab(_tabSupervisor), sayLabel(nullptr), sayEdit(nullptr)
|
||||
{
|
||||
// THIS CTOR IS USED ON REPLAY
|
||||
game = new Replay(this, _replay);
|
||||
game = new Replay(this, _replay, tabSupervisor->getIsLocalGame());
|
||||
|
||||
createCardInfoDock(true);
|
||||
createPlayerListDock(true);
|
||||
|
|
@ -92,7 +92,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor,
|
|||
: Tab(_tabSupervisor), userListProxy(_tabSupervisor->getUserListManager())
|
||||
{
|
||||
// THIS CTOR IS USED ON GAMES
|
||||
game = new Game(this, _clients, event, _roomGameTypes);
|
||||
game = new Game(this, tabSupervisor->getIsLocalGame(), _clients, event, _roomGameTypes);
|
||||
|
||||
createCardInfoDock();
|
||||
createPlayerListDock();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue