WTS/game/scripts/interface/achievements.rpy

240 lines
13 KiB
Plaintext
Raw Normal View History

init python:
from collections import namedtuple
AchievementKind = namedtuple("AchievementKind", ("category", "name", "description", "icon", "secret"))
AchievementKind.title = AchievementKind.name
define achievements_db = {
# id : (categoryname, title, description, icon, secret)
"unlockher": AchievementKind("Characters", "Granger Danger", "Awarded for unlocking Hermione Granger.", "interface/icons/head/hermione.webp", False),
"unlockcho": AchievementKind("Characters", "Chang Dynasty", "Awarded for unlocking Cho Chang.", "interface/icons/head/cho.webp", False),
"unlocklun": AchievementKind("Characters", "Looney Tunes", "Awarded for unlocking Luna Lovegood.", "interface/icons/head/luna.webp", False),
"unlockast": AchievementKind("Characters", "Green Peas", "Awarded for unlocking Astoria Greengrass.", "interface/icons/head/astoria.webp", False),
"unlockton": AchievementKind("Characters", "Nymphadoreador", "Awarded for unlocking Nymphadora Tonks.", "interface/icons/head/tonks.webp", False),
"overwhored": AchievementKind("Characters", "Overwhored", "Awarded for fully corrupting Hermione.", "interface/icons/head/hermione.webp", False),
"unlocksus": AchievementKind("Characters", "Boner", "Awarded for unlocking Susan Bones.", "interface/icons/head/susan.webp", False),
"unlocksna": AchievementKind("Characters", "Strictly colleagues", "Awarded for unlocking Severus Snape.", "interface/icons/head/snape.webp", False),
"mirror": AchievementKind("Mirror", "Mirror, mirror on the wall..", "Awarded for unlocking the Room of Requirement.", "images/rooms/room_of_requirement/mirror_hover.webp", False),
"gold": AchievementKind("General", "Gold Digger", "Awarded for having 10,000 gold in total.", "interface/icons/gold.webp", False),
"drunkard": AchievementKind("General", "Drunken Master", "Awarded for collecting 25 bottles of wine.", "interface/icons/wine.webp", True),
"workaholic": AchievementKind("General", "Workaholic", "Awarded for completing five full reports.", "interface/icons/generic_scroll.webp", False),
"fireplace": AchievementKind("General", "Feel the Heat", "Awarded for lighting the fireplace 5 times or more.", "images/rooms/main_room/fireplace/fireplace_idle.webp", True),
"peta": AchievementKind("General", "I think I forgot something...", "Awarded for not feeding the bird for 50 days.... \nYou monster.\n{size=-4}Disclaimer: No real nor fictional animals were harmed in the process.{/size}", "images/rooms/main_room/phoenix/phoenix_01.webp", True),
"petpal": AchievementKind("General", "Regular stroking", "Awarded for petting the bird 25 times.", "images/rooms/main_room/phoenix/phoenix_01.webp", False),
"postman": AchievementKind("Cardgame", "Poster Boy", "Awarded for buying all posters from the token shop.", "interface/icons/agrabah_poster.webp", False),
"hats": AchievementKind("Cardgame", "Mad Hatter", "Awarded for buying all hat decorations from the token shop.", "interface/icons/icon_gambler_hat.webp", False),
"daddy": AchievementKind("Characters", "Who's your daddy?", "Awarded for letting Hermione call you a {size=-5}(sugar){/size} daddy.", "interface/icons/head/hermione.webp", True),
"pantiesfap": AchievementKind("Characters", "I sneezed on them...", "Awarded for rubbing one out on Hermione's panties.", "characters/genie/chibis/jerk_off/02.webp", False),
"pantiesfapcho": AchievementKind("Characters", "Exercise is important", "Awarded for rubbing one out on Cho's panties.", "characters/genie/chibis/jerk_off/02.webp", False),
"bros": AchievementKind("Characters", "Bros before hoes", "Awarded for becoming best pals with Snape.", "interface/icons/head/snape.webp", False),
"knock": AchievementKind("Characters", "*Knock* *knock*", "Awarded for telling Hermione to go away during her introductory events.", "images/rooms/main_room/door/door_idle.webp", True),
"decorator": AchievementKind("Cardgame", "Decorator", "Awarded for decorating the office for the first time.", "interface/icons/stag_trophy.webp", False),
"flashback": AchievementKind("Cardgame", "Flashback", "Awarded for retelling what actually happened...", "interface/icons/cards.webp", True),
"start": AchievementKind("General", "Welcome to Hogwarts!", "Awarded for finishing the intro.", "interface/icon.webp", False),
"export": AchievementKind("General", "Sharing is caring", "Awarded for exporting an outfit through the wardrobe menu.", "interface/wardrobe/icons/load.webp", False),
"Credits": AchievementKind("General", "New game, who this?", "Awarded for checking out the Credits Menu.", "interface/icons/silver_scroll.webp", False),
"Cardwin": AchievementKind("Cardgame", "Time to duel", "Awarded for winning your first Card game duel.", "interface/icons/cards.webp", False),
"puzzle": AchievementKind("General", "Down the hatch!", "Awarded for wasting a bottle of unbelievably rare phoenix tears by drinking it.", "interface/icons/item_potion.webp", True),
"ending": AchievementKind("General", "Bittersweet Farewell", "Awarded for reaching the original ending.", "interface/icons/silver.webp", True),
2022-05-16 23:48:22 +00:00
#1.37 HG achievements
"busted": AchievementKind("Characters", "BUSTED!", "Awarded for getting busted by Hermione when busting a nut.", "interface/icons/head/hermione.webp", False),
"herstrip": AchievementKind("Characters", "Dance lessons", "Awarded for having Hermione dance naked in front of you... and Snape.", "interface/icons/head/hermione.webp", False),
"herkiss": AchievementKind("Characters", "First Kiss", "Awarded for having Hermione make out with you-- r... cock...", "interface/icons/head/hermione.webp", False),
"hertits": AchievementKind("Characters", "Boobs Lover", "Awarded for sticking it between Hermione's fun bags.", "interface/icons/head/hermione.webp", False),
"headlib": AchievementKind("Characters", "Head Librarian", "Awarded for releasing your seed in Hermione's mouth.", "interface/icons/head/hermione.webp", False),
"nerdgasm": AchievementKind("Characters", "Nerdgasm", "Awarded for doing the deed with Hermione.", "interface/icons/head/hermione.webp", False)
2022-05-16 23:48:22 +00:00
}
init python hide:
for name in achievements_db:
achievement.register(name)
2022-05-16 23:48:22 +00:00
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'):
2022-05-16 23:48:22 +00:00
if sound:
play sound soundfile
2022-05-16 23:48:22 +00:00
hide screen achievement_window
show screen achievement_window(msg=msg, title=title, icon=icon, xpos=xpos, ypos=ypos)
2022-05-16 23:48:22 +00:00
return
screen achievement_window(msg="", title="", icon=None, xpos=0, ypos=60):
2022-05-16 23:48:22 +00:00
tag popup_window
layer "interface"
frame:
style "empty"
at popup_animation(time=5.0, xx=-410)
pos (xpos, ypos)
xsize 410
ysize 96
add gui.format("interface/achievements/{}/box.webp")
if icon:
frame:
style "empty"
pos (6, 6)
xsize 84
ysize 84
$ image_zoom = crop_image_zoom(icon, 84, 84)
if 'head' in icon:
add image_zoom align (0.5, 1.0) yoffset -1
else:
add image_zoom align (0.5, 0.5)
add "interface/achievements/glass.webp"
frame:
style "empty"
xpos 96
xsize 314
vbox:
ypos 12
spacing 10
xalign 0.5
text title size 18 xalign 0.5
text msg size 14 xalign 0.5
2022-05-16 23:48:22 +00:00
timer 6.0 action Hide("achievement_window")
transform rotate_circular(t=7):
2022-05-16 23:48:22 +00:00
on show, appear, start:
subpixel True
2022-05-16 23:48:22 +00:00
rotate 0
linear t rotate 360
2022-05-16 23:48:22 +00:00
repeat
2024-09-12 15:16:41 +00:00
init python in achievements:
def validate():
"""Check if icons are loadable at init"""
for i in renpy.store.achievements_db.values():
if not renpy.loadable(i.icon):
raise IOError(repr(i.icon))
validate()
def unlock(id, silent=False):
if renpy.store._in_replay:
return
if not renpy.store.achievement.has(id):
renpy.store.achievement.grant(id)
if not silent:
renpy.play('sounds/achievement.ogg')
renpy.store.__popup_stack.append(id)
status = renpy.store.achievement.has
lock = renpy.store.achievement.clear
def get_list(category=None):
if category:
items = filter((lambda x: category==renpy.store.achievements_db[x].category.lower()), renpy.store.achievements_db)
else:
items = renpy.store.achievements_db
items = sorted(items, key=lambda x: renpy.store.natsort_key(renpy.store.achievements_db[x].title))
return items
label achievements:
$ disable_game_menu()
call screen achievements
$ enable_game_menu()
jump main_room_menu
2024-09-12 15:16:41 +00:00
screen achievements():
2022-05-16 23:48:22 +00:00
modal True
2024-09-12 15:16:41 +00:00
layer "interface"
zorder 0
style_prefix "achievements"
2022-05-16 23:48:22 +00:00
2024-09-12 15:16:41 +00:00
default navigation_atl = navigation_show
default last_frame = (screenshot.capture() or screenshot.image)
default navigation_last_frame_atl = navigation_last_frame_show
default navigation_exit = False
2022-05-16 23:48:22 +00:00
2024-09-12 15:16:41 +00:00
default category = None
default menu_items = achievements.get_list(category)
2022-05-16 23:48:22 +00:00
2024-09-12 15:16:41 +00:00
add last_frame at navigation_last_frame_atl
2022-05-16 23:48:22 +00:00
2024-09-12 15:16:41 +00:00
if navigation_exit:
timer 0.4 action Return()
2022-05-16 23:48:22 +00:00
2024-09-12 15:16:41 +00:00
$ print(menu_items)
2022-05-16 23:48:22 +00:00
2024-09-12 15:16:41 +00:00
frame:
2022-05-16 23:48:22 +00:00
style "empty"
2024-09-12 15:16:41 +00:00
align (0.5, 0.5)
at navigation_atl
2022-05-16 23:48:22 +00:00
2024-09-12 15:16:41 +00:00
vbox:
style_prefix "navigation_subtabs"
pos (286, 170)
2022-05-16 23:48:22 +00:00
2024-09-12 15:16:41 +00:00
at navigation_subtabs_show
2022-05-16 23:48:22 +00:00
2024-09-12 15:16:41 +00:00
textbutton _("All") action [SetScreenVariable("category", None), SetScreenVariable("menu_items", achievements.get_list())] selected (category==None) at navigation_tabs
textbutton _("General") action [SetScreenVariable("category", "general"), SetScreenVariable("menu_items", achievements.get_list("general"))] selected (category=="general") at navigation_tabs
textbutton _("Characters") action [SetScreenVariable("category", "characters"), SetScreenVariable("menu_items", achievements.get_list("characters"))] selected (category=="characters") at navigation_tabs
textbutton _("Cards") action [SetScreenVariable("category", "cardgame"), SetScreenVariable("menu_items", achievements.get_list("cardgame"))] selected (category=="cardgame") at navigation_tabs
textbutton _("Mirror of Erised") action [SetScreenVariable("category", "mirror"), SetScreenVariable("menu_items", achievements.get_list("mirror"))] selected (category=="mirror") at navigation_tabs
null height 35
textbutton _("Return") action [SetScreenVariable("navigation_last_frame_atl", navigation_last_frame_hide), SetScreenVariable("navigation_atl", navigation_hide), SetScreenVariable("navigation_exit", True)] keysym ["game_menu"] at navigation_tabs
2022-05-16 23:48:22 +00:00
2024-09-12 15:16:41 +00:00
frame:
label _("Achievements")
2024-09-12 15:16:41 +00:00
# Add items
viewport:
ypos 32
2022-05-16 23:48:22 +00:00
xalign 0.5
2024-09-12 15:16:41 +00:00
ymaximum 392
scrollbars "vertical"
mousewheel True
vbox:
for item in menu_items:
$ item_unlocked = achievement.has(item)
$ item_data = achievements_db[item]
$ item_color = "#ffffff" if item_unlocked else "#8d8d8d"
fixed:
fit_first True
button:
hbox:
add crop_image_zoom(item_data.icon, 48, 48, not item_unlocked) xysize (48, 48)
null width 5
vbox:
text "[item_data.title]" color item_color
text "[item_data.description]" color item_color style "achievements_text_small"
action NullAction()
if item_unlocked:
add "interface/topbar/icon_check.webp" xysize (24, 24) yalign 0.5
add "frame_spacer" xalign 0.5 xsize 500
style achievements_vbox is frame_vbox:
ypos 0
yspacing 0
xalign 0
style achievements_frame is frame
style achievements_label is frame_label
style achievements_label_text is frame_label_text
style achievements_text is frame_text:
xalign 0
style achievements_text_small is achievements_text:
xalign 0
2022-05-16 23:48:22 +00:00
size 12
2024-09-12 15:16:41 +00:00
style achievements_button is frame_button:
xfill True
yminimum 48
style achievements_button_text is frame_button_text