Ren'Py Gallery code

Honey hunters

Member
Jan 23, 2020
118
26
Hello everyone I'm new to Ren'Py coding and Game development , in my game I want to add a Gallery which should be unlocked by player , soo will you please help me for Gallery coding .
Thank you.
 
  • Like
Reactions: libertypics

M$hot

Member
May 28, 2017
238
371
It's been quite a while since I've worked with Ren'Py so I'm not entirely sure about the syntax used. That said, I do know that a gallery is basically all conditional code. So in the main game, there should be a flag that's triggered to have it either be grey/hidden or visible in the gallery.
If it's active you can make it link towards wherever you want (like the beginning of the scene you want to have show up in the gallery).

I think for a gallery I personally would have a duplicate of every scene within the game, and have the flag in the maingame unlock the duplicate scene, because the duplicate scene won't have the flag behind it plus it can be made to return to the menu as soon as you've watched the scene again. Something like 'Sex scene 1' which at the end triggers the flag 'ss1_gal'. Now sex scene 1 shows up in your gallery, but once clicked you don't go back to 'sex scene 1' but 'ss1_dup' or something.

I hope that helps, if not, I'm sure there are other people out here who can help better.
 

Honey hunters

Member
Jan 23, 2020
118
26
hello everyone i used a Rich gallery code as it is same in my game , but i got little wired problem .
when i convert my game in PC(WINDOWS) version there is no locked button showing in Gallery

PC.png



and when i converted into Android mobile version the gallery locked button is working

mobile.png




soo can anyone help me why it's not working on PC version and why it's working on Android version , so where i made a mistake here it is the program which i used in my game development.

Python:
Python:
init python:
LAST_SAVE_REGEX = r"\d+"
def has_recent_save():
return renpy.newest_slot(LAST_SAVE_REGEX) != None

def load_most_recent_save():
filename = renpy.newest_slot(LAST_SAVE_REGEX)
if filename != None:
renpy.load(filename)




init 2 python:
def gallery_thumbnail(thumbnail_name):
return im.FactorScale(thumbnail_name, 0.2)

image_gallery = Gallery()
image_gallery.transition = dissolve
image_gallery.locked_button = "game_gui/gallery_locked_button.png"

image_gallery.button("slot01")
image_gallery.condition('renpy.seen_image("intro6")')
image_gallery.unlock_image("intro1")
image_gallery.unlock_image("intro2")
image_gallery.unlock_image("intro3")
image_gallery.unlock_image("intro6")

image_gallery.button("slot02")
image_gallery.condition('renpy.seen_image("intro1")')
image_gallery.unlock_image("intro4")
image_gallery.unlock_image("intro0")
image_gallery.unlock_image("intro2")
image_gallery.unlock_image("intro1")

image_gallery.button("slot03")
image_gallery.condition('renpy.seen_image("intro2")')
image_gallery.unlock_image("intro6")
image_gallery.unlock_image("intro1")
image_gallery.unlock_image("intro0")
image_gallery.unlock_image("intro3")
image_gallery.unlock_image("intro2")

image_gallery.button("slot04")
image_gallery.condition('renpy.seen_image("intro6")')
image_gallery.unlock_image("intro1")
image_gallery.unlock_image("intro2")
image_gallery.unlock_image("intro3")
image_gallery.unlock_image("intro6")

image_gallery.button("slot05")
image_gallery.condition('renpy.seen_image("intro1")')
image_gallery.unlock_image("intro4")
image_gallery.unlock_image("intro0")
image_gallery.unlock_image("intro2")
image_gallery.unlock_image("intro1")

image_gallery.button("slot06")
image_gallery.condition('renpy.seen_image("intro2")')
image_gallery.unlock_image("intro6")
image_gallery.unlock_image("intro1")
image_gallery.unlock_image("intro0")
image_gallery.unlock_image("intro3")
image_gallery.unlock_image("intro2")

image_gallery.button("slot07")
image_gallery.condition('renpy.seen_image("intro6")')
image_gallery.unlock_image("intro1")
image_gallery.unlock_image("intro2")
image_gallery.unlock_image("intro3")
image_gallery.unlock_image("intro6")

image_gallery.button("slot08")
image_gallery.condition('renpy.seen_image("intro1")')
image_gallery.unlock_image("intro4")
image_gallery.unlock_image("intro0")
image_gallery.unlock_image("intro2")
image_gallery.unlock_image("intro1")

image_gallery.button("slot09")
image_gallery.condition('renpy.seen_image("intro2")')
image_gallery.unlock_image("intro6")
image_gallery.unlock_image("intro1")
image_gallery.unlock_image("intro0")
image_gallery.unlock_image("intro3")
image_gallery.unlock_image("intro2")

image_gallery.button("slot10")
image_gallery.condition('renpy.seen_image("intro6")')
image_gallery.unlock_image("intro1")
image_gallery.unlock_image("intro2")
image_gallery.unlock_image("intro3")
image_gallery.unlock_image("intro6")

image_gallery.button("slot11")
image_gallery.condition('renpy.seen_image("intro1")')
image_gallery.unlock_image("intro4")
image_gallery.unlock_image("intro0")
image_gallery.unlock_image("intro2")
image_gallery.unlock_image("intro1")

image_gallery.button("slot12")
image_gallery.condition('renpy.seen_image("intro2")')
image_gallery.unlock_image("intro6")
image_gallery.unlock_image("intro1")
image_gallery.unlock_image("intro0")
image_gallery.unlock_image("intro3")
image_gallery.unlock_image("intro2")



image_gallery_slots = []

image_gallery_slots.extend(
[
( "slot01", "Ch 1: Brad and Emily", "intro/intro1.png" ),
( "slot02", "Ch 1: Parker and Becky", "intro/intro4.png" ),
( "slot03", "Ch 2: Melanie\u2019s Bra", "intro/intro6.png" ),
( "slot04", "Ch 1: Brad and Emily", "intro/intro1.png" ),
( "slot05", "Ch 1: Parker and Becky", "intro/intro4.png" ),
( "slot05", "Ch 2: Melanie\u2019s Bra", "intro/intro6.png" ),
( "slot06", "Ch 1: Brad and Emily", "intro/intro1.png" ),
( "slot07", "Ch 1: Parker and Becky", "intro/intro4.png" ),
( "slot08", "Ch 2: Melanie\u2019s Bra", "intro/intro6.png" ),
( "slot09", "Ch 1: Brad and Emily", "intro/intro1.png" ),
( "slot10", "Ch 1: Parker and Becky", "intro/intro4.png" ),
( "slot11", "Ch 2: Melanie\u2019s Bra", "intro/intro6.png" ),
( "slot12", "Ch 2: Melanie\u2019s Bra", "intro/intro6.png" ),

])

@renpy.pure
def get_image_gallery_page_count():
return (len(image_gallery_slots) + 5) // 6

@renpy.pure
def get_image_gallery_page(page):
slots = []
first_index = (page - 1) * 6
for i in range(first_index, first_index + 6):
if i < len(image_gallery_slots):
slots.append(image_gallery_slots)
else:
slots.append((None, None, None))
return slots

screen gallery_buttons(data):
for (name, title, thumbnail) in data:
if name:
vbox:
$ the_button = image_gallery.make_button(name, gallery_thumbnail(thumbnail))
add the_button
if image_gallery.buttons[name].check_unlock():
text title
else:
text ""
else:
text ""

screen gallery():
tag menu
default page = 1
default total_pages = get_image_gallery_page_count()


use game_menu(_("Gallery"), scroll="viewport"):

style_prefix "gallery"

vbox:
xsize 940
ysize 500
label "Page [page]":
xalign 0.5
bottom_margin 10

grid 3 2:
style_prefix "gallery_slot"

xalign 0.5
yalign 0.5

xspacing 30
yspacing 20

use gallery_buttons(get_image_gallery_page(page))

hbox:
style_prefix "page"

anchor (0.5, 0.0)
pos (0.5, 1.0)

spacing gui.page_spacing

if page > 1:
textbutton _("<") action SetScreenVariable("page", page - 1)
else:
textbutton _("<") action NullAction()

for i in range(1, total_pages + 1):
textbutton "" action SetScreenVariable("page", i)

if page < total_pages:
textbutton _(">") action SetScreenVariable("page", page + 1)
else:
textbutton _(">") action NullAction()

style gallery_slot_text:
size 18
xalign 0.5
yalign 0.0

style gallery_button is button:
hover_background "#fff"

style gallery_button_text:
size 24
bold True
color "#fff"
hover_color "#000"
underline True

style gallery_button_current is button
style gallery_button_current_text is gallery_button_text:
underline False
hover_color "#fff"
Can any one help me where i made wrong in this and what i missed in this programme
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
Maybe it's because of this line:
Python:
image_gallery.locked_button = "game_gui/gallery_locked_button.png"

Rich uses this:
Python:
image_gallery.locked_button = "gallery_locked_button"
 
Last edited:

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,382
It's locked button image folder
But the question is whether it's underneath your game's "images" folder or not. If it is, you don't need the full path name - just the image name, since Ren'py will find every png and jpg unmder the "images" folder, and assign it to a corresponding image name according to its rules.

Images that are NOT somewhere underneath the game's "images" folder can be problematic.