mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 12:23:58 -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 "../interface/widgets/tabs/tab_game.h"
|
||||||
#include "player/player_logic.h"
|
#include "player/player_logic.h"
|
||||||
|
|
||||||
AbstractGame::AbstractGame(TabGame *_tab) : QObject(_tab), tab(_tab)
|
AbstractGame::AbstractGame(QObject *_parent) : QObject(_parent)
|
||||||
{
|
{
|
||||||
gameMetaInfo = new GameMetaInfo(this);
|
gameMetaInfo = new GameMetaInfo(this);
|
||||||
gameEventHandler = new GameEventHandler(this);
|
gameEventHandler = new GameEventHandler(this);
|
||||||
|
|
|
||||||
|
|
@ -16,26 +16,19 @@
|
||||||
#include <libcockatrice/protocol/pb/game_replay.pb.h>
|
#include <libcockatrice/protocol/pb/game_replay.pb.h>
|
||||||
|
|
||||||
class CardItem;
|
class CardItem;
|
||||||
class TabGame;
|
|
||||||
class AbstractGame : public QObject
|
class AbstractGame : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AbstractGame(TabGame *tab);
|
explicit AbstractGame(QObject *parent);
|
||||||
|
|
||||||
TabGame *tab;
|
|
||||||
GameMetaInfo *gameMetaInfo;
|
GameMetaInfo *gameMetaInfo;
|
||||||
GameState *gameState;
|
GameState *gameState;
|
||||||
GameEventHandler *gameEventHandler;
|
GameEventHandler *gameEventHandler;
|
||||||
PlayerManager *playerManager;
|
PlayerManager *playerManager;
|
||||||
CardItem *activeCard;
|
CardItem *activeCard;
|
||||||
|
|
||||||
TabGame *getTab() const
|
|
||||||
{
|
|
||||||
return tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameMetaInfo *getGameMetaInfo()
|
GameMetaInfo *getGameMetaInfo()
|
||||||
{
|
{
|
||||||
return gameMetaInfo;
|
return gameMetaInfo;
|
||||||
|
|
|
||||||
|
|
@ -482,8 +482,7 @@ void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
(!SettingsCache::instance().getDoubleClickToPlay())) {
|
(!SettingsCache::instance().getDoubleClickToPlay())) {
|
||||||
handleClickedToPlay(event->modifiers().testFlag(Qt::ShiftModifier));
|
handleClickedToPlay(event->modifiers().testFlag(Qt::ShiftModifier));
|
||||||
}
|
}
|
||||||
|
if (owner != nullptr) {
|
||||||
if (owner != nullptr) { // cards without owner will be deleted
|
|
||||||
setCursor(Qt::OpenHandCursor);
|
setCursor(Qt::OpenHandCursor);
|
||||||
}
|
}
|
||||||
AbstractCardItem::mouseReleaseEvent(event);
|
AbstractCardItem::mouseReleaseEvent(event);
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,16 @@
|
||||||
|
|
||||||
#include <libcockatrice/protocol/pb/event_game_joined.pb.h>
|
#include <libcockatrice/protocol/pb/event_game_joined.pb.h>
|
||||||
|
|
||||||
Game::Game(TabGame *_tab,
|
Game::Game(QObject *_parent,
|
||||||
|
bool isLocalGame,
|
||||||
QList<AbstractClient *> &_clients,
|
QList<AbstractClient *> &_clients,
|
||||||
const Event_GameJoined &event,
|
const Event_GameJoined &event,
|
||||||
const QMap<int, QString> &_roomGameTypes)
|
const QMap<int, QString> &_roomGameTypes)
|
||||||
: AbstractGame(_tab)
|
: AbstractGame(_parent)
|
||||||
{
|
{
|
||||||
gameMetaInfo->setFromProto(event.game_info());
|
gameMetaInfo->setFromProto(event.game_info());
|
||||||
gameMetaInfo->setRoomGameTypes(_roomGameTypes);
|
gameMetaInfo->setRoomGameTypes(_roomGameTypes);
|
||||||
gameState = new GameState(this, 0, event.host_id(), tab->getTabSupervisor()->getIsLocalGame(), _clients, false,
|
gameState = new GameState(this, 0, event.host_id(), isLocalGame, _clients, false, event.resuming(), -1, false);
|
||||||
event.resuming(), -1, false);
|
|
||||||
connect(gameMetaInfo, &GameMetaInfo::startedChanged, gameState, &GameState::onStartedChanged);
|
connect(gameMetaInfo, &GameMetaInfo::startedChanged, gameState, &GameState::onStartedChanged);
|
||||||
playerManager = new PlayerManager(this, event.player_id(), event.judge(), event.spectator());
|
playerManager = new PlayerManager(this, event.player_id(), event.judge(), event.spectator());
|
||||||
gameMetaInfo->setStarted(false);
|
gameMetaInfo->setStarted(false);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ class Game : public AbstractGame
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Game(TabGame *tab,
|
Game(QObject *parent,
|
||||||
|
bool isLocalGame,
|
||||||
QList<AbstractClient *> &_clients,
|
QList<AbstractClient *> &_clients,
|
||||||
const Event_GameJoined &event,
|
const Event_GameJoined &event,
|
||||||
const QMap<int, QString> &_roomGameTypes);
|
const QMap<int, QString> &_roomGameTypes);
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
#include "../interface/widgets/tabs/tab_game.h"
|
#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);
|
connect(gameMetaInfo, &GameMetaInfo::startedChanged, gameState, &GameState::onStartedChanged);
|
||||||
playerManager = new PlayerManager(this, -1, false, true);
|
playerManager = new PlayerManager(this, -1, false, true);
|
||||||
loadReplay(_replay);
|
loadReplay(_replay);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class Replay : public AbstractGame
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Replay(TabGame *_tab, GameReplay *_replay);
|
explicit Replay(QObject *_parent, GameReplay *_replay, bool isLocalGame);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCKATRICE_REPLAY_H
|
#endif // COCKATRICE_REPLAY_H
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
|
||||||
: Tab(_tabSupervisor), sayLabel(nullptr), sayEdit(nullptr)
|
: Tab(_tabSupervisor), sayLabel(nullptr), sayEdit(nullptr)
|
||||||
{
|
{
|
||||||
// THIS CTOR IS USED ON REPLAY
|
// THIS CTOR IS USED ON REPLAY
|
||||||
game = new Replay(this, _replay);
|
game = new Replay(this, _replay, tabSupervisor->getIsLocalGame());
|
||||||
|
|
||||||
createCardInfoDock(true);
|
createCardInfoDock(true);
|
||||||
createPlayerListDock(true);
|
createPlayerListDock(true);
|
||||||
|
|
@ -92,7 +92,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor,
|
||||||
: Tab(_tabSupervisor), userListProxy(_tabSupervisor->getUserListManager())
|
: Tab(_tabSupervisor), userListProxy(_tabSupervisor->getUserListManager())
|
||||||
{
|
{
|
||||||
// THIS CTOR IS USED ON GAMES
|
// THIS CTOR IS USED ON GAMES
|
||||||
game = new Game(this, _clients, event, _roomGameTypes);
|
game = new Game(this, tabSupervisor->getIsLocalGame(), _clients, event, _roomGameTypes);
|
||||||
|
|
||||||
createCardInfoDock();
|
createCardInfoDock();
|
||||||
createPlayerListDock();
|
createPlayerListDock();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue