From 227f266df78b143b0c5dd2c7f498b755199707eb Mon Sep 17 00:00:00 2001 From: troido Date: Mon, 13 Nov 2017 13:37:05 +0100 Subject: display parts now use windows as arguments --- asciifarm/client/display/fieldpad.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'asciifarm/client/display/fieldpad.py') diff --git a/asciifarm/client/display/fieldpad.py b/asciifarm/client/display/fieldpad.py index 9be20e5..1966611 100644 --- a/asciifarm/client/display/fieldpad.py +++ b/asciifarm/client/display/fieldpad.py @@ -13,7 +13,7 @@ class FieldPad: self.center = (0, 0) self.colours = colours self.changed = False - self.lastView = None + #self.lastView = None def resize(self, width, height): self.size = (width, height) @@ -35,22 +35,24 @@ class FieldPad: def getHeight(self): return self.size[1] - def roundWidth(self, x): + def _roundWidth(self, x): return x // self.charSize * self.charSize - def update(self, screen, x, y, xmax, ymax, force=False): - if not self.changed and (x, y, xmax, ymax) == self.lastView or xmax <= x or ymax <= y and not force: + def update(self, win, force=False): + if not self.changed and not force: return - self.lastView = (x, y, xmax, ymax) - self.changed = False - width = xmax-x - height = ymax-y + #self.lastView = (x, y, xmax, ymax) + height, width = win.getmaxyx() + y, x = win.getparyx() + xmax = x + width + ymax = y + height self.pad.noutrefresh( max(0, min(self.getHeight()-height, self.center[1] - int(height/2))), max(0, min( - self.roundWidth(self.getWidth()-width), - self.roundWidth(self.center[0]*self.charSize - int(width/2)))), + self._roundWidth(self.getWidth()-width), + self._roundWidth(self.center[0]*self.charSize - int(width/2)))), y, x, - ymax-1, - xmax-1) + ymax, + xmax) + self.changed = False -- cgit