Problems with CG Gallery (I'm using leon's code)

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
User avatar
Catlip Candy
Posts: 146
Joined: Tue Nov 25, 2014 5:03 am
Completed: Raven // Encanto
Projects: My Twisted Love Story (title susceptible to change)
Organization: Catlip Candy
Tumblr: catlipcandy
Deviantart: CatlipCandy
Soundcloud: Catlip Candy
itch: catlipcandy
Location: Philippines

Problems with CG Gallery (I'm using leon's code)

#1 Post by Catlip Candy » Sun Mar 26, 2017 6:46 am

leon's CG gallery code in this thread worked like magic on my first visual novel. I was about to reply on his thread to ask a question about something but it says questions don't belong there and that questions should belong in the Renpy Questions section so I got scared and so I went here to ask the question.

So now that I'm working on my second one for this year's NaNoRenO, I can't make this code work again... There's no problem on the script or code since no "traceback" text is appearing but I have this problem:
As you can see, the boxes are not in line and they're on top of each other, overlapping. The first CG and the fourth CG overlaps, and that's what happen if there's more 5th and 6th CGs. I only have 5 CGs to show for the game in total but I used this 4 CGs to test the code again. When the reader sees the CG on the gameplay, the code automatically unlocks the photo, so I have no problem with getting it unlocked... But the problems I have are:

1. The photos are overlapping each other and
2. When I click the unlocked CG photos to view them full screen, it doesn't happpen (because on my previous VN, you can view them by full screen when you unlock the CG)
3. Background is transparent.

Here's the code that I have as of now:

Code: Select all

init python:
    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["Dead 1", "Dead 2", "Dead 3", "Prisoner 1"]

    #how many rows and columns in the gallery screens?
    gal_rows = 3
    gal_cols = 3
    #thumbnail size in pixels:
    thumbnail_x = 450
    thumbnail_y = 300
    #the setting above (267x150) will work well with 16:9 screen ratio. Make sure to adjust it, if your are using 4:3 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.transition = fade

init +1 python:
    #Here we create the thumbnails. We create a grayscale thumbnail image for BGs, but 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 navigation
    frame background None xpos 10:
        grid gal_rows gal_cols:
            ypos 10
            $ 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=24)
            for j in range(i, (cg_page+1)*gal_cells): #we need this to fully fill the grid
            yalign 0.97
                if len(gallery_cg_items)>gal_cells:
                    textbutton _("Next Page") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]
The code is pasted on my screens.rpy right now. I'm also currently using the 1280x720 screen with the new GUI theme, and I don't know if the latest ren'py software affects this code. leon's thread is old tho, but I'm hoping the code is still reusable. I tried to change some settings on the code above such as the thumbnail size (it does make it bigger and looks more stretched) and the frame background xpos which is originally 10 in the code above (I observed when I set the number higher, this adjusts all the CG boxes/photos more to the right of the screen, like, it added some margin on the left side).

NaNoRenO is almost done, and I'm not sure whether I can make a CG gallery for it. It's my first participation on NaNoRenO and everything feels like rushed, so I'm rushing the code, too. If I couldn't make the code work for this NaNoRenO, I then hope that my problem gets solved even after NaNoRenO cos leon's code is just amazing and easier to understand than any other code/tutorial I've searched, I want to keep using this code. I owe my life to it. Jk. But I really like the code a lot.
All I ask from the readers is to give feedback on what they think I should improve more.
Even the harshest comments are welcomed and greatly appreciated, as long as it is your truthful opinion!
Please help me become a better visual novel creator!

~~~~~~ Catlip Candy ~~~~~~~

Post Reply

Who is online

Users browsing this forum: KingsCard