Leon's CG Gallery - Not working as expected with new GUI

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
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Leon's CG Gallery - Not working as expected with new GUI

#1 Post by Imperf3kt »

I can't see why, but I'm porting a comic / novel I made some time ago by request of the artist (who is very slowly doing more) to the new GUI.
So far, it's been pretty easy but I've run into a snag. When I try to add a CG Gallery, using Leon's code, I get the gallery show as intended, but the buttons only work if I click on the top ~1/10th of the image. Clicking anywhere else does nothing.

I'm thinking of writing my own gallery later on, but for now I need what I have.
Can anybody see what I've missed or mistaken that is causing this to happen?

Code: Select all

#CG Gallery

init-1:
    image bg sc01 = "bcde34f.jpg"
    image bg sc02 = "bf27888.jpg"
    image bg sc03 = "c099f80.jpg"
    image bg sc04 = "f7d7b0e.jpg"
    image bg sc05 = "105320c.jpg"
    image bg sc06 = "cf24501.jpg"
    image bg sc07 = "538adc8.jpg"
    image bg sc08 = "1c56479.jpg"
    image bg sc09 = "ae34943.jpg"
    image bg sc10 = "20420d5.jpg"
    image bg sc11 = "9796f4a78d.jpg"
    image bg sc12 = "2fXx6.jpg"

init python:
    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["bg sc01", "bg sc02", "bg sc03", "bg sc04", "bg sc05", "bg sc06", "bg sc07", "bg sc08", "bg sc09", "bg sc10", "bg sc11", "bg sc12"]
    #how many rows and columns in the gallery screens?
    gal_rows = 3
    gal_cols = 3
    #thumbnail size in pixels:
    thumbnail_x = 150
    thumbnail_y = 130
    #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.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"):
        grid gal_rows gal_cols:
            spacing 110
            $ 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
                null
        frame:
            xpos 0
            ypos 150
            has vbox:
                if len(gallery_cg_items)>gal_cells:
                    textbutton _("Next Page") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]

Here's a video of the issue:
https://puu.sh/vGcLU/3677167744.mp4

It doesn't show on the video, but I'm clicking like a madman.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
juunishi master
Regular
Posts: 61
Joined: Sat Oct 31, 2015 12:08 am
Organization: Linemancer Works
Skype: juunishi_master
itch: juunishi-master
Location: Indonesia
Contact:

Re: Leon's CG Gallery - Not working as expected with new GUI

#2 Post by juunishi master »

I will seconded this question.

I have the exact same problem, but in my case, I follow the code in https://renpy.org/doc/html/rooms.html and I can't press the button except the top part of it, which I accidentally found after clicking around the screen frantically.

H E L P ? orz

pandadeath
Newbie
Posts: 8
Joined: Mon May 09, 2016 3:04 pm
Contact:

Re: Leon's CG Gallery - Not working as expected with new GUI

#3 Post by pandadeath »

I have some code that worked before the update. I made some changes to get it to display in the new GUI, but the gallery buttons no longer function. There are no error messages, clicking the button simply does not do anything. Unless it is clicked on the very top of the image. (I actually did not notice this for a long time, it is a very narrow place.)

I also tried with the bare bones code from https://www.renpy.org/doc/html/rooms.html But the buttons do not display the image (unless clicked on the very top of the image).

I have the code attached.
Attachments
gallery_test-1.0-pc.zip
gallery code
(25.49 MiB) Downloaded 38 times

pandadeath
Newbie
Posts: 8
Joined: Mon May 09, 2016 3:04 pm
Contact:

Re: Leon's CG Gallery - Not working as expected with new GUI

#4 Post by pandadeath »

By the way, to change the code for the first post:

#CG Gallery

init-1:
image bg sc01 = "bcde34f.jpg"
image bg sc02 = "bf27888.jpg"
image bg sc03 = "c099f80.jpg"
image bg sc04 = "f7d7b0e.jpg"
image bg sc05 = "105320c.jpg"
image bg sc06 = "cf24501.jpg"
image bg sc07 = "538adc8.jpg"
image bg sc08 = "1c56479.jpg"
image bg sc09 = "ae34943.jpg"
image bg sc10 = "20420d5.jpg"
image bg sc11 = "9796f4a78d.jpg"
image bg sc12 = "2fXx6.jpg"

init python:
#Galleries settings - start
#list the CG gallery images here:
gallery_cg_items = ["bg sc01", "bg sc02", "bg sc03", "bg sc04", "bg sc05", "bg sc06", "bg sc07", "bg sc08", "bg sc09", "bg sc10", "bg sc11", "bg sc12"]
#how many rows and columns in the gallery screens?
gal_rows = 3
gal_cols = 3
#thumbnail size in pixels:
thumbnail_x = 150
thumbnail_y = 130
#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.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(gal_item+".jpg", thumbnail_x, thumbnail_y))

screen cg_gallery():
tag menu
use game_menu(_("Image Gallery"), scroll="viewport"):
grid gal_rows gal_cols:
spacing 110
$ 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
null
frame:
xpos 0
ypos 150
has vbox:
if len(gallery_cg_items)>gal_cells:
textbutton _("Next Page") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]


I was able to clear the fatal error by changing the ImageReference to Image. The issue seems to be a change when creating the thumbnail. I am sure that there is a better way to just name an image the list item name + butt and define that image to be the thumbnail of the image.

I also had issues passing in the string straight from the list, so I had to use im.Scale(gal_item+".jpg", blah blah). This requires you to list the image names in the gal_items list. If I tried to define the images the "normal" way, the program would complain that it could not find the file.

Post Reply

Who is online

Users browsing this forum: Google [Bot], mirceea