Allow several achievements to be displayed at the same time

like in steam
the change to popup_animation is not thoroughly tested
This commit is contained in:
Gouvernathor 2023-11-18 05:00:01 +01:00
parent 3b5f35a732
commit f714e482f6
2 changed files with 21 additions and 9 deletions

View File

@ -60,7 +60,7 @@ init python:
class Achievements(object):
"""
Useless class, to be rolled out.
Useless class, can't be rolled out because of pickle and save compatibility.
"""
@staticmethod
@ -84,7 +84,7 @@ init python:
if not silent:
renpy.play('sounds/achievement.ogg')
renpy.show_screen("achievement_window", msg=achievements_db[id].title, title="Achievement unlocked!", icon=achievements_db[id].icon)
__popup_stack.append(id)
@staticmethod
def lock(self, id):
@ -118,6 +118,21 @@ default achievements = Achievements()
###
init python:
# intentionaly not a define nor a default
__popup_stack = []
config.after_default_callbacks.append(__popup_stack.clear)
config.always_shown_screens.append("achievement_main")
screen achievement_main():
layer "interface"
vbox:
for id index id in __popup_stack[:3]:
use achievement_window(msg=achievements_db[id].title, title="Achievement unlocked!", icon=achievements_db[id].icon)
timer 6 action Function(__popup_stack.remove, id)
label popup(msg="", title="", icon=None, xpos=0, ypos=60, sound=True, soundfile='sounds/achievement.ogg'):
if sound:
play sound soundfile

View File

@ -1,11 +1,8 @@
transform popup_animation(time=4.0, xx=-200):
on start:
xoffset xx
on show:
xoffset xx
linear 0.5 xoffset absolute(0)
pause time
linear 0.5 xoffset absolute(xx)
xoffset xx
linear 0.5 xoffset absolute(0)
pause time
linear 0.5 xoffset absolute(xx)
screen popup_window(msg="", xpos=0, ypos=60):
tag popup_window