summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortroido <troido@hotmail.com>2017-11-06 21:12:10 +0100
committertroido <troido@hotmail.com>2017-11-06 21:12:10 +0100
commit07250230943a5fdfd7961063478523ee948710f4 (patch)
treeebec70993152b583485fad9687ccf3d89349bd40
parent47b57891ef4940a6fa2047345e092ba2f00cd1ba (diff)
changed ui places for inventory and ground. fixed bug where small screens would crash game
-rw-r--r--asciifarm/client/display/__init__.py14
-rw-r--r--asciifarm/client/display/fieldpad.py2
-rw-r--r--asciifarm/client/display/healthpad.py2
-rw-r--r--asciifarm/client/display/infopad.py2
-rw-r--r--asciifarm/client/display/inventorypad.py4
-rw-r--r--asciifarm/client/display/messagepad.py6
6 files changed, 15 insertions, 15 deletions
diff --git a/asciifarm/client/display/__init__.py b/asciifarm/client/display/__init__.py
index 870571e..ea86557 100644
--- a/asciifarm/client/display/__init__.py
+++ b/asciifarm/client/display/__init__.py
@@ -30,8 +30,8 @@ class Display:
charMap.get("healthfull", ("@",7, 2)),
charMap.get("healthempty", ("-",7, 1)),
self.colours)
- self.inventoryPad = InventoryPad("Inventory", 16)
- self.groundPad = InventoryPad("Ground", 8)
+ self.inventoryPad = InventoryPad("Inventory", 10)
+ self.groundPad = InventoryPad("Ground", 5)
self.lastinfostring = None
self.changed = False
self.messagePad = messagepad.MessagePad(5)
@@ -86,14 +86,14 @@ class Display:
fieldRight = min(self.fieldPad.getWidth(), self.screen.getWidth()-SIDEWIDTH-1)
fieldBottom = min(self.fieldPad.getHeight(), self.screen.getHeight()-self.messagePad.getHeight())
healthBottom = self.healthPad.getHeight()
- inventoryBottom = healthBottom + self.inventoryPad.getHeight()
- groundBottom = inventoryBottom + self.groundPad.getHeight()
+ groundBottom = healthBottom + self.groundPad.getHeight()
+ inventoryBottom = groundBottom + self.inventoryPad.getHeight()
self.fieldPad.update(self, 0,0,fieldRight, fieldBottom)
self.messagePad.update(self, 0,fieldBottom, fieldRight, min(self.screen.getHeight(), fieldBottom+self.messagePad.getHeight()))
self.healthPad.update(self, fieldRight+1,0, self.screen.getWidth(), healthBottom)
- self.inventoryPad.update(self, fieldRight+1, healthBottom, self.screen.getWidth(), min(self.screen.getHeight(), inventoryBottom))
- self.groundPad.update(self, fieldRight+1, inventoryBottom, self.screen.getWidth(), min(self.screen.getHeight(), groundBottom))
- self.infoPad.update(self, fieldRight+1,groundBottom+1, self.screen.getWidth(), self.screen.getHeight())
+ self.groundPad.update(self, fieldRight+1, healthBottom, self.screen.getWidth(), min(self.screen.getHeight(), groundBottom))
+ self.inventoryPad.update(self, fieldRight+1, groundBottom, self.screen.getWidth(), min(self.screen.getHeight(), inventoryBottom))
+ self.infoPad.update(self, fieldRight+1,inventoryBottom+1, self.screen.getWidth(), self.screen.getHeight())
curses.doupdate()
self.changed = False
diff --git a/asciifarm/client/display/fieldpad.py b/asciifarm/client/display/fieldpad.py
index 8d177d5..3196eff 100644
--- a/asciifarm/client/display/fieldpad.py
+++ b/asciifarm/client/display/fieldpad.py
@@ -36,7 +36,7 @@ class FieldPad:
return self.size[1]
def update(self, screen, x, y, xmax, ymax):
- if not self.changed and (x, y, xmax, ymax) == self.lastView:
+ if not self.changed and (x, y, xmax, ymax) == self.lastView or xmax <= x or ymax <= y:
return
self.lastView = (x, y, xmax, ymax)
self.changed = False
diff --git a/asciifarm/client/display/healthpad.py b/asciifarm/client/display/healthpad.py
index 8c7a9b1..3e0a09d 100644
--- a/asciifarm/client/display/healthpad.py
+++ b/asciifarm/client/display/healthpad.py
@@ -29,7 +29,7 @@ class HealthPad:
return 2
def update(self, screen, x, y, xmax, ymax):
- if not self.changed and (x, y, xmax, ymax) == self.lastView:
+ if not self.changed and (x, y, xmax, ymax) == self.lastView or xmax <= x or ymax <= y:
return
self.lastView = (x, y, xmax, ymax)
self.changed = False
diff --git a/asciifarm/client/display/infopad.py b/asciifarm/client/display/infopad.py
index 6de3692..b3d900e 100644
--- a/asciifarm/client/display/infopad.py
+++ b/asciifarm/client/display/infopad.py
@@ -19,7 +19,7 @@ class InfoPad:
self.changed = True
def update(self, screen, x, y, xmax, ymax):
- if not self.changed and (x, y, xmax, ymax) == self.lastView:
+ if not self.changed and (x, y, xmax, ymax) == self.lastView or xmax <= x or ymax <= y:
return
self.lastView = (x, y, xmax, ymax)
self.changed = False
diff --git a/asciifarm/client/display/inventorypad.py b/asciifarm/client/display/inventorypad.py
index 0b3bdf9..e81f9de 100644
--- a/asciifarm/client/display/inventorypad.py
+++ b/asciifarm/client/display/inventorypad.py
@@ -20,10 +20,10 @@ class InventoryPad:
self.changed = True
def getHeight(self):
- return len(self.items)+2
+ return self.maxItems+2
def update(self, screen, x, y, xmax, ymax):
- if not self.changed and (x, y, xmax, ymax) == self.lastView:
+ if not self.changed and (x, y, xmax, ymax) == self.lastView or xmax <= x or ymax <= y:
return
self.lastView = (x, y, xmax, ymax)
self.changed = False
diff --git a/asciifarm/client/display/messagepad.py b/asciifarm/client/display/messagepad.py
index 50d34f5..ab3afab 100644
--- a/asciifarm/client/display/messagepad.py
+++ b/asciifarm/client/display/messagepad.py
@@ -2,7 +2,7 @@
import curses
import textwrap
-class MessagePad:
+class MessagePad():
def __init__(self, maxLines=10):
self.maxLines = maxLines
@@ -16,10 +16,10 @@ class MessagePad:
self.changed = True
def getHeight(self):
- return min(len(self.messages), self.maxLines)
+ return self.maxLines
def update(self, screen, x, y, xmax, ymax):
- if not self.changed and (x, y, xmax, ymax) == self.lastView :
+ if not self.changed and (x, y, xmax, ymax) == self.lastView or xmax <= x or ymax <= y:
return
width = xmax - x
height = ymax - y # should equal self.getHeight()