Main menu help (Solved)

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
Ai Makai
Newbie
Posts: 9
Joined: Tue Mar 20, 2012 6:43 pm
Contact:

Main menu help (Solved)

#1 Post by Ai Makai » Thu Mar 22, 2012 2:58 pm

I don't know that much about coding at all and can understand a bit of what I learn from the tutorial Ren'py comes with. so a more basic explanation might be more helpful to me since Ren'Py is also my first time dealing with coding at all.

First I was looking to set up the main menu Layout a little differently than how it is. I've seen this, http://www.renpy.org/wiki/renpy/doc/reference/Layouts , page and a lot of it is just... confusing to me. I'd also like to add two other choice options, one a CG gallery, and the other a screen that would allow a player to look over some basic information about the main characters. For the CG Gallery I have seen this, http://www.renpy.org/wiki/renpy/doc/coo ... CG_Gallery , But again am having a hard time understanding all the coding of it..

Any help would be greatly appreciated.
Last edited by Ai Makai on Mon Mar 26, 2012 12:06 pm, edited 1 time in total.

HigurashiKira
Miko-Class Veteran
Posts: 832
Joined: Mon Nov 01, 2010 9:10 pm
Contact:

Re: Main menu help

#2 Post by HigurashiKira » Thu Mar 22, 2012 4:04 pm

Alright, I myself don't understand the CG code that well, but I can do something about the main menu.

You have 3 layout styles, which can be changed 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")
        textbutton _("Preferences") action ShowMenu("preferences")
        textbutton _("Help") action Help()
        textbutton _("Quit") action Quit(confirm=False)

init -2 python:

    # Make all the main menu buttons be the same size.
    style.mm_button.size_group = "mm"
This is the general style, as in "classic" If you want to change positioning of the options, just change the code as needed.

Code: Select all

# The main menu buttons.
    hbox:
        xalign .5
        yalign .85

        textbutton _("Start Game") action Start()
        textbutton _("Load Game") action ShowMenu("load")
        textbutton _("Preferences") action ShowMenu("preferences")
    hbox:
        xalign 0.5
        yalign .9
        textbutton _("Help") action Help()
        textbutton _("Quit") action Quit(confirm=False)
This is the 2nd style, the across button style. The difference between the two is the box. The top one uses vbox(v as in vertical) and this one uses hbox (h as in horizontal) They also need different placements to have all the buttons fiton the screen.

Code: Select all

imagemap:
        ground "menu_idle.png"
        hover "menu_hover.png"
      
        hotspot (419,271,185,40) action Start()
        hotspot (396,335,235,40) action ShowMenu("load")
        hotspot (450,400,185,40) action ShowMenu("preferences")
        hotspot (383,463,260,40) action ShowMenu("music_room")
        hotspot (480,527,70,40) action Quit(confirm=False)
And this is an imagemap menu. What makes this one special is that it uses an image to design the menu. The hotspots are where the options are located, that way someone can select them. Main menu imagemaps need at least two images: a ground (The base image) and a hover (What's shown when the mouse is over an option.

If you need more clarification, feel free to say :D
I have moved to a new account. Please contact me here from now on. T/Y~

Ai Makai
Newbie
Posts: 9
Joined: Tue Mar 20, 2012 6:43 pm
Contact:

Re: Main menu help

#3 Post by Ai Makai » Fri Mar 23, 2012 1:23 am

Thanks! I figured the layout think out now :) Now I just need some assistance with those two other bits..

HigurashiKira
Miko-Class Veteran
Posts: 832
Joined: Mon Nov 01, 2010 9:10 pm
Contact:

Re: Main menu help

#4 Post by HigurashiKira » Fri Mar 23, 2012 1:57 pm

Oh yeah, to add options just add them to the main menu:

Code: Select all

hotspot (585,278,54,22) action Start()
        hotspot (100,155,94,22) action ShowMenu("load")
        hotspot (100,107,78,22) action ShowMenu("preferences")
        hotspot (100,200,78,22) action ShowMenu("extras")
        hotspot (83,490,118,22) action Quit(confirm=False)   
Just make sure to label the screens poroperly so that it can jump properly between screens. And as for your basic info one...if it's going to be looked at in-game, then you might want to read this
I have moved to a new account. Please contact me here from now on. T/Y~

User avatar
Nuxill
Veteran
Posts: 464
Joined: Sat Sep 25, 2010 4:50 pm
Projects: We Are the Hunted, Heart Shard
Tumblr: nuxill
itch: nuxill
Contact:

Re: Main menu help

#5 Post by Nuxill » Fri Mar 23, 2012 4:33 pm

Here's a really handy walkthrough of the CG gallery code!

Ai Makai
Newbie
Posts: 9
Joined: Tue Mar 20, 2012 6:43 pm
Contact:

Re: Main menu help

#6 Post by Ai Makai » Fri Mar 23, 2012 6:24 pm

I have the Main menu buttons moved around how I like them now, so there isn't a problem anymore with that thank you :)

As for the CG gallery... It won't work. I've tried following what was said in there in reference to getting the code to work and all I keep getting is,

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/screens.rpy", line 563, in script
  File "game/screens.rpy", line 566, in python
NameError: name 'grid_layout' is not defined

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

Full traceback:
  File "E:\renpy-6.13.9\renpy\execution.py", line 265, in run
  File "E:\renpy-6.13.9\renpy\ast.py", line 632, in execute
  File "E:\renpy-6.13.9\renpy\python.py", line 977, in py_exec_bytecode
  File "game/screens.rpy", line 566, in <module>
NameError: name 'grid_layout' is not defined

Windows-post2008Server-6.1.7601-SP1
Ren'Py 6.13.9.1702
A Ren'Py Game 0.0

Code: Select all

init:
    # Position the navigation on the right side of the screen.
    $ style.gallery_nav_frame.xpos = 800 - 10
    $ style.gallery_nav_frame.xanchor = 1.0
    $ style.gallery_nav_frame.ypos = 12

    # Add the gallery to the main menu.
    $ config.main_menu.insert(2, ('Gallery', "gallery", "True"))

# The entry point to the gallery code.
label gallery:
    python hide:

        # Construct a new gallery object.
        g = Gallery(grid_layout)

        # The image used for locked buttons.
        g.locked_button = "buttons.png"

        # The background of a locked image.
        g.locked_background = "buttons.png"

        # Frames added over unlocked buttons, in hover and idle states.
        g.hover_border = "buttons.png"
        g.idle_border = "buttons.png"

        # An images used as the background of the various gallery pages.
        g.background = "buttons.png"

        # Lay out the gallery images on the screen.
        # These settings lay images out 3 across and 4 down.
        # The upper left corner of the gird is at xpos 10, ypos 20.
        # They expect button images to be 155x112 in size.
        g.grid_layout((3, 4), (10, 12), (160, 124))

        # Show the background page.
        g.page("Backgrounds")

        # Our first button is a picture of the beach.
        g.button("thumnail.png")
        #
        # These show images, if they have been unlocked. The image name must
        # have been defined using an image statement.
        g.unlock_image("buttons.png")
        #
        # This shows a displayable...
        g.display("buttons.png")
        # ... if all prior images have been show.
        g.allprior()

        # A second set of images.
        g.button("thumnail.png")
        g.unlock_image("buttons.png")
        g.display("thumnail.png")
        g.allprior()



        # We can use g.page to introduce a second page.
        g.page("Characters")

        g.button("thumnail.png")
        g.unlock_image("buttons.png")
        g.display("thumnail.png")


        # Another page, this one for concept art.
        g.page("Concept Art")
        
        g.button("thumnail.png")
        # We can apply conditions to buttons as well as to images.
        # The "condition" condition checks an arbitrary expression.
        g.condition("persistent.beat_game")
        #
        g.unlock_image("buttons.png")
        g.display("thumnail.png")
        g.allprior()


        # Now, show the gallery.
        g.show()

    jump main_menu_screen
That's how the code turned out
What do I have to do to 'define' it?

HigurashiKira
Miko-Class Veteran
Posts: 832
Joined: Mon Nov 01, 2010 9:10 pm
Contact:

Re: Main menu help

#7 Post by HigurashiKira » Fri Mar 23, 2012 6:38 pm

new_gallery.rpy
(8.2 KiB) Downloaded 125 times
Try adding this to your game folder and see what happens
I have moved to a new account. Please contact me here from now on. T/Y~

Ai Makai
Newbie
Posts: 9
Joined: Tue Mar 20, 2012 6:43 pm
Contact:

Re: Main menu help

#8 Post by Ai Makai » Fri Mar 23, 2012 8:09 pm

I can't find the label in order to run it, and I don't exactly know how to make one that would work >.<..

HigurashiKira
Miko-Class Veteran
Posts: 832
Joined: Mon Nov 01, 2010 9:10 pm
Contact:

Re: Main menu help

#9 Post by HigurashiKira » Fri Mar 23, 2012 8:15 pm

Ai Makai wrote:I can't find the label in order to run it, and I don't exactly know how to make one that would work >.<..
Wait, so you got the same error after putting the file inside your game folder, or did you just look through the code?
I have moved to a new account. Please contact me here from now on. T/Y~

Ai Makai
Newbie
Posts: 9
Joined: Tue Mar 20, 2012 6:43 pm
Contact:

Re: Main menu help

#10 Post by Ai Makai » Fri Mar 23, 2012 8:44 pm

No this time it just can't connect the button label from the main menu to the file you sent me, that's what I meant by label. Sorry for not being clear.

HigurashiKira
Miko-Class Veteran
Posts: 832
Joined: Mon Nov 01, 2010 9:10 pm
Contact:

Re: Main menu help

#11 Post by HigurashiKira » Fri Mar 23, 2012 8:45 pm

Ai Makai wrote:No this time it just can't connect the button label from the main menu to the file you sent me, that's what I meant by label. Sorry for not being clear.
You weren't supposed to copy your CG gallery code into that file. All the file was supposed to do was define what you needed. Move your CG code BACK to where you had it and leave that file intact.
I have moved to a new account. Please contact me here from now on. T/Y~

Ai Makai
Newbie
Posts: 9
Joined: Tue Mar 20, 2012 6:43 pm
Contact:

Re: Main menu help

#12 Post by Ai Makai » Fri Mar 23, 2012 8:57 pm

Oh >.<... Sorry I'm quite new with this..

When I put it all back the way it is suppose to go I get this,

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/screens.rpy", line 564, in script
  File "game/screens.rpy", line 567, in python
NameError: name 'grid_layout' is not defined

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

Full traceback:
  File "E:\renpy-6.13.9\renpy\execution.py", line 265, in run
  File "E:\renpy-6.13.9\renpy\ast.py", line 632, in execute
  File "E:\renpy-6.13.9\renpy\python.py", line 977, in py_exec_bytecode
  File "game/screens.rpy", line 567, in <module>
NameError: name 'grid_layout' is not defined

Windows-post2008Server-6.1.7601-SP1
Ren'Py 6.13.9.1702
A Ren'Py Game 0.0

Ai Makai
Newbie
Posts: 9
Joined: Tue Mar 20, 2012 6:43 pm
Contact:

Re: Main menu help

#13 Post by Ai Makai » Sat Mar 24, 2012 2:46 pm

Never mind I figured the rest out :) thanks for your help.

Post Reply

Who is online

Users browsing this forum: Google [Bot], pronehouse, staffofmagic