Scene Gallery - Using CG Gallery behavior as Scene Selector

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Scene Gallery - Using CG Gallery behavior as Scene Selector

#1 Post by DaFool »

Instead of a plain menu scene selector / selection, I would like to use the standard layout of the CG Gallery as the scene selector.

Basically, a representative image of the scene will be the image displayed as a thumbnail in the gallery...it doesn't have to be the first image in the scene. When you click on the thumbnail, however, instead of displaying a CG, the scene plays just like a regular jump in the game.

A scene is unlocked once you finished playing its duration -- a persistent variable is triggered that will make it available in the 'Scene Gallery'. The reason for this behavior is because it will be very useful for ero games where the player would rather go through the whole story at once and leave the sex scenes for enjoyment at a later time. This way, ero scenes can be unlocked even if they aren't displayed during the course of the main game. But I assume this kind of behavior will also prove useful for non-ero games in the form of unlocking special side stories. Currently side stories are unlocked as extras using standard menus.

But using the CG Gallery layout for scene unlocking will give the player a better scope of how much stuff there is in the game.

Would be helpful if there is specific code to use -- I would experiment with it but it won't hurt to ask. Thanks.

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: Scene Gallery - Using CG Gallery behavior as Scene Selector

#2 Post by DaFool »

Ok, I have a specific request. Appreciate it if anyone can post code.

I just need a game menu that has 4 scenes to select, arranged on a 2 x 2 grid, a background with 4 thumbnails. I haven't used ui.interact but I think that would be the way to go about it in this case.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Scene Gallery - Using CG Gallery behavior as Scene Selector

#3 Post by PyTom »

Basically, what you want is to use ui.imagebutton, perhaps along with ui.image for locked scenes.

Code: Select all

python:
    if persistent.unlocked_scene_1:
        ui.imagebutton("s1_idle.png", "s1_hover.png", clicked=ui.jumps('scene_1'), xpos=100, ypos=100)
    else:
        ui.image('s_locked.png', xpos=100, ypos=100)

    # Repeat code for the other three images/scenes, changing xpos and ypos.

    ui.interact()
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: Scene Gallery - Using CG Gallery behavior as Scene Selector

#4 Post by DaFool »

Thanks, I'll experiment with it.

I just realized imagemaps might do the trick but having an imagemap for all the permutations of locked / unlocked scene combinations might be a nightmare to juggle.

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

Re: Scene Gallery - Using CG Gallery behavior as Scene Selector

#5 Post by monele »

I really wish people forgot about imagemaps :) It might be the easiest concept to start with but it's a pain to make anything slightly complex to work with it ^^;... In your case, imagebuttons and image will work perfectly. You could also use ui.grid to have things neatly arranged in a grid :

Code: Select all

python:
    ui.grid(2,2)
    if persistent.unlocked_scene_1:
        ui.imagebutton("s1_idle.png", "s1_hover.png", clicked=ui.jumps('scene_1'))
    else:
        ui.image('s_locked.png', xpos=100, ypos=100)

    # Repeat code for the other three images/scenes (no need to position anything)
    ui.close()

    ui.interact()
You might need to position the grid itself, unless you put it in a frame or window which you can also position at your convenience :)

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: Scene Gallery - Using CG Gallery behavior as Scene Selector

#6 Post by DaFool »

I only got to tinker with this recently, and I admit I still don't have a clue. Even for a simple 1x1 grid... how does one invoke this--as a new game menu?

Is there more to it than a simple copy paste to the options.rpy as well as appending a jump menu? Whats the difference between a menu jump to a regular vn scene versus a menu jump to a game / preferences screen?

JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: Scene Gallery - Using CG Gallery behavior as Scene Selector

#7 Post by JQuartz »

I only got to tinker with this recently, and I admit I still don't have a clue. Even for a simple 1x1 grid... how does one invoke this--as a new game menu?Is there more to it than a simple copy paste to the options.rpy as well as appending a jump menu?
http://www.renpy.org/wiki/renpy/doc/ref ... Game_Menus

I think this might help...
Whats the difference between a menu jump to a regular vn scene versus a menu jump to a game / preferences screen?
Regular to regular jump is the same as a menu to menu jump.
Regular to menu jump however is a jumpoutofcontext and so menu to regular is a return.
What is a jump out of context? I have no idea.
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Scene Gallery - Using CG Gallery behavior as Scene Selector

#8 Post by PyTom »

JQuartz wrote:Regular to regular jump is the same as a menu to menu jump.
Regular to menu jump however is a jumpoutofcontext and so menu to regular is a return.
What is a jump out of context? I have no idea.
Actually, this is wrong.

First, let me explain what contexts are. Contexts exist for two reasons:

1) To let python code invoke Ren'Py code.
2) To ensure we leave a menu when we load a game.

Something to note is that interactions take place in python code, rather than Ren'Py code. So if you want to be able to go to the game menu in the middle of an interaction, and then come back to the exact same place, you need to go to the game menu in a new context.

There are two "levels" of context in a Ren'Py game. The "main" context is where the game itself runs, while the "menu" context is where the main and game menus live.

Control is automatically sent to the menu context when the main menu is reached (at the end of the splashscreen, which runs in the default context). We can also go to the menu context by right clicking to invoke the game menu. Finally, you can go to the game menu using renpy.call_in_new_context and the _game_menu_save, _game_menu_load, or _game_menu_preferences labels. For example:

Code: Select all

# Big battle coming up, why not prompt the user to save?
$ renpy.call_in_new_context("_game_menu_save")
In the menu context, you can jump around between the various menu screens. If you run "return" in the menu context, and the call stack is empty, it leaves the context and returns to where you were in the main context.

You can also do a jumpsoutofcontext, which takes a label. This brings you back to the main context, but jumps to a label rather than the point where you came from. This lets you do things like invoke the gallery (which runs in the main context) from the main menu.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: Scene Gallery - Using CG Gallery behavior as Scene Selector

#9 Post by JQuartz »

I see, so it's a call in new context. Sorry.
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot]