Sectionalizing Leon's CG Gallery? [Solved (kinda)]

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
User avatar
MoonByte
Regular
Posts: 173
Joined: Thu Mar 24, 2016 9:18 pm
Completed: Shine (RPG Maker), Heroes (RPG Maker), Lantern Bearer (RPG Maker), Loop the Loop (Unity), Other Stars (Unreal), Sky Eye (RPG Maker), WIN Delivery & Fateful (Ren'Py)
Projects: Weird Is Normal (Ren'Py)
Location: Germany
Contact:

Sectionalizing Leon's CG Gallery? [Solved (kinda)]

#1 Post by MoonByte »

EDIT:
I broke the gallery like 10 times, trying to figure this out, and finally decided to improvise and build the entire thing with image buttons, so I don't need help anymore :P
-------

I am using Leon's code for a CG gallery which works just fine except for two small things:
1) I have so many CGs that it literally breaks the code :'D

Code: Select all

gallery_cg_items = ["bg w_cg1", "bg e_cg1", "bg t_cg1", "bg z_cg1"]
This line has so many items that it stops reading it as code until the end of the block (#Galleries settings - end).

2) Related but since I got so many CGs, it's probably also just plain annoying for players to find what they're looking for. Like, if I wanna find the CGs I unlocked of Andrea, I don't wanna have to click through 6 pages of other characters first, if possible.

So my question would be if it is possible to somehow add like a sub-menu to Leon's code so I can call different galleries for it?
Like, a button labeled Main, one button labeled Andrea, one labeled Michael, one labeled Ina.
And then, ONLY the CGs related to each would be found there. That way, the gallery list is less likely to break AND it is easier to navigate.

EDIT:
Just to be 100% clear, my code looks like this in full:

Code: Select all

#CG Gallery
init-1:
    image bg w_cg1 = "CG/w_w_cg1.png"
    image bg e_cg1 = "CG/w_e_cg1.png"
    image bg t_cg1 = "CG/w_t_cg1.png"
    image bg z_cg1 = "CG/w_z_cg1.png"

init python:
    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["bg w_cg1", "bg e_cg1", "bg t_cg1", "bg z_cg1"]
    #how many rows and columns in the gallery screens?
    gal_rows = 3
    gal_cols = 3
    #thumbnail size in pixels:
    thumbnail_x = 356
    thumbnail_y = 200
    #the setting above will work well with 4:3 screen ratio. Make sure to adjust it, if your are using 16:9 (such as 267x150) or something else.
    #Galleries settings - end

    gal_cells = gal_rows * gal_cols
    g_cg = Gallery()
    for gal_item in gallery_cg_items:
        g_cg.button(gal_item + " butt")
        g_cg.image(gal_item)
        g_cg.unlock(gal_item)
    g_cg.transition = fade
    cg_page=0

init +1 python:
    #Here we create the thumbnails. We use a special "locked" image for CGs to prevent spoilers.
    for gal_item in gallery_cg_items:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))

screen cg_gallery():
    tag menu
    use game_menu(_("Image Gallery"), scroll="viewport"):
        hbox:
            grid gal_cols gal_rows:
                spacing 35
                $ i = 0
                $ next_cg_page = cg_page + 1
                if next_cg_page > int(len(gallery_cg_items)/gal_cells):
                    $ next_cg_page = 0
                for gal_item in gallery_cg_items:
                    $ i += 1
                    if i <= (cg_page+1)*gal_cells and i>cg_page*gal_cells:
                        add g_cg.make_button(gal_item + " butt", gal_item + " butt", im.Scale("gallocked.png", thumbnail_x, thumbnail_y), xalign=0.5, yalign=0.5, idle_border=None, background=None, bottom_margin=0)
                for j in range(i, (cg_page+1)*gal_cells): #we need this to fully fill the grid
                    null
            frame:
                xpos 35
                ypos 610
                if len(gallery_cg_items)>gal_cells:
                    textbutton _("Next Page") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]