Fixed color clearing ANSI codes still appearing when colors are off
This commit is contained in:
parent
ab5d01908e
commit
e96bdfaead
2 changed files with 36 additions and 32 deletions
16
gameshell.py
16
gameshell.py
|
@ -23,7 +23,7 @@ class GameShell(Shell):
|
|||
super(GameShell, self).__init__()
|
||||
self.outstream = _sys.stdout
|
||||
self.gameBase = gameBase
|
||||
self.colorMode = 24
|
||||
self.colorMode = 0
|
||||
|
||||
# register functions
|
||||
|
||||
|
@ -117,7 +117,7 @@ If -l is given, a map legend will be printed under the map."""
|
|||
textColor = level.wallColors[0]
|
||||
floorColor = level.floorColors[0]
|
||||
for y in range(level.dimensions[1]):
|
||||
rows.append(['\x1b[0m{0:2} {1}{2}'.format(y, self.color(textColor[1:]), self.color(floorColor[1:], fg = False))])
|
||||
rows.append(['{0}{1:2} {2}{3}'.format(self.clearColor(), y, self.color(textColor[1:]), self.color(floorColor[1:], fg = False))])
|
||||
rows[-1].append(self.color(textColor[1:]))
|
||||
for x in range(level.dimensions[0]):
|
||||
pos = level.mapMatrix[y][x]
|
||||
|
@ -163,24 +163,24 @@ If -l is given, a map legend will be printed under the map."""
|
|||
rows[-1] = ''.join(rows[-1])
|
||||
|
||||
print(xAxis)
|
||||
print('\x1b[0m\n'.join(rows) + '\x1b[0m')
|
||||
print('{0}\n'.format(self.clearColor()).join(rows) + self.clearColor())
|
||||
self.clearColor()
|
||||
|
||||
if len(args) > 0:
|
||||
if args[0] == '-l' or args[0] == 'l' or args[0] == 'legend':
|
||||
legend = ["\n---Legend---\n", "{0}()\x1b[0m - {1}".format(self.color('0000FF'), self.gameBase.playerName),
|
||||
legend = ["\n---Legend---\n", "{0}(){1} - {2}".format(self.color('0000FF'), self.clearColor(), self.gameBase.playerName),
|
||||
"Xn - Exit to another area"]
|
||||
for i in exits:
|
||||
legend.append(' {0}X{1}\x1b[0m - {2}'.format(self.color(exits[i][1][1:]), i, exits[i][0]))
|
||||
legend.append(' {0}X{1}{2} - {3}'.format(self.color(exits[i][1][1:]), i, self.clearColor(), exits[i][0]))
|
||||
legend.append("Un - Useable object")
|
||||
for i in useables:
|
||||
legend.append(' {0}U{1}\x1b[0m - {2}'.format(self.color(useables[i][1][1:]), i, useables[i][0]))
|
||||
legend.append(' {0}U{1}{2} - {3}'.format(self.color(useables[i][1][1:]), i, self.clearColor(), useables[i][0]))
|
||||
legend.append("In - Item")
|
||||
for i in items:
|
||||
legend.append(' {0}I{1}\x1b[0m - {2}'.format(self.color(items[i][1][1:]), i, items[i][0]))
|
||||
legend.append(' {0}I{1}{2} - {3}'.format(self.color(items[i][1][1:]), i, self.clearColor(), items[i][0]))
|
||||
legend.append("Dn - Door")
|
||||
for i in doors:
|
||||
legend.append(' {0}D{1}\x1b[0m - {2}'.format(self.color(doors[i][1][1:]), i, doors[i][0]))
|
||||
legend.append(' {0}D{1}{2} - {3}'.format(self.color(doors[i][1][1:]), i, self.clearColor(), doors[i][0]))
|
||||
print('\n'.join(legend))
|
||||
heapq.heappush(self.gameBase.eventQueue, (self.gameBase.gameTime, gameevents.NoOpEvent()))
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue