summaryrefslogtreecommitdiff
path: root/asciifarm/client/display/healthpad.py
diff options
context:
space:
mode:
Diffstat (limited to 'asciifarm/client/display/healthpad.py')
-rw-r--r--asciifarm/client/display/healthpad.py59
1 files changed, 35 insertions, 24 deletions
diff --git a/asciifarm/client/display/healthpad.py b/asciifarm/client/display/healthpad.py
index 502559a..2ca0a89 100644
--- a/asciifarm/client/display/healthpad.py
+++ b/asciifarm/client/display/healthpad.py
@@ -6,10 +6,10 @@ class HealthPad:
def __init__(self, width=1, char=('@',7,0), emptyChar=('-',7,0), colours=False):
self.char = char
self.emptyChar = emptyChar
- self.pad = curses.newpad(2, width+1)
- self.width = width
+ #self.pad = curses.newpad(2, width+1)
+ #self.width = width
self.changed = False
- self.lastView = None
+ #self.lastView = None
self.colours = colours
self.health = 0
self.maxHealth = 0
@@ -19,30 +19,41 @@ class HealthPad:
self.maxHealth = maxHealth
- self.pad.erase()
- barEnd = round(health/maxHealth * self.width)
- self.pad.addstr(0,0,"Health: {}/{}".format(health, maxHealth)[:self.width])
- if self.colours:
- self.pad.addstr(1,0, self.char[0]*barEnd, self.colours.get(*self.char[1:]))
- self.pad.addstr(1,barEnd, self.emptyChar[0]*(self.width-barEnd), self.colours.get(*self.emptyChar[1:]))
- else:
- self.pad.addstr(1,0, self.char[0]*barEnd)
- self.pad.addstr(1,barEnd, self.emptyChar[0]*(self.width-barEnd))
+ #self.pad.erase()
+ #barEnd = round(health/maxHealth * self.width)
+ #self.pad.addstr(0,0,"Health: {}/{}".format(health, maxHealth)[:self.width])
+ #if self.colours:
+ #self.pad.addstr(1,0, self.char[0]*barEnd, self.colours.get(*self.char[1:]))
+ #self.pad.addstr(1,barEnd, self.emptyChar[0]*(self.width-barEnd), self.colours.get(*self.emptyChar[1:]))
+ #else:
+ #self.pad.addstr(1,0, self.char[0]*barEnd)
+ #self.pad.addstr(1,barEnd, self.emptyChar[0]*(self.width-barEnd))
self.changed = True
- def getHeight(self):
- return 2
+ #def getHeight(self):
+ #return 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:
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()
+ width -= 1
+ barEnd = round(self.health/self.maxHealth * width)
+ win.erase()
+ win.addstr(0,0,"Health: {}/{}".format(self.health, self.maxHealth)[:width])
+ if self.colours:
+ win.addstr(1,0, self.char[0]*barEnd, self.colours.get(*self.char[1:]))
+ win.addstr(1,barEnd, self.emptyChar[0]*(width-barEnd), self.colours.get(*self.emptyChar[1:]))
+ else:
+ win.addstr(1,0, self.char[0]*barEnd)
+ win.addstr(1,barEnd, self.emptyChar[0]*(width-barEnd))
+ win.noutrefresh()
+ #0,
+ #0,
+ #y,
+ #x,
+ #ymax-1,
+ #xmax-1)