mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 22:42:14 -07:00
Fix regressions.
Took 17 minutes Took 9 seconds
This commit is contained in:
parent
040eacee72
commit
0745996cb4
4 changed files with 19 additions and 12 deletions
|
|
@ -53,8 +53,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
|
||||||
gameMetaInfo = new GameMetaInfo();
|
gameMetaInfo = new GameMetaInfo();
|
||||||
gameState = new GameState(0, -1, -1, _tabSupervisor->getIsLocalGame(), QList<AbstractClient *>(), true, false,
|
gameState = new GameState(0, -1, -1, _tabSupervisor->getIsLocalGame(), QList<AbstractClient *>(), true, false,
|
||||||
false, false, -1, false);
|
false, false, -1, false);
|
||||||
connect(gameState, &GameState::playerAdded, this, &TabGame::addPlayer);
|
connectToGameState();
|
||||||
connect(gameState, &GameState::gameStarted, this, &TabGame::startGame);
|
|
||||||
|
|
||||||
gameEventHandler = new GameEventHandler(this);
|
gameEventHandler = new GameEventHandler(this);
|
||||||
connectToGameEventHandler();
|
connectToGameEventHandler();
|
||||||
|
|
@ -101,13 +100,12 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor,
|
||||||
gameMetaInfo->setRoomGameTypes(_roomGameTypes);
|
gameMetaInfo->setRoomGameTypes(_roomGameTypes);
|
||||||
gameState = new GameState(0, event.host_id(), event.player_id(), _tabSupervisor->getIsLocalGame(), _clients,
|
gameState = new GameState(0, event.host_id(), event.player_id(), _tabSupervisor->getIsLocalGame(), _clients,
|
||||||
event.spectator(), event.judge(), false, event.resuming(), -1, false);
|
event.spectator(), event.judge(), false, event.resuming(), -1, false);
|
||||||
|
connectToGameState();
|
||||||
|
|
||||||
// THIS CTOR IS USED ON GAMES
|
// THIS CTOR IS USED ON GAMES
|
||||||
gameMetaInfo->setStarted(false);
|
gameMetaInfo->setStarted(false);
|
||||||
connect(gameState, &GameState::playerAdded, this, &TabGame::addPlayer);
|
|
||||||
|
|
||||||
connect(gameMetaInfo, &GameMetaInfo::startedChanged, gameState, &GameState::onStartedChanged);
|
connect(gameMetaInfo, &GameMetaInfo::startedChanged, gameState, &GameState::onStartedChanged);
|
||||||
connect(gameState, &GameState::gameStarted, this, &TabGame::startGame);
|
|
||||||
|
|
||||||
gameEventHandler = new GameEventHandler(this);
|
gameEventHandler = new GameEventHandler(this);
|
||||||
connectToGameEventHandler();
|
connectToGameEventHandler();
|
||||||
|
|
@ -146,6 +144,14 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor,
|
||||||
QTimer::singleShot(0, this, &TabGame::loadLayout);
|
QTimer::singleShot(0, this, &TabGame::loadLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabGame::connectToGameState()
|
||||||
|
{
|
||||||
|
connect(gameState, &GameState::playerAdded, this, &TabGame::addPlayer);
|
||||||
|
connect(gameState, &GameState::gameStarted, this, &TabGame::startGame);
|
||||||
|
connect(gameState, &GameState::activePhaseChanged, this, &TabGame::setActivePhase);
|
||||||
|
connect(gameState, &GameState::activePlayerChanged, this, &TabGame::setActivePlayer);
|
||||||
|
}
|
||||||
|
|
||||||
void TabGame::connectToGameEventHandler()
|
void TabGame::connectToGameEventHandler()
|
||||||
{
|
{
|
||||||
connect(this, &TabGame::gameLeft, gameEventHandler, &GameEventHandler::handleGameLeft);
|
connect(this, &TabGame::gameLeft, gameEventHandler, &GameEventHandler::handleGameLeft);
|
||||||
|
|
@ -230,7 +236,7 @@ void TabGame::resetChatAndPhase()
|
||||||
messageLog->clearChat();
|
messageLog->clearChat();
|
||||||
|
|
||||||
// reset phase markers
|
// reset phase markers
|
||||||
setActivePhase(-1);
|
gameState->setCurrentPhase(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabGame::emitUserEvent()
|
void TabGame::emitUserEvent()
|
||||||
|
|
@ -826,7 +832,7 @@ Player *TabGame::setActivePlayer(int id)
|
||||||
Player *player = gameState->getPlayer(id);
|
Player *player = gameState->getPlayer(id);
|
||||||
if (!player)
|
if (!player)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
gameState->setActivePlayer(id);
|
|
||||||
playerListWidget->setActivePlayer(id);
|
playerListWidget->setActivePlayer(id);
|
||||||
QMapIterator<int, Player *> i(gameState->getPlayers());
|
QMapIterator<int, Player *> i(gameState->getPlayers());
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
|
|
@ -848,10 +854,7 @@ Player *TabGame::setActivePlayer(int id)
|
||||||
|
|
||||||
void TabGame::setActivePhase(int phase)
|
void TabGame::setActivePhase(int phase)
|
||||||
{
|
{
|
||||||
if (gameState->getCurrentPhase() != phase) {
|
phasesToolbar->setActivePhase(phase);
|
||||||
gameState->setCurrentPhase(phase);
|
|
||||||
phasesToolbar->setActivePhase(phase);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabGame::newCardAdded(AbstractCardItem *card)
|
void TabGame::newCardAdded(AbstractCardItem *card)
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,7 @@ public:
|
||||||
QList<AbstractClient *> &_clients,
|
QList<AbstractClient *> &_clients,
|
||||||
const Event_GameJoined &event,
|
const Event_GameJoined &event,
|
||||||
const QMap<int, QString> &_roomGameTypes);
|
const QMap<int, QString> &_roomGameTypes);
|
||||||
|
void connectToGameState();
|
||||||
void connectToGameEventHandler();
|
void connectToGameEventHandler();
|
||||||
void connectMessageLogToGameEventHandler();
|
void connectMessageLogToGameEventHandler();
|
||||||
void connectPlayerListToGameEventHandler();
|
void connectPlayerListToGameEventHandler();
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@ public:
|
||||||
void setActivePlayer(int activePlayerId)
|
void setActivePlayer(int activePlayerId)
|
||||||
{
|
{
|
||||||
activePlayer = activePlayerId;
|
activePlayer = activePlayerId;
|
||||||
|
emit activePlayerChanged(activePlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getIsLocalGame() const
|
bool getIsLocalGame() const
|
||||||
|
|
@ -181,6 +182,7 @@ public:
|
||||||
void setCurrentPhase(int phase)
|
void setCurrentPhase(int phase)
|
||||||
{
|
{
|
||||||
currentPhase = phase;
|
currentPhase = phase;
|
||||||
|
emit activePhaseChanged(phase);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isMainPlayerConceded() const
|
bool isMainPlayerConceded() const
|
||||||
|
|
@ -224,6 +226,8 @@ signals:
|
||||||
void spectatorRemoved(int spectatorId, ServerInfo_User spectator);
|
void spectatorRemoved(int spectatorId, ServerInfo_User spectator);
|
||||||
void gameStarted(bool resuming);
|
void gameStarted(bool resuming);
|
||||||
void gameStopped();
|
void gameStopped();
|
||||||
|
void activePhaseChanged(int activePhase);
|
||||||
|
void activePlayerChanged(int playerId);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void incrementGameTime();
|
void incrementGameTime();
|
||||||
|
|
|
||||||
|
|
@ -805,8 +805,7 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
||||||
connect(player, &Player::logAttachCard, this, &MessageLogWidget::logAttachCard);
|
connect(player, &Player::logAttachCard, this, &MessageLogWidget::logAttachCard);
|
||||||
connect(player, &Player::logUnattachCard, this, &MessageLogWidget::logUnattachCard);
|
connect(player, &Player::logUnattachCard, this, &MessageLogWidget::logUnattachCard);
|
||||||
connect(player, &Player::logDumpZone, this, &MessageLogWidget::logDumpZone);
|
connect(player, &Player::logDumpZone, this, &MessageLogWidget::logDumpZone);
|
||||||
// TODO: Reconnect this
|
connect(player, &Player::logDrawCards, this, &MessageLogWidget::logDrawCards);
|
||||||
// connect(player, &Player::AlogDrawCards, this, &MessageLogWidget::logDrawCards);
|
|
||||||
connect(player, &Player::logUndoDraw, this, &MessageLogWidget::logUndoDraw);
|
connect(player, &Player::logUndoDraw, this, &MessageLogWidget::logUndoDraw);
|
||||||
connect(player, &Player::logRevealCards, this, &MessageLogWidget::logRevealCards);
|
connect(player, &Player::logRevealCards, this, &MessageLogWidget::logRevealCards);
|
||||||
connect(player, &Player::logAlwaysRevealTopCard, this, &MessageLogWidget::logAlwaysRevealTopCard);
|
connect(player, &Player::logAlwaysRevealTopCard, this, &MessageLogWidget::logAlwaysRevealTopCard);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue