change text size/alignment in menu but not otherwise in UI

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
tametick
Newbie
Posts: 14
Joined: Fri Apr 14, 2017 7:48 am
Contact:

change text size/alignment in menu but not otherwise in UI

#1 Post by tametick »

Hi,
I want to make my main menu look like [see attachment].

i figured i can change the font and text size in gui.rpy (e.g. define gui.interface_text_size) but i dont want ALL gui text to be huge, only the main menu. further more i would like to change the text alignment only in the main menu to centered.

Any idea how to do that?
Attachments
main.png

tametick
Newbie
Posts: 14
Joined: Fri Apr 14, 2017 7:48 am
Contact:

Re: change text size/alignment in menu but not otherwise in

#2 Post by tametick »

ok, figured out i can change the main menu in screens.rpy, like:

Code: Select all

screen navigation():
    vbox:
        style_prefix "navigation"

        xalign 0.5
        yalign 0.5
        spacing 100
but i still can't seem to change the text alignment to centered - it does not accept the text_align keyword...

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: change text size/alignment in menu but not otherwise in

#3 Post by Imperf3kt »

I'd suggest using imagebuttons to be perfectly honest.

However, you can still do this with textbuttons, it just requires a touch more code.

Personally, I don't use textbuttons, so I may have this slightly incorrect.

Code: Select all

screen main_menu():

    tag menu

    style_prefix "main_menu"
    vbox:
        xalign 0.5
        yalign 0.5
        spacing 100

        textbutton _("NEW GAME")
        textbutton _("LOAD")

style main_menu_textbutton is gui.main_menu_text
Then in gui.rpy, press CTRL+F to find

Code: Select all

## The position of the main menu text.
define gui.main_menu_text_xalign = 0
Edit these lines to

Code: Select all

## The size of the main menu text.
define gui.main_menu_textbutton_size = 100
Or whatever size you want it to be.

You'll need to set a font as well and also remember to include that font in the base directory... Or was it the game directory? The documentation should be able to tell you.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

tametick
Newbie
Posts: 14
Joined: Fri Apr 14, 2017 7:48 am
Contact:

Re: change text size/alignment in menu but not otherwise in

#4 Post by tametick »

cheers!

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: change text size/alignment in menu but not otherwise in

#5 Post by Imperf3kt »

I'd like to clarify an error I made in my previous post.

Code: Select all

## The size of the main menu text.
define gui.main_menu_textbutton_size = 100
Should be

Code: Select all

## The size of the main menu text.
define gui.main_menu_button_text:
    size 100
I made this in about ten minutes. It should work well with all HD resolutions. (It'll probably work with any resolution to be honest, but you should consider editing the xmaximum.)

First, edit options.rpy to this:

Code: Select all

## Basics ######################################################################

## A human-readable name of the game. This is used to set the default window
## title, and shows up in the interface and error reports.
##
## The _() surrounding the string marks it as eligible for translation.

define config.name = _("your game name here")

## The version of the game.

define config.version = "1.0"
Then replace everything you see in the main menu screen, with this code.

Code: Select all

screen main_menu():

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

    style_prefix "main_menu"
    
    #The following can be changed on line 88 of gui.rpy or by editing/overwriting the image at gui/main_menu.jpg
    add gui.main_menu_background

    ## The use statement includes another screen inside this one. The actual
    ## contents of the main menu are in the navigation screen.
    vbox:
        #make a grid 1 wide, 2 high
        grid 1 2:
            #make sure the buttons don't overlap
            spacing 30
            textbutton _("New Game") action Start()
            textbutton _("Load") action ShowMenu("load")


style main_menu_vbox is vbox
style main_menu_button_text:
    size 90

style main_menu_vbox:
    #align the buttons in the center of the screen
    xalign 0.5
    #restrict the buttons to a space 960 pixels wide
    xmaximum 960
    #align the buttons 80% toward the bottom of the screen
    yalign 0.8
The result is as follows (with an image I added)
screenshot0002.png
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: No registered users