Customizing "Extra Menu" in Main Menu

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
salventus
Newbie
Posts: 20
Joined: Fri Jun 20, 2014 12:16 am
Contact:

Customizing "Extra Menu" in Main Menu

#1 Post by salventus »

Just like many other VN, i want to create menu "Extras" in Main menu, which will lead to list of Ending, Gallery, Music, etc
so i make the menu list in extra ending like this (and also shown in the pict):

Code: Select all

init:
    $ config.main_menu.insert(2, ('Extras', "extra", "persistent.my_extras"))

label extras:
    
#This part here indicates whether or not the player has unlocked the menu
    if not persistent.my_bonus:
        show bg black with dissolve
        centered "You haven't unlocked this yet"
        $ renpy.full_restart()
    
    scene bg meadow
    with dissolve
    
    menu:
        "Endings":
            jump Endings
        "Gallery":
            jump cg_gallery_screen
        "Return":
            jump main_menu_screen
for the proceeding 'Endings' menu, this code work for me

Code: Select all

init python:
    
    # If persistent.endings is None (the first pass through the game), then make it a set.
    if persistent.endings is None:
        persistent.endings = set()

    # This shows a single ending, as necessary.
    def show_ending(number, name):
         if name in persistent.endings:
             ui.text("% 2d. %s" % (number, name))
         else:
             ui.text("% 2d. ???" % (number,))

    # Add a button that brings people to the ending list to the main menu.
    config.main_menu.insert(2, ("Endings", "endings_1", "True"))
    
label Endings:
    scene bg cave with dissolve
    $ ui.vbox()
        
    $ ui.text("Askary Endings")
    $ show_ending(1, "True Ending")
    $ show_ending(2, "Bad Ending")
    $ show_ending(3, "Worst Ending")
        
    $ ui.close()
    $ ui.textbutton("Return", clicked=ui.jumps("endings_return"), xalign=0.05, yalign=0.95)
     
    $ ui.interact(suppress_overlay=True) 
    
# Jump here to return to the main menu.
label endings_return:
      jump extras
but, for the proceeding gallery menu, by using code like this always lead me to error:

Code: Select all

init python:
    
    gallery_cg_items = ["cg01"]

    gal_rows = 2
    gal_cols = 2

    thumbnail_x = 200
    thumbnail_y = 150
    
    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:

    for gal_item in gallery_cg_items:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))

label cg_gallery:
    scene bg cave with dissolve
    $ ui.vbox()
    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.jpg", 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")]
it is said in the traceback that i need to put 'label' to the gallery instead of 'screen', but i don't know whether i just have to change the gallery code a bit or i need to change the whole code.

What code do it really needed in order to show list of picture in 'Gallery' menu inside 'label' Extras?
And also, with the same condition in 'label' Extras, how to create a music gallery?

mjshi
Regular
Posts: 179
Joined: Wed Mar 13, 2013 9:55 pm
Completed: MazeSite01, Ponderings of Time
Contact:

Re: Customizing "Extra Menu" in Main Menu

#2 Post by mjshi »

For now I can just suggest a few things that might be wrong.

First off, this

Code: Select all

label cg_gallery:
    scene bg cave with dissolve
is Ren'Py normal dialogue language, but this

Code: Select all

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.jpg", 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")]
is actually screen language, and you probably can't mix the two.

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

Re: Customizing "Extra Menu" in Main Menu

#3 Post by salventus »

@mjshi: ahh thanks, now i understand :D

soo, i think i might need to delete the screen languange gallery, but is there a way to make gallery code by using 'label'? or do i need to fix the choice in extra menu in order i can call the screen?

sometimes i kinda confused about screen and label though, sorry ._.

mjshi
Regular
Posts: 179
Joined: Wed Mar 13, 2013 9:55 pm
Completed: MazeSite01, Ponderings of Time
Contact:

Re: Customizing "Extra Menu" in Main Menu

#4 Post by mjshi »

The preferred way is to make the gallery screen with screen language :P

But, I mean, it's definitely possible...

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

Re: Customizing "Extra Menu" in Main Menu

#5 Post by salventus »

@mjshi: Hmm okay ._. will it be easier if i change the Extra menu to screen languange, maybe? So it's like i'm making another 'main menu' (Extras) consist of ending list screen and gallery screen.

mjshi
Regular
Posts: 179
Joined: Wed Mar 13, 2013 9:55 pm
Completed: MazeSite01, Ponderings of Time
Contact:

Re: Customizing "Extra Menu" in Main Menu

#6 Post by mjshi »

You could have something like

Main menu>Extras label>menu: "Endings", "Gallery", "Music Room"> if click endings, show screen endings

Although tbh I'm not really sure if it's possible to change a menu into screen language (unless you're asking imagemaps/textbuttons). I suggest you stick with the setup above, I can code something and explain it if you would like, though I've never used the gallery code (or the music room code, for that matter) so I can't claim to be an expert on that.

EDIT: Okay so I got around to doing it

Code: Select all

# You can place the script of your game in this file.

# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8")

$ persistent.completed = False

# The game starts here.
label start:

    e "You've created a new Ren'Py game."

    e "Once you add a story, pictures, and music, you can release it to the world!"
    
    $ persistent.completed = True

    return


# Put the extra screen anywhere, you could even make a separate RPY file for it

label extra:

    # For the gallery and music room screens, use these codes: 
    # http://www.renpy.org/doc/html/rooms.html
    # For the endings list, check out this topic:
    # http://lemmasoft.renai.us/forums/viewtopic.php?f=8&t=4309

    menu:
        
        "Endings":
            
            show screen endings
            
        "Gallery":
            
            show screen gallery
            
        "Music Room":
            
            show screen music_room
and in screens.rpy:

Code: Select all

screen main_menu:

    # This ensures that any other menu screen is replaced.
    tag menu

    # The background of the main menu.
    window:
        style "mm_root"

    # The main menu buttons.
    frame:
        style_group "mm"
        xalign .98
        yalign .98

        has vbox

        textbutton _("Start Game") action Start()
        textbutton _("Load Game") action ShowMenu("load")
        
        # Once the player completes the game, the extras button appears        
        if persistent.completed:
          textbutton _("Extra") action Start("extra")
        
        textbutton _("Preferences") action ShowMenu("preferences")
        textbutton _("Help") action Help()
        textbutton _("Quit") action Quit(confirm=False)

init -2:

    # Make all the main menu buttons be the same size.
    style mm_button:
        size_group "mm"
The persistent.completed makes it so that you have to complete the game before an extra button will pop up.

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

Re: Customizing "Extra Menu" in Main Menu

#7 Post by salventus »

@mjshi: your code seems amazing :0. Thankyou very much for doing it! I will try using it and see if i could make the extra menus really appeared normally (well my hands are the one that oftenly make mistake and error, your codes are perfectly great, hahaha)

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ocelot