From 79f95a1996d9afc7cd52d7673065cdf026d04af6 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Sat, 17 Oct 2009 02:33:46 +0000 Subject: Skip full flipping animation if second speaking card is correct --- diff --git a/cardtable.py b/cardtable.py index 0a39a62..1f251e2 100644 --- a/cardtable.py +++ b/cardtable.py @@ -226,8 +226,8 @@ class CardTable(gtk.EventBox): def flop_card(self, widget, identifer): self.id2cd.get(identifer).flop() - def flip_card(self, widget, identifer): - self.id2cd.get(identifer).flip() + def flip_card(self, widget, identifer, full_animation): + self.id2cd.get(identifer).flip(full_animation) def cement_card(self, widget, identifer): self.id2cd.get(identifer).cement() diff --git a/game.py b/game.py index e94cda7..4c4b04d 100644 --- a/game.py +++ b/game.py @@ -44,7 +44,7 @@ class MemorizeGame(GObject): 'change_game': (SIGNAL_RUN_FIRST, None, 2 * [TYPE_PYOBJECT]), 'change_game_signal': (SIGNAL_RUN_FIRST, None, 5 * [TYPE_PYOBJECT]), 'set-border': (SIGNAL_RUN_FIRST, None, 3 * [TYPE_PYOBJECT]), - 'flip-card': (SIGNAL_RUN_FIRST, None, [int]), + 'flip-card': (SIGNAL_RUN_FIRST, None, [int, bool]), 'flip-card-signal': (SIGNAL_RUN_FIRST, None, [int]), 'cement-card': (SIGNAL_RUN_FIRST, None, [int]), 'flop-card': (SIGNAL_RUN_FIRST, None, [int]), @@ -112,11 +112,11 @@ class MemorizeGame(GObject): for card in self.model.grid: if card['state'] == '1': - self.emit('flip-card', self.model.grid.index(card)) + self.emit('flip-card', self.model.grid.index(card), False) self.last_flipped = self.model.grid.index(card) elif card['state'] != '0': stroke_color, fill_color = card['state'].split(',') - self.emit('flip-card', self.model.grid.index(card)) + self.emit('flip-card', self.model.grid.index(card), False) self.emit('set-border', self.model.grid.index(card), stroke_color, fill_color) @@ -194,17 +194,20 @@ class MemorizeGame(GObject): self.model.data['running'] = 'True' + def flip_card(full_animation): + self.emit('flip-card', identifier, full_animation) + if not signal: + self.emit('flip-card-signal', identifier) + snd = self.model.grid[identifier].get('snd', None) if snd != None: sound_file = join(self.model.data.get('pathsnd'), snd) self.audio.play(sound_file) - self.emit('flip-card', identifier) - if not signal: - self.emit('flip-card-signal', identifier) - # First card case if self.last_flipped == -1: + flip_card(full_animation=True) + self.last_flipped = identifier self.model.grid[identifier]['state'] = '1' self.flip_block = False @@ -216,6 +219,8 @@ class MemorizeGame(GObject): pair_key_2 = self.model.grid[identifier]['pairkey'] if pair_key_1 == pair_key_2: + flip_card(full_animation=False) + stroke_color, fill_color = \ self.current_player.props.color.split(',') self.emit('set-border', identifier, stroke_color, fill_color) @@ -234,6 +239,8 @@ class MemorizeGame(GObject): # Pair didn't match else: + flip_card(full_animation=True) + self.model.grid[identifier]['state'] = '1' self.set_sensitive(False) self._flop_cards = (identifier, self.last_flipped) diff --git a/playerscoreboard.py b/playerscoreboard.py index 832c4d9..99b11bb 100644 --- a/playerscoreboard.py +++ b/playerscoreboard.py @@ -113,6 +113,9 @@ class PlayerScoreboard(gtk.EventBox): score_label = Score(self.fill_color, self.stroke_color) score_pixbuf_unsel = score_label.get_pixbuf() score_pixbuf_sel = score_label.get_pixbuf_sel() + else: + score_pixbuf_unsel = None + score_pixbuf_sel = None new_score = Score(self.fill_color, self.stroke_color, score_pixbuf_sel, score_pixbuf_unsel, self.status) diff --git a/svgcard.py b/svgcard.py index 5090f84..d408ca6 100644 --- a/svgcard.py +++ b/svgcard.py @@ -201,7 +201,7 @@ class SvgCard(gtk.EventBox): self.current_face = 'back' self.queue_draw() - def flip(self): + def flip(self, full_animation=False): if self.flipped: return @@ -226,13 +226,14 @@ class SvgCard(gtk.EventBox): else: self.show_text = False - if self.id != -1 and self.get_speak(): - speaking_face = face.acquire() - if speaking_face: - self._switch_to_face(speaking_face) - speaking_face.face.status.voice = \ - speak.voice.by_name(self.get_speak()) - speaking_face.face.say(self.get_text()) + if full_animation: + if self.id != -1 and self.get_speak(): + speaking_face = face.acquire() + if speaking_face: + self._switch_to_face(speaking_face) + speaking_face.face.status.voice = \ + speak.voice.by_name(self.get_speak()) + speaking_face.face.say(self.get_text()) self.current_face = 'front' self.flipped = True -- cgit v0.9.1