Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/chess.py
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-07-23 03:33:38 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-07-23 03:33:38 (GMT)
commit088232d0f39d3ffea673b1ed8dd3baa2067e9923 (patch)
tree86dc55f77203b83e7cd1e39c0236ea91c805d017 /chess.py
parent4147633d7caef21ce8b291803ce5839177876ed9 (diff)
add reskinning
Diffstat (limited to 'chess.py')
-rw-r--r--chess.py43
1 files changed, 31 insertions, 12 deletions
diff --git a/chess.py b/chess.py
index 5bcb04e..14fe7a7 100644
--- a/chess.py
+++ b/chess.py
@@ -504,6 +504,25 @@ class Gnuchess():
def _destroy_cb(self, win, event):
gtk.main_quit()
+ def reskin(self, piece, file_path):
+ DICT = {'white-pawn': WP, 'black-pawn': BP,
+ 'white-rook': WR, 'black-rook': BR,
+ 'white-knight': WN, 'black-knight': BN,
+ 'white-bishop': WB, 'black-bishop': BB,
+ 'white-queen': WQ, 'black-queen': BQ,
+ 'white-king': WK, 'black-king': BK}
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
+ file_path, self._scale, self._scale)
+ self.skins[DICT[piece]] = pixbuf
+ if piece == 'white-pawn':
+ for i in range(8):
+ self.white[i + 8].set_image(pixbuf)
+ elif piece == 'black-pawn':
+ for i in range(8):
+ self.black[i + 8].set_image(pixbuf)
+ else:
+ _logger.debug('FIXME')
+
def _generate_sprites(self, colors):
bg = Sprite(self._sprites, 0, 0, self._box(self._width, self._height,
color=colors[1]))
@@ -537,29 +556,29 @@ class Gnuchess():
y += self._scale
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
- 'images/WP.png', w, h))
+ '%s/icons/white-pawn.svg' % (self._bundle_path), w, h))
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
- 'images/BP.png', w, h))
+ '%s/icons/black-pawn.svg' % (self._bundle_path), w, h))
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
- 'images/WR.png', w, h))
+ '%s/icons/white-rook.svg' % (self._bundle_path), w, h))
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
- 'images/BR.png', w, h))
+ '%s/icons/black-rook.svg' % (self._bundle_path), w, h))
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
- 'images/WN.png', w, h))
+ '%s/icons/white-knight.svg' % (self._bundle_path), w, h))
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
- 'images/BN.png', w, h))
+ '%s/icons/black-knight.svg' % (self._bundle_path), w, h))
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
- 'images/WB.png', w, h))
+ '%s/icons/white-bishop.svg' % (self._bundle_path), w, h))
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
- 'images/BB.png', w, h))
+ '%s/icons/black-bishop.svg' % (self._bundle_path), w, h))
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
- 'images/WQ.png', w, h))
+ '%s/icons/white-queen.svg' % (self._bundle_path), w, h))
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
- 'images/BQ.png', w, h))
+ '%s/icons/black-queen.svg' % (self._bundle_path), w, h))
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
- 'images/WK.png', w, h))
+ '%s/icons/white-king.svg' % (self._bundle_path), w, h))
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
- 'images/BK.png', w, h))
+ '%s/icons/black-king.svg' % (self._bundle_path), w, h))
self.white.append(Sprite(self._sprites, 0, 0, self.skins[WR]))
self.white[-1].type = 'R'