From 7b5458e1d55c0c39da9ce826eee3f9b965a58ad9 Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 6 Apr 2017 07:32:40 +0000 Subject: [PATCH] Redraw map on key press --- client.py | 7 ++++--- maps.py | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/client.py b/client.py index 58c72c6..72e60be 100644 --- a/client.py +++ b/client.py @@ -43,7 +43,8 @@ class Client(): while True: i = scr.getkey() - if i == "q": self.stop() + if i == "q": self.stop() + elif i == "r": self.map_.redraw() # normal cursor movement elif i == "KEY_UP": self.map_.move_cursor(0, -1) elif i == "KEY_DOWN": self.map_.move_cursor(0, 1) @@ -55,8 +56,8 @@ class Client(): elif i == "KEY_SLEFT": self.map_.move_cursor(-10, 0) elif i == "KEY_SRIGHT": self.map_.move_cursor(10, 0) # scrolling the map (10 vertical, 20 horizontal) - elif i == "kUP5": self.map_.scroll(0, -10) - elif i == "kDN5": self.map_.scroll(0, 10) + elif i == "kUP5": self.map_.scroll(0, -10) + elif i == "kDN5": self.map_.scroll(0, 10) elif i == "kLFT5": self.map_.scroll(-20, 0) elif i == "kRIT5": self.map_.scroll(20, 0) diff --git a/maps.py b/maps.py index 08e768a..1915d5c 100644 --- a/maps.py +++ b/maps.py @@ -34,6 +34,11 @@ class Map(): def __exit__(self, type, value, tb): self._lock.release() + def redraw(self): + self._pad.redrawwin() + + self.drawevent.set() + def draw(self): with self.chunkpool as pool: for x in range(chunkx(self.width) + 2): # +2, not +1, or there will be empty gaps