In my last few posts, I showed you how I made a global look and feel for all my buttons. Every button, everywhere, for any purpose. Well, it turns out that, afterward, I decided that some needed to be different. And you might not be as crazy as I am, which means that you don't want all yours to look the same in the first place. So today I'll be telling you how to override the global style we created in the last post (or, ignoring my last post and starting from here). Sound good? Good. ^^
On the left you'll see Ren'Py's default Save/Load screen (Theme: "A White Tulip", color scheme: "Dramatic Flesh") and on the right is the (much cooler, IMHO) screen that I whipped up.
The Save/Load screen is actually what prompted all of these design changes in the first place, because this annoyed me the most. You'll notice how the menu disappears into the save slots, which means once you're here, you can't get out without quitting. I also thought that ten slots per screen was a little overkill. So I made the slots bigger, with the intent of putting more information in them (ie, amount of time played, being able to name your saves, etc), but that's a future project.
First and foremost, you'll need to create a button style, and a button text style. No worries, though. It's easier than it sounds. ^^
The save/load slots are referred to as "large buttons" inside of Ren'Py. There aren't many others that fall into that category (as of this writing, I've yet to encounter more), so I'm going to create a global large_button style in this post.
Wherever you've been putting your custom styles (I have mine at the bottom of options.rpy), you can craft a code similar to this:
style large_button:
yminimum 190
background Frame("menu/frame_saveload.png",10,10)
hover_background Frame("menu/hover_saveload.png",10,10)
style large_button_text:
font "charlemagnestd.ttf"
size 22
color "#FFFFFF" # white
outlines [(.5, "#00006B", 0, 0)] # dark blue
"Style" will always begin your block when you're trying to create styles. Rocket science, I know. But I trust you'll remember it. ;)
Again, yminimum is the minimum amount of pixels (in height) I want these buttons to be. It's not a completely necessary step, but it helps the uniformity. You can also add a ymaximum, or an xmin/xmax (the width) to really constrain your buttons. It's really up to what you want. Play with numbers until it looks right to you.
background Frame (don't forget to capitalize!) is the picture you want for the button itself. Make sure the image you want to work with is in your "game" folder, and if it's in a subfolder (like all of mine are), make sure you include that folder name too (the word before the / above). Remember the comma. The two numbers are the amount of pixels you'll allow for the button's corners. Follow the same process for hover_background, which is what your button will look like with the mouse over it (see the upper left of my screenshot for my design choice).
large_button_text is exactly what I went over in my last post, so I won't reiterate it here. Style your text however you like, and you're all set! Because large_button and large_button_text are recognized by Ren'Py, all the work has been done for you.
This is the bit you really came here for, isn't it? ^^
What pushed me to create a second button style was the decision to include a pause menu (which I'll go over in depth in another post). The images you've seen so far weren't quite right once I started in with sprites and backgrounds, so this is my stand-in art in the meantime, with the Options button representing the hover effect.
This is actually very, very similar to what I went over above. We're going to create a custom style, the only difference being that we'll actually have to tell Ren'Py where and how to use it.
Each screen already has its own style group (defined by the theme and color scheme you chose as your template), which you can override with your own design. Here's a list of the different screens, and the style groups you'll need to know if you want to change those buttons specifically.
Main Menu - "gm_nav"
Navigation - "gm_nav"
Save/Load - "file_picker_nav"
Save/Load save slots - "file_picker"
Preferences - "pref"
Yes/No prompt - "yesno"
Quick Menu - "quick"
Beyond that, it's everything that we've been working on up to this point: choose your image(s), font(s), color(s), and decide on what size you want your buttons to be. Remember, all buttons are beautiful, regardless of size. ;)
Changing Style Groups:
The example I'm going with here is the Save/Load Screen. There are two different parts to that: the buttons across the very top (Previous, Auto, Quick, etc), and the save slots themselves. The following code should change the former:
style file_picker_nav:
background Frame("menu/frame_saveload.png",10,10)
hover_background Frame("menu/hover_saveload.png",10,10)
yminimum 40
xminimum 150
font "charlemagnestd.ttf"
size 22
color "#FFFFFF" # white
outlines [(.5, "#00006B", 0, 0)] # dark blue
size 22
color "#FFFFFF" # white
outlines [(.5, "#00006B", 0, 0)] # dark blue
The buttons across the top of the page should now reflect the image and text you wanted. For the slots themselves, replace file_picker_nav with file_picker. To change the look of the main menu, replace it with gm_nav. And so on.
Creating Custom Styles:
If you want a custom style (as I did with my pause menu), the creation is very similar, although the implementation is different. You can name that new style anything you want, but to make your life easier, it should be something
that's immediately obvious as to what you're using it for. For instance, my
pause screen buttons are named pause_button. Inspired, I know. ^^
Again, fill in all the information about how you want your button to look and feel. Here's the code for that pretty picture above:
style pause_button:
background Frame("buttons/pause_idle.png",10,10)
hover_background Frame("buttons/pause_hover.png",10,10)
yminimum 40
xminimum 150
style pause_button_text:
font "MTCORSVA.ttf"
size 24
color "#FFFFFF" # white
outlines [(.9, "#00006B", 0, 0)] # dark blue
hover_color "#FFFFFF" # white
hover_outlines [(.5, "#191975", 0, 0)] # dark blue
background Frame("buttons/pause_idle.png",10,10)
hover_background Frame("buttons/pause_hover.png",10,10)
yminimum 40
xminimum 150
style pause_button_text:
font "MTCORSVA.ttf"
size 24
color "#FFFFFF" # white
outlines [(.9, "#00006B", 0, 0)] # dark blue
hover_color "#FFFFFF" # white
hover_outlines [(.5, "#191975", 0, 0)] # dark blue
Now, if you have experience creating new screens (or using Screen Language, as Ren'Py likes to call it), then you likely don't need my advice on making text buttons. However, if you're here for such advice, this might get complicated as I break the how-to into two separate posts. If that gets messy, I do apologize. I'm trying to keep these short enough that even the newest newbie won't have their eyes glaze while stuffing as much information in as I can. If there is real, genuine confusion after my next post, I will come back and try to edit them into a more cohesive whole.
That being said, I placed the following code into the brand new screen I made for my pause menu. The procedure for making text buttons is the same no matter where they are though, so go ahead and Ctrl/Cmd + F to search for textbutton and see if you can change different buttons within the same style group. Just for fun. ^^
vbox:
pos (0.5, 0.5)
anchor (0.5, 0.5)
textbutton _("Continue") style "pause_button" text_style "pause_button_text" action Return()
textbutton _("Main Menu") style "pause_button" action MainMenu()
textbutton _("Save Game") style "pause_button" action ShowMenu("save")
textbutton _("Load Game") style "pause_button" action ShowMenu("load")
textbutton _("Options") style "pause_button" action ShowMenu("preferences")
textbutton _("Quit") style "pause_button" action Quit()
Vbox, pos and anchor I'll go over in my next post. They're all very related, and I wanted to make sure that the code to enact these buttons is all correct before we worry about aesthetics. ^^
You'll notice each text button starts off with textbutton. Not difficult to follow. Make sure there is a space before the underscore. The text in the quotes are the words that will appear on your button. style "pause_button" calls to the code I wrote earlier, the image. text_style calls to the other bit of code, the well... text style. Actions I went over previously, and they're pretty self-explanatory, I think.
I will fully admit to not being sure why each button requires a style, but I only had to write in the text style once. It's something I've been bouncing around in the forums, and thus far NOBODY can tell me why. If/when I figure it out, I'll be sure to pass on my wisdom.
Goodbye, and Good Luck:
That's all for today's wall o' text. Next time you can look forward to a deeper explanation of my custom pause menu, with hopes that you'll be be conversational in Screen Language afterward. Until then, happy coding!
That being said, I placed the following code into the brand new screen I made for my pause menu. The procedure for making text buttons is the same no matter where they are though, so go ahead and Ctrl/Cmd + F to search for textbutton and see if you can change different buttons within the same style group. Just for fun. ^^
vbox:
pos (0.5, 0.5)
anchor (0.5, 0.5)
textbutton _("Continue") style "pause_button" text_style "pause_button_text" action Return()
textbutton _("Main Menu") style "pause_button" action MainMenu()
textbutton _("Save Game") style "pause_button" action ShowMenu("save")
textbutton _("Load Game") style "pause_button" action ShowMenu("load")
textbutton _("Options") style "pause_button" action ShowMenu("preferences")
textbutton _("Quit") style "pause_button" action Quit()
Vbox, pos and anchor I'll go over in my next post. They're all very related, and I wanted to make sure that the code to enact these buttons is all correct before we worry about aesthetics. ^^
You'll notice each text button starts off with textbutton. Not difficult to follow. Make sure there is a space before the underscore. The text in the quotes are the words that will appear on your button. style "pause_button" calls to the code I wrote earlier, the image. text_style calls to the other bit of code, the well... text style. Actions I went over previously, and they're pretty self-explanatory, I think.
I will fully admit to not being sure why each button requires a style, but I only had to write in the text style once. It's something I've been bouncing around in the forums, and thus far NOBODY can tell me why. If/when I figure it out, I'll be sure to pass on my wisdom.
Goodbye, and Good Luck:
That's all for today's wall o' text. Next time you can look forward to a deeper explanation of my custom pause menu, with hopes that you'll be be conversational in Screen Language afterward. Until then, happy coding!