Redraw map on key press

This commit is contained in:
Joscha 2017-04-06 07:32:40 +00:00
parent 9f02d63a7d
commit 7b5458e1d5
2 changed files with 9 additions and 3 deletions

View file

@ -44,6 +44,7 @@ class Client():
i = scr.getkey() i = scr.getkey()
if i == "q": self.stop() if i == "q": self.stop()
elif i == "r": self.map_.redraw()
# normal cursor movement # normal cursor movement
elif i == "KEY_UP": self.map_.move_cursor(0, -1) elif i == "KEY_UP": self.map_.move_cursor(0, -1)
elif i == "KEY_DOWN": self.map_.move_cursor(0, 1) elif i == "KEY_DOWN": self.map_.move_cursor(0, 1)

View file

@ -34,6 +34,11 @@ class Map():
def __exit__(self, type, value, tb): def __exit__(self, type, value, tb):
self._lock.release() self._lock.release()
def redraw(self):
self._pad.redrawwin()
self.drawevent.set()
def draw(self): def draw(self):
with self.chunkpool as pool: with self.chunkpool as pool:
for x in range(chunkx(self.width) + 2): # +2, not +1, or there will be empty gaps for x in range(chunkx(self.width) + 2): # +2, not +1, or there will be empty gaps