[Kde-games-devel] KDE/kdegames/kgoldrunner

Luciano Montanaro mikelima at cirulla.net
Thu Aug 9 10:08:14 CEST 2007


SVN commit 698126 by montanaro:

Split theme graphics in a "Set" (as in cinematographic set) and "Actors" parts.

Added a second background to the geek city theme (it's a copy of the first one,
painted blue instead of green. Someone more artistically inclined may even move
some of the components around...

Tweaked the coin in the default theme and changed the black with a dark blue in
the backgrounds, so that enemies will show.

Maybe it would be useful to further split the actors in hero, villain and
villain with gold, and use identical names for the frames. In this way, it
would be possible to, say, copy the hero to the villain, tweak the template
body parts (change colors, add different details...) and have a decent
animation that could be further tweaked if needed.

CCMAIL: kde-games-devel at kde.org
CCMAIL: Ian Wadham <ianw2 at optusnet.com.au>



 M  +25 -19    src/kgrtheme.cpp  
 M  +2 -2      src/kgrtheme.h  
 M  +2 -2      themes/CMakeLists.txt  
 M  +2 -1      themes/default.desktop  
 A             themes/default/actors.svg  
 D             themes/default/kgr_default.svg  
 A             themes/default/set.svg  
 M  +2 -1      themes/kgr_geek.desktop  
 AM            themes/kgr_geek/actors.svgz  
 D             themes/kgr_geek/kgr_geek.svgz  
 AM            themes/kgr_geek/set.svgz  


--- trunk/KDE/kdegames/kgoldrunner/src/kgrtheme.cpp #698125:698126
@@ -32,7 +32,6 @@
 
 KGrTheme::KGrTheme(const QString &systemDataDir) : 
 	themeDataDir(systemDataDir + "../theme/"),
-	filepathSVG(""), 
 	m_themeFilepath(""), 
 	tileGraphics(NONE),
 	backgroundGraphics(NONE),
@@ -51,7 +50,6 @@
 
     KConfig theme (themeFilepath, KConfig::OnlyLocal);	// Read graphics config.
     KConfigGroup group = theme.group ("KDEGameTheme");
-    QString f = group.readEntry ("FileName", "");
 
     // Check if the theme asks us to draw our border, and set the specified
     // color
@@ -68,28 +66,37 @@
       m_textColor.setNamedColor(themeTextColor);
     }
 
+    QString f = group.readEntry ("Set", "");
     if (f.endsWith (".svg") || f.endsWith (".svgz")) {
 	// Load a SVG theme (KGoldrunner 3+ and KDE 4+).
-	filepathSVG = themeFilepath.left (themeFilepath.lastIndexOf("/")+1) + f;
-	if (! filepathSVG.isEmpty()) {
-	    svg.load (filepathSVG);
+	QString path = themeFilepath.left(themeFilepath.lastIndexOf("/") + 1) + f;
+	if (!path.isEmpty()) {
+	    svgSet.load(path);
 	    
-	    // The thema may have multiple backgrounds, called background0...backgroundN
-	    // or just one background, called background0 or simply background.
+	    // The theme may have multiple backgrounds, called
+	    // background0...backgroundN or just one background, called
+	    // background0 or simply background.
 	    QString backgroundPattern("background%1");
 	    numBackgrounds = 0;
-	    while (svg.elementExists(backgroundPattern.arg(numBackgrounds))) {
+	    while (svgSet.elementExists(backgroundPattern.arg(numBackgrounds))) {
 		++numBackgrounds;
 	    }
 	    if (numBackgrounds == 0) {
-		if (svg.elementExists("background")) {
+		if (svgSet.elementExists("background")) {
 		    numBackgrounds = 1;
 		}
 	    }
 	}
-	tileGraphics = SVG;
-	backgroundGraphics = SVG;
-	runnerGraphics = SVG;
+	f = group.readEntry ("Actors", "default/actors.svg");
+	if (f.endsWith (".svg") || f.endsWith (".svgz")) {
+	    QString path = themeFilepath.left(themeFilepath.lastIndexOf("/") + 1) + f;
+	    if (!path.isEmpty()) {
+		svgActors.load(path);
+	    }
+	    tileGraphics = SVG;
+	    backgroundGraphics = SVG;
+	    runnerGraphics = SVG;
+	}
     } else {
 	// Load a XPM theme (KGoldrunner 2 and KDE 3).
 	int colorIndex = group.readEntry ("ColorIndex", 0);
@@ -110,7 +117,6 @@
 
 QImage KGrTheme::background(unsigned int width, unsigned int height, unsigned int variant)
 {
-    kDebug() << "KGrTheme::background(" << width <<"," << height <<", "<< variant << ") called";
     if ((width != 0) && (height != 0) && 
 	    (backgroundGraphics == SVG) && numBackgrounds > 0) {
 	QImage background(width, height, QImage::Format_ARGB32_Premultiplied);
@@ -119,10 +125,10 @@
 	variant %= numBackgrounds;
 	QString backgroundName = "background%1";
 	kDebug() << "Trying to load background" << backgroundName.arg(variant);
-	if (svg.elementExists(backgroundName.arg(variant))) 
-	    svg.render(&painter, backgroundName.arg(variant));
-	else if (svg.elementExists("background")) 
-	    svg.render(&painter, "background");
+	if (svgSet.elementExists(backgroundName.arg(variant))) 
+	    svgSet.render(&painter, backgroundName.arg(variant));
+	else if (svgSet.elementExists("background")) 
+	    svgSet.render(&painter, "background");
 	return background;
     }
     return QImage();
@@ -159,7 +165,7 @@
     for (int i = 1; i <= nFrames; i++) {
 	QString s = elementPattern.arg(i);	// e.g. "hero_1", "hero_2", etc.
 	img.fill (0);
-	svg.render (&q, s);
+	svgActors.render (&q, s);
 	frames.append (QPixmap::fromImage (img));
     }
     return frames;
@@ -180,7 +186,7 @@
 QPixmap KGrTheme::svgTile (QImage & img, QPainter & q, const QString & name)
 {
     img.fill (0);
-    svg.render (&q, name);
+    svgSet.render (&q, name);
     return QPixmap::fromImage (img);
 }
 
--- trunk/KDE/kdegames/kgoldrunner/src/kgrtheme.h #698125:698126
@@ -57,11 +57,11 @@
     
     QColor textColor() { return m_textColor; }
 private:
-    KSvgRenderer svg;
+    KSvgRenderer svgSet;
+    KSvgRenderer svgActors;
     QColor m_borderColor, m_textColor;	// Border colours.
 
     QString themeDataDir;
-    QString filepathSVG;
     QString m_themeFilepath;
     short themeDrawBorder;
     void changeColors (const char * colours []);
--- trunk/KDE/kdegames/kgoldrunner/themes/CMakeLists.txt #698125:698126
@@ -12,9 +12,9 @@
                midnight.desktop
                DESTINATION ${DATA_INSTALL_DIR}/kgoldrunner/themes )
 
-install( FILES default/kgr_default.svg
+install( FILES default/set.svg default/actors.svg
                DESTINATION ${DATA_INSTALL_DIR}/kgoldrunner/themes/default )
 
-install( FILES kgr_geek/kgr_geek.svgz
+install( FILES kgr_geek/set.svgz kgr_geek/actors.svgz
                DESTINATION ${DATA_INSTALL_DIR}/kgoldrunner/themes/kgr_geek )
 
--- trunk/KDE/kdegames/kgoldrunner/themes/default.desktop #698125:698126
@@ -21,7 +21,8 @@
 Description[x-test]=xxA light and clean theme for KDE4xx
 Description[zh_TW]=簡單又乾淨的 KDE 主題
 Author=Mauricio Piacentini
-FileName=default/kgr_default.svg
+Set=default/set.svg
+Actors=default/actors.svg
 DrawCanvasBorder=1
 BorderColor=#2C89A0
 TextColor=#FFFFFF
--- trunk/KDE/kdegames/kgoldrunner/themes/kgr_geek.desktop #698125:698126
@@ -15,7 +15,8 @@
 Description[sv]=Hjälten är fångad i en dator
 Description[zh_TW]=英雄被困在電腦裡面。
 Author=Eugene Trounev and Mauricio Piacentini
-FileName=kgr_geek/kgr_geek.svgz
+Set=kgr_geek/set.svgz
+Actors=kgr_geek/actors.svgz
 DrawCanvasBorder=1
 BorderColor=#687D54
 TextColor=#FFFFFF
** trunk/KDE/kdegames/kgoldrunner/themes/kgr_geek/actors.svgz #property svn:mime-type
   + application/octet-stream
** trunk/KDE/kdegames/kgoldrunner/themes/kgr_geek/set.svgz #property svn:mime-type
   + application/octet-stream


More information about the kde-games-devel mailing list