From afbf383db4d91d8cfdbb3ce58b5bda63a7d432d2 Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 25 Nov 2008 19:38:02 +0100 Subject: [PATCH] proper handling for zoomin/zoomout keypress --- hr.py | 1 - lib/mapview.py | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hr.py b/hr.py index c6ffda3..4762734 100644 --- a/hr.py +++ b/hr.py @@ -43,7 +43,6 @@ class LoadScreen(object): self.window.push_handlers(renderer) self.window.push_handlers(mapview) self.window.push_handlers(interface) - self.window.push_handlers(self.window.keys) if __name__ == '__main__': if len(sys.argv) < 2: diff --git a/lib/mapview.py b/lib/mapview.py index a729624..4437102 100644 --- a/lib/mapview.py +++ b/lib/mapview.py @@ -249,6 +249,14 @@ class MapView(object): for i, atlas in enumerate(self.mapset.atlases): self.cur_objects[i] = list(set(self.cur_objects[i])) + def on_key_press(self, symbol, modifiers): + if symbol == pyglet.window.key.PLUS and self.tile_size < 32: + self.tile_size+=8 + self._init_view() + elif symbol == pyglet.window.key.MINUS and self.tile_size > 16: + self.tile_size-=8 + self._init_view() + def update(self, dt): try: if self.window.keys[pyglet.window.key.LCTRL] and \ @@ -272,14 +280,6 @@ class MapView(object): y = 0 self.dx += x*8 self.dy += y*8 - elif self.window.keys[pyglet.window.key.PLUS] and \ - self.tile_size < 32: - self.tile_size+=8 - self._init_view() - elif self.window.keys[pyglet.window.key.MINUS] and \ - self.tile_size > 16: - self.tile_size-=8 - self._init_view() except KeyError: pass if self.dx or self.dy: