From 42a55a582c1d5e46a08ac0325fa691490a2823a4 Mon Sep 17 00:00:00 2001 From: Exodia <67595890+DonRP@users.noreply.github.com> Date: Sun, 17 Jul 2022 16:00:06 +0200 Subject: [PATCH 1/3] Create notify.rpy --- game/tool/notify.rpy | 72 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 game/tool/notify.rpy diff --git a/game/tool/notify.rpy b/game/tool/notify.rpy new file mode 100644 index 0000000..6e3f235 --- /dev/null +++ b/game/tool/notify.rpy @@ -0,0 +1,72 @@ +init python: + ## Notifications + # to use: default ... = NotifyEx(msg="...", img="...") + class NotifyEx( renpy.python.RevertableObject ): + def __init__( self, msg, img ): + super(NotifyEx, self).__init__() + self.msg = msg + self.img = img + self.remain = gui.notifyEx_delay + ## view undefined notifications + # to use: $ notifyEx(msg="...") + # to use: $ notifyEx(msg="...", img="...") + # to use: $ notifyEx(img="...") + def notifyEx( msg=None, img=None ): + notifications.append( NotifyEx( msg, img ) ) + if len( store.notifications ) == 1: renpy.show_screen( "notifyEx" ) + def notifyExClean( value ): + if value in store.notifications: store.notifications.remove( value ) + if len( store.notifications ) == 0: renpy.hide_screen( "notifyEx" ) + ## view defined notifications + # to use: $ notify(...) + def notify( n ): + notifications.append( NotifyEx( n.msg, n.img ) ) + if len( store.notifications ) == 1: renpy.show_screen( "notifyEx" ) + +# Delay of visibility of a notification. +define gui.notifyEx_delay = 10.0 +# Width of the images. +define gui.notifyEx_width = 64 +# Height of the images. +define gui.notifyEx_height = 64 + +default notifications = [] + +style notify_text is default: + # color "#49aae6" + yalign 0.5 + +style notify_hbox is default: + ysize gui.notifyEx_height + +screen notifyEx(): + + zorder 100 + + style_prefix "notify" + + vbox: + for d in notifications: + use notifyExInternal( d ) + # aerate a little. + null height 5 + +screen notifyExInternal( n ): + + style_prefix "notify" + + frame at notify_appear: + hbox: + if not n.img is None: + add n.img + else: + # Ensure that all the texts will be aligned. + null width gui.notifyEx_width + + # aerate a little. + null width 5 + + if not n.msg is None: + text n.msg + + timer 0.05 repeat True action [ SetField( n, "remain", n.remain - 0.05 ), If( n.remain <= 0, Function( notifyExClean, n ), NullAction() ) ] From 88d4171909a21ad83c5fcfdebe9bae99f22103a5 Mon Sep 17 00:00:00 2001 From: Exodia <67595890+DonRP@users.noreply.github.com> Date: Sun, 17 Jul 2022 16:12:31 +0200 Subject: [PATCH 2/3] NotifyEx --- game/tool/notify.rpy | 50 ++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/game/tool/notify.rpy b/game/tool/notify.rpy index 6e3f235..221e364 100644 --- a/game/tool/notify.rpy +++ b/game/tool/notify.rpy @@ -1,27 +1,35 @@ init python: - ## Notifications - # to use: default ... = NotifyEx(msg="...", img="...") - class NotifyEx( renpy.python.RevertableObject ): - def __init__( self, msg, img ): + class NotifyEx(renpy.python.RevertableObject): + """Notifications, to use: default ... = NotifyEx(msg="...", img="...")""" + def __init__(self, + msg: str, + img: str + ): super(NotifyEx, self).__init__() self.msg = msg self.img = img self.remain = gui.notifyEx_delay - ## view undefined notifications - # to use: $ notifyEx(msg="...") - # to use: $ notifyEx(msg="...", img="...") - # to use: $ notifyEx(img="...") - def notifyEx( msg=None, img=None ): - notifications.append( NotifyEx( msg, img ) ) - if len( store.notifications ) == 1: renpy.show_screen( "notifyEx" ) - def notifyExClean( value ): - if value in store.notifications: store.notifications.remove( value ) - if len( store.notifications ) == 0: renpy.hide_screen( "notifyEx" ) - ## view defined notifications - # to use: $ notify(...) - def notify( n ): - notifications.append( NotifyEx( n.msg, n.img ) ) - if len( store.notifications ) == 1: renpy.show_screen( "notifyEx" ) + + + def notifyEx(msg: str = None, img: str = None): + notifications.append(NotifyEx(msg, img)) + if len(store.notifications) == 1: + renpy.show_screen("notifyEx") + + + def notifyExClean(value): + if value in store.notifications: + store.notifications.remove(value) + if len(store.notifications) == 0: + renpy.hide_screen("notifyEx") + + + def notify(notific): + """View defined notifications. + to use: $ notify(...)""" + notifications.append(NotifyEx(notific.msg, notific.img)) + if len(store.notifications) == 1: + renpy.show_screen("notifyEx") # Delay of visibility of a notification. define gui.notifyEx_delay = 10.0 @@ -30,10 +38,12 @@ define gui.notifyEx_width = 64 # Height of the images. define gui.notifyEx_height = 64 +define gui.notifyEx_color = "#000000" + default notifications = [] style notify_text is default: - # color "#49aae6" + color gui.notifyEx_color yalign 0.5 style notify_hbox is default: From 0c41b8fc89ecf31e1dbb342dec8fe24153bb1344 Mon Sep 17 00:00:00 2001 From: Exodia <67595890+DonRP@users.noreply.github.com> Date: Sun, 17 Jul 2022 16:14:00 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 67cf014..55b9a4c 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ This template includes VSCode launchs and extensions for developing Ren'Py proje - `.gitignore`: Git configuration file for ignoring certain file paths and types. - `/game/tool/utility.rpy`: Useful functions such as: isNullOrEmpty - `/game/tool/flags.rpy`: Flags System +- `/game/tool/notify.rpy`: Notify System ## How Run Debug (F5)