Main menu buttons?

A place to discuss things that aren't specific to any one creator or game.
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Post Reply
Message
Author
User avatar
Raijenki
Regular
Posts: 33
Joined: Fri Sep 03, 2010 2:07 pm
Location: Natal, Brazil
Contact:

Main menu buttons?

#1 Post by Raijenki » Fri Sep 03, 2010 2:23 pm

Hey there, people!
I recently joined a VN team and started using Ren'Py for the Visual Novel. So, in order to learn, I'll start being active here, since I'm don't have all that time to learn everything about this engine.

Anyway, I've been using Ren'Py for about 1 week and there are some infos I cant find on wiki/forum.

I know it's pretty dumb to ask, but: How the heck I change the main menu buttons?
I mean, I have 5 files for the main menu:
  • main_menu.bmp (The background)
  • start.png (Start button)
  • continue.png
  • config.png
  • quit.png
I changed the mm_root to main_menu.bmp and tried to find a way to change buttons to my images. No luck.
I tried to code an imagemap, but it just doesn't let me use my buttons.

So... what should I do? I'm taking any ideas/snippets of codes.
I'd be glad if someone help me the easiest way possible, since I'm still new to Ren'Py.

Thanks in advance!

P.S.: I'm not sure if this is the correct board to post this.

User avatar
kinougames
Miko-Class Veteran
Posts: 522
Joined: Tue Jul 13, 2010 1:37 pm
Projects: Working on ミツマタ [Mitsumata (c)].
Contact:

Re: Main menu buttons?

#2 Post by kinougames » Fri Sep 03, 2010 2:42 pm

I'm not using Renpy so am like, completely worthless as far as that, but Renpy support questions should go in the Renpy support forum. :)
Check out the new interactive media project, Mitsumata(c). Follow 8 colorful characters in a story full of drama, horror, all sexualities and exciting gameplay~!

Development blog's up! Visit!

User avatar
Raijenki
Regular
Posts: 33
Joined: Fri Sep 03, 2010 2:07 pm
Location: Natal, Brazil
Contact:

Re: Main menu buttons?

#3 Post by Raijenki » Fri Sep 03, 2010 2:45 pm

WOOOOOOOOOOPS
I didn't noticed the existence of the Support forum XD

I'll just wait for some moderator move this, or someone answer :P

fortaat
Regular
Posts: 183
Joined: Tue May 18, 2010 1:16 pm
Contact:

Re: Main menu buttons?

#4 Post by fortaat » Fri Sep 03, 2010 5:14 pm

The easiest way would be this.

If you only want to change the background of the menu, change the options.rpy file. Open it with your favorite editor, read the #comments, and the rest is self explanatory.

User avatar
Samu-kun
King of Moé
Posts: 2262
Joined: Mon Sep 03, 2007 3:49 pm
Organization: Love in Space Inc
Location: United States
Contact:

Re: Main menu buttons?

#5 Post by Samu-kun » Fri Sep 03, 2010 5:23 pm

The easiest way to implement this is through imagemaps. In order to use imagemaps, you need two pictures of the main screen, in the example "menu2.jpg" and "menu1.jpg"

menu2.jpg is a picture of the main screen that the player will see, with the background picture and all the buttons in it. menu1.jpg is another picture of the main screen, except it has all the buttons highlighted, as if the player was hovering the mouse over it.

Once you have those two images, you tell the game where the buttons are, using (x1,y1,x2,y2) coordinates. Whenever the player hovers the mouse over this box, the game will know that the player is hovering over a button and do the expected function when the player clicks and replace the button image with the highlighted version on top of the indicated box.

Code: Select all

init -2 python:
    layout.imagemap_main_menu("menu2.jpg", "menu1.jpg", [
        (111, 248, 392 ,313, "Start Game"),
        (111, 313, 392, 378, "Load Game"),
        (48, 432, 237, 529, "Preferences"),
        (48,529,237,576, "Quit"),
        (48, 435, 237, 482, "instructions"),
        ])

User avatar
Raijenki
Regular
Posts: 33
Joined: Fri Sep 03, 2010 2:07 pm
Location: Natal, Brazil
Contact:

Re: Main menu buttons?

#6 Post by Raijenki » Fri Sep 03, 2010 5:46 pm

Is this the only way? I don't want to use imagemaps!
I mean, I have the background without buttons and the buttons in png alpha and want to add them separately.

Thanks!

User avatar
Samu-kun
King of Moé
Posts: 2262
Joined: Mon Sep 03, 2007 3:49 pm
Organization: Love in Space Inc
Location: United States
Contact:

Re: Main menu buttons?

#7 Post by Samu-kun » Fri Sep 03, 2010 5:59 pm

It's not the only way, but the other way is quite difficult to program. You need to use UI buttons. It takes longer and the end result isn't much different from imagemaps.

User avatar
Raijenki
Regular
Posts: 33
Joined: Fri Sep 03, 2010 2:07 pm
Location: Natal, Brazil
Contact:

Re: Main menu buttons?

#8 Post by Raijenki » Fri Sep 03, 2010 6:05 pm

Interesting, I'll take a look at it and check out how it works.

Anyway, thanks for the help.

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Main menu buttons?

#9 Post by Jake » Fri Sep 03, 2010 7:23 pm

If UI programming is too complex and you still don't want to use imagemaps, you might also be able to achieve the effect you're after with Styles.

For example, the following code will change the 'Start Game' button into a custom graphical button, if placed in the options.rpy file (say around line 160, just after the other style sections) and accompanied by the relevant graphics (attached).

Code: Select all

    style.mm_button[u'Start Game'].background = 'mm_start_button.png'
    style.mm_button[u'Start Game'].hover_background = 'mm_start_button_hover.png'
    style.mm_button[u'Start Game'].xminimum = 133
    style.mm_button[u'Start Game'].xmaximum = 133
    style.mm_button[u'Start Game'].yminimum = 33
    style.mm_button[u'Start Game'].ymaximum = 33

    style.mm_button_text[u'Start Game'].color="#0000"
    style.mm_button_text[u'Start Game'].size=1

What we're doing here is setting the style specifically for the button and text of the 'Start Game' button. If you want to re-style pretty much any UI element you do it in the same way, and you can find out exactly which you need to modify by hovering the mouse over the element in question and hitting Shift-I to open the style-inspector, so long as developer mode is still set to True in options.rpy.
  • The 'background' property tells it to use the specified image as the background of the button (which gives it the visual appearance - by default the background is set to that blue rounded rectangle).
  • The 'hover_background' property tells it to use a different background graphic when the user hovers the mouse over it.
  • The xminimum/maximum and y min/max properties are there to explicitly size the button to exactly the pixel size of the graphic, to make sure it shows up properly... otherwise the button will try to resize itself to fit the text that's inside it.
  • mm_button_text is modifying the properties of the text itself - we're setting it to totally transparent and so small that it won't affect the size of the button, so it doesn't get in the way.
On top of this, it's pretty cheeky, but you can actually move those buttons around the screen by using the xoffset and yoffset properties. They'll move relative to the position they 'should' be in - inside that little light-blue box in the bottom right by default - so you'll have to mess around with negative values to get the button to move up or to the left. For example, these values position it somewhere in the middle-left of the screen:

Code: Select all

    style.mm_button[u'Start Game'].xoffset = -450
    style.mm_button[u'Start Game'].yoffset = -100
example.jpg
Obviously, you can do the same with all the other buttons as well, so you should be able to do more or less what you like if you just want graphical buttons.

You can set the main menu background with 'style.mm_root.background', and you might also want to set 'mm_menu_frame.background' to hide the light-blue box the buttons used to be in:

Code: Select all

    style.mm_root.background = 'menu_bg.jpg'
    style.mm_menu_frame.background = '#0000'
Attachments
mm_start_button_hover.png
mm_start_button_hover.png (1.17 KiB) Viewed 2792 times
mm_start_button.png
mm_start_button.png (1.21 KiB) Viewed 2792 times
Server error: user 'Jake' not found

User avatar
Raijenki
Regular
Posts: 33
Joined: Fri Sep 03, 2010 2:07 pm
Location: Natal, Brazil
Contact:

Re: Main menu buttons?

#10 Post by Raijenki » Fri Sep 03, 2010 7:31 pm

Wow, I had a look at Styles and didn't thought it was so simple.
Maybe it's just me who's still a newbie at Ren'py XD

Anyway, I made my menu screen (bleh, I bet that the team will want to change it later in the development, more work to me ;_:)

Thanks, Jake! I'll keep this post for future references!

Post Reply

Who is online

Users browsing this forum: No registered users