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
KurisuCrush
Newbie
Posts: 7
Joined: Sun May 22, 2016 8:21 am
Contact:

Re: Instant CG and BG gallery

#136 Post by KurisuCrush » Sun May 22, 2016 4:54 pm

I got this errore:

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/screens.rpy", line 543: expected statement.
    gallery_cg_items = ["cg1","cg2"]
                     ^

File "game/screens.rpy", line 545: expected statement.
    gal_rows = 3
             ^

File "game/screens.rpy", line 546: expected statement.
    gal_cols = 3
             ^

File "game/screens.rpy", line 548: expected statement.
    cg_thumbnail_x = 150
                   ^

File "game/screens.rpy", line 549: expected statement.
    cg_thumbnail_y = 300
                   ^

File "game/screens.rpy", line 553: expected statement.
    gal_cells = gal_rows * gal_cols    
              ^

File "game/screens.rpy", line 554: expected statement.
    g_cg = Gallery()
         ^

File "game/screens.rpy", line 555: expected statement.
    for gal_item in gallery_cg_items:
                 ^

File "game/screens.rpy", line 559: expected statement.
    g_cg.transition = fade
                    ^

File "game/screens.rpy", line 560: expected statement.
    cg_page=0
           ^

Ren'Py Version: Ren'Py 6.99.10.1227
My code:

Code: Select all

#CG Gallery

init-1:
    image cg1 = "images/steinsgate3.jpg"
    image cg2 = "images/steinsgate2.jpg"
    ## and so on

    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["cg1","cg2"]
    #how many rows and columns in the gallery screens?
    gal_rows = 3
    gal_cols = 3
    #thumbnail size in pixels:
    cg_thumbnail_x = 150
    cg_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.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), cg_thumbnail_x, cg_thumbnail_y))
        
screen extra:
    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", cg_thumbnail_x, cg_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("extra")]

timcampy118
Newbie
Posts: 2
Joined: Fri Jun 23, 2017 1:36 am
Github: timcampy118
Skype: timothyn118
Contact:

Re: Instant CG and BG gallery

#137 Post by timcampy118 » Fri Jun 23, 2017 1:42 am

...Im new to this, didnt edit a post and made a new one. Not sure how to delete ._." (just look at the post below sorry XD)
Last edited by timcampy118 on Mon Jul 03, 2017 12:42 am, edited 2 times in total.

timcampy118
Newbie
Posts: 2
Joined: Fri Jun 23, 2017 1:36 am
Github: timcampy118
Skype: timothyn118
Contact:

Re: Instant CG and BG gallery

#138 Post by timcampy118 » Sun Jul 02, 2017 11:03 pm

I'm a total scrub with this kind of thing, i'm more of a logic person but anyways. I'm not getting any errors but the positions of my CG are all bundled together and they're not unlocking after the image been loaded into the game. Here's a screenshot and the code.

http://imgur.com/a/2MZn2


Code: Select all


init:
    image magazine = "CGI_intromagazine.jpg"
    image baseball =  "CGI_introbaseball.jpg"
    image school = "BG_schoolfront.png"
    image hall = "BG_hallway.jpg"
    image classRoom = "BG_classroom.jpg"
    image bed = "BG_bedroom_day.png"
    image kitchen = "BG_kitchen.jpg"
    image path = "BG_pathhome_evening.jpg"
    image lr = "BG_lr_daytime.jpg"

init python:
    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["baseball","magazine","school","hall","classRoom","bed","kitchen","path","lr"]
    #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",(Transform(gal_item, size=(thumbnail_x, thumbnail_y))))

        
screen gallery:
    tag menu
    frame background "BG_pathhome_daytime.jpg" xpos 10:
        use navigation
        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("x.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")]





User avatar
MidnightCafe
Newbie
Posts: 3
Joined: Fri Jun 09, 2017 4:20 pm
Contact:

Re: Instant CG and BG gallery

#139 Post by MidnightCafe » Mon Jul 31, 2017 4:05 pm

I ran into a bit of a hiccup while creating a sub-gallery (so the routes can have their own galleries) and I'm hoping someone can help.

The page works and the CG unlocks, but the thumbnail doesn't change from the locked image.

A "sample game" with the galleries is included if that helps.

Any help would be appreciated!
Attachments
sample.7z
(703.34 KiB) Downloaded 24 times

Mitula
Newbie
Posts: 8
Joined: Sun Mar 10, 2013 1:19 pm
Contact:

Re: Instant CG and BG gallery

#140 Post by Mitula » Thu Aug 10, 2017 8:06 am

I recreated my game under the new GUI form of Renpy.
Unfortunately, for the gallery, as long as it does not exceed one line, everything goes well (Gallery 01).

On the other hand, as soon as it exceeds one line, the other lines are superimposed between them (Gallery 02).

This works very well under the old version. Is there a solution ?
Attachments
Gallery 02.jpg
Gallery 01.jpg

User avatar
MonsoonMushroom
Regular
Posts: 62
Joined: Thu Jan 21, 2016 2:19 pm
Projects: Fate of the Squire
Organization: MonsoonMushroom
Contact:

Re: Instant CG and BG gallery

#141 Post by MonsoonMushroom » Thu Aug 31, 2017 4:13 pm

I've had the problem above too. I sort of fixed it by using yfill True. The gallery is firmly stuck to the left for some reason (if I move it further right it cuts the last images off) but I'll keep tinkering and see what happens. In the meantime, I figured I'd post my code in case it helps anyone:

Code: Select all

screen cg_gallery:
    tag menu
    add gui.main_menu_background
    use navigation
    use game_menu(_("Gallery"), scroll="viewport"):
        frame background None:
            ypos -50
            xpos 150
            grid gal_rows gal_cols:
                yfill True
                ymaximum 450
                spacing 5
                $ 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("gui/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.9
        xalign 0.5
        vbox:
            if len(gallery_cg_items)>gal_cells:
                textbutton _(">") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]
    
Image

...Though I do have a problem of my own. I have no idea why, but I can only view that unlocked image fullscreen if I click near the top of it - clicking, say, the middle of the image doesn't do anything. Does anyone have any idea what's causing this?

Xaiyeon
Newbie
Posts: 12
Joined: Thu May 14, 2015 10:47 pm
Contact:

Re: Instant CG and BG gallery

#142 Post by Xaiyeon » Mon Oct 09, 2017 5:59 am

MonsoonMushroom wrote:
Thu Aug 31, 2017 4:13 pm
I've had the problem above too. I sort of fixed it by using yfill True. The gallery is firmly stuck to the left for some reason (if I move it further right it cuts the last images off) but I'll keep tinkering and see what happens. In the meantime, I figured I'd post my code in case it helps anyone:


Image

...Though I do have a problem of my own. I have no idea why, but I can only view that unlocked image fullscreen if I click near the top of it - clicking, say, the middle of the image doesn't do anything. Does anyone have any idea what's causing this?
Hi if you're still facing that problem you have to go to gui.rpy and change this line

define gui.button_height = None

Because it's the default value for all button creations.
If people ignore others with a lack of understanding, then they are close-minded.

User avatar
noeinan
Eileen-Class Veteran
Posts: 1080
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: daikiraikimi
Github: daikiraikimi
Location: Washington State, USA
Contact:

Re: Instant CG and BG gallery

#143 Post by noeinan » Wed Nov 01, 2017 11:47 am

Mitula wrote:
Thu Aug 10, 2017 8:06 am
I recreated my game under the new GUI form of Renpy.
Unfortunately, for the gallery, as long as it does not exceed one line, everything goes well (Gallery 01).

On the other hand, as soon as it exceeds one line, the other lines are superimposed between them (Gallery 02).

This works very well under the old version. Is there a solution ?
I had this problem, fixed it with both xfill and yfill. The only problem I'm having is... After the newest Ren'Py update, some of my images don't go fullscreen anymore? Basically, they're supposed to be buttons but seven out of fifteen don't act as buttons for some reason. (In a 3x3 grid, numbers 6-11 and then 15 don't work.) No idea why...

Code: Select all

screen cg_gallery:
    tag menu
    use game_menu("CG Gallery"):
        

        frame background None xpos -10:
            grid gal_rows gal_cols:
                ypos -20
                yfill True
                xfill True
                $ 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("gui/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 1.03
                xalign 1.005
                vbox:
                    if len(gallery_cg_items)>gal_cells:
                        textbutton _("Next Page") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]
Image

Image
Image

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 2690
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Instant CG and BG gallery

#144 Post by Imperf3kt » Wed Nov 01, 2017 4:14 pm

Check button height (set it to None) in gui.rpy

I'm making a tutorial covering a CG and BG Gallery in the latest Ren'Py edition. I hope its not turning out too complicated, but currently it needs quite a lot of work and some rewriting.
I expect it to take another few months.

If you're interested in checking out my current progress though, I have an Android version on the Google Play store.
Searching for "imperf3kt" should find it.

E: Onhold for an unknown amount of time.
Last edited by Imperf3kt on Fri Feb 09, 2018 1:51 am, edited 1 time in total.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Todo list:
Actually finish a project

User avatar
noeinan
Eileen-Class Veteran
Posts: 1080
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: daikiraikimi
Github: daikiraikimi
Location: Washington State, USA
Contact:

Re: Instant CG and BG gallery

#145 Post by noeinan » Fri Nov 03, 2017 5:44 pm

Imperf3kt wrote:
Wed Nov 01, 2017 4:14 pm
Check button height (set it to None) in gui.rpy

I'm making a tutorial covering a CG and BG Gallery in the latest Ren'Py edition. I hope its not turning out too complicated, but currently it needs quite a lot of work and some rewriting.
I expect it to take another few months.

If you're interested in checking out my current progress though, I have an Android version on the Google Play store.
Searching for "imperf3kt" should find it.
Button height fixes the issue where only the top bit of the button works, but unfortunately not the issue of some buttons not working at all... I've been thinking of just copy/pasting the save/load screen built into RenPy and seeing if I can have it store CGs instead of save files.
Image

Image
Image

User avatar
Ertal77
Veteran
Posts: 287
Joined: Sat Feb 27, 2016 2:33 pm
Completed: A Hand in the Darkness, Chasing the Stars, My Burning Heart, Blood and Lust
Projects: Lurkers, Night and Day
Organization: Ertal Games
Tumblr: ertal77
itch: ertal-games
Location: Spain
Contact:

Re: Instant CG and BG gallery

#146 Post by Ertal77 » Sat Dec 23, 2017 7:02 am

Firstly, thank you very much for this awesome code!

Second... it works perfect on the "extras" of my after-story, where all the images are unlocked by default. But I can't get the images of the CG gallery to unlock in the main game :cry:

This is the code (basically the same as in the example):

Code: Select all

init-1:
    #image button = "images/button.png"
    image buttonlock = "images/chibialex.png"
    
    image cg1 = "images/menugame.png"
    image cg2 = "images/dinner.png"
    image cg3 = "images/kiss damian.png"
    image cg4 = "images/damian woods.png"
    image cg5 = "images/card.png"
    image cg6 = "images/fightoscene_sc4.png"
    image cg7 = "images/rick closet.png"
    image cg8 = "images/kiss rick.png"
    image cg9 = "images/rickbed.png"
    image cg10 = "images/kiss monty.png"
    image cg11 = "images/bath5.png"
    image cg12 = "images/ghost.png"
    

init python:
    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["cg1", "cg2", "cg3", "cg4", "cg5", "cg6", "cg7", "cg8", "cg9", "cg10", "cg11", "cg12"]
    #list the BG gallery images here (if a BG includes several variations, such as night version, include only one variation here):
    #gallery_bg_items = ["bg kitchen", "bg road"]
    #how many rows and columns in the gallery screens?
    gal_rows = 3
    gal_cols = 4
    #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 + "button")
        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 + "button", 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 + "button", gal_item + "button", im.Scale("images/chibialex.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")]
Do someone see what's wrong? Why the images don't unlock?
Current projects:
Image
Image

User avatar
rayminator
Veteran
Posts: 265
Joined: Fri Feb 09, 2018 12:05 am
Projects: Redoing games to fix spelling mistakes other companys that don't care
Location: Canada
Contact:

Re: Instant CG and BG gallery

#147 Post by rayminator » Fri Feb 09, 2018 12:10 am

Ertal77 wrote:
Sat Dec 23, 2017 7:02 am
Firstly, thank you very much for this awesome code!

Second... it works perfect on the "extras" of my after-story, where all the images are unlocked by default. But I can't get the images of the CG gallery to unlock in the main game :cry:
Hi there i am having the same problems as well

I am using your code you have one the first post

hope someone can me out

UPDATE:
Got to work but only one image

UPDATE 2:
got all images to show up by removing this g_cg.unlock(gal_item) there as to be something missing?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 2690
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Instant CG and BG gallery

#148 Post by Imperf3kt » Mon Feb 19, 2018 4:07 am

Confirming there seems to be a bug regarding this code and the latest versions of Ren'Py.
I have been trying to help rayminator for a while and I am experiencing the same results. For some reason, images do not unlock.

I have the exact same code in another game (made in an older version of Ren'Py) and it works fine (in the latest version of Ren'Py)

I cannot understand what is happening.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Todo list:
Actually finish a project

User avatar
tohtamish
Regular
Posts: 61
Joined: Thu Apr 29, 2010 4:56 am
Contact:

Re: Instant CG and BG gallery

#149 Post by tohtamish » Wed Mar 07, 2018 11:15 am

Is it possible to use this gallery code as the chapter selection at the beginning of the game? (something like "walking dead" game)

User avatar
rayminator
Veteran
Posts: 265
Joined: Fri Feb 09, 2018 12:05 am
Projects: Redoing games to fix spelling mistakes other companys that don't care
Location: Canada
Contact:

Re: Instant CG and BG gallery

#150 Post by rayminator » Wed Mar 07, 2018 1:43 pm

tohtamish wrote:
Wed Mar 07, 2018 11:15 am
Is it possible to use this gallery code as the chapter selection at the beginning of the game? (something like "walking dead" game)
this gallery doesn't work with the latest renpy

I have tried this gallery it doesn't work

if it work for you that great

if so i think it is possible but i can't really help you cause it didn't work for me

Post Reply

Who is online

Users browsing this forum: No registered users