mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-09 03:23:24 -08:00
[Replay] Fix cards accumulating in zone view when rewinding (#7357)
* [Replay] Fix cards accumulating in zone view when rewinding * rename method
This commit is contained in:
parent
ecd955bc60
commit
ffcb9094ca
6 changed files with 31 additions and 3 deletions
|
|
@ -154,6 +154,14 @@ void ZoneViewZoneLogic::removeCard(int position, bool toNewZone)
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZoneViewZoneLogic::clearCards()
|
||||||
|
{
|
||||||
|
for (auto card : cards) {
|
||||||
|
card->deleteLater();
|
||||||
|
}
|
||||||
|
cards.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void ZoneViewZoneLogic::setWriteableRevealZone(bool _writeableRevealZone)
|
void ZoneViewZoneLogic::setWriteableRevealZone(bool _writeableRevealZone)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,10 @@ public:
|
||||||
bool prepareAddCard(int x);
|
bool prepareAddCard(int x);
|
||||||
void removeCard(int position, bool toNewZone);
|
void removeCard(int position, bool toNewZone);
|
||||||
void updateCardIds(CardAction action);
|
void updateCardIds(CardAction action);
|
||||||
|
|
||||||
|
/** @brief Removes all cards from the view, without touching anything else. Used in replay rewind */
|
||||||
|
void clearCards();
|
||||||
|
|
||||||
int getNumberCards() const
|
int getNumberCards() const
|
||||||
{
|
{
|
||||||
return numberCards;
|
return numberCards;
|
||||||
|
|
|
||||||
|
|
@ -735,6 +735,16 @@ void GameScene::clearViews()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameScene::emptyActiveViews()
|
||||||
|
{
|
||||||
|
for (auto zoneView : zoneViews) {
|
||||||
|
auto logic = qobject_cast<ZoneViewZoneLogic *>(zoneView->getZone()->getLogic());
|
||||||
|
if (!logic->getRevealZone()) {
|
||||||
|
logic->clearCards();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Closes the most recently added zone view.
|
* @brief Closes the most recently added zone view.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,9 @@ public slots:
|
||||||
/** @brief Closes all zone views. */
|
/** @brief Closes all zone views. */
|
||||||
void clearViews();
|
void clearViews();
|
||||||
|
|
||||||
|
/** @brief Empties the contents of all non-reveal zone views. Used for replay rewinding */
|
||||||
|
void emptyActiveViews();
|
||||||
|
|
||||||
/** @brief Closes the most recently added zone view. */
|
/** @brief Closes the most recently added zone view. */
|
||||||
void closeMostRecentZoneView();
|
void closeMostRecentZoneView();
|
||||||
QTransform getViewTransform() const;
|
QTransform getViewTransform() const;
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ void TabGame::linkCardToChat(const QString &cardName)
|
||||||
sayEdit->setFocus();
|
sayEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabGame::resetChatAndPhase()
|
void TabGame::resetForRewind()
|
||||||
{
|
{
|
||||||
// reset chat log
|
// reset chat log
|
||||||
messageLog->clearChat();
|
messageLog->clearChat();
|
||||||
|
|
@ -267,6 +267,9 @@ void TabGame::resetChatAndPhase()
|
||||||
// reset phase markers
|
// reset phase markers
|
||||||
game->getGameState()->setCurrentPhase(-1);
|
game->getGameState()->setCurrentPhase(-1);
|
||||||
|
|
||||||
|
// reset view zones
|
||||||
|
static_cast<GameScene *>(gameView->scene())->emptyActiveViews();
|
||||||
|
|
||||||
// reset spectator state so the replay can rebuild it from the start
|
// reset spectator state so the replay can rebuild it from the start
|
||||||
game->getPlayerManager()->clearSpectators();
|
game->getPlayerManager()->clearSpectators();
|
||||||
playerListWidget->clearSpectators();
|
playerListWidget->clearSpectators();
|
||||||
|
|
@ -1270,7 +1273,7 @@ void TabGame::createReplayDock(GameReplay *replay)
|
||||||
replayDock->setWidget(replayWidget);
|
replayDock->setWidget(replayWidget);
|
||||||
replayDock->setFloating(false);
|
replayDock->setFloating(false);
|
||||||
|
|
||||||
connect(replayWidget, &ReplayWidget::rewound, this, &TabGame::resetChatAndPhase);
|
connect(replayWidget, &ReplayWidget::rewound, this, &TabGame::resetForRewind);
|
||||||
connect(replayWidget, &ReplayWidget::eventReplayed, game->getGameEventHandler(),
|
connect(replayWidget, &ReplayWidget::eventReplayed, game->getGameEventHandler(),
|
||||||
[this](const auto &event, auto options) {
|
[this](const auto &event, auto options) {
|
||||||
game->getGameEventHandler()->processGameEventContainer(event, nullptr, options);
|
game->getGameEventHandler()->processGameEventContainer(event, nullptr, options);
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void viewCardInfo(const CardRef &cardRef = {}) const;
|
void viewCardInfo(const CardRef &cardRef = {}) const;
|
||||||
void resetChatAndPhase();
|
void resetForRewind();
|
||||||
void updateTimeElapsedLabel(QString newTime);
|
void updateTimeElapsedLabel(QString newTime);
|
||||||
void addPlayerToAutoCompleteList(QString playerName);
|
void addPlayerToAutoCompleteList(QString playerName);
|
||||||
void removePlayerFromAutoCompleteList(QString playerName);
|
void removePlayerFromAutoCompleteList(QString playerName);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue