Page 10 of 11

Re: Instant CG and BG gallery

Posted: Sun May 22, 2016 4:54 pm
by KurisuCrush
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")]

Re: Instant CG and BG gallery

Posted: Fri Jun 23, 2017 1:42 am
by timcampy118
...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)

Re: Instant CG and BG gallery

Posted: Sun Jul 02, 2017 11:03 pm
by timcampy118
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")]





Re: Instant CG and BG gallery

Posted: Mon Jul 31, 2017 4:05 pm
by MidnightCafe
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!

Re: Instant CG and BG gallery

Posted: Thu Aug 10, 2017 8:06 am
by Mitula
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 ?

Re: Instant CG and BG gallery

Posted: Thu Aug 31, 2017 4:13 pm
by MonsoonMushroom
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?

Re: Instant CG and BG gallery

Posted: Mon Oct 09, 2017 5:59 am
by Xaiyeon
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.

Re: Instant CG and BG gallery

Posted: Wed Nov 01, 2017 11:47 am
by noeinan
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")]

Re: Instant CG and BG gallery

Posted: Wed Nov 01, 2017 4:14 pm
by Imperf3kt
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.

Re: Instant CG and BG gallery

Posted: Fri Nov 03, 2017 5:44 pm
by noeinan
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.

Re: Instant CG and BG gallery

Posted: Sat Dec 23, 2017 7:02 am
by Ertal77
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?

Re: Instant CG and BG gallery

Posted: Fri Feb 09, 2018 12:10 am
by rayminator
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?

Re: Instant CG and BG gallery

Posted: Mon Feb 19, 2018 4:07 am
by Imperf3kt
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.

Re: Instant CG and BG gallery

Posted: Wed Mar 07, 2018 11:15 am
by tohtamish
Is it possible to use this gallery code as the chapter selection at the beginning of the game? (something like "walking dead" game)

Re: Instant CG and BG gallery

Posted: Wed Mar 07, 2018 1:43 pm
by rayminator
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