mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-15 23:12:14 -07:00
Refactor: Represent cardName + providerId with CardRef struct (#6039)
* card_ref.h * update CardDatabase signatures * make everything compile * rename methods * add docs * mark stuff const * set cardRef in CardItem * cleanup * fix build failure * Fix builds on mac --------- Co-authored-by: ZeldaZach <zahalpern+github@gmail.com>
This commit is contained in:
parent
e05dad4267
commit
a9b3be33e0
61 changed files with 328 additions and 305 deletions
|
|
@ -161,8 +161,7 @@ void AbstractTabDeckEditor::openDeck(DeckLoader *deck)
|
|||
void AbstractTabDeckEditor::setDeck(DeckLoader *_deck)
|
||||
{
|
||||
deckDockWidget->setDeck(_deck);
|
||||
PictureLoader::cacheCardPixmaps(
|
||||
CardDatabaseManager::getInstance()->getCardsByNameAndProviderId(getDeckList()->getCardListWithProviderId()));
|
||||
PictureLoader::cacheCardPixmaps(CardDatabaseManager::getInstance()->getCards(getDeckList()->getCardRefList()));
|
||||
setModified(false);
|
||||
|
||||
// If they load a deck, make the deck list appear
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ EdhrecApiResponseCardDetailsDisplayWidget::EdhrecApiResponseCardDetailsDisplayWi
|
|||
setLayout(layout);
|
||||
|
||||
cardPictureWidget = new CardInfoPictureWidget(this);
|
||||
cardPictureWidget->setCard(CardDatabaseManager::getInstance()->guessCard(toDisplay.sanitized));
|
||||
cardPictureWidget->setCard(CardDatabaseManager::getInstance()->guessCard({toDisplay.sanitized}));
|
||||
|
||||
nameLabel = new QLabel(this);
|
||||
nameLabel->setText(toDisplay.name);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ EdhrecCommanderResponseCommanderDetailsDisplayWidget::EdhrecCommanderResponseCom
|
|||
setLayout(layout);
|
||||
|
||||
commanderPicture = new CardInfoPictureWidget(this);
|
||||
commanderPicture->setCard(CardDatabaseManager::getInstance()->getCard(commanderDetails.getName()));
|
||||
commanderPicture->setCard(CardDatabaseManager::getInstance()->getCardInfo(commanderDetails.getName()));
|
||||
|
||||
QWidget *currentParent = parentWidget();
|
||||
TabEdhRecMain *parentTab = nullptr;
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ void TabEdhRecMain::retranslateUi()
|
|||
|
||||
void TabEdhRecMain::doSearch()
|
||||
{
|
||||
CardInfoPtr searchedCard = CardDatabaseManager::getInstance()->getCard(searchBar->text());
|
||||
CardInfoPtr searchedCard = CardDatabaseManager::getInstance()->getCardInfo(searchBar->text());
|
||||
if (!searchedCard) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,14 +14,13 @@ Tab::Tab(TabSupervisor *_tabSupervisor)
|
|||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
}
|
||||
|
||||
void Tab::showCardInfoPopup(const QPoint &pos, const QString &cardName, const QString &providerId)
|
||||
void Tab::showCardInfoPopup(const QPoint &pos, const CardRef &cardRef)
|
||||
{
|
||||
if (infoPopup) {
|
||||
infoPopup->deleteLater();
|
||||
}
|
||||
currentCardName = cardName;
|
||||
currentProviderId = providerId;
|
||||
infoPopup = new CardInfoDisplayWidget(cardName, providerId, nullptr,
|
||||
currentCard = cardRef;
|
||||
infoPopup = new CardInfoDisplayWidget(currentCard, nullptr,
|
||||
Qt::Widget | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint |
|
||||
Qt::WindowStaysOnTopHint);
|
||||
infoPopup->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
|
|
@ -37,7 +36,7 @@ void Tab::showCardInfoPopup(const QPoint &pos, const QString &cardName, const QS
|
|||
void Tab::deleteCardInfoPopup(const QString &cardName)
|
||||
{
|
||||
if (infoPopup) {
|
||||
if ((currentCardName == cardName) || (cardName == "_")) {
|
||||
if (currentCard.name == cardName || cardName == "_") {
|
||||
infoPopup->deleteLater();
|
||||
infoPopup = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef TAB_H
|
||||
#define TAB_H
|
||||
|
||||
#include "card_ref.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class QMenu;
|
||||
|
|
@ -27,12 +29,12 @@ protected:
|
|||
tabMenus.append(menu);
|
||||
}
|
||||
protected slots:
|
||||
void showCardInfoPopup(const QPoint &pos, const QString &cardName, const QString &providerId);
|
||||
void showCardInfoPopup(const QPoint &pos, const CardRef &cardRef);
|
||||
void deleteCardInfoPopup(const QString &cardName);
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
QString currentCardName, currentProviderId;
|
||||
CardRef currentCard;
|
||||
bool contentsChanged;
|
||||
CardInfoDisplayWidget *infoPopup;
|
||||
QList<QMenu *> tabMenus;
|
||||
|
|
|
|||
|
|
@ -929,8 +929,8 @@ void TabGame::eventGameStateChanged(const Event_GameStateChanged &event,
|
|||
DeckViewContainer *deckViewContainer = deckViewContainers.value(playerId);
|
||||
if (playerInfo.has_deck_list()) {
|
||||
DeckLoader newDeck(QString::fromStdString(playerInfo.deck_list()));
|
||||
PictureLoader::cacheCardPixmaps(CardDatabaseManager::getInstance()->getCardsByNameAndProviderId(
|
||||
newDeck.getCardListWithProviderId()));
|
||||
PictureLoader::cacheCardPixmaps(
|
||||
CardDatabaseManager::getInstance()->getCards(newDeck.getCardRefList()));
|
||||
deckViewContainer->setDeck(newDeck);
|
||||
player->setDeck(newDeck);
|
||||
}
|
||||
|
|
@ -1625,9 +1625,9 @@ void TabGame::createDeckViewContainerWidget(bool bReplay)
|
|||
deckViewContainerWidget->setLayout(deckViewContainerLayout);
|
||||
}
|
||||
|
||||
void TabGame::viewCardInfo(const QString &cardName, const QString &providerId) const
|
||||
void TabGame::viewCardInfo(const CardRef &cardRef) const
|
||||
{
|
||||
cardInfoFrameWidget->setCard(cardName, providerId);
|
||||
cardInfoFrameWidget->setCard(cardRef);
|
||||
}
|
||||
|
||||
void TabGame::createCardInfoDock(bool bReplay)
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ public:
|
|||
public slots:
|
||||
void sendGameCommand(PendingCommand *pend, int playerId = -1);
|
||||
void sendGameCommand(const ::google::protobuf::Message &command, int playerId = -1);
|
||||
void viewCardInfo(const QString &cardName, const QString &providerId = "") const;
|
||||
void viewCardInfo(const CardRef &cardRef = {}) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue