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.
Post Reply
Message
Author
User avatar
TheOneAndOnly-K
Regular
Posts: 78
Joined: Mon Apr 07, 2014 10:33 am
Contact:

Re: Instant CG and BG gallery

#76 Post by TheOneAndOnly-K »

Ah it works~! Thank you!~

User avatar
TheOneAndOnly-K
Regular
Posts: 78
Joined: Mon Apr 07, 2014 10:33 am
Contact:

Re: Instant CG and BG gallery

#77 Post by TheOneAndOnly-K »

Oh bother, another error came up when I added my CG gallery to my main menu.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/_layout/screen_main_menu.rpym", line 29, in script
IOError: Couldn't find file 'gallocked.png'.

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

Full traceback:
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\execution.py", line 294, in run
    node.execute()
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\ast.py", line 732, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\python.py", line 1382, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/_layout/screen_main_menu.rpym", line 29, in <module>
    $ ui.interact()
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\ui.py", line 237, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\core.py", line 2048, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\core.py", line 2373, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\core.py", line 1574, in draw_screen
    renpy.config.screen_height,
  File "render.pyx", line 362, in renpy.display.render.render_screen (gen\renpy.display.render.c:5300)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2491)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\layout.py", line 536, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2764)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2491)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\layout.py", line 536, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2764)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2491)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\layout.py", line 536, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2764)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2491)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\screen.py", line 299, in render
    child = renpy.display.render.render(self.child, w, h, st, at)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2764)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2491)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\layout.py", line 536, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2764)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2491)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\layout.py", line 880, in render
    st, at)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2764)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2491)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\layout.py", line 536, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2764)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2491)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\layout.py", line 372, in render
    renders = [ render(i, renwidth, renheight, st, at) for i in self.children ]
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2764)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2491)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\behavior.py", line 551, in render
    rv = super(Button, self).render(width, height, st, at)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\layout.py", line 880, in render
    st, at)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2764)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2491)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\im.py", line 465, in render
    im = cache.get(self)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\im.py", line 198, in get
    surf = image.load()
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\im.py", line 656, in load
    child = cache.get(self.image)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\im.py", line 198, in get
    surf = image.load()
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\im.py", line 509, in load
    surf = renpy.display.pgrender.load_image(renpy.loader.load(self.filename), self.filename)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\loader.py", line 431, in load
    raise IOError("Couldn't find file '%s'." % name)
IOError: Couldn't find file 'gallocked.png'.

Windows-7-6.1.7601-SP1
Ren'Py 6.17.4.409
Do I have to make a 'gallock.png' and if so where do I put it?

:(

Another question; can this be used for a music room?

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

#78 Post by leon »

Yes, you need gallocked.png. It's a thumbnail used for locked images. Place it in the game folder.

No, but the build-in music room is simple enough.

User avatar
TheOneAndOnly-K
Regular
Posts: 78
Joined: Mon Apr 07, 2014 10:33 am
Contact:

Re: Instant CG and BG gallery

#79 Post by TheOneAndOnly-K »

Thanks I got it working~

RubyD
Newbie
Posts: 10
Joined: Sat May 17, 2014 2:31 am
Projects: DMMd fangame
Contact:

Re: Instant CG and BG gallery

#80 Post by RubyD »

Hi! I used the code for the CG gallery after some fiddling and it works very nicely. :D However, one of the CG pics is bigger than my game screen. Game window is 1024x576, the CG is 1024x794.

How can I make it so you can scroll around to see the full picture once you click on the thumbnail?

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

#81 Post by leon »

I don't think that is possible with the in-built gallery. You'll need to code one yourself.

tsubame-chi
Newbie
Posts: 12
Joined: Mon Feb 03, 2014 2:18 am
Projects: Chosen Ghost
Organization: JACT Productions
Location: United States
Contact:

Re: Instant CG and BG gallery

#82 Post by tsubame-chi »

um i have a question. How do you put buttons on the side to separate character CGs?

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

#83 Post by leon »

I'm not sure what you mean. :? Can you elaborate a bit?

tsubame-chi
Newbie
Posts: 12
Joined: Mon Feb 03, 2014 2:18 am
Projects: Chosen Ghost
Organization: JACT Productions
Location: United States
Contact:

Re: Instant CG and BG gallery

#84 Post by tsubame-chi »

Like in many games with cgs, there would be buttons with the character's names which you can click to view cgs about that character only. I'm sorry if I didn't explain it that well...

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

#85 Post by leon »

I was confused because CGs are a luxury in EVNs. :P

Just create a gallery for each character. The example has galleries for CGs and BGs, which are essentially the same, so just copy that for each character.

For the character selection you'll want to create a special screen with character names (you can show this screen on it's own or include it into other screens using "use"). To make the buttons there are many ways - Button, Imagebutton, Textbutton and Imagemap. Check out the Screen Language documentation.

tsubame-chi
Newbie
Posts: 12
Joined: Mon Feb 03, 2014 2:18 am
Projects: Chosen Ghost
Organization: JACT Productions
Location: United States
Contact:

Re: Instant CG and BG gallery

#86 Post by tsubame-chi »

Ohhhhh. Ok. I'll try that out. Thank you! :)

Carrogath
Regular
Posts: 106
Joined: Wed Jan 25, 2012 12:08 pm
Completed: Basiliska, Green Eyed Monster
Tumblr: carrogath
Location: United States
Contact:

Re: Instant CG and BG gallery

#87 Post by Carrogath »

Hi Leon, I'm using a very slightly modified version of your gallery code, but when I try to add a border to the images, the entire grid of borders ends up being off by a few pixels. I posted about it in the Ren'Py Questions forum already, so I'll just link to it here:

http://lemmasoft.renai.us/forums/viewto ... =8&t=26989

There's some pictures there too. Is there some code I could add to make them line up?

Thanks!

salventus
Newbie
Posts: 20
Joined: Fri Jun 20, 2014 12:16 am
Contact:

Re: Instant CG and BG gallery

#88 Post by salventus »

so um, i copied your code and change it like this

Code: Select all

init python:
    #Galleries settings - start
    #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 cave", "bg meadow"]
    #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_bg = Gallery()
    for gal_item in gallery_bg_items:
        g_bg.button(gal_item + " butt")
        g_bg.image(gal_item)
        g_bg.unlock(gal_item)
        #if BGs have variations, such as night version, uncomment the lines below and include the code for each BG with variations
#        if gal_item == "bg cave":
#            g_bg.image("bg cave")
#            g_bg.unlock("bg cave")
    g_bg.transition = fade
    bg_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_bg_items:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
        renpy.image (gal_item + " butt dis", im.Grayscale(ImageReference(gal_item + " butt")))
        
screen bg_gallery:
#The BG gallery screen is more or less copy pasted from the CG screen above, I only changed "make_button" to include a grayscale thumbnail for locked items
    tag menu
    use navigation
    frame background None xpos 10:
        grid gal_rows gal_cols:
            ypos 10
            $ i = 0
            $ next_bg_page = bg_page + 1
            if next_bg_page > int(len(gallery_bg_items)/gal_cells):
                $ next_bg_page = 0
            for gal_item in gallery_bg_items:
                $ i += 1
                if i <= (bg_page+1)*gal_cells and i>bg_page*gal_cells:
                    add g_bg.make_button(gal_item + " butt", gal_item + " butt", gal_item + " butt dis", xalign=0.5, yalign=0.5, idle_border=None, background=None, bottom_margin=24)
            for j in range(i, (bg_page+1)*gal_cells):
                null
        frame:
            yalign 0.97
            vbox:
                if len(gallery_bg_items)>gal_cells:
                    textbutton _("Next Page") action [SetVariable('bg_page', next_bg_page), ShowMenu("bg_gallery")]
I'm trying to show the picture of bg cave and bg meadow in the gallery but the it always encounter an error like this (the picture i included)
so what should i change to fix these things?
Attachments
eror.png

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

#89 Post by leon »

@Carrogath: It's hard to say without seeing the code where you add the borders. If you are using im.Composite, you just need to add a few pixels to position arguments for the border.

@salventus: The error indicates that "bg cave" and "bg meadow" images aren't defined. Double check for typos and try adding "init" in front of the image definition. You can also download the code and first get that to work with your images, then work from there.

Carrogath
Regular
Posts: 106
Joined: Wed Jan 25, 2012 12:08 pm
Completed: Basiliska, Green Eyed Monster
Tumblr: carrogath
Location: United States
Contact:

Re: Instant CG and BG gallery

#90 Post by Carrogath »

I'm actually using whatever bit of code is included with the Gallery class in Ren'Py. Here's the exact code:

Code: Select all

    g_bg = Gallery()
    for gal_item in gallery_bg_items:
        g_bg.button(gal_item + " butt")
        g_bg.image(gal_item)
    g_bg.transition = dissolve
    g_bg.hover_border = "menu/border.png"
    g_bg.idle_border = "menu/idleborder.png"
    bg_page=0
If that doesn't really help, I can just PM you the whole .rpy file (or at least the part that uses the gallery).

Post Reply

Who is online

Users browsing this forum: No registered users