[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-games-devel
Subject: [Kde-games-devel] [kde4][klines] patch submission
From: "Guillaume Denry" <guillaume.denry () gmail ! com>
Date: 2007-05-12 14:05:48
Message-ID: e4e5bb5e0705120705h9c26cc9idb0373ba1c624849 () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi,
This one fixes a bug which concerns the focused cell movement.
There was a problem with lower and upper bounds.
Thanks,
Guillaume
[Attachment #5 (text/html)]
Hi,<br><br>This one fixes a bug which concerns the focused cell movement.<br>There \
was a problem with lower and upper bounds.<br><br>Thanks,<br><br>Guillaume<br>
["klines.patch" (text/x-patch)]
Index: klines/scene.cpp
===================================================================
--- klines/scene.cpp (revision 663840)
+++ klines/scene.cpp (working copy)
@@ -474,11 +474,12 @@
return;
}
- QPointF pos = m_focusItem->pos();
- pos.rx() -= m_cellSize;
- if( pos.x() < 0 )
- pos.setX( (FIELD_SIZE - 1)*m_cellSize );
- m_focusItem->setPos( pos );
+ FieldPos focusPos = pixToField( m_focusItem->pos() );
+ focusPos.x--;
+ if (focusPos.x < 0) // rotate on the torus
+ focusPos.x = FIELD_SIZE - 1;
+
+ m_focusItem->setPos ( fieldToPix( focusPos ) );
}
void KLinesScene::moveFocusRight()
@@ -490,11 +491,12 @@
return;
}
- QPointF pos = m_focusItem->pos();
- pos.rx() += m_cellSize;
- if( pos.x() > (FIELD_SIZE-1)*m_cellSize )
- pos.setX( 0 );
- m_focusItem->setPos( pos );
+ FieldPos focusPos = pixToField( m_focusItem->pos() );
+ focusPos.x++;
+ if (focusPos.x >= FIELD_SIZE) // rotate on the torus
+ focusPos.x = 0;
+
+ m_focusItem->setPos ( fieldToPix( focusPos ) );
}
void KLinesScene::moveFocusUp()
@@ -506,11 +508,12 @@
return;
}
- QPointF pos = m_focusItem->pos();
- pos.ry() -= m_cellSize;
- if( pos.y() < 0 )
- pos.setY( (FIELD_SIZE - 1)*m_cellSize );
- m_focusItem->setPos( pos );
+ FieldPos focusPos = pixToField( m_focusItem->pos() );
+ focusPos.y--;
+ if (focusPos.y < 0) // rotate on the torus
+ focusPos.y = FIELD_SIZE - 1;
+
+ m_focusItem->setPos ( fieldToPix( focusPos ) );
}
void KLinesScene::moveFocusDown()
@@ -522,11 +525,12 @@
return;
}
- QPointF pos = m_focusItem->pos();
- pos.ry() += m_cellSize;
- if( pos.y() > (FIELD_SIZE-1)*m_cellSize )
- pos.setY( 0 );
- m_focusItem->setPos( pos );
+ FieldPos focusPos = pixToField( m_focusItem->pos() );
+ focusPos.y++;
+ if (focusPos.y >= FIELD_SIZE) // rotate on the torus
+ focusPos.y = 0;
+
+ m_focusItem->setPos ( fieldToPix( focusPos ) );
}
void KLinesScene::cellSelected()
_______________________________________________
kde-games-devel mailing list
kde-games-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-games-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic