Instant CG and BG gallery

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Message
Author
User avatar
Fenrir34
Miko-Class Veteran
Posts: 560
Joined: Fri Jul 05, 2013 4:39 am
Completed: Escaping Sorrow
Projects: Crisis Beat,Lynarsia-The Broken Song
Location: California
Contact:

Re: Instant CG and BG gallery

#31 Post by Fenrir34 »

leon wrote:You need to add the button to "screen main_menu" in screens.rpy to call the gallery screen. Something like this:

Code: Select all

        textbutton _("Start Game") action Start()
        textbutton _("CG Gallery") action ShowMenu("cg_gallery")
        textbutton _("Load Game") action ShowMenu("load")

Okay. It showed but when I click on it says that gallery is not a screen or label.

Sorry if I'm a bother. I only know basic renpy coding. Never done this part before :(

User avatar
leon
Miko-Class Veteran
Posts: 554
Joined: Sun Oct 09, 2011 11:15 pm
Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
Organization: Team ANARKY
Contact:

Re: Instant CG and BG gallery

#32 Post by leon »

Double check that the screen has the same name (cg_gallery in this case) when you define it and when you call it:

Code: Select all

screen cg_gallery:

Code: Select all

        textbutton _("CG Gallery") action ShowMenu("cg_gallery")

User avatar
Fenrir34
Miko-Class Veteran
Posts: 560
Joined: Fri Jul 05, 2013 4:39 am
Completed: Escaping Sorrow
Projects: Crisis Beat,Lynarsia-The Broken Song
Location: California
Contact:

Re: Instant CG and BG gallery

#33 Post by Fenrir34 »

Oh thank you so much! It worked :D . Just one last question. How to a keep an image invisible till a person unlocks the path

User avatar
leon
Miko-Class Veteran
Posts: 554
Joined: Sun Oct 09, 2011 11:15 pm
Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
Organization: Team ANARKY
Contact:

Re: Instant CG and BG gallery

#34 Post by leon »

Glad you got it working. :)
The images will be locked from the start and will unlock automatically when they are shown for the first time. Delete persistent data from Ren'Py launcher to test it. If you want more complicated unlocking conditions check the documentation on how to use Gallery.condition().

User avatar
Fenrir34
Miko-Class Veteran
Posts: 560
Joined: Fri Jul 05, 2013 4:39 am
Completed: Escaping Sorrow
Projects: Crisis Beat,Lynarsia-The Broken Song
Location: California
Contact:

Re: Instant CG and BG gallery

#35 Post by Fenrir34 »

leon wrote:Glad you got it working. :)
The images will be locked from the start and will unlock automatically when they are shown for the first time. Delete persistent data from Ren'Py launcher to test it. If you want more complicated unlocking conditions check the documentation on how to use Gallery.condition().
Okay and thanks again for all you're help. Really appreciate it :D

User avatar
mahochido
Newbie
Posts: 10
Joined: Mon Aug 12, 2013 11:24 am
Projects: "Lustful Love-My cute foreing boyfriend"
Contact:

Re: Instant CG and BG gallery

#36 Post by mahochido »

How I can do to put everything in a variation of the cg's?

User avatar
leon
Miko-Class Veteran
Posts: 554
Joined: Sun Oct 09, 2011 11:15 pm
Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
Organization: Team ANARKY
Contact:

Re: Instant CG and BG gallery

#37 Post by leon »

Assuming you mean the same thing as Riku, check out this post - http://lemmasoft.renai.us/forums/viewto ... 15#p285111

User avatar
kuri_chii
Regular
Posts: 69
Joined: Sat Apr 27, 2013 10:34 am
Completed: RHWIMY beta 1.0
Projects: Right here where I met you, Love Snatch, Monarchy High
Organization: VND - AWA
IRC Nick: Kuri
Deviantart: franzzzz002
Skype: franz.mole
Location: Somewhere in Asia
Contact:

Re: Instant CG and BG gallery

#38 Post by kuri_chii »

etto...while viewing the image in full view...can we make a button or just clicking it to move to the next image?
The best way showing your feelings is to write Novel Stories :3
Image
DeviantArt | Monarchy High | RHWIMY | Love Snatch

User avatar
Chairrypie
Newbie
Posts: 13
Joined: Sun Jan 06, 2013 7:59 pm
Projects: Kokoro Double!
Organization: Little Star Productions
Location: LoOk BeHiNd YoU
Contact:

Re: Instant CG and BG gallery

#39 Post by Chairrypie »

Sorry but I am still having the same problem as Riku and Kindydos did:
I'm sorry, but an uncaught exception occurred.

While executing init code:
File "game/screens.rpy", line 567, in script
File "game/screens.rpy", line 570, in python
Exception: Expected an image, but got a general displayable.

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "E:\renpy-6.13.12\renpy\execution.py", line 265, in run
File "E:\renpy-6.13.12\renpy\ast.py", line 632, in execute
File "E:\renpy-6.13.12\renpy\python.py", line 972, in py_exec_bytecode
File "game/screens.rpy", line 570, in <module>
File "E:\renpy-6.13.12\renpy\display\im.py", line 607, in __init__
File "E:\renpy-6.13.12\renpy\display\im.py", line 1500, in image
File "E:\renpy-6.13.12\renpy\display\im.py", line 1515, in image
Exception: Expected an image, but got a general displayable.

Windows-7-6.1.7601-SP1
Ren'Py 6.13.12.1728
A Ren'Py Game 0.0
lines 567 to 570:

Code: Select all

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))
I replaced "cg1", "cg2" with my own images and also deleted all the lines that include the word bg

Here is the entire code that I copy pasted and edited:

Code: Select all

init python:
    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["kyandere", "kaisleep", "oni"]
    #how many rows and columns in the gallery screens?
    gal_rows = 3
    gal_cols = 3
    #thumbnail size in pixels:
    thumbnail_x = 267
    thumbnail_y = 150
    #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 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
                null
        frame:
            yalign 0.97
            vbox:
                if len(gallery_cg_items)>gal_cells:
                    textbutton _("Next Page") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]
I didn't really understand Kindydos's solution and I don't wanna have to download "All-In-One RenPy Framework" just for a cg gallery so please help and sorry for being such a bother...

User avatar
leon
Miko-Class Veteran
Posts: 554
Joined: Sun Oct 09, 2011 11:15 pm
Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
Organization: Team ANARKY
Contact:

Re: Instant CG and BG gallery

#40 Post by leon »

kuri_chii wrote:etto...while viewing the image in full view...can we make a button or just clicking it to move to the next image?
Not sure how to do that... I haven't tested this, but you could combine the image with the button like this:

Code: Select all

g_cg.image("image", "button")
This won't make the button clickable, but it will show it on top of the image.

@Chairrypie: Do you have your images defined under "init"? You can download a working gallery here - http://lemmasoft.renai.us/forums/downlo ... p?id=21639.

User avatar
kuri_chii
Regular
Posts: 69
Joined: Sat Apr 27, 2013 10:34 am
Completed: RHWIMY beta 1.0
Projects: Right here where I met you, Love Snatch, Monarchy High
Organization: VND - AWA
IRC Nick: Kuri
Deviantart: franzzzz002
Skype: franz.mole
Location: Somewhere in Asia
Contact:

Re: Instant CG and BG gallery

#41 Post by kuri_chii »

leon wrote:
kuri_chii wrote:etto...while viewing the image in full view...can we make a button or just clicking it to move to the next image?
Not sure how to do that... I haven't tested this, but you could combine the image with the button like this:

Code: Select all

g_cg.image("image", "button")
This won't make the button clickable, but it will show it on top of the image.

where should I put that exactly?
i tried your given code,

Code: Select all

#CG-->CHARLOTTE#    
    gal_cells = gal_rows * gal_cols    
    g_charlotte = Gallery()
    for gal_item in gallery_charlotte_items:
        g_charlotte.button(gal_item + " butt")
        g_charlotte.image("image", "button")
        g_charlotte.image(gal_item)
        g_charlotte.unlock(gal_item)
    g_charlotte.transition = fade
    charlotte_page=
it said. Image "image/button" not found (image and button is mixed u..I cant read it)
screenshot
screenshot
also this one...I dont know what is this.
also this one...I dont know what is this.
does 'text button' will work?
in your default code, once you click into the full view image it returns to the gallery menu.
The best way showing your feelings is to write Novel Stories :3
Image
DeviantArt | Monarchy High | RHWIMY | Love Snatch

User avatar
leon
Miko-Class Veteran
Posts: 554
Joined: Sun Oct 09, 2011 11:15 pm
Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
Organization: Team ANARKY
Contact:

Re: Instant CG and BG gallery

#42 Post by leon »

Sorry, I meant like this:

Code: Select all

g_cg.image(gal_item, "button")
While also defining a button somewhere:

Code: Select all

init:
    image button = "button.png"
And you'll need to make button.png. button.png should have the size of your game resolution and have a transparent background.

This creates a fake button (since you can just click anywhere) on top of each image.
kuri_chii wrote:in your default code, once you click into the full view image it returns to the gallery menu.
Yes, it only shows more images for images with variations. I don't know how to change the behavior to show the next gallery item on click. Try asking about this in Ren'Py Questions and Announcements.

User avatar
kuri_chii
Regular
Posts: 69
Joined: Sat Apr 27, 2013 10:34 am
Completed: RHWIMY beta 1.0
Projects: Right here where I met you, Love Snatch, Monarchy High
Organization: VND - AWA
IRC Nick: Kuri
Deviantart: franzzzz002
Skype: franz.mole
Location: Somewhere in Asia
Contact:

Re: Instant CG and BG gallery

#43 Post by kuri_chii »

can we disable that feature? the click anywhere

and i'll try to make that button a imagebutton...

i'll try to ask at the QA section...or explore it myself...

arigatou gozaimasu *bows* :D
your code make everything easier :3
The best way showing your feelings is to write Novel Stories :3
Image
DeviantArt | Monarchy High | RHWIMY | Love Snatch

User avatar
Chairrypie
Newbie
Posts: 13
Joined: Sun Jan 06, 2013 7:59 pm
Projects: Kokoro Double!
Organization: Little Star Productions
Location: LoOk BeHiNd YoU
Contact:

Re: Instant CG and BG gallery

#44 Post by Chairrypie »

Thank you leon! You're right it turns out all i needed was to add "init:" The CG gallery looks excellent!

User avatar
Zebragirl
Newbie
Posts: 8
Joined: Fri Apr 05, 2013 3:54 pm
Contact:

Re: Instant CG and BG gallery

#45 Post by Zebragirl »

Hello.

Thanks for this script, it is very fast and useful.

The code works for me everything, but the images in the gallery are already unlocked,also your file has CG images already unlocked without i need view them before unlocking...

I need that the images are all locked, and only after seeing them may appear in the gallery.

how can I do this?
What I'm wrong?


Code: Select all

init python:
    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["cg flower", ]
    
    #how many rows and columns in the gallery screens?
    gal_rows = 3
    gal_cols = 3
    #thumbnail size in pixels:
    thumbnail_x = 267
    thumbnail_y = 150
    #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 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
                null
        frame:
            yalign 0.97
            vbox:
                if len(gallery_cg_items)>gal_cells:
                    textbutton _("Next Page") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]




Thanks if you can help me!

Post Reply

Who is online

Users browsing this forum: No registered users