diff options
| author | troido <troido@protonmail.com> | 2018-05-23 20:36:47 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2018-05-23 20:36:47 +0200 |
| commit | ce116aeade07eb57760e42dbbeeca83ded8214ce (patch) | |
| tree | 902e0d488e4aadb6681c5fadd012dd34c38d7bf1 | |
| parent | af31b7692a44666b78554464266e513dc78bf0be (diff) | |
game doesn't crash anymore when cursor can't be set
| -rw-r--r-- | asciifarm/client/display/display.py | 3 | ||||
| -rw-r--r-- | asciifarm/client/display/screen.py | 16 | ||||
| -rw-r--r-- | asciifarm/client/gameclient.py | 1 |
3 files changed, 15 insertions, 5 deletions
diff --git a/asciifarm/client/display/display.py b/asciifarm/client/display/display.py index 4ca5816..2e10772 100644 --- a/asciifarm/client/display/display.py +++ b/asciifarm/client/display/display.py @@ -24,7 +24,7 @@ class Display: if colours: self.colours = Colours() else: - self.colours = None + self.colours = None self.characters = {} def parseSprite(sprite): @@ -142,7 +142,6 @@ class Display: if self.forced or widget.isChanged(): widget.update() changed = True - if changed: self.screen.update() self.forced = False diff --git a/asciifarm/client/display/screen.py b/asciifarm/client/display/screen.py index 21d7200..605eca5 100644 --- a/asciifarm/client/display/screen.py +++ b/asciifarm/client/display/screen.py @@ -9,7 +9,19 @@ class Screen: def __init__(self, display, stdscr, colours): self.display = display - curses.curs_set(0) + try: + curses.curs_set(0) + self.cursorSet = False + except curses.error: + # Not all terminals support this functionality. + # When the error is ignored the screen will look a little uglier, + # A cursor will move around, but that's not terrible + # So in order to keep the game as accesible as possible to everyone, it should be safe to ignore the error. + self.cursorSet = True + # It is probably possible to make sure the cursor is only in a corner of the screen + # but I can't figure out how. + # it seems to ignore all my move commands unless I press a key + # I give up self.stdscr = stdscr self.colours = colours self.setWins() @@ -67,7 +79,6 @@ class Screen: self.display.forceUpdate() def update(self): - curses.doupdate() def getWidth(self): @@ -76,3 +87,4 @@ class Screen: def getHeight(self): return self.height + diff --git a/asciifarm/client/gameclient.py b/asciifarm/client/gameclient.py index 965239c..0cb7c2d 100644 --- a/asciifarm/client/gameclient.py +++ b/asciifarm/client/gameclient.py @@ -114,7 +114,6 @@ class Client: if msgType == "message": self.log(msg[1]) - self.display.update() def log(self, text): |
