Gallery with Pages Linkage

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
ourdecemberdreams
Regular
Posts: 58
Joined: Sat Apr 15, 2017 3:26 pm
Projects: The Last December
Tumblr: ourdecemberdreams
Deviantart: ourdecemberdreams
itch: ourdecemberdreams
Contact:

Gallery with Pages Linkage

#1 Post 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()

PruJo
Newbie
Posts: 6
Joined: Sun Jan 27, 2019 5:14 pm
Projects: Ascension: Remake, Helix Felix
Contact:

Re: Gallery with Pages Linkage

#2 Post 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.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Gallery with Pages Linkage

#3 Post by rayminator »

have you tried using this one in the cookbook

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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Kocker