[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegames/kpat
From: Parker Coates <parker.coates () kdemail ! net>
Date: 2012-02-15 4:45:25
Message-ID: 20120215044525.A681BAC896 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1280172 by coates:
Move the <move face=""> attribute to <card turn="">.
Additionally, the attribute is only written out when there is an actual
change in the card's face direction, further increasing readability.
M +11 -4 dealer.cpp
--- trunk/KDE/kdegames/kpat/dealer.cpp #1280171:1280172
@@ -458,14 +458,18 @@
xml.writeStartElement( "move" );
xml.writeAttribute( "pile", change.newState.pile->objectName() );
xml.writeAttribute( "position", QString::number( change.newState.index ) );
- xml.writeAttribute( "face", change.newState.faceUp ? "up" : "down" );
+ bool faceChanged = !change.oldState.pile
+ || change.oldState.faceUp != change.newState.faceUp;
+
foreach ( const KCard * card, change.cards )
{
xml.writeStartElement( "card" );
xml.writeAttribute( "suit", suitToString( card->suit() ) );
xml.writeAttribute( "rank", rankToString( card->rank() ) );
xml.writeAttribute( "id", QString::number( card->id() ) );
+ if ( faceChanged )
+ xml.writeAttribute( "turn", change.newState.faceUp ? "face-up" : "face-down" );
xml.writeEndElement();
}
@@ -541,8 +545,6 @@
bool indexOk;
int index = readIntAttribute( xml, "position", &indexOk );
- bool faceUp = xml.attributes().value( "face" ) == "up";
-
if ( !pile || !indexOk )
{
kWarning() << "Unrecognized pile or index.";
@@ -563,7 +565,12 @@
kWarning() << "Unrecognized card.";
return false;
}
- card->setFaceUp( faceUp );
+
+ if ( xml.attributes().value("turn") == "face-up" )
+ card->setFaceUp( true );
+ else if ( xml.attributes().value("turn") == "face-down" )
+ card->setFaceUp( false );
+
pile->insert( card, index );
++index;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic