Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2014-07-21 18:11:08 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2014-07-21 18:11:08 (GMT)
commit9afa34c5978b650f54a7914f35687195f58009be (patch)
treed1370df0d898ceb653dc5e763cd99c84c0ad7de3
parent62e694366d09cdbd591bf2818b00315dcbee62a1 (diff)
Reset the game when the creen is rotated
When the screen is rotated, we need reload the cards in the table game, to resize images if needed. This patch reset values in the game too. In particular set last_flipped = -1, we need check if something more is needed.
-rw-r--r--activity.py6
-rw-r--r--cardtable.py5
2 files changed, 10 insertions, 1 deletions
diff --git a/activity.py b/activity.py
index c18e5dc..87a9142 100644
--- a/activity.py
+++ b/activity.py
@@ -141,6 +141,7 @@ class MemorizeActivity(Activity):
self.connect('key-press-event', self.table.key_press_event)
self.table.connect('card-flipped', self.game.card_flipped)
self.table.connect('card-highlighted', self.game.card_highlighted)
+ self.table.connect('resize-table', self.__resize_table_cb)
self.game.connect('set-border', self.table.set_border)
self.game.connect('flop-card', self.table.flop_card)
@@ -238,6 +239,11 @@ class MemorizeActivity(Activity):
self.table.resize(width, height - style.GRID_CELL_SIZE)
self.show_all()
+ def __resize_table_cb(self, widget):
+ # need reset the game
+ # because we reload the cards in the table
+ self.game.last_flipped = -1
+
def _change_mode_bt(self, button):
if button.get_active():
self._change_mode(_MODE_CREATE)
diff --git a/cardtable.py b/cardtable.py
index ad292bc..b2afd5c 100644
--- a/cardtable.py
+++ b/cardtable.py
@@ -37,7 +37,9 @@ class CardTable(Gtk.EventBox):
'card-flipped': (GObject.SignalFlags.RUN_FIRST,
None, [int, GObject.TYPE_PYOBJECT]),
'card-highlighted': (GObject.SignalFlags.RUN_FIRST,
- None, [int, GObject.TYPE_PYOBJECT]), }
+ None, [int, GObject.TYPE_PYOBJECT]),
+ 'resize-table': (GObject.SignalFlags.RUN_FIRST,
+ None, []), }
def __init__(self):
Gtk.EventBox.__init__(self)
@@ -82,6 +84,7 @@ class CardTable(Gtk.EventBox):
self.change_game(None, self.data, self.cards_data)
else:
self.load_game(None, self.data, self.cards_data)
+ self.emit('resize-table')
def _allocate_cb(self, widget, allocation):
size = allocation.height