mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 00:42:14 -07:00
saving before changing something
This commit is contained in:
parent
40a482686d
commit
70b37804db
2 changed files with 34 additions and 9 deletions
|
|
@ -108,12 +108,12 @@ void ZoneViewZone::zoneDumpReceived(const Response &r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previousOrigSize = origZone->getCards().size();
|
previousOrigSize = origZone->getCards().size();
|
||||||
updateCardIds(false);
|
updateCardIds(INITIALIZE, -1);
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
emit cardCountChanged();
|
emit cardCountChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneViewZone::updateCardIds(bool /*isRemoval*/)
|
void ZoneViewZone::updateCardIds(CardAction action, int index)
|
||||||
{
|
{
|
||||||
int cardCount = cards.size();
|
int cardCount = cards.size();
|
||||||
if (!origZone->contentsKnown()) {
|
if (!origZone->contentsKnown()) {
|
||||||
|
|
@ -127,11 +127,28 @@ void ZoneViewZone::updateCardIds(bool /*isRemoval*/)
|
||||||
if (cards.first()->getId() != firstCardId) {
|
if (cards.first()->getId() != firstCardId) {
|
||||||
startId -= 1;
|
startId -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "TRACK" << "action" << action << "index" << index << "startId" << startId;
|
||||||
|
switch (action) {
|
||||||
|
case INITIALIZE:
|
||||||
|
break;
|
||||||
|
case ADD_CARD:
|
||||||
|
if (index > startId) {
|
||||||
|
startId += 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case REMOVE_CARD:
|
||||||
|
startId -= 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/*if (cards.first()->getId() != firstCardId) {
|
||||||
|
startId -= 1;
|
||||||
|
}
|
||||||
if (origZone->getCards().size() != previousOrigSize) {
|
if (origZone->getCards().size() != previousOrigSize) {
|
||||||
qDebug() << "TRACK origZoneSize changed" << "orig" << origZone->getCards().size() << "prev"
|
qDebug() << "TRACK origZoneSize changed" << "orig" << origZone->getCards().size() << "prev"
|
||||||
<< previousOrigSize;
|
<< previousOrigSize;
|
||||||
previousOrigSize = origZone->getCards().size();
|
previousOrigSize = origZone->getCards().size();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < cardCount; ++i) {
|
for (int i = 0; i < cardCount; ++i) {
|
||||||
|
|
@ -291,7 +308,7 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
||||||
}
|
}
|
||||||
card->setParentItem(this);
|
card->setParentItem(this);
|
||||||
card->update();
|
card->update();
|
||||||
updateCardIds(false);
|
updateCardIds(ADD_CARD, x);
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -314,11 +331,12 @@ void ZoneViewZone::handleDropEvent(const QList<CardDragItem *> &dragItems,
|
||||||
player->sendGameCommand(cmd);
|
player->sendGameCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneViewZone::removeCard(int position)
|
void ZoneViewZone::removeCard(const int position)
|
||||||
{
|
{
|
||||||
if (isReversed) {
|
if (isReversed) {
|
||||||
position -= cards.first()->getId();
|
int bottomPos = position - cards.first()->getId();
|
||||||
if (position < 0 || position >= cards.size()) {
|
if (bottomPos < 0 || bottomPos >= cards.size()) {
|
||||||
|
updateCardIds(REMOVE_CARD, bottomPos);
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -330,7 +348,7 @@ void ZoneViewZone::removeCard(int position)
|
||||||
|
|
||||||
CardItem *card = cards.takeAt(position);
|
CardItem *card = cards.takeAt(position);
|
||||||
card->deleteLater();
|
card->deleteLater();
|
||||||
updateCardIds(false);
|
updateCardIds(REMOVE_CARD, position);
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,14 @@ private:
|
||||||
int firstCardId;
|
int firstCardId;
|
||||||
int previousOrigSize;
|
int previousOrigSize;
|
||||||
|
|
||||||
void updateCardIds(bool isRemoval);
|
enum CardAction
|
||||||
|
{
|
||||||
|
INITIALIZE,
|
||||||
|
ADD_CARD,
|
||||||
|
REMOVE_CARD
|
||||||
|
};
|
||||||
|
|
||||||
|
void updateCardIds(CardAction action, int index);
|
||||||
|
|
||||||
struct GridSize
|
struct GridSize
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue