mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-11 21:04:07 -07:00
refactor everything else
This commit is contained in:
parent
5734f51f3f
commit
c58bdd08e0
10 changed files with 43 additions and 33 deletions
|
|
@ -60,7 +60,8 @@ void AbstractCardItem::refreshCardInfo()
|
||||||
exactCard = CardDatabaseManager::query()->getCard(cardRef);
|
exactCard = CardDatabaseManager::query()->getCard(cardRef);
|
||||||
|
|
||||||
if (!exactCard && !cardRef.name.isEmpty()) {
|
if (!exactCard && !cardRef.name.isEmpty()) {
|
||||||
auto info = CardInfo::newInstance(cardRef.name, "", true, {}, {}, {}, {}, false, false, -1, false);
|
CardInfo::UiAttributes attributes = {.tableRow = -1};
|
||||||
|
auto info = CardInfo::newInstance(cardRef.name, "", true, {}, {}, {}, {}, attributes);
|
||||||
exactCard = ExactCard(info);
|
exactCard = ExactCard(info);
|
||||||
}
|
}
|
||||||
if (exactCard) {
|
if (exactCard) {
|
||||||
|
|
|
||||||
|
|
@ -238,8 +238,8 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (startZone->getName().compare("hand") == 0) {
|
if (startZone->getName().compare("hand") == 0) {
|
||||||
startCard->playCard(false);
|
startCard->playCard(false);
|
||||||
CardInfoPtr ci = startCard->getCard().getCardPtr();
|
CardInfoPtr ci = startCard->getCard().getCardPtr();
|
||||||
if (ci && ((!SettingsCache::instance().getPlayToStack() && ci->getTableRow() == 3) ||
|
if (ci && ((!SettingsCache::instance().getPlayToStack() && ci->getUiAttributes().tableRow == 3) ||
|
||||||
(SettingsCache::instance().getPlayToStack() && ci->getTableRow() != 0 &&
|
(SettingsCache::instance().getPlayToStack() && ci->getUiAttributes().tableRow != 0 &&
|
||||||
startCard->getZone()->getName().toStdString() != "stack")))
|
startCard->getZone()->getName().toStdString() != "stack")))
|
||||||
cmd.set_start_zone("stack");
|
cmd.set_start_zone("stack");
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ void PlayerActions::playCard(CardItem *card, bool faceDown)
|
||||||
|
|
||||||
const CardInfo &info = exactCard.getInfo();
|
const CardInfo &info = exactCard.getInfo();
|
||||||
|
|
||||||
int tableRow = info.getTableRow();
|
int tableRow = info.getUiAttributes().tableRow;
|
||||||
bool playToStack = SettingsCache::instance().getPlayToStack();
|
bool playToStack = SettingsCache::instance().getPlayToStack();
|
||||||
QString currentZone = card->getZone()->getName();
|
QString currentZone = card->getZone()->getName();
|
||||||
if (currentZone == "stack" && tableRow == 3) {
|
if (currentZone == "stack" && tableRow == 3) {
|
||||||
|
|
@ -72,13 +72,13 @@ void PlayerActions::playCard(CardItem *card, bool faceDown)
|
||||||
cmd.set_x(-1);
|
cmd.set_x(-1);
|
||||||
cmd.set_y(0);
|
cmd.set_y(0);
|
||||||
} else {
|
} else {
|
||||||
tableRow = faceDown ? 2 : info.getTableRow();
|
tableRow = faceDown ? 2 : info.getUiAttributes().tableRow;
|
||||||
QPoint gridPoint = QPoint(-1, TableZone::clampValidTableRow(2 - tableRow));
|
QPoint gridPoint = QPoint(-1, TableZone::clampValidTableRow(2 - tableRow));
|
||||||
cardToMove->set_face_down(faceDown);
|
cardToMove->set_face_down(faceDown);
|
||||||
if (!faceDown) {
|
if (!faceDown) {
|
||||||
cardToMove->set_pt(info.getPowTough().toStdString());
|
cardToMove->set_pt(info.getPowTough().toStdString());
|
||||||
}
|
}
|
||||||
cardToMove->set_tapped(!faceDown && info.getCipt());
|
cardToMove->set_tapped(!faceDown && info.getUiAttributes().cipt);
|
||||||
if (tableRow != 3)
|
if (tableRow != 3)
|
||||||
cmd.set_target_zone("table");
|
cmd.set_target_zone("table");
|
||||||
cmd.set_x(gridPoint.x());
|
cmd.set_x(gridPoint.x());
|
||||||
|
|
@ -111,7 +111,7 @@ void PlayerActions::playCardToTable(const CardItem *card, bool faceDown)
|
||||||
|
|
||||||
const CardInfo &info = exactCard.getInfo();
|
const CardInfo &info = exactCard.getInfo();
|
||||||
|
|
||||||
int tableRow = faceDown ? 2 : info.getTableRow();
|
int tableRow = faceDown ? 2 : info.getUiAttributes().tableRow;
|
||||||
// default instant/sorcery cards to the noncreatures row
|
// default instant/sorcery cards to the noncreatures row
|
||||||
if (tableRow > 2) {
|
if (tableRow > 2) {
|
||||||
tableRow = 1;
|
tableRow = 1;
|
||||||
|
|
@ -122,7 +122,7 @@ void PlayerActions::playCardToTable(const CardItem *card, bool faceDown)
|
||||||
if (!faceDown) {
|
if (!faceDown) {
|
||||||
cardToMove->set_pt(info.getPowTough().toStdString());
|
cardToMove->set_pt(info.getPowTough().toStdString());
|
||||||
}
|
}
|
||||||
cardToMove->set_tapped(!faceDown && info.getCipt());
|
cardToMove->set_tapped(!faceDown && info.getUiAttributes().cipt);
|
||||||
cmd.set_target_zone("table");
|
cmd.set_target_zone("table");
|
||||||
cmd.set_x(gridPoint.x());
|
cmd.set_x(gridPoint.x());
|
||||||
cmd.set_y(gridPoint.y());
|
cmd.set_y(gridPoint.y());
|
||||||
|
|
@ -859,7 +859,7 @@ void PlayerActions::actCreateToken()
|
||||||
ExactCard correctedCard = CardDatabaseManager::query()->guessCard({lastTokenInfo.name, lastTokenInfo.providerId});
|
ExactCard correctedCard = CardDatabaseManager::query()->guessCard({lastTokenInfo.name, lastTokenInfo.providerId});
|
||||||
if (correctedCard) {
|
if (correctedCard) {
|
||||||
lastTokenInfo.name = correctedCard.getName();
|
lastTokenInfo.name = correctedCard.getName();
|
||||||
lastTokenTableRow = TableZone::clampValidTableRow(2 - correctedCard.getInfo().getTableRow());
|
lastTokenTableRow = TableZone::clampValidTableRow(2 - correctedCard.getInfo().getUiAttributes().tableRow);
|
||||||
if (lastTokenInfo.pt.isEmpty()) {
|
if (lastTokenInfo.pt.isEmpty()) {
|
||||||
lastTokenInfo.pt = correctedCard.getInfo().getPowTough();
|
lastTokenInfo.pt = correctedCard.getInfo().getPowTough();
|
||||||
}
|
}
|
||||||
|
|
@ -910,7 +910,7 @@ void PlayerActions::setLastToken(CardInfoPtr cardInfo)
|
||||||
.providerId =
|
.providerId =
|
||||||
SettingsCache::instance().cardOverrides().getCardPreferenceOverride(cardInfo->getName())};
|
SettingsCache::instance().cardOverrides().getCardPreferenceOverride(cardInfo->getName())};
|
||||||
|
|
||||||
lastTokenTableRow = TableZone::clampValidTableRow(2 - cardInfo->getTableRow());
|
lastTokenTableRow = TableZone::clampValidTableRow(2 - cardInfo->getUiAttributes().tableRow);
|
||||||
|
|
||||||
utilityMenu->setAndEnableCreateAnotherTokenAction(tr("C&reate another %1 token").arg(lastTokenInfo.name));
|
utilityMenu->setAndEnableCreateAnotherTokenAction(tr("C&reate another %1 token").arg(lastTokenInfo.name));
|
||||||
}
|
}
|
||||||
|
|
@ -1080,7 +1080,7 @@ void PlayerActions::createCard(const CardItem *sourceCard,
|
||||||
|
|
||||||
// get the target token's location
|
// get the target token's location
|
||||||
// TODO: Define this QPoint into its own function along with the one below
|
// TODO: Define this QPoint into its own function along with the one below
|
||||||
QPoint gridPoint = QPoint(-1, TableZone::clampValidTableRow(2 - cardInfo->getTableRow()));
|
QPoint gridPoint = QPoint(-1, TableZone::clampValidTableRow(2 - cardInfo->getUiAttributes().tableRow));
|
||||||
|
|
||||||
// create the token for the related card
|
// create the token for the related card
|
||||||
Command_CreateToken cmd;
|
Command_CreateToken cmd;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ void TableZoneLogic::addCardImpl(CardItem *card, int _x, int _y)
|
||||||
if (!card->getFaceDown() && card->getPT().isEmpty()) {
|
if (!card->getFaceDown() && card->getPT().isEmpty()) {
|
||||||
card->setPT(card->getCardInfo().getPowTough());
|
card->setPT(card->getCardInfo().getPowTough());
|
||||||
}
|
}
|
||||||
if (card->getCardInfo().getCipt() && card->getCardInfo().getLandscapeOrientation()) {
|
if (card->getCardInfo().getUiAttributes().cipt && card->getCardInfo().getUiAttributes().landscapeOrientation) {
|
||||||
card->setDoesntUntap(true);
|
card->setDoesntUntap(true);
|
||||||
}
|
}
|
||||||
card->setGridPoint(QPoint(_x, _y));
|
card->setGridPoint(QPoint(_x, _y));
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ void CardPictureLoader::imageLoaded(const ExactCard &card, const QImage &image)
|
||||||
qCDebug(CardPictureLoaderLog) << "Caching NULL pixmap for" << card.getName();
|
qCDebug(CardPictureLoaderLog) << "Caching NULL pixmap for" << card.getName();
|
||||||
QPixmapCache::insert(card.getPixmapCacheKey(), QPixmap());
|
QPixmapCache::insert(card.getPixmapCacheKey(), QPixmap());
|
||||||
} else {
|
} else {
|
||||||
if (card.getInfo().getUpsideDownArt()) {
|
if (card.getInfo().getUiAttributes().upsideDownArt) {
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0))
|
||||||
QImage mirrorImage = image.flipped(Qt::Horizontal | Qt::Vertical);
|
QImage mirrorImage = image.flipped(Qt::Horizontal | Qt::Vertical);
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ void CardInfoPictureWidget::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
QPixmap transformedPixmap = resizedPixmap; // Default pixmap
|
QPixmap transformedPixmap = resizedPixmap; // Default pixmap
|
||||||
if (SettingsCache::instance().getAutoRotateSidewaysLayoutCards()) {
|
if (SettingsCache::instance().getAutoRotateSidewaysLayoutCards()) {
|
||||||
if (exactCard.getInfo().getLandscapeOrientation()) {
|
if (exactCard.getInfo().getUiAttributes().landscapeOrientation) {
|
||||||
// Rotate pixmap 90 degrees to the left
|
// Rotate pixmap 90 degrees to the left
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
transform.rotate(90);
|
transform.rotate(90);
|
||||||
|
|
|
||||||
|
|
@ -165,8 +165,8 @@ void DlgEditTokens::actAddToken()
|
||||||
QString setName = CardSet::TOKENS_SETNAME;
|
QString setName = CardSet::TOKENS_SETNAME;
|
||||||
SetToPrintingsMap sets;
|
SetToPrintingsMap sets;
|
||||||
sets[setName].append(PrintingInfo(databaseModel->getDatabase()->getSet(setName)));
|
sets[setName].append(PrintingInfo(databaseModel->getDatabase()->getSet(setName)));
|
||||||
CardInfoPtr card = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(),
|
CardInfo::UiAttributes attributes = {.tableRow = -1};
|
||||||
QList<CardRelation *>(), sets, false, false, -1, false);
|
CardInfoPtr card = CardInfo::newInstance(name, "", true, {}, {}, {}, sets, attributes);
|
||||||
card->setCardType("Token");
|
card->setCardType("Token");
|
||||||
|
|
||||||
databaseModel->getDatabase()->addCard(card);
|
databaseModel->getDatabase()->addCard(card);
|
||||||
|
|
|
||||||
|
|
@ -282,9 +282,13 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
}
|
}
|
||||||
|
|
||||||
properties.insert("colors", colors);
|
properties.insert("colors", colors);
|
||||||
CardInfoPtr newCard =
|
|
||||||
CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards, _sets, cipt,
|
CardInfo::UiAttributes attributes = {.cipt = cipt,
|
||||||
landscapeOrientation, tableRow, upsideDown);
|
.landscapeOrientation = landscapeOrientation,
|
||||||
|
.tableRow = tableRow,
|
||||||
|
.upsideDownArt = upsideDown};
|
||||||
|
CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards,
|
||||||
|
reverseRelatedCards, _sets, attributes);
|
||||||
emit addCard(newCard);
|
emit addCard(newCard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -417,14 +421,15 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
|
||||||
}
|
}
|
||||||
|
|
||||||
// positioning
|
// positioning
|
||||||
xml.writeTextElement("tablerow", QString::number(info->getTableRow()));
|
const CardInfo::UiAttributes &attributes = info->getUiAttributes();
|
||||||
if (info->getCipt()) {
|
xml.writeTextElement("tablerow", QString::number(attributes.tableRow));
|
||||||
|
if (attributes.cipt) {
|
||||||
xml.writeTextElement("cipt", "1");
|
xml.writeTextElement("cipt", "1");
|
||||||
}
|
}
|
||||||
if (info->getLandscapeOrientation()) {
|
if (attributes.landscapeOrientation) {
|
||||||
xml.writeTextElement("landscapeOrientation", "1");
|
xml.writeTextElement("landscapeOrientation", "1");
|
||||||
}
|
}
|
||||||
if (info->getUpsideDownArt()) {
|
if (attributes.upsideDownArt) {
|
||||||
xml.writeTextElement("upsidedown", "1");
|
xml.writeTextElement("upsidedown", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -262,9 +262,12 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardInfoPtr newCard =
|
CardInfo::UiAttributes attributes = {.cipt = cipt,
|
||||||
CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards, _sets, cipt,
|
.landscapeOrientation = landscapeOrientation,
|
||||||
landscapeOrientation, tableRow, upsideDown);
|
.tableRow = tableRow,
|
||||||
|
.upsideDownArt = upsideDown};
|
||||||
|
CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards,
|
||||||
|
reverseRelatedCards, _sets, attributes);
|
||||||
emit addCard(newCard);
|
emit addCard(newCard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -379,14 +382,15 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
|
||||||
}
|
}
|
||||||
|
|
||||||
// positioning
|
// positioning
|
||||||
xml.writeTextElement("tablerow", QString::number(info->getTableRow()));
|
const CardInfo::UiAttributes &attributes = info->getUiAttributes();
|
||||||
if (info->getCipt()) {
|
xml.writeTextElement("tablerow", QString::number(attributes.tableRow));
|
||||||
|
if (attributes.cipt) {
|
||||||
xml.writeTextElement("cipt", "1");
|
xml.writeTextElement("cipt", "1");
|
||||||
}
|
}
|
||||||
if (info->getLandscapeOrientation()) {
|
if (attributes.landscapeOrientation) {
|
||||||
xml.writeTextElement("landscapeOrientation", "1");
|
xml.writeTextElement("landscapeOrientation", "1");
|
||||||
}
|
}
|
||||||
if (info->getUpsideDownArt()) {
|
if (attributes.upsideDownArt) {
|
||||||
xml.writeTextElement("upsidedown", "1");
|
xml.writeTextElement("upsidedown", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -204,11 +204,11 @@ CardInfoPtr OracleImporter::addCard(QString name,
|
||||||
bool upsideDown = layout == "flip" && side == "back";
|
bool upsideDown = layout == "flip" && side == "back";
|
||||||
|
|
||||||
// insert the card and its properties
|
// insert the card and its properties
|
||||||
QList<CardRelation *> reverseRelatedCards;
|
|
||||||
SetToPrintingsMap setsInfo;
|
SetToPrintingsMap setsInfo;
|
||||||
setsInfo[printingInfo.getSet()->getShortName()].append(printingInfo);
|
setsInfo[printingInfo.getSet()->getShortName()].append(printingInfo);
|
||||||
CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards,
|
CardInfo::UiAttributes attributes = {cipt, landscapeOrientation, tableRow, upsideDown};
|
||||||
setsInfo, cipt, landscapeOrientation, tableRow, upsideDown);
|
CardInfoPtr newCard =
|
||||||
|
CardInfo::newInstance(name, text, isToken, properties, relatedCards, {}, setsInfo, attributes);
|
||||||
|
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
qDebug() << "warning: an empty card was added to set" << printingInfo.getSet()->getShortName();
|
qDebug() << "warning: an empty card was added to set" << printingInfo.getSet()->getShortName();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue