Page 1 of 1

Gallery with Pages Linkage

Posted: Mon Feb 05, 2018 1:30 pm
by ourdecemberdreams
I tried making a cg gallery by combining the cg gallery code and the save/load code. But I can't seem to get the pages to link together. Right now, the title of the page will follow the correct page number selected, but the grids displaying the cgs wouldn't change pages.

Also, if I leave the "<" and ">" arrows, the page will be linked to the "Automatic Saves" and "Quick Saves" (because I copied the page number code from the save/load pages hehe) Is there any way for it to stop at page 1 instead of going to the "Automatic Saves" and "Quick Saves"? Please help!

Code: Select all

init python:

    g = Gallery()

    thumbnail_x = 390
    thumbnail_y = 215
    
    g.transition = dissolve
    g.locked_button = im.Scale("cg/gallerylocked.jpg", thumbnail_x, thumbnail_y)

    g.button(1)
    g.unlock_image("cg1")

    g.button(2)
    g.unlock_image("cg2")

    g.button(3)
    g.unlock_image("cg3")

    g.button(4)
    g.unlock_image("cg4")

    g.button(5)
    g.unlock_image("cg5")

    g.button(6)
    g.unlock_image("cg6")

    g.button(7)
    g.unlock_image("cg7")

    g.button(8)
    g.unlock_image("cg8")

    g.button(9)
    g.unlock_image("cg9")
    
screen gallery():
    
    tag menu
    use Gallery(_("Gallery"))
    
    
screen Gallery(title):
    
    default page_name_value = FilePageNameInputValue(pattern=_("Page {}"))

    use game_menu(title):
        fixed:
            ## This ensures the input will get the enter event before any of the
            ## buttons do.
            order_reverse True

            ## The page name, which can be edited by clicking on a button.
            button:
                style "page_label"

                key_events True
                xalign 0.5
                action page_name_value.Toggle()

                input:
                    style "page_label_text"
                    value page_name_value


            # A grid of buttons.
            grid 3 2:
                style_prefix "slot"

                xalign 0.5
                yalign 0.5

                spacing gui.slot_spacing

                for i in range(3 * 2):

                    $ slot = i + 1

                    button:
                        add g.make_button(slot, im.Scale("images/cg/cg{}.jpg".format(slot), thumbnail_x, thumbnail_y), xoffset=-17, yoffset=-5, xsize=thumbnail_x, ysize=thumbnail_y) xalign 0.5


            ## Buttons to access other pages.
            hbox:
                style_prefix "page"

                xalign 1.0
                yalign 1.0  

                spacing gui.page_spacing

                #textbutton _("<") action FilePagePrevious()

                ## range(1, 10) gives the numbers from 1 to 9.
                for page in range(1, 10):
                    textbutton "[page]" action FilePage(page)

                #textbutton _(">") action FilePageNext()

Re: Gallery with Pages Linkage

Posted: Sat Mar 21, 2020 5:47 am
by PruJo
Did you ever figure this out? I'm trying to make pretty much this (but somehow more complicated) and I'm having the same problem. The convoluted layers of mine are working fine, but that page stuff just won't cooperate. Is it inherently linked to the save/load system? If so that would be a shame, because I really want to use this thing.

Re: Gallery with Pages Linkage

Posted: Sat Mar 21, 2020 1:38 pm
by rayminator
have you tried using this one in the cookbook

Per-Character Gallery (+ Multiple Pages)
viewtopic.php?f=51&t=55597