################################################################################
# SatoMod — Fates Collide
# by satoshi bae
#
# Includes:
#   - Choice walkthrough (press W)
#   - Gallery unlock (Renders + Scenes)
#   - Extra gallery scenes
################################################################################

define satomod_author = "satoshi bae"
define satomod_version = "1.0"

default persistent.fc_walkthrough = True
default persistent.Ep2_AvisSunMassage_replay = False
default persistent.Ep4_AvisBarKiss_replay = False
default persistent.Ep3_KokoSkinnyDip_replay = False
default persistent.Ep2_RaikoSwimsuit_replay = False
default persistent.Ep3_RaikoBathroom_replay = False
default persistent.Ep4_RaikoMovie_replay = False
default persistent.Ep3_SerenaRooftop_replay = False
default persistent.Ep3_AvisRevealTits_replay = False
default fc_replay_end_at = None


################################################################################
# Walkthrough — readable English hints
################################################################################

init 10000 python:
    import re

    _SM_ASSIGN = re.compile(
        r"^\s*(?:persistent\.)?([A-Za-z_][\w]*)\s*(\+=|-=|=)\s*(.+?)\s*$"
    )

    _SM_GIRL_POINTS = {
        "Avis", "Eiko", "Koko", "Levy", "Raiko", "Serena", "Valentina",
        "Simon", "Sooah", "RaikoDad", "Ego", "Falazio", "Atlas", "Bethany",
        "Dimitri", "James",
    }

    _SM_FLAG_NAMES = {
        "Ep4_AvisKissed": "Avis kiss",
        "Ep4_AvisMCLikesBoobs": "prefers boobs",
        "Ep4_AvisMCLikesButt": "prefers butt",
        "Ep4_AvisMCLikesFeet": "prefers feet",
        "Ep4_KokoBlowed": "Koko scene",
        "Ep4_SexSooah": "Soo-Ah scene",
        "Ep4_RaikoTriedKiss": "Raiko kiss attempt",
        "Ep4_SidingWithSerena": "side with Serena",
        "Ep4_SidingWithAvis": "side with Avis",
        "Ep3_SerenaKissAttempt": "Serena kiss attempt",
        "Ep3_SerenaDidntAdvance": "did not advance with Serena",
        "Ep3_SerenaPong": "Serena beer-pong",
        "Ep3_RaikoKiss": "Raiko kiss",
        "Ep3_HotelGetKissed": "hotel kiss",
        "Ep3_HotelGotUnderwear": "got underwear",
        "Ep3_RaikoGivePanties": "Raiko gave panties",
        "Ep3_AskRaikoUnderwear": "asked Raiko for panties",
        "Ep3_KokoPeeked": "peeked at Koko",
        "Ep3_KokoLookedYou": "Koko saw you naked",
        "Ep3_SwimWithKoko": "swam with Koko",
        "Ep3_HotelKokoKiss": "Koko kiss",
        "Ep3_AvisRevealTits": "Avis flash reveal",
        "Ep3_SerenaJokesAboutStars": "star jokes with Serena",
        "Ep2_AvisSunScreenButt": "Avis sunscreen on butt",
        "Ep2_AvisSun": "sun time with Avis",
        "Ep2_AvisBeachHangout": "beach with Avis",
        "Ep2_KokoBeachHangout": "beach with Koko",
        "AvisLostFlag": "Avis route warning",
        "RaikoLostFlag": "Raiko route warning",
        "Ep1_AvisLookButt": "looked at Avis' butt",
        "Ep1_ClubRaikoKiss": "Raiko club kiss",
        "Ep3_KokoKissIfPs": "Koko kiss (points)",
        "Ep3_KokoTitsAreBetter": "Koko tits comment",
        "Ep3_KokoOffersMcRide": "Koko offers a ride",
    }

    _SM_SKIP_VARS = {
        "renpy", "config", "persistent", "store", "i", "k", "x", "y",
        "randomize_chibi",
    }

    def _sm_nice_name(var):
        if var in _SM_FLAG_NAMES:
            return _SM_FLAG_NAMES[var]
        if var in _SM_GIRL_POINTS:
            return var
        # Ep4_SomeFlag -> some flag
        name = var
        m = re.match(r"^Ep\d+_(.+)$", var)
        if m:
            name = m.group(1)
        name = re.sub(r"_replay$", "", name)
        name = re.sub(r"_+", " ", name)
        name = re.sub(r"(?<!^)(?=[A-Z])", " ", name)
        return name.strip().lower()

    def _sm_fmt_effect(var, op, val, maybe=False):
        val = val.strip().rstrip(";")
        prefix = "maybe: " if maybe else ""

        if var in _SM_GIRL_POINTS or var.endswith("LostFlag") or var in (
            "Ep4_SidingWithSerena", "Ep4_SidingWithAvis",
        ):
            nice = _sm_nice_name(var)
            if op == "+=":
                return "{}{} +{}".format(prefix, nice, val)
            if op == "-=":
                return "{}{} -{}".format(prefix, nice, val)

        if op == "=" and val in ("True", "False"):
            nice = _sm_nice_name(var)
            if val == "True":
                if var.endswith("_replay"):
                    return "{}unlocks replay".format(prefix)
                return "{}sets: {}".format(prefix, nice)
            return "{}clears: {}".format(prefix, nice)

        if op == "+=":
            return "{}{} +{}".format(prefix, _sm_nice_name(var), val)
        if op == "-=":
            return "{}{} -{}".format(prefix, _sm_nice_name(var), val)
        return None

    def _sm_interesting(var, op):
        if var in _SM_SKIP_VARS:
            return False
        if var in _SM_GIRL_POINTS:
            return True
        if var in _SM_FLAG_NAMES:
            return True
        if var.endswith("_replay") or var.endswith("LostFlag"):
            return True
        if var.startswith("Ep") and op == "=":
            return True
        if op in ("+=", "-=") and not var.startswith("_"):
            return True
        return False

    def _sm_eval_cond(cond):
        if cond is True or cond == "True":
            return True
        if cond is False or cond == "False":
            return False
        try:
            return bool(renpy.python.py_eval(cond))
        except Exception:
            return None

    def _sm_scan_python(src, effects, maybe=False):
        if not src:
            return
        for raw in str(src).replace(";", "\n").splitlines():
            line = raw.strip()
            if not line or line.startswith("#"):
                continue
            m = _SM_ASSIGN.match(line)
            if not m:
                continue
            var, op, val = m.group(1), m.group(2), m.group(3)
            if not _sm_interesting(var, op):
                continue
            text = _sm_fmt_effect(var, op, val, maybe=maybe)
            if text and text not in effects:
                effects.append(text)

    def _sm_scan_block(block, effects, depth=0, maybe=False):
        if not block or depth > 5:
            return
        for node in block:
            try:
                if isinstance(node, renpy.ast.Python):
                    _sm_scan_python(getattr(node.code, "source", None), effects, maybe)
                elif isinstance(node, renpy.ast.If):
                    # Only show the branch that applies right now
                    unknown = []
                    taken = False
                    for cond, iblock in node.entries:
                        result = _sm_eval_cond(cond)
                        if result is True:
                            _sm_scan_block(iblock, effects, depth + 1, False)
                            taken = True
                            break
                        if result is None:
                            unknown.append(iblock)
                    if not taken:
                        for iblock in unknown:
                            _sm_scan_block(iblock, effects, depth + 1, True)
                elif isinstance(node, renpy.ast.While):
                    _sm_scan_block(node.block, effects, depth + 1, maybe)
                # Internal jumps intentionally omitted
            except Exception:
                continue

    def sm_effects_for_caption(caption):
        if not persistent.fc_walkthrough:
            return []
        try:
            node = renpy.game.script.lookup(renpy.game.context().current)
        except Exception:
            return []
        if not isinstance(node, renpy.ast.Menu):
            return []

        effects = []
        for label, _condition, block in node.items:
            if label != caption:
                continue
            if block:
                _sm_scan_block(block, effects)
            break

        # Points first, then flags; keep at most 3
        points = [e for e in effects if re.search(r"[+-]\d+", e)]
        flags = [e for e in effects if e not in points]
        return (points + flags)[:3]

    def sm_safe_text(s):
        if s is None:
            return ""
        return str(s).replace("[", "[[")

    def sm_choice_label(caption):
        base = sm_safe_text(caption)
        if not persistent.fc_walkthrough:
            return base
        effects = sm_effects_for_caption(caption)
        if not effects:
            return base
        hint = "  {color=#7CFF9A}(" + " · ".join(effects) + "){/color}"
        return base + hint

    def sm_wt_toggle():
        persistent.fc_walkthrough = not bool(persistent.fc_walkthrough)
        renpy.save_persistent()
        renpy.restart_interaction()


screen choice(items):
    style_prefix "choice"

    key "w" action Function(sm_wt_toggle)
    key "W" action Function(sm_wt_toggle)

    vbox:
        for i in items:
            $ enabled = i.kwargs.get("enabled", True)
            $ _label = sm_choice_label(i.caption)
            textbutton _label action i.action sensitive enabled

    vbox:
        xalign 0.98
        yalign 0.02
        spacing 2
        if persistent.fc_walkthrough:
            text "Walkthrough ON  (W)":
                size 18
                color "#7CFF9A"
                xalign 1.0
                outlines [(1, "#000000", 0, 0)]
        else:
            text "Walkthrough OFF  (W)":
                size 18
                color "#aaaaaa"
                xalign 1.0
                outlines [(1, "#000000", 0, 0)]
        text "SatoMod by [satomod_author]":
            size 14
            color "#f13370"
            xalign 1.0
            outlines [(1, "#000000", 0, 0)]


################################################################################
# Credits on main menu + About/Credits screen
################################################################################

# Shown inside the game's Credits page
define gui.about = "{color=#f13370}{b}SatoMod v[satomod_version]{/b} by {b}[satomod_author]{/b}{/color}\nWalkthrough + Gallery Unlock + Extra Scenes\n"

# Redefine main menu so the credit is always visible (overlay was hidden)
screen main_menu():
    tag menu
    style_prefix "main_menu"

    add main_menu_eikomovie
    frame
    use navigation_mainmenu

    textbutton (""):
        area (30, 1005, 65, 65)
        background "gui/button/patreonmenu_idle.png"
        hover_background "gui/button/patreonmenu_hover.png"
        hover_sound "audio/sfx/hover.wav" activate_sound "audio/sfx/Button.mp3"
        action OpenURL("https://www.patreon.com/KatanaVN")

    textbutton (""):
        area (110, 1005, 65, 65)
        background "gui/button/discordmenu_idle.png"
        hover_background "gui/button/discordmenu_hover.png"
        hover_sound "audio/sfx/hover.wav" activate_sound "audio/sfx/Button.mp3"
        action OpenURL("https://discord.gg/cwSpvFDV8q")

    textbutton (""):
        area (190, 1005, 65, 65)
        background "gui/button/subscribestar_idle.png"
        hover_background "gui/button/subscribestar_hover.png"
        hover_sound "audio/sfx/hover.wav" activate_sound "audio/sfx/Button.mp3"
        action OpenURL("https://subscribestar.art/KatanaVN")

    textbutton (""):
        area (1825, 1005, 65, 65)
        background "gui/button/version_idle.png"

    # SatoMod credit — bottom-right, above version icon
    text "SatoMod by [satomod_author]":
        size 22
        color "#f13370"
        outlines [(2, "#000000", 0, 0)]
        xpos 1520
        ypos 1015

# Redefine About/Credits with SatoMod section at the top
screen about():
    tag menu
    use game_menu(_("About"), scroll="viewport", particles="leaf_particles"):
        style_prefix "about"
        vbox:
            at fleft2(0.2)
            xmaximum 0.8
            label "[config.name!t]"
            text _("Version [config.version!t]\n")

            text "{color=#f13370}{size=32}{b}SatoMod{/b}{/size}{/color}"
            text "{color=#f13370}Created by [satomod_author]  ·  v[satomod_version]{/color}"
            text "Walkthrough (press W) · Gallery unlock · Extra Scenes"
            text " "

            text _("Game made by {color=#9C04B1}KatanaVN{/color}")
            text _(" ")
            text _(" ")
            text _("Hey everyone! Thanks for checking out my game. I hope you enjoyed the game so far, and I hope you will keep enjoying it in the future as well!")
            text _("Before saying anything else, I have to give a huge thank you to all of my Patrons.")
            text _("Supporting a new developer with no prior experience is most appreciated. Especially one that went through reworking their game.")
            text _("If I didn't receive the support I did so far, I'd already have to cancel this whole project. So thank you for sticking by my side to tell this story.")
            text _(" ")
            text _("{color=#00CED5}A shout-out to each of my Patrons that contributed!{/color}")
            text _(" ")
            text _("{color=#00CED5}Also special thanks to the following people:{/color}")
            text _("April Yawns, for his constant assistance, helping me improve and push my limits, and always being a shoulder I can cry on when needed.")
            text _("Caribdis for helping me continuously with all my dumbo questions and being an inspiration, and NiiChan for many tips of his own, alongside his contribution with mods.")
            text _("Gary, Claim and Canchez, Pax, for general coding and UI assistance.")
            text _("Dark Ass for his work on multiple of the animating effects.")
            text _("Messe for multiple UI elements designs and ingame UI elements (such as Eiko's phone app).")
            text _("Fouetty for multiple of the newly made maps shown ingame.")
            text _("And of course, to my closest mods and team for assisting me and pushing me to finish the dreaded rework in one piece. Can't thank them enough.")
            text _(" ")
            text _(" ")
            text _("I {b}don't{/b} give permission for my work, characters, renders or animations to be used in any kind of AI tools, programmes, or other games.")
            text _("They are entirely my own, and using in AI tools is not permitted in any capacity.")
            text _("This is a completely free game, if you paid for it you got scammed.")
            text _(" ")
            text _("Renders are made in tools provided by IllusionSoft's software.")
            text _("This is a work of fiction. Names, characters, businesses, places, events, locales are either the products of the author’s imagination or used in a fictitious manner.")
            text _("Any resemblance to actual persons, living or dead, or actual events is purely coincidental.")
            text _(" ")
            text _("{color=#00CED5}Links to my sites:{/color}")
            text _("Patreon: {a=https://www.patreon.com/KatanaVN}https://www.patreon.com/KatanaVN{/a}")
            text _("Discord: {a=https://discord.com/invite/cwSpvFDV8q}https://discord.gg/cwSpvFDV8q{/a} ")
            text _(" ")
            text _(" ")
            text _(" ")
            text _("Autumn Leaves © 2026 by Kigyodev (https://kigyodev.com/) is licensed under CC BY 4.0. To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/ ")
            text _("Credit to be given as Kigyodev (https://kigyodev.com/)")
            text _(" ")
            if gui.about:
                text "[gui.about!t]\n"
            text _("Made with {a=https://www.renpy.org/}Ren'Py{/a} [renpy.version_only].\n\n[renpy.license!t]")


################################################################################
# Extra Scenes (gallery)
################################################################################

init 5 python:
    def fc_replay_label_cb(name, abnormal):
        try:
            if not renpy.store._in_replay:
                return
        except Exception:
            return
        end_at = getattr(renpy.store, "fc_replay_end_at", None)
        if end_at and name == end_at:
            renpy.store.fc_replay_end_at = None
            renpy.end_replay()

    if fc_replay_label_cb not in config.label_callbacks:
        config.label_callbacks.append(fc_replay_label_cb)

    def fc_replay_prep(end_label, **vars_to_set):
        store.fc_replay_end_at = end_label
        for key, value in vars_to_set.items():
            cur = getattr(store, key, None)
            if isinstance(value, bool) or cur is None:
                setattr(store, key, value)
            elif isinstance(value, (int, float)) and isinstance(cur, (int, float)):
                setattr(store, key, max(cur, value))
            else:
                setattr(store, key, value)


init 20 python:
    store.avis_extra_replay1 = replaybutton(
        "ep2beachav86", "images/Episode2/ep2beachav86.jpg",
        "Avis_Gal_1", "Beach sunscreen massage", "Ep2_AvisSunMassage_replay",
    )
    store.avis_extra_replay2 = replaybutton(
        "ep4baravis445", "images/Episode4/ep4baravis445.jpg",
        "Avis_Gal_2", "Bar night ending / kiss", "Ep4_AvisBarKiss_replay",
    )
    store.koko_extra_replay2 = replaybutton(
        "ep3hotelkobe80", "images/Episode3/ep3hotelkobe80.jpg",
        "Koko_Gal_2", "Skinny-dipping on the secluded beach", "Ep3_KokoSkinnyDip_replay",
    )
    store.raiko_extra_replay1 = replaybutton(
        "ep2swimsuitshop134", "images/Episode2/ep2swimsuitshop134.jpg",
        "Raiko_Gal_1", "Swimsuit shop peek", "Ep2_RaikoSwimsuit_replay",
    )
    store.raiko_extra_replay2 = replaybutton(
        "ep3hotelchallr150", "images/Episode3/ep3hotelchallr150.jpg",
        "Raiko_Gal_2", "Hotel party bathroom kiss", "Ep3_RaikoBathroom_replay",
    )
    store.raiko_extra_replay3 = replaybutton(
        "ep4movieplan322", "images/Episode4/ep4movieplan322.jpg",
        "Raiko_Gal_3", "Movie night with Raiko", "Ep4_RaikoMovie_replay",
    )
    store.serena_extra_replay1 = replaybutton(
        "ep3hotelrooftop171", "images/Episode3/ep3hotelrooftop171.jpg",
        "Serena_Gal_1", "Rooftop stars / kiss attempt", "Ep3_SerenaRooftop_replay",
    )
    store.others_extra_replay2 = replaybutton(
        "ep3hotelpoints221", "images/Episode3/ep3hotelpoints221.jpg",
        "Others_Gal_2", "Avis points-game reveal", "Ep3_AvisRevealTits_replay",
    )

    def _sm_add_replay(lst_name, btn):
        lst = getattr(store, lst_name, None)
        if lst is None:
            return
        labels = [getattr(x, "replaylabel", None) for x in lst]
        if btn.replaylabel not in labels:
            lst.append(btn)

    _sm_add_replay("avisreplaygallerybuttons", avis_extra_replay1)
    _sm_add_replay("avisreplaygallerybuttons", avis_extra_replay2)
    _sm_add_replay("kokoreplaygallerybuttons", koko_extra_replay2)
    _sm_add_replay("raikoreplaygallerybuttons", raiko_extra_replay1)
    _sm_add_replay("raikoreplaygallerybuttons", raiko_extra_replay2)
    _sm_add_replay("raikoreplaygallerybuttons", raiko_extra_replay3)
    _sm_add_replay("serenareplaygallerybuttons", serena_extra_replay1)
    _sm_add_replay("othersreplaygallerybuttons", others_extra_replay2)


label Avis_Gal_1:
    if not _in_replay:
        $ persistent.Ep2_AvisSunMassage_replay = True
    $ fc_replay_prep("Ep2_BeachAfter", Avis=20, Ep2_AvisSun=True, Ep2_AvisSunScreenButt=True, Ep2_AvisBeachHangout=True)
    jump Ep2_AvisBeach

label Avis_Gal_2:
    if not _in_replay:
        $ persistent.Ep4_AvisBarKiss_replay = True
    $ fc_replay_prep("Ep4_RaikoHome", Avis=25, Ep4_AvisKissed=True)
    jump Ep4_BarAvisPartTwo

label Koko_Gal_2:
    if not _in_replay:
        $ persistent.Ep3_KokoSkinnyDip_replay = True
    $ fc_replay_prep("Ep3_HotelKokoSkinDip2", Koko=20, Ep2_KokoBeachHangout=True, Ep3_SwimWithKoko=True, Ep3_KokoPeeked=True, Ep3_KokoLookedYou=True)
    jump Ep3_HotelKokoSkinDip

label Raiko_Gal_1:
    if not _in_replay:
        $ persistent.Ep2_RaikoSwimsuit_replay = True
    $ fc_replay_prep("Ep2_BeachMain", Raiko=20)
    jump Ep2_RaikoSwimsuit

label Raiko_Gal_2:
    if not _in_replay:
        $ persistent.Ep3_RaikoBathroom_replay = True
    $ fc_replay_prep("Ep3_KokoLastChallenge", Raiko=25, Ep3_HotelGetKissed=True, Ep3_RaikoKiss=True, Ep3_AskRaikoUnderwear=True, Ep3_RaikoGivePanties=True, Ep3_HotelGotUnderwear=True)
    jump Ep3HotelRaiko

label Raiko_Gal_3:
    if not _in_replay:
        $ persistent.Ep4_RaikoMovie_replay = True
    $ fc_replay_prep("Ep4_LevyHomey", Raiko=25, Ep4_RaikoTriedKiss=True)
    jump Ep4_RaikoMovie

label Serena_Gal_1:
    if not _in_replay:
        $ persistent.Ep3_SerenaRooftop_replay = True
    $ fc_replay_prep("Ep3HotelEndingPart1", Serena=20, Ep3_SerenaPong=True, Ep3_SerenaKissAttempt=True)
    jump Ep3HotelRooftopSecond

label Others_Gal_2:
    if not _in_replay:
        $ persistent.Ep3_AvisRevealTits_replay = True
    $ fc_replay_prep("Ep3AvisPostChat", Avis=20, Ep3_AvisRevealTits=True)
    jump Ep3PointsCounting


################################################################################
# Gallery unlocker + Scenes fix
################################################################################

init 9999 python:
    def _sm_mark_seen(img):
        if not img:
            return
        try:
            renpy.mark_image_seen(img)
        except Exception:
            if persistent._seen_images is None:
                persistent._seen_images = {}
            key = tuple(str(img).split()) if not isinstance(img, tuple) else img
            persistent._seen_images[key] = True

    def _sm_unlock_button_list(buttons):
        for btn in buttons:
            imgs = btn.image if isinstance(btn.image, list) else [btn.image]
            for img in imgs:
                _sm_mark_seen(img)

    def _sm_unlock_replay_list(buttons):
        for btn in buttons:
            setattr(persistent, btn.flag, True)
            try:
                renpy.mark_label_seen(btn.replaylabel)
            except Exception:
                pass

    for _name in (
        "avisgallerybuttons", "eikogallerybuttons", "kokogallerybuttons",
        "levygallerybuttons", "raikogallerybuttons", "serenagallerybuttons",
        "valentinagallerybuttons", "othersgallerybuttons",
    ):
        if hasattr(store, _name):
            _sm_unlock_button_list(getattr(store, _name))

    for _name in (
        "avisreplaygallerybuttons", "eikoreplaygallerybuttons", "kokoreplaygallerybuttons",
        "levyreplaygallerybuttons", "raikoreplaygallerybuttons", "serenareplaygallerybuttons",
        "valentinareplaygallerybuttons", "othersreplaygallerybuttons",
    ):
        if hasattr(store, _name):
            _sm_unlock_replay_list(getattr(store, _name))

    for _flag, _label in (
        ("Ep4_KokoClubBlow_replay", "Koko_Gal_1"),
        ("Ep4_SexSooah_replay", "Others_Gal_1"),
        ("Ep2_AvisSunMassage_replay", "Avis_Gal_1"),
        ("Ep4_AvisBarKiss_replay", "Avis_Gal_2"),
        ("Ep3_KokoSkinnyDip_replay", "Koko_Gal_2"),
        ("Ep2_RaikoSwimsuit_replay", "Raiko_Gal_1"),
        ("Ep3_RaikoBathroom_replay", "Raiko_Gal_2"),
        ("Ep4_RaikoMovie_replay", "Raiko_Gal_3"),
        ("Ep3_SerenaRooftop_replay", "Serena_Gal_1"),
        ("Ep3_AvisRevealTits_replay", "Others_Gal_2"),
    ):
        setattr(persistent, _flag, True)
        try:
            renpy.mark_label_seen(_label)
        except Exception:
            pass

    if hasattr(store, "serenareplaygallerybuttons"):
        store.serenareplaygallerybuttons = [
            b for b in serenareplaygallerybuttons
            if getattr(b, "flag", None) != "Ep3_SerenaRooftopKiss_replay"
        ]

    renpy.save_persistent()


screen replaygallery(who, bg, gallery):
    tag menu
    key "game_menu" action Show("gallerygirls", transition=Dissolve(0.7))

    default faketooltip = None
    default hoverfix = -1
    default newentry = True
    default tooltip_h = None
    default edit_mode = False

    add bg

    hbox:
        anchor (0.0, 0.0)
        pos (0.8, 0.07)
        text "\""
        if not edit_mode:
            button:
                text persistent.replayname size 32 offset (-6, -6) color "#f13370" hover_color "#eda9ff"
                action SetScreenVariable("edit_mode", True)
        else:
            key "dismiss" action SetScreenVariable("edit_mode", False)
            input:
                length 10
                value FieldInputValue(persistent, "replayname")
        text "\""

    frame:
        background None
        yalign 0.5
        xalign 0.95
        has vpgrid

        area (0, -4, 1315, 754)
        cols 3
        spacing 35
        scrollbars "vertical"
        mousewheel True
        xalign 0.1
        allow_underfull True

        if len(who) == 0:
            text "No Scenes for this character yet.":
                size 28
                color "#ffffff"
                xmaximum 900
        else:
            for i, k in enumerate(who):
                if k.unlocked():
                    button:
                        xysize (384, 216)
                        focus_mask None
                        fixed:
                            xysize (384, 216)
                            add k.path xysize (384, 216)
                            add "gui/galleryframe.png":
                                align (0.5, 0.5)
                                if hoverfix == i:
                                    at transform:
                                        zoom 0.2
                                        linear 1.0 alpha 1.0
                                elif not newentry:
                                    at transform:
                                        zoom 0.2
                                        linear 1.0 alpha 0.0
                                else:
                                    at transform:
                                        zoom 0.2
                                        alpha 0.0
                        hovered [SetScreenVariable("hoverfix", i), SetScreenVariable("newentry", False)]
                        unhovered SetScreenVariable("hoverfix", -1)
                        action Replay(
                            k.replaylabel,
                            scope={"mainchar": (persistent.replayname.strip()).title() or "Nathan"},
                            locked=False,
                        )
                else:
                    button:
                        xysize (384, 216)
                        focus_mask None
                        fixed:
                            xysize (384, 216)
                            add "locked" xysize (384, 216) align (0.5, 0.5):
                                if tooltip_h == [k.image, 1]:
                                    at transform:
                                        linear .75 blur 55
                                elif tooltip_h == [k.image, 0]:
                                    at transform:
                                        linear .75 blur 0
                                else:
                                    at transform:
                                        blur 0
                            vbox:
                                align (.5, .5)
                                offset (8, 0)
                                text "Hint!" size 48 text_align .5 align (.5, .5) color "#f13370" outlines [(0, "#00000000", 0, 0)] font "fonts/Stress-2OXgd.otf"
                                text k.clue:
                                    align (.5, .5)
                                    size 24
                                    text_align .5
                                    outlines [(0, "#00000000", 0, 0)]
                                    font "fonts/ChampagneAndLimousines-7KRB.ttf"
                                if tooltip_h == [k.image, 1]:
                                    at transform:
                                        linear .75 alpha 1.0
                                elif tooltip_h == [k.image, 0]:
                                    at transform:
                                        linear .75 alpha .0
                                else:
                                    at transform:
                                        alpha .0
                        action NullAction()
                        hovered [SetScreenVariable("tooltip_h", [k.image, 1])]
                        unhovered [SetScreenVariable("tooltip_h", [k.image, 0])]

    $ tooltip = GetTooltip()
    if tooltip:
        $ faketooltip = tooltip
        frame:
            background "hintframe"
            yalign 0.5
            xalign 0.5
            text "[tooltip]"
            at ttin
    elif faketooltip != None:
        frame:
            background "hintframe"
            yalign 0.5
            xalign 0.5
            text "[faketooltip]"
            at ttout

    button:
        xalign 0.3275
        yalign 0.97
        imagebutton auto "gallery/returngallery_%s.png" action Show("gallerygirls", transition=Dissolve(0.7)) tooltip None xalign 0.5 yalign 0.0 hover_sound "audio/sfx/hover.wav" activate_sound "audio/sfx/Button.mp3"

    button:
        xalign 0.85
        yalign 0.97
        imagebutton auto "gallery/rendersgallery_%s.png" action ShowMenu("gallery", replays=who, bg=bg, who=gallery) xalign 0.5 yalign 0.0 hover_sound "audio/sfx/hover.wav" activate_sound "audio/sfx/Button.mp3"

    button:
        xalign 0.95
        yalign 0.97
        add "gallery/scenesgallery_hover.png"
