[Kde-games-devel] KDE/kdegames/kapman
Mauricio Piacentini
piacentini at kde.org
Fri Jan 9 01:18:25 CET 2009
SVN commit 907963 by piacentini:
Set element ID again after loading a theme, causes QGV to reread the
bounding rects and scale elements correctly. Change rotation fix for
Mountain Adventure theme so that it works after a theme change.
CCMAIL:kde-games-devel at kde.org
M +33 -0 gamescene.cpp
M +5 -0 gamescene.h
M +6 -5 kapmanitem.cpp
--- trunk/KDE/kdegames/kapman/gamescene.cpp #907962:907963
@@ -190,12 +190,45 @@
return;
}
m_cache->discard();
+
+ //Update elementIDs,
+ updateSvgIds();
+
update(0, 0, width(), height());
// Update the theme config: if the default theme is selected, no theme entry is written -> the theme selector does not select the theme
Settings::self()->config()->group("General").writeEntry("Theme", Settings::self()->theme());
}
+void GameScene::updateSvgIds() {
+ //Needed so new boundingRects() are read for all SVG elements after a theme change
+ //Only update if elements already exist
+ if (m_ghostItems.size()==0) return;
+
+ // Set the element Id to the right value
+ m_mazeItem->setElementId("maze");
+
+ // Create the KapmanItem
+ m_kapmanItem->setElementId("kapman_0");
+ // Corrects the position of the KapmanItem
+ m_kapmanItem->update(m_game->getKapman()->getX(), m_game->getKapman()->getY());
+
+ for (int i = 0; i < m_ghostItems.size(); ++i) {
+ GhostItem* ghost = m_ghostItems[i];
+ ghost->setElementId(m_game->getGhosts()[i]->getImageId());
+ ghost->update(m_game->getGhosts()[i]->getX(), m_game->getGhosts()[i]->getY());
+ }
+ for (int i = 0; i < m_game->getMaze()->getNbRows();++i) {
+ for (int j = 0; j < m_game->getMaze()->getNbColumns(); ++j) {
+ if (m_elementItems[i][j] != NULL) {
+ ElementItem* element = m_elementItems[i][j];
+ element->setElementId(m_game->getMaze()->getCell(i,j).getElement()->getImageId());
+ element->update(m_game->getMaze()->getCell(i, j).getElement()->getX(), m_game->getMaze()->getCell(i, j).getElement()->getY());
+ }
+ }
+ }
+}
+
void GameScene::intro(const bool p_newLevel) {
// If a new level has begun
if (p_newLevel) {
--- trunk/KDE/kdegames/kapman/gamescene.h #907962:907963
@@ -97,6 +97,11 @@
* Loads the game theme.
*/
void loadTheme();
+
+ /**
+ * Update theme id elements.
+ */
+ void updateSvgIds();
private slots:
--- trunk/KDE/kdegames/kapman/kapmanitem.cpp #907962:907963
@@ -61,11 +61,6 @@
}
void KapmanItem::updateDirection() {
- // TODO This is a temporary fix to avoid the character rotating when the game theme is "Mountain Adventure".
- // This has to be changed to manage the rotation independently of the used theme.
- if (Settings::self()->theme() == "themes/mountain.desktop") {
- return;
- }
QTransform transform;
int angle = 0;
Kapman* model = (Kapman*)getModel();
@@ -81,6 +76,12 @@
} else if (model->getYSpeed() < 0) {
angle = -90;
}
+
+ // TODO This is a temporary fix to avoid the character rotating when the game theme is "Mountain Adventure".
+ // This has to be changed to manage the rotation independently of the used theme.
+ if (Settings::self()->theme() == "themes/mountain.desktop") {
+ angle=0;
+ }
// Rotate the item
transform.translate(boundingRect().width() / 2, boundingRect().height() / 2);
transform.rotate(angle);
More information about the kde-games-devel
mailing list