## Replay Gallery screen ######################################
## Take care when making changes to this file #################

screen Replayexit():
    zorder 100
    imagebutton:
        auto "images/exit_%s.png" 
        action EndReplay() 
        yalign .99 
        xalign .99
            #yes AUTO create 2 images titled exit_hover.png and exit_idle.png
            #if you want to change the images for this screen

#add these 2 line below if you want an exit button during the replay(optional)
#this must be added after every label used for replay
label replayOne:
    if _in_replay:
        show screen Replayexit

screen replay_gallery_B():

    tag menu
    use game_menu(_("{size=-20}Replay Gallery{/size}"), scroll="viewport"):
        style_prefix "about"

    $ start = replay_page * 9
    $ end = min(start + 9 - 1, len(Replay_items) - 1)

    #grid for images
    grid maxnumx maxnumy:
        pos (gx1, gy1)
        yfill True
        xspacing 25
        yspacing - 160

        for i in range(start, end + 1):
            if renpy.seen_label(Replay_items[i].replay):
                imagebutton:
                    idle Replay_items[i].thumbs
                    style "gallery_button" #delete this line to remove hover
                    action Replay(Replay_items[i].replay)
                    xalign 0.5
                    yalign 0.5
                    at imageThumb
            else:
                vbox xalign 0.5 yalign 0.5:
                    # image Replay_items[i].locked:
                    #     at imageThumb
                    #add im.Grayscale(Replay_items[i].thumbs):
                    #add im.MatrRixColor(Replay_items[i].thumbs, im.matrix.saturation(0)):
                    add Transform(Replay_items[i].thumbs,matrixcolor=SaturationMatrix(0)):
                        at imageThumb

        #required to fill in empty grid items (do not change)
        for i in range(end - start + 1, 9):
            null

    if replay_page > 0:
        imagebutton:
            idle "images/phone_prev.png"
            hover "images/phone_prevb.png"
            action SetVariable("replay_page", replay_page - 1)
            xalign 0.8
            yalign 0.98

    if (replay_page + 1) * 9 < len(Replay_items):
        imagebutton:
            idle "images/phone_next.png"
            hover "images/phone_nextb.png"
            action SetVariable("replay_page", replay_page + 1)
            xalign 0.9
            yalign 0.98


## Replay Gallery screen ######################################
##
## This is a simple screen that shows buttons that replay a scene from the game.
init python:

    maxthumbx = config.screen_width / (3 + 1)
    maxthumby = config.screen_height / (3 + 1)

    replay_page = 0

    class ReplayItem:
        def __init__(self, thumbs, replay, name, locked="locked"):
            self.thumbs = thumbs
            self.replay = replay
            self.name = name
            self.locked=locked

    #add replay items here format below
    #Replay_items.append(ReplayItem(["the thumbnail"], "the_label_from_code", "brief description"))
    Replay_items = []
    Replay_items.append(ReplayItem("bf_mc_sex", "bf_mc_sex", "First time sex with mc and bf."))
    Replay_items.append(ReplayItem("mc_mast", "mc_mast", "MC alone time."))


    seen_gallery_labels = [
    ##"bf_mc_sex", ##TODO add this after next update
    ##"mc_mast" ##TODO add this after next update
    
    ]

    def unlock_all_gallery():
        if not hasattr(persistent, "_seen_ever"):
            persistent._seen_ever = {}

        for label in seen_gallery_labels:
            persistent._seen_ever[label] = True
        renpy.save_persistent()


# a black background screen for the selection
image black = "#000000"

#replay thumbnails images setup defined here
image bf_mc_sex = ("images/bf/bf mc sex1.jpg")
image mc_mast = ("images/mc/mc mast1.jpg")



