mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-12 15:49:28 -08:00
Re-Add ability to share editable deck views (#5060)
- Rolls back6811819161- Follow up toadbb607700
This commit is contained in:
@@ -481,7 +481,8 @@ void MessageLogWidget::logRevealCards(Player *player,
|
||||
QString cardName,
|
||||
Player *otherPlayer,
|
||||
bool faceDown,
|
||||
int amount)
|
||||
int amount,
|
||||
bool isLentToAnotherPlayer)
|
||||
{
|
||||
// getFromStr uses cardname.empty() to check if it should contain the start zone, it's not actually used
|
||||
QPair<QString, QString> temp = getFromStr(zone, amount == 1 ? cardName : QString::number(amount), cardId, false);
|
||||
@@ -507,10 +508,17 @@ void MessageLogWidget::logRevealCards(Player *player,
|
||||
}
|
||||
if (cardId == -1) {
|
||||
if (otherPlayer) {
|
||||
appendHtmlServerMessage(tr("%1 reveals %2 to %3.")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg(zone->getTranslatedName(true, CaseRevealZone))
|
||||
.arg(sanitizeHtml(otherPlayer->getName())));
|
||||
if (isLentToAnotherPlayer) {
|
||||
appendHtmlServerMessage(tr("%1 lends %2 to %3.")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg(zone->getTranslatedName(true, CaseRevealZone))
|
||||
.arg(sanitizeHtml(otherPlayer->getName())));
|
||||
} else {
|
||||
appendHtmlServerMessage(tr("%1 reveals %2 to %3.")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg(zone->getTranslatedName(true, CaseRevealZone))
|
||||
.arg(sanitizeHtml(otherPlayer->getName())));
|
||||
}
|
||||
} else {
|
||||
appendHtmlServerMessage(tr("%1 reveals %2.")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
@@ -845,8 +853,8 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
||||
connect(player, SIGNAL(logDumpZone(Player *, CardZone *, int)), this, SLOT(logDumpZone(Player *, CardZone *, int)));
|
||||
connect(player, SIGNAL(logDrawCards(Player *, int, bool)), this, SLOT(logDrawCards(Player *, int, bool)));
|
||||
connect(player, SIGNAL(logUndoDraw(Player *, QString)), this, SLOT(logUndoDraw(Player *, QString)));
|
||||
connect(player, SIGNAL(logRevealCards(Player *, CardZone *, int, QString, Player *, bool, int)), this,
|
||||
SLOT(logRevealCards(Player *, CardZone *, int, QString, Player *, bool, int)));
|
||||
connect(player, SIGNAL(logRevealCards(Player *, CardZone *, int, QString, Player *, bool, int, bool)), this,
|
||||
SLOT(logRevealCards(Player *, CardZone *, int, QString, Player *, bool, int, bool)));
|
||||
connect(player, SIGNAL(logAlwaysRevealTopCard(Player *, CardZone *, bool)), this,
|
||||
SLOT(logAlwaysRevealTopCard(Player *, CardZone *, bool)));
|
||||
connect(player, SIGNAL(logAlwaysLookAtTopCard(Player *, CardZone *, bool)), this,
|
||||
|
||||
@@ -77,7 +77,8 @@ public slots:
|
||||
QString cardName,
|
||||
Player *otherPlayer,
|
||||
bool faceDown,
|
||||
int amount);
|
||||
int amount,
|
||||
bool isLentToAnotherPlayer);
|
||||
void logReverseTurn(Player *player, bool reversed);
|
||||
void logRollDie(Player *player, int sides, const QList<uint> &rolls);
|
||||
void logSay(Player *player, QString message);
|
||||
|
||||
@@ -314,6 +314,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
|
||||
libraryMenu->addAction(aViewTopCards);
|
||||
libraryMenu->addSeparator();
|
||||
playerLists.append(mRevealLibrary = libraryMenu->addMenu(QString()));
|
||||
singlePlayerLists.append(mLendLibrary = libraryMenu->addMenu(QString()));
|
||||
playerLists.append(mRevealTopCard = libraryMenu->addMenu(QString()));
|
||||
libraryMenu->addAction(aAlwaysRevealTopCard);
|
||||
libraryMenu->addAction(aAlwaysLookAtTopCard);
|
||||
@@ -582,14 +583,22 @@ void Player::addPlayer(Player *player)
|
||||
}
|
||||
|
||||
for (auto &playerList : playerLists) {
|
||||
QAction *newAction = playerList->addAction(player->getName());
|
||||
newAction->setData(player->getId());
|
||||
connect(newAction, SIGNAL(triggered()), this, SLOT(playerListActionTriggered()));
|
||||
addPlayerToList(playerList, player);
|
||||
}
|
||||
for (auto &playerList : singlePlayerLists) {
|
||||
addPlayerToList(playerList, player);
|
||||
}
|
||||
|
||||
playersInfo.append(qMakePair(player->getName(), player->getId()));
|
||||
}
|
||||
|
||||
void Player::addPlayerToList(QMenu *playerList, Player *player)
|
||||
{
|
||||
QAction *newAction = playerList->addAction(player->getName());
|
||||
newAction->setData(player->getId());
|
||||
connect(newAction, SIGNAL(triggered()), this, SLOT(playerListActionTriggered()));
|
||||
}
|
||||
|
||||
void Player::removePlayer(Player *player)
|
||||
{
|
||||
if (player == nullptr) {
|
||||
@@ -597,12 +606,10 @@ void Player::removePlayer(Player *player)
|
||||
}
|
||||
|
||||
for (auto &playerList : playerLists) {
|
||||
QList<QAction *> actionList = playerList->actions();
|
||||
for (auto &j : actionList)
|
||||
if (j->data().toInt() == player->getId()) {
|
||||
playerList->removeAction(j);
|
||||
j->deleteLater();
|
||||
}
|
||||
removePlayerFromList(playerList, player);
|
||||
}
|
||||
for (auto &playerList : singlePlayerLists) {
|
||||
removePlayerFromList(playerList, player);
|
||||
}
|
||||
|
||||
for (auto it = playersInfo.begin(); it != playersInfo.end();) {
|
||||
@@ -614,6 +621,16 @@ void Player::removePlayer(Player *player)
|
||||
}
|
||||
}
|
||||
|
||||
void Player::removePlayerFromList(QMenu *playerList, Player *player)
|
||||
{
|
||||
QList<QAction *> actionList = playerList->actions();
|
||||
for (auto &j : actionList)
|
||||
if (j->data().toInt() == player->getId()) {
|
||||
playerList->removeAction(j);
|
||||
j->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void Player::playerListActionTriggered()
|
||||
{
|
||||
auto *action = static_cast<QAction *>(sender());
|
||||
@@ -625,8 +642,9 @@ void Player::playerListActionTriggered()
|
||||
cmd.set_player_id(otherPlayerId);
|
||||
}
|
||||
|
||||
if (menu == mRevealLibrary) {
|
||||
if (menu == mRevealLibrary || menu == mLendLibrary) {
|
||||
cmd.set_zone_name("deck");
|
||||
cmd.set_grant_write_access(menu == mLendLibrary);
|
||||
} else if (menu == mRevealTopCard) {
|
||||
int deckSize = zones.value("deck")->getCards().size();
|
||||
bool ok;
|
||||
@@ -752,6 +770,7 @@ void Player::retranslateUi()
|
||||
aViewHand->setText(tr("&View hand"));
|
||||
aViewTopCards->setText(tr("View &top cards of library..."));
|
||||
mRevealLibrary->setTitle(tr("Reveal &library to..."));
|
||||
mLendLibrary->setTitle(tr("Lend library to..."));
|
||||
mRevealTopCard->setTitle(tr("Reveal &top cards to..."));
|
||||
topLibraryMenu->setTitle(tr("&Top of library..."));
|
||||
bottomLibraryMenu->setTitle(tr("&Bottom of library..."));
|
||||
@@ -1974,8 +1993,7 @@ void Player::eventRollDie(const Event_RollDie &event)
|
||||
#endif
|
||||
std::sort(rolls.begin(), rolls.end());
|
||||
emit logRollDie(this, static_cast<int>(event.sides()), rolls);
|
||||
}
|
||||
else if (event.value()) {
|
||||
} else if (event.value()) {
|
||||
// Backwards compatibility for old clients
|
||||
emit logRollDie(this, static_cast<int>(event.sides()), {event.value()});
|
||||
}
|
||||
@@ -2373,7 +2391,8 @@ void Player::eventRevealCards(const Event_RevealCards &event)
|
||||
}
|
||||
|
||||
emit logRevealCards(this, zone, cardId, cardName, otherPlayer, false,
|
||||
event.has_number_of_cards() ? event.number_of_cards() : cardList.size());
|
||||
event.has_number_of_cards() ? event.number_of_cards() : cardList.size(),
|
||||
event.grant_write_access());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,8 @@ signals:
|
||||
QString cardName,
|
||||
Player *otherPlayer,
|
||||
bool faceDown,
|
||||
int amount);
|
||||
int amount,
|
||||
bool isLentToAnotherPlayer = false);
|
||||
void logAlwaysRevealTopCard(Player *player, CardZone *zone, bool reveal);
|
||||
void logAlwaysLookAtTopCard(Player *player, CardZone *zone, bool reveal);
|
||||
|
||||
@@ -225,11 +226,12 @@ private slots:
|
||||
|
||||
private:
|
||||
TabGame *game;
|
||||
QMenu *sbMenu, *countersMenu, *sayMenu, *createPredefinedTokenMenu, *mRevealLibrary, *mRevealTopCard, *mRevealHand,
|
||||
*mRevealRandomHandCard, *mRevealRandomGraveyardCard;
|
||||
QMenu *sbMenu, *countersMenu, *sayMenu, *createPredefinedTokenMenu, *mRevealLibrary, *mLendLibrary, *mRevealTopCard,
|
||||
*mRevealHand, *mRevealRandomHandCard, *mRevealRandomGraveyardCard;
|
||||
TearOffMenu *moveGraveMenu, *moveRfgMenu, *graveMenu, *moveHandMenu, *handMenu, *libraryMenu, *topLibraryMenu,
|
||||
*bottomLibraryMenu, *rfgMenu, *playerMenu;
|
||||
QList<QMenu *> playerLists;
|
||||
QList<QMenu *> singlePlayerLists;
|
||||
QList<QAction *> allPlayersActions;
|
||||
QList<QPair<QString, int>> playersInfo;
|
||||
QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary, *aMoveHandToGrave, *aMoveHandToRfg,
|
||||
@@ -299,6 +301,8 @@ private:
|
||||
bool persistent = false);
|
||||
bool createRelatedFromRelation(const CardItem *sourceCard, const CardRelation *cardRelation);
|
||||
void moveOneCardUntil(const CardInfoPtr card);
|
||||
void addPlayerToList(QMenu *playerList, Player *player);
|
||||
static void removePlayerFromList(QMenu *playerList, Player *player);
|
||||
|
||||
QRectF bRect;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user