CG gallery help

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
yoshibb
Veteran
Posts: 202
Joined: Thu Nov 27, 2014 12:37 pm
Contact:

CG gallery help

#1 Post by yoshibb »

I was hoping to be able to figure it out for myself, but nothing I do seems to work. I'm building a CG gallery using code from here https://www.renpy.org/doc/html/rooms.html. The gallery is functioning with the thumbnails showing up and the cgs are unlocking properly but there is a transparent border around the images and inside the locked button. This is what it looks like:

Image

This is the code for it:

Code: Select all

init python:

    # Step 1. Create the gallery object.
    g = Gallery()

    # Step 2. Add buttons and images to the gallery.

    g.locked_background = "gallery.png"
    
    g.locked_button = "commonlock.png"
    g.hover_border = None
    g.idle_border = None

    # A button that contains an image that automatically unlocks.
    g.button("cgcarryunlock")
    g.image("cgcarry")
    g.unlock("cgcarry")
    
    g.button("cgcarry")
    g.unlock_image ("cgcarry")
    
    g.button("cg1unlock")
    g.image("cg1")
    g.unlock("cg1")
    
    g.button("cg1")
    g.unlock_image ("cg1")

    g.button("cg2unlock")
    g.image("cg2")
    g.unlock("cg2")
    
    g.button("cg2")
    g.unlock_image ("cg2")
    
    g.button("cgprotectunlock")
    g.image("cgprotect")
    g.unlock("cgprotect")
    
    g.button("cgprotect")
    g.unlock_image ("cgprotect")
    
    g.button("cgfightunlock")
    g.image("cgfight")
    g.unlock("cgfight")
    
    g.button("cgfight")
    g.unlock_image ("cgfight")
    
    g.button("cg3unlock")
    g.image("cg3")
    g.unlock("cg3")
    
    g.button("cg3")
    g.unlock_image ("cg3")

# Step 3. The gallery screen we use.
screen gallery:

    # Ensure this replaces the main menu.
    tag menu

    imagemap:
        ground "gallery.png"
        idle "gallery.png"
        hover "galleryhover.png"
        cache False
     
        hotspot (281,53,68,26) action ShowMenu("save")
        hotspot (360,53,68,26) action ShowMenu("load")
        hotspot (455,53,104,26) action ShowMenu("preferences")
        hotspot (575,53,76,26) action ShowMenu ("extra")
        hotspot (667,53,68,26) action Help()
        hotspot (750,53,68,26) action Quit(confirm=True)
        
        hotspot (384,553,29,28) action ShowMenu ("gallery")
        hotspot (419,553,29,28) action ShowMenu ("gallery2")
        hotspot (453,553,29,28) action ShowMenu ("gallery3")
        hotspot (484,553,29,28) action ShowMenu ("gallery4")
        
        hotspot (761,540,130,44) action Return()


    # A grid of buttons.
    grid 2 3:

        xfill True
        yfill True

        # Call make_button to show a particular button.
        add g.make_button("cgcarry", "cgcarryunlock.png", xalign=0.65, yalign=1.18)
        add g.make_button("cg1", "cg1unlock.png", xalign=0.35, yalign=1.18)
        add g.make_button("cg2", "cg2unlock.png", xalign=0.65, yalign=0.73)
        add g.make_button("cgprotect", "cgprotectunlock.png", xalign=0.35, yalign=0.75)
        add g.make_button("cgfight", "cgfightunlock.png", xalign=0.64, yalign=0.31)
        add g.make_button("cg3", "cg3unlock.png", xalign=0.35, yalign=0.3)
I thought that it had something to do with the hover/idle border, but when I set them to none, nothing seems to happen. I also tried setting the locked button to none, but that didn't work either. I'm really at a loss. If anyone has any ideas on how to fix this, I'd be extremely grateful. This is the last thing I need to do to finish my game, so I'd like to fix it as soon as possible.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: CG gallery help

#2 Post by gas »

Try to set an xminimum and yminimum for the button images.

Like that (but with your values):

Code: Select all

add prf.make_button("dawn", "GALLERY/image1.jpg", xalign=0.5, yalign=0.5, xminimum=160, yminimum=120)
Note the xminimum and yminimum.

(Also note that the gallery buttons inherit the default button style of your game)
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

yoshibb
Veteran
Posts: 202
Joined: Thu Nov 27, 2014 12:37 pm
Contact:

Re: CG gallery help

#3 Post by yoshibb »

gas wrote:Try to set an xminimum and yminimum for the button images.

Like that (but with your values):

Code: Select all

add prf.make_button("dawn", "GALLERY/image1.jpg", xalign=0.5, yalign=0.5, xminimum=160, yminimum=120)
Note the xminimum and yminimum.

(Also note that the gallery buttons inherit the default button style of your game)
I tried this but it unfortunately did not fix the problem. I'm not sure what your mean by inheriting the default button style? None of the other buttons in the game have that border around them. It's only these image buttons that are giving me trouble.

kichithewolf
Newbie
Posts: 1
Joined: Tue Feb 08, 2011 4:47 pm
Projects: TwitchDatesPokemon
Github: kichithewolf
Contact:

Re: CG gallery help

#4 Post by kichithewolf »

I just ran into a similar problem myself. As far as I can tell, make_button seems to add a frame as the background of the thumbnail buttons. It takes window style properties though, so I just removed the padding and resized my borders a bit.

Code: Select all

add g.make_button("blah", "blah_icon.png", xalign=0.5, yalign=0.5, xpadding = 0, ypadding = 0)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot]