summaryrefslogtreecommitdiff
path: root/asciifarm/client/display/inventorypad.py
diff options
context:
space:
mode:
authortroido <troido@hotmail.com>2017-11-13 13:37:05 +0100
committertroido <troido@hotmail.com>2017-11-13 13:37:05 +0100
commit227f266df78b143b0c5dd2c7f498b755199707eb (patch)
tree9af5dac95f684e79d04fcc96b03dc81689dff78a /asciifarm/client/display/inventorypad.py
parent336f6f873c52ef62e2f304436b381c166eac872f (diff)
display parts now use windows as arguments
Diffstat (limited to 'asciifarm/client/display/inventorypad.py')
-rw-r--r--asciifarm/client/display/inventorypad.py39
1 files changed, 22 insertions, 17 deletions
diff --git a/asciifarm/client/display/inventorypad.py b/asciifarm/client/display/inventorypad.py
index f10b138..8ef3296 100644
--- a/asciifarm/client/display/inventorypad.py
+++ b/asciifarm/client/display/inventorypad.py
@@ -5,32 +5,37 @@ class InventoryPad:
def __init__(self, title, maxItems=20):
self.title = title
- self.maxItems = maxItems
- self.pad = curses.newpad(maxItems+2, 100)
+ #self.maxItems = maxItems
+ #self.pad = curses.newpad(maxItems+2, 100)
self.setInventory([])
self.changed = False
- self.lastView = None
+ #self.lastView = None
def setInventory(self, items):
self.items = items
- self.pad.erase()
- self.pad.addstr(0,0, self.title + ":\n")
- for i, item in enumerate(items[:self.maxItems]):
- self.pad.addstr(i+1, 2, item)
+ #self.pad.erase()
+ #self.pad.addstr(0,0, self.title + ":\n")
+ #for i, item in enumerate(items[:self.maxItems]):
+ #self.pad.addstr(i+1, 2, item)
self.changed = True
def getHeight(self):
return self.maxItems+2
- 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 or not win:
return
- self.lastView = (x, y, xmax, ymax)
+ #self.lastView = (x, y, xmax, ymax)
self.changed = False
- self.pad.noutrefresh(
- 0,
- 0,
- y,
- x,
- ymax-1,
- xmax-1)
+ height, width = win.getmaxyx()
+ win.erase()
+ win.addstr(0,0, self.title + ":\n")
+ for i, item in enumerate(self.items[:height-1]):
+ win.addstr(i+1, 2, item)
+ win.noutrefresh()
+ #0,
+ #0,
+ #y,
+ #x,
+ #ymax-1,
+ #xmax-1)