From be9f071660668caa5dcad296f6a2243655e9f403 Mon Sep 17 00:00:00 2001 From: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com> Date: Wed, 15 Nov 2023 22:51:38 +0100 Subject: [PATCH] Clean most stats variables from the global store (cherry picked from commit c493a4b9aa45ae4aa619a9edbb09bc0e5bea98b3) --- game/scripts/interface/stats.rpy | 127 ++++++++++++++----------------- 1 file changed, 56 insertions(+), 71 deletions(-) diff --git a/game/scripts/interface/stats.rpy b/game/scripts/interface/stats.rpy index f1e30c87..e3b9d378 100644 --- a/game/scripts/interface/stats.rpy +++ b/game/scripts/interface/stats.rpy @@ -81,60 +81,45 @@ label stats: $ gui.in_context("stats_menu") jump main_room_menu +define stats_categories_sorted = ("Genie", "Snape", "Tonks", "Hermione", "Cho", "Luna", "Astoria", "Susan") #"Ginny", "Daphne", "Padma", "Patil", "Myrtle", "Mafkin" +# Stats dictionary +define stats_dict = { + "Genie": {"ico": "genie", "name": "Genie", "sex": "Yes", "height": "6.2ft", "weight": "200lb", "job": "Headmaster", "hates": "Lamps", "likes": "Tits"}, + "Snape": {"ico": "snape", "name": "Severus Snape", "sex": "Male", "height": "5.9ft", "weight": "155lb", "job": "Teacher", "hates": "Everyone", "likes": "Rain"}, + "Tonks": {"ico": "tonks", "name": "Nymphadora Tonks", "sex": "Fluid", "height": "5.6ft", "weight": "130lb", "job": "Teacher", "hates": "Pineapple Pizza", "likes": "Girls"}, + "Hermione": {"ico": "hermione", "name": "Hermione Granger", "sex": "Female", "height": "5.2ft", "weight": "126lb", "job": "Student", "hates": "Slytherin", "likes": "Books"}, + "Cho": {"ico": "cho", "name": "Cho Chang", "sex": "Female", "height": "5.1ft", "weight": "122lb", "job": "Student", "hates": "Hermione", "likes": "Winning"}, + "Luna": {"ico": "luna", "name": "Luna Lovegood", "sex": "Female", "height": "5.2ft", "weight": "117lb", "job": "Student", "hates": "Wrackspurts", "likes": "{size=-2}Magical creatures{/size}"}, + "Astoria": {"ico": "astoria", "name": "Astoria Greengrass", "sex": "Female", "height": "5.0ft", "weight": "102lb", "job": "Student", "hates": "Rules", "likes": "Breaking them"}, + "Susan": {"ico": "susan", "name": "Susan Bones", "sex": "Female", "height": "5.1ft", "weight": "135lb", "job": "Student", "hates": "Chores", "likes": "You {size=-4}Secretly..{/size}"} +} + label stats_menu(xx=150, yy=90): call update_stats - # Stats dictionary - $ stats_dict = { - "Genie": {"ico": "genie", "flag": True, "name": "Genie", "sex": "Yes", "height": "6.2ft", "weight": "200lb", "job": "Headmaster", "hates": "Lamps", "likes": "Tits"}, - "Snape": {"ico": "snape", "flag": states.sna.unlocked, "name": "Severus Snape", "sex": "Male", "height": "5.9ft", "weight": "155lb", "job": "Teacher", "hates": "Everyone", "likes": "Rain"}, - "Tonks": {"ico": "tonks", "flag": states.ton.unlocked, "name": "Nymphadora Tonks", "sex": "Fluid", "height": "5.6ft", "weight": "130lb", "job": "Teacher", "hates": "Pineapple Pizza", "likes": "Girls"}, - "Hermione": {"ico": "hermione", "flag": states.her.unlocked, "name": "Hermione Granger", "sex": "Female", "height": "5.2ft", "weight": "126lb", "job": "Student", "hates": "Slytherin", "likes": "Books"}, - "Cho": {"ico": "cho", "flag": states.cho.unlocked, "name": "Cho Chang", "sex": "Female", "height": "5.1ft", "weight": "122lb", "job": "Student", "hates": "Hermione", "likes": "Winning"}, - "Luna": {"ico": "luna", "flag": states.lun.unlocked, "name": "Luna Lovegood", "sex": "Female", "height": "5.2ft", "weight": "117lb", "job": "Student", "hates": "Wrackspurts", "likes": "{size=-2}Magical creatures{/size}"}, - "Astoria": {"ico": "astoria", "flag": states.ast.unlocked, "name": "Astoria Greengrass", "sex": "Female", "height": "5.0ft", "weight": "102lb", "job": "Student", "hates": "Rules", "likes": "Breaking them"}, - "Susan": {"ico": "susan", "flag": states.sus.unlocked, "name": "Susan Bones", "sex": "Female", "height": "5.1ft", "weight": "135lb", "job": "Student", "hates": "Chores", "likes": "You {size=-4}Secretly..{/size}"} - } - - $ stats_categories_sorted = ["Genie", "Snape", "Tonks", "Hermione", "Cho", "Luna", "Astoria", "Susan"] #"Ginny", "Daphne", "Padma", "Patil", "Myrtle", "Mafkin" - $ stats_categories_sorted_length = len(stats_categories_sorted) - - $ current_category = states.last_girl.capitalize() if states.last_girl else stats_categories_sorted[0] - $ current_item = stats_dict[current_category] - $ current_subcategory = "overview" - $ current_sorting = stats_show_locked - - $ category_items = stats_dict[current_category] - $ menu_items = category_items - $ menu_items_length = len(menu_items) - - show screen stats(xx, yy) - - label .after_init: - $ renpy.dynamic(__choice = ui.interact()) - - if __choice[0] == "category": - $ current_category = __choice[1] - $ category_items = stats_dict[current_category] - $ menu_items = stats_sortfilter(category_items, current_sorting) - $ menu_items_length = len(menu_items) - $ current_item = stats_dict[current_category] - #$ current_subcategory = "overview" - elif __choice[0] == "subcat": - if __choice[1] != current_subcategory: - $ current_subcategory = __choice[1] - else: - hide screen stats - return - - jump .after_init + call screen stats(xx, yy) + return screen stats(xx, yy): tag stats zorder 30 modal True + default stats_flags = { + "Genie": True, + "Snape": states.sna.unlocked, + "Tonks": states.ton.unlocked, + "Hermione": states.her.unlocked, + "Cho": states.cho.unlocked, + "Luna": states.lun.unlocked, + "Astoria": states.ast.unlocked, + "Susan": states.sus.unlocked, + } + + default current_category = states.last_girl.capitalize() if states.last_girl else stats_categories_sorted[0] + default current_item = stats_dict[current_category] + add "gui_fade" if renpy.mobile: @@ -144,10 +129,10 @@ screen stats(xx, yy): fixed: if settings.get("animations"): at gui_animation - use stats_menu(xx, yy) - use stats_menuitem(xx, yy) + use stats_menu(current_category, stats_flags, xx, yy) + use stats_menuitem(current_category, current_item, stats_flags, xx, yy) -screen stats_menu(xx, yy): +screen stats_menu(current_category, stats_flags, xx, yy): tag stats_menu zorder 30 modal True @@ -173,14 +158,14 @@ screen stats_menu(xx, yy): vbox: pos (6, 6) for category in stats_categories_sorted: - if not stats_show_locked and not stats_dict[category]["flag"]: + if not stats_show_locked and not stats_flags[category]: pass else: frame: style "empty" xysize (195, 50) vbox: - textbutton (category if stats_dict[category]["flag"] else "???"): + textbutton (category if stats_flags[category] else "???"): style "empty" xysize (195, 46) text_align (0.6, 0.5) @@ -190,26 +175,26 @@ screen stats_menu(xx, yy): background gui.format("interface/achievements/{}/highlight_left_b.webp") else: hover_background gui.format("interface/achievements/{}/highlight_left_b.webp") - action Return(["category", category]) + action [ + SelectedIf(SetScreenVariable("current_category", category)), + SetScreenVariable("current_item", stats_dict[category]), + ] add gui.format("interface/achievements/{}/spacer_left.webp") - if stats_dict[category]["flag"]: - $ image_zoom = crop_image_zoom("interface/icons/head/"+stats_dict.get(category).get("ico")+".webp", 42, 42) - else: - $ image_zoom = crop_image_zoom("interface/icons/head/"+stats_dict.get(category).get("ico")+"_locked.webp", 42, 42) - button: style gui.theme("overlay_button") background gui.format("interface/achievements/{}/iconbox.webp") foreground "interface/achievements/glass_iconbox.webp" xysize (48, 48) - add image_zoom align (0.5, 0.5) + add crop_image_zoom("interface/icons/head/"+stats_dict.get(category).get("ico")+("" if stats_flags[category] else "_locked")+".webp", 42, 42) align (0.5, 0.5) -screen stats_menuitem(xx, yy): +screen stats_menuitem(current_category, current_item, stats_flags, xx, yy): tag stats_menuitem zorder 30 + default current_subcategory = "overview" + window: style "empty" style_prefix gui.theme() @@ -229,9 +214,9 @@ screen stats_menuitem(xx, yy): yanchor 0.5 textbutton "Overview": - action [Return(["subcat", "overview"]), SelectedIf(current_subcategory=="overview")] + action SetLocalVariable("current_subcategory", "overview") textbutton "Details": - action [Return(["subcat", "details"]), SelectedIf(current_subcategory=="details")] + action SetLocalVariable("current_subcategory", "details") # Character sprites frame: @@ -243,37 +228,37 @@ screen stats_menuitem(xx, yy): if current_category == "Genie": add "genie_stats" zoom 0.175 align (1.0, 1.0) xzoom -1 elif current_category == "Snape": - if current_item["flag"]: + if stats_flags[current_category]: add "characters/snape/main/snape_09.webp" zoom 0.35 align (0.9, 1.0) xzoom 1 else: add "interface/characters/snape_locked.webp" zoom 0.35 align (0.9, 1.0) xzoom 1 elif current_category == "Tonks": - if current_item["flag"]: + if stats_flags[current_category]: add tonks.image zoom 0.41 align (0.7, 1.0) xzoom 1 else: add "interface/characters/tonks_locked.webp" zoom 0.41 align (0.7, 1.0) xzoom 1 elif current_category == "Hermione": - if current_item["flag"]: + if stats_flags[current_category]: add hermione.image zoom 0.39 align (0.7, 1.0) xzoom 1 else: add "interface/characters/hermione_locked.webp" zoom 0.39 align (0.65, 1.0) xzoom 1 elif current_category == "Cho": - if current_item["flag"]: + if stats_flags[current_category]: add cho.image zoom 0.42 align (0.65, 1.0) xzoom 1 else: add "interface/characters/cho_locked.webp" zoom 0.42 align (0.65, 1.0) xzoom 1 elif current_category == "Luna": - if current_item["flag"]: + if stats_flags[current_category]: add luna.image zoom 0.39 align (0.75, 1.0) xzoom 1 else: add "interface/characters/luna_locked.webp" zoom 0.39 align (0.75, 1.0) xzoom 1 elif current_category == "Astoria": - if current_item["flag"]: + if stats_flags[current_category]: add astoria.image zoom 0.4 align (0.7, 1.0) xzoom 1 else: add "interface/characters/astoria_locked.webp" zoom 0.4 align (0.7, 1.0) xzoom 1 elif current_category == "Susan": - if current_item["flag"]: + if stats_flags[current_category]: add susan.image zoom 0.4 align (0.65, 1.0) xzoom 1 else: add "interface/characters/susan_locked.webp" zoom 0.4 align (0.65, 1.0) xzoom 1 @@ -284,7 +269,7 @@ screen stats_menuitem(xx, yy): yalign 1.0 xoffset 6 if current_subcategory == "overview": - if current_item["flag"]: + if stats_flags[current_category]: text current_item["name"] size 20 xalign 0.5 xanchor 0.5 ypos 5 else: text "???" size 20 xalign 0.5 xanchor 0.5 ypos 5 @@ -302,7 +287,7 @@ screen stats_menuitem(xx, yy): vbox: spacing 3 - if current_item["flag"]: + if stats_flags[current_category]: text current_item["sex"] size 12 text current_item["height"] size 12 text current_item["weight"] size 12 @@ -318,7 +303,7 @@ screen stats_menuitem(xx, yy): vbox: spacing 3 - if current_item["flag"]: + if stats_flags[current_category]: text current_item["job"] size 12 text current_item["hates"] size 12 text current_item["likes"] size 12 @@ -327,7 +312,7 @@ screen stats_menuitem(xx, yy): text "unknown" size 12 text "unknown" size 12 - if current_item["flag"]: + if stats_flags[current_category]: vbox: yoffset 35 xoffset 50 @@ -381,7 +366,7 @@ screen stats_menuitem(xx, yy): use stat_bar(int(0/0.9), "-Reputation-", "Invisible", 0) # TODO: Add word list and variable use stat_bar(int(0), "{size=-10}-Assertiveness Training-{/size}" , "Not started", 0) # TODO: Add word list else: - if current_item["flag"]: + if stats_flags[current_category]: vbox: if current_category == "Genie": use text_stat("Bird fed:")