##                                                                                                                                                                                                                                                            #簡陋
default persistent.repNameSet = False
default replayBG = "shaddyMod/images/ShaddyBG.png"

    #label :
    #if _in_replay:
        #call Rep_Start

    #if _in_replay:
        #call Rep_End

init python:
    import math
    replayMenu = []
    replayItems = []

    class ReplayMenu:
        def __init__(self, character, image):
            self.character = character
            self.image = image

            replayMenu.append(self)

    class ReplayItem:
        def __init__(self, character, label, image, scope=None):
            self.character = character
            self.label = label
            self.image = image

            if scope is None: self.scope = {}
            else: self.scope = scope

            replayItems.append(self)

    ReplayMenu("Chrys", "/images/bg 1_cs_snipkitchen1_8.webp")
    ReplayMenu("Harper", "/gui/bg harper_mainmenu0_2.webp")
    ReplayMenu("Riley", "/images/bg 1_rb_event1_4.webp")
    ReplayMenu("Valentina", "/images/bg 1_ve_event2_3.webp")
    ReplayMenu("Other", "/images/bg 1_pro_event4_1.webp")

    ReplayItem("Chrys", "chrys_event_6_a", "/images/bg 6_cs_event7_16.webp", {})
    ReplayItem("Chrys", "ChrysScene002", "/images/bg 3_lecture11_1.webp", {})
    ReplayItem("Chrys", "ChrysScene003", "/images/bg 9_cs_event5_3.webp", {})
    ReplayItem("Chrys", "chrys_event_12", "/images/bg 12_cs_event0_2.webp", {})
    ReplayItem("Chrys", "ChrysScene005", "/images/bg 21_cs_event14_1.webp", {})
    ReplayItem("Chrys", "ChrysScene006", "/images/bg 25_cs_event3_3.webp", {})
    ReplayItem("Chrys", "ChrysScene007", "/images/bg 31_cs_event0_12.webp", {})
    ReplayItem("Chrys", "ChrysScene008", "/images/bg 34_cs_event5_1.webp", {})

    ReplayItem("Harper", "HarperScene001", "/images/bg 4_hp_event5_1.webp", {})
    ReplayItem("Harper", "HarperScene002", "/images/bg 5_hp_event2_1.webp", {})
    ReplayItem("Harper", "HarperScene003", "/images/bg 10_hp_event3_1.webp", {})
    ReplayItem("Harper", "HarperScene004", "/images/bg 12_hp_event4_2.webp", {})
    ReplayItem("Harper", "HarperScene005", "/images/bg 18_hp_event14_1.webp", {})
    ReplayItem("Harper", "HarperScene006", "/images/bg 33_hp_event15_1.webp", {})

    ReplayItem("Riley", "RileyScene001", "/images/bg 12_rb_event3_18.webp", {})
    ReplayItem("Riley", "RileyScene002", "/images/bg 13_rb_event4_1.webp", {})
    ReplayItem("Riley", "RileyScene003", "/images/bg 15_rb_event2_2.webp", {})
    ReplayItem("Riley", "riley_event_17", "/images/bg 17_rb_event0_1.webp", {})
    ReplayItem("Riley", "RileyScene004", "/images/bg 22_rb_event2_1.webp", {})
    ReplayItem("Riley", "RileyScene018", "/images/bg 18_rb_sand11_2.webp", {})
    

    ReplayItem("Valentina", "ValentinaScene001", "/images/bg 7_ve_event3_2.webp", {})
    ReplayItem("Valentina", "ValentinaScene002", "/images/bg 14_ve_event9_1.webp", {})
    ReplayItem("Valentina", "ValentinaScene003", "/images/bg 16_ve_event3_1.webp", {})
    ReplayItem("Valentina", "ValentinaScene004", "/images/bg 20_ve_event2_5.webp", {})
    ReplayItem("Valentina", "ValentinaScene005", "/images/bg 22_ve_event19_1.webp", {})

    ReplayItem("Other", "OtherScene001", "/images/bg introduction15_1.webp", {})

default replayCharacter = ""
default replayPage = 1

screen sceneReplayMenu():
    tag menu
    modal True

    add "#000"
    add "shaddyMod/images/ShaddyBG.png" xcenter 0.5 ycenter 0.5 alpha 0.65

    hbox:
        xcenter 0.5
        ycenter 40
        spacing 15
        hbox:
            spacing -5
            text "S" at delayed_blink(1.1, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "h" at delayed_blink(1.0, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "a" at delayed_blink(0.9, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "d" at delayed_blink(0.8, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "d" at delayed_blink(0.7, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "y" at delayed_blink(0.6, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "M" at delayed_blink(0.5, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "o" at delayed_blink(0.4, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "d" at delayed_blink(0.3, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "d" at delayed_blink(0.2, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "a" at delayed_blink(0.1, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "'" at delayed_blink(0.0, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "s" at delayed_blink(0.0, 2.0) outlines [(3, "#000")] style "shaddyHeader"
        hbox:
            spacing -5
            text "S" at delayed_blink(0.1, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "c" at delayed_blink(0.2, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "e" at delayed_blink(0.3, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "n" at delayed_blink(0.4, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "e" at delayed_blink(0.5, 2.0) outlines [(3, "#000")] style "shaddyHeader"
        hbox:
            spacing -5
            text "R" at delayed_blink(0.6, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "e" at delayed_blink(0.7, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "p" at delayed_blink(0.8, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "l" at delayed_blink(0.9, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "a" at delayed_blink(1.0, 2.0) outlines [(3, "#000")] style "shaddyHeader"
            text "y" at delayed_blink(1.0, 2.0) outlines [(3, "#000")] style "shaddyHeader"

#    text "ShaddyModda's Scene Replay" xcenter 0.5 ycenter 40 style "shaddyHeader"

    vpgrid:
        cols 2
        xspacing 810
        yspacing 10
        align(0.5, 0.5)

        for i in replayMenu:
            vbox:
                spacing 0
                frame:
                    background Solid("#0ed6f97F")
                    xysize(300,172)
                    imagebutton:
                        xcenter 0.5 ycenter 0.5
                        action ShowMenu("sceneCharacterMenu"), Hide("sceneReplayMenu"), SetVariable("replayCharacter", i.character)
                        idle Transform(i.image, zoom=0.15)
                        hover Transform(im.MatrixColor(i.image, im.matrix.brightness(0.2)), zoom=0.15)

                text i.character xcenter 0.5 ycenter 0.5 style "shaddyTextBody2"

    textbutton _("RENAME"):
        text_style "shaddyTextButton2"
        align(0.01,1.0)
        action [ui.callsinnewcontext("Rename")]

    textbutton "RETURN":
        text_style "shaddyTextButton2"
        align(0.5,1.0)
        action Hide("sceneReplayMenu"), Return()

    vbox:
        align(0.998,0.998)
        xysize(175,150)
        imagebutton:
            #xalign 0.99 yalign 0.89
            idle im.Scale("shaddyMod/images/patreon.png", 150, 40)
            hover im.Scale(im.MatrixColor("shaddyMod/images/patreon.png", im.matrix.colorize("#cc33cc", "#009dff")), 175, 50)
            action OpenURL("https://www.patreon.com/ShaddyModda")
        imagebutton:
            #xalign 0.99 yalign 0.94
            idle im.Scale("shaddyMod/images/substar.png", 150, 40)
            hover im.Scale(im.MatrixColor("shaddyMod/images/substar.png", im.matrix.colorize("#cc33cc", "#009dff")), 175, 50)
            action OpenURL("https://subscribestar.adult/shaddymodda")
        imagebutton:
            #xalign 0.99 yalign 0.99
            idle im.Scale("shaddyMod/images/Discord.png", 150, 40)
            hover im.Scale(im.MatrixColor("shaddyMod/images/Discord.png", im.matrix.colorize("#f00", "#f00")), 175, 50)
            action OpenURL("https://discord.gg/MS3nkmkpm6")


screen sceneCharacterMenu():
    tag menu
    modal True

    if replayCharacter == "Chrys":
        #add renpy.random.choice(['scenes/day_1/39.webp', 'scenes/day_2/289.webp', 'scenes/day_3/554az.webp'])
        add "ChrShow" xcenter 0.5 ycenter 0.5 #alpha 0.3

    elif replayCharacter == "Harper":
        #add renpy.random.choice(['scenes/day_1/69e.webp', 'scenes/day_2/254c.webp', 'scenes/day_3/480.webp'])
        add "HarShow" xcenter 0.5 ycenter 0.5 #alpha 0.3

    elif replayCharacter == "Riley":
        #add renpy.random.choice(['scenes/day_1/50.webp', 'scenes/day_2/288.webp', 'scenes/day_3/553az.webp'])
        add "RilShow" xcenter 0.5 ycenter 0.5 #alpha 0.3

    elif replayCharacter == "Valentina":
        #add renpy.random.choice(['scenes/day_1/144.webp', 'scenes/day_2/244.webp', 'scenes/day_3/352.webp'])
        add "ValShow" xcenter 0.5 ycenter 0.5 #alpha 0.3

    elif replayCharacter == "Victoria":
        #add renpy.random.choice(['scenes/day_1/199c.webp', 'scenes/day_2/253w.webp', 'scenes/day_3/413d.webp'])
        add "VicShow" xcenter 0.5 ycenter 0.5 #alpha 0.3

    elif replayCharacter == "Missus Powell":
        #add renpy.random.choice(['scenes/day_1/199c.webp', 'scenes/day_2/253w.webp', 'scenes/day_3/413d.webp'])
        add "PowShow" xcenter 0.5 ycenter 0.5 #alpha 0.3

    else:
        #add gui.main_menu_background
        add "OthShow" xcenter 0.5 ycenter 0.5 #alpha 0.3


    text "[replayCharacter] Scenes":
    #text "[replayCharacter] Scenes - Page [replayPage]":
        style "shaddyHeader"
        xcenter 0.5
        ycenter 40

    if replayPage == 1:
        textbutton "BACK":
            text_style "shaddyTextButton2"
            align(0.5,1.0)
            action Show("sceneReplayMenu"), Hide("sceneCharacterMenu")
    else:
        vpgrid:
            rows 1
            align(0.5, 1.0)
            hbox:
                textbutton "BACK":
                    text_style "shaddyTextButton2"
                    action SetVariable("replayPage", replayPage - 1)

                if replayPageNumber != max([replayItem.pageNum for replayItem in replayItems if replayItem.character == replayCharacter]):
                    textbutton "NEXT":
                        text_style "shaddyTextButton2"
                        action SetVariable("replayPage", replayPage + 1)

    vpgrid:
        cols 2
        xspacing 810
        yspacing 20
        align(0.5, 0.5)

        for item in replayItems:
            if item.character == replayCharacter:
                $ scopeDict = {"p":persistent.repName, "quick_menu":False}
                $ scopeDict.update(item.scope)
                frame:
                    background Solid("#0ed6f97F")
                    xysize(298,170)
                    imagebutton:
                        xcenter 0.5 ycenter 0.5
                        idle Transform(item.image, zoom=0.15)
                        hover Transform(im.MatrixColor(item.image, im.matrix.brightness(0.2)), zoom=0.15)
                        action Replay(item.label, scope=scopeDict, locked = False)

init:
    image ChrShow:
        "gui/bg chrys_mainmenu0_1.webp" with Dissolve(2.0)
        pause(5.0)
        "gui/bg chrys_mainmenu0_2.webp" with Dissolve(2.0)
        pause(5.0)
        "gui/bg chrys_mainmenu1_1.webp" with Dissolve(2.0)
        pause(5.0)
        repeat
    image HarShow:
        "gui/bg harper_mainmenu0_1.webp" with Dissolve(2.0)
        pause(5.0)
        "gui/bg harper_mainmenu0_2.webp" with Dissolve(2.0)
        pause(5.0)
        "gui/bg harper_mainmenu1_1.webp" with Dissolve(2.0)
        pause(5.0)
        repeat
    image RilShow:
        "gui/bg riley_mainmenu0_1.webp" with Dissolve(2.0)
        pause(5.0)
        "gui/bg riley_mainmenu0_2.webp" with Dissolve(2.0)
        pause(5.0)
        "gui/bg main_menu_riley1_1.jpg" with Dissolve(2.0)
        pause(5.0)
        repeat
    image ValShow:
        "gui/bg main_menu_valentina0_1.jpg" with Dissolve(2.0)
        pause(5.0)
        "gui/bg main_menu_valentina0_2.jpg" with Dissolve(2.0)
        pause(5.0)
        "gui/bg main_menu_valentina1_1.jpg" with Dissolve(2.0)
        pause(5.0)
        repeat
    #image VicShow:
        #"gui/199c.webp" with Dissolve(2.0)
        #pause(5.0)
        #"gui/253w.webp" with Dissolve(2.0)
        #pause(5.0)
        #"gui/413d.webp" with Dissolve(2.0)
        #pause(5.0)
        #repeat
    #image PowShow:
        #"gui/199c.webp" with Dissolve(2.0)
        #pause(5.0)
        #"gui/253w.webp" with Dissolve(2.0)
        #pause(5.0)
        #"gui/413d.webp" with Dissolve(2.0)
        #pause(5.0)
        #repeat
    image OthShow:
        "images/bg introduction15_7.webp" with Dissolve(2.0)
        pause(5.0)
        "images/bg 3_patrol10_5.webp" with Dissolve(2.0)
        pause(5.0)
        "images/bg 3_patrol11_8.webp" with Dissolve(2.0)
        pause(5.0)
        repeat

label replayName:
    if persistent.repNameSet == True:
        return
    else:
        scene black
        if persistent.repName == "" or "None":
            $ persistent.repName = renpy.input("Enter your replay name: Default is Hero.", "Hero").strip()
        $ persistent.repNameSet = True
        return

label replayRename:
    scene black
    $ persistent.repName = renpy.input("Enter your replay name: Default is Hero.", "Hero").strip()

    #call screen sceneReplayMenu
    return

label Rep_End:
    scene black with dissolve
    $ renpy.end_replay()
    return
##                                                                                                                                                                                                                                                            #簡陋
