diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-12-17 23:54:36 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-12-17 23:54:36 -0300 |
commit | 423e3032f662e9e7062c2e8220540fddadb475aa (patch) | |
tree | f9956d1c47bbb3f91b7506e61eb20fd4d54f5646 | |
parent | 11f2291cefe90f5c43765754d7cdffa247cc31f9 (diff) | |
download | client-423e3032f662e9e7062c2e8220540fddadb475aa.tar.gz client-423e3032f662e9e7062c2e8220540fddadb475aa.tar.bz2 client-423e3032f662e9e7062c2e8220540fddadb475aa.tar.xz client-423e3032f662e9e7062c2e8220540fddadb475aa.zip |
Make SERVNOTICE even more annoying, but it autocloses after a while.
(No special codes like newlines and such are allowed)
Fix an interpreter crash of trying to execute onerror after program had a regular
and clean exit.
-rw-r--r-- | game/04_init.rpy | 20 | ||||
-rw-r--r-- | game/screens.rpy | 41 | ||||
-rw-r--r-- | game/script.rpy | 3 |
3 files changed, 57 insertions, 7 deletions
diff --git a/game/04_init.rpy b/game/04_init.rpy index 9f09454..482f85e 100644 --- a/game/04_init.rpy +++ b/game/04_init.rpy @@ -31,13 +31,15 @@ init python: try: if (message.split(':')[0] == "NOTICE"): # FIXME - renpy.notify(str(":".join(message.split(':')[1:]))) - raise NotImplemented("You cannot call screens from threads!") - renpy.call_screen("msgbox", + #renpy.notify(str(":".join(message.split(':')[1:]))) + display_msgbox(str(":".join(message.split(':')[1:]))) + #raise NotImplemented("You cannot call screens from threads!") + #renpy.call_screen("msgbox", #renpy.call_in_new_context("msgbox_label", - "{b}SERVER NOTICE{b}\n\n%s" % str(":".join(message.split(':')[1:]))) + # "{b}SERVER NOTICE{b}\n\n%s" % str(":".join(message.split(':')[1:]))) return except: + raise stdout("Error displaying SERVNOTICE") return @@ -71,6 +73,9 @@ init python: send_packet_now("PING") def onerror(self, err): + if err == "Quit": + return + stdout("ERROR RECEIVED") stdout("More details: %s" % repr(err)) stdout("An error happened: %s" % str(err)) @@ -91,7 +96,7 @@ init python: #renpy.quit(relaunch=True, status=1) except: pass - return 1 + return class GameClient(WebSocketClient): def opened(self): @@ -100,7 +105,10 @@ init python: # FIXME This is also onerror def closed(self, code, reason=None): print "Closed down", code, reason - onerror(self, "%s" % str(reason)) + if reason is None: + reason="Connection died" + if reason != "Quit": + onerror(self, "%s" % str(reason)) def received_message(self, m): onmsg(self, str(m)) diff --git a/game/screens.rpy b/game/screens.rpy index e6e31fc..4b544bf 100644 --- a/game/screens.rpy +++ b/game/screens.rpy @@ -1392,3 +1392,44 @@ screen input_box(ib_message=_("Please write it down here: "), baloney=""): text_size 54 text_outlines [ (1, "#000", 0, 0) ] + + +screen notabox(message): + + zorder 100 + #style_prefix "notify" + style_prefix "confirm" + + frame at notify_appear: + vbox: + xalign 0.5 + yalign 0.5 + spacing 30 + + label "{b}SERVER NOTICE{/b}": + xalign 0.5 + + label "[message!tq]": + style "confirm_prompt" + xalign 0.5 + + hbox: + xalign 0.5 + spacing 100 + + textbutton _("Ok") action Hide('notabox') + + timer 20.00 action Hide('notabox') + +init python: + def display_msgbox(message): + """ + :doc: other + + The default implementation of :func:`renpy.notify`. + """ + + renpy.hide_screen('notabox') + renpy.show_screen('notabox', message=message) + renpy.restart_interaction() + diff --git a/game/script.rpy b/game/script.rpy index e910d89..5752f44 100644 --- a/game/script.rpy +++ b/game/script.rpy @@ -288,9 +288,10 @@ label quit: except: pass + # FIXME # If needed, close the socket try: - ws.close() + ws.close(reason="Quit") except: pass |