changed colours to work better with 8-colour terminals and update screen before each wait (so also with each keypress)
This commit is contained in:
parent
d880939711
commit
b6b6a2c5f6
|
@ -4,7 +4,7 @@
|
|||
"tree": ["T",0,2],
|
||||
"wall": ["#",7,8],
|
||||
"builtwall": ["+",7,8],
|
||||
"rock": [" ",7,8],
|
||||
"rock": ["#",8,8],
|
||||
"stone": ["o",7],
|
||||
"pebble": ["*",7],
|
||||
"player": ["@",15],
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"tree": ["T", 0, 2],
|
||||
"wall": ["#", 7, 8],
|
||||
"builtwall": ["+", 7, 8],
|
||||
"rock": [" ", 7, 8],
|
||||
"rock": ["#", 8, 8],
|
||||
"stone": ["o", 7],
|
||||
"pebble": ["*", 7],
|
||||
"player": ["@", 15],
|
||||
|
|
|
@ -13,9 +13,20 @@ class Colours:
|
|||
curses.init_pair(i, i%self.colours, i//self.colours)
|
||||
|
||||
def get(self, fg=0, bg=0):
|
||||
dfg = fg % self.colours
|
||||
dbg = bg % self.colours
|
||||
if (dfg, dbg) == (0, 0) and (fg, bg) != (0, 0):
|
||||
# avoid unintended use of (0,0), which is settings dependent
|
||||
dfg, dbg = 7, 0
|
||||
return curses.color_pair(dfg + dbg*self.colours)
|
||||
if self.colours == 16:
|
||||
return curses.color_pair(fg + bg*self.colours)
|
||||
elif self.colours == 8:
|
||||
dfg = fg % 8
|
||||
dbg = bg % 8
|
||||
if bg == 8:
|
||||
dbg = 7
|
||||
if fg == 8:
|
||||
dfg = 7
|
||||
colour = curses.color_pair(dfg + dbg*self.colours)
|
||||
if fg >= 8 and bg < 8:
|
||||
colour |= curses.A_BOLD
|
||||
elif fg < 8 and bg >= 8:
|
||||
colour |= curses.A_DIM
|
||||
return colour
|
||||
else:
|
||||
return curses.color_pair(0)
|
||||
|
|
|
@ -119,7 +119,6 @@ class Client:
|
|||
for option in options:
|
||||
self.log(option)
|
||||
|
||||
self.display.update()
|
||||
|
||||
def log(self, text, type=None):
|
||||
if not isinstance(text, str):
|
||||
|
@ -132,6 +131,7 @@ class Client:
|
|||
|
||||
def command_loop(self):
|
||||
while self.keepalive:
|
||||
self.display.update()
|
||||
action = self.queue.get()
|
||||
if action[0] == "message":
|
||||
self.update(action[1])
|
||||
|
|
Loading…
Reference in New Issue