Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/implodegame.py
diff options
context:
space:
mode:
authorJoe Lee <joe@jotaro.com>2008-03-30 05:00:51 (GMT)
committer Joe Lee <joe@jotaro.com>2008-03-30 05:00:51 (GMT)
commit26cd1b9ec3da1186a2c6157c128cf19851b97099 (patch)
treee729b16ca45f87ba592f70886cba4258d0b9234f /implodegame.py
parentd24881f4add199245a25f1794c1df8fe885d7ffc (diff)
Added initial gamepad/keyboard support.
Diffstat (limited to 'implodegame.py')
-rw-r--r--implodegame.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/implodegame.py b/implodegame.py
index c3b2c9a..93409db 100644
--- a/implodegame.py
+++ b/implodegame.py
@@ -73,10 +73,17 @@ class ImplodeGame(gtk.EventBox):
self._grid = gridwidget.GridWidget()
self._grid.connect('piece-selected', self._piece_selected_cb)
+ self._grid.connect('undo-key-pressed', self._undo_key_pressed_cb)
+ self._grid.connect('redo-key-pressed', self._redo_key_pressed_cb)
+ self._grid.connect('new-key-pressed', self._new_key_pressed_cb)
self.add(self._grid)
self.new_game()
+ def grab_focus(self):
+ self._grid.grab_focus()
+ self._grid.select_center_cell()
+
def new_game(self):
_logger.debug('New game.')
self._finish_animation()
@@ -150,6 +157,18 @@ class ImplodeGame(gtk.EventBox):
self._end_anim_func = self._end_removal_animation
gobject.timeout_add(_TIMER_INTERVAL, self._removal_timer)
+ def _undo_key_pressed_cb(self, widget, dummy):
+ self.undo()
+
+ def _redo_key_pressed_cb(self, widget, dummy):
+ self.redo()
+
+ def _new_key_pressed_cb(self, widget, dummy):
+ # Only invoke new command via game pad if board is clear, to prevent
+ # terrible accidents.
+ if self._board.is_empty():
+ self.new_game()
+
def _finish_animation(self):
if self._end_anim_func:
temp_animate = self._animate