Page 1 of 1

[Solved] Centering text vertically?

Posted: Mon Oct 03, 2016 3:10 pm
by shwippie
Hello! I'm having trouble centering text inside the textbox vertically in the newest version of Ren'Py. The instructions say to use 0.5 to center, but it doesn't appear to work if I use yalign, and if I use ypos, it moves it to 0.5 pixels instead of centering it. If I try using only yalign and delete ypos, I get an error. This is what the code looks like:

Code: Select all

## The placement of dialogue relative to the textbox. These can be a whole
## number of pixels relative to the left or top side of the textbox, or 0.5 to
## center.
define gui.text_xpos = 300
define gui.text_ypos = 60 
define gui.text_yalign = 0.5

## The maximum width of dialogue text, in pixels.
define gui.text_width = 790

## The horizontal alignment of the dialogue text. This can be 0.0 for left-
## aligned, 0.5 for centered, and 1.0 for right-aligned.
define gui.text_xalign = 0.0
This is what the result looks like. I'd like it to be centered vertically, whether it's one line or three lines of text. It currently only looks centered when there are two lines of text. Thank you for any help!

Image

Re: Centering text vertically?

Posted: Mon Oct 03, 2016 3:27 pm
by Ocelot
Check say_dialogue style. It is defined after say screen in screens.rpy.

Default definition is:

Code: Select all

style say_dialogue:
    xpos gui.text_xpos
    xanchor gui.text_xalign
    xsize gui.text_width
    ypos gui.text_ypos

    text_align gui.text_xalign
    layout ("subtitle" if gui.text_xalign else "tex")
You want to remove ypos line and replave it with yalign 0.5

Re: Centering text vertically?

Posted: Mon Oct 03, 2016 3:40 pm
by shwippie
Ocelot wrote: You want to remove ypos line and replave it with yalign 0.5
Thank you, Ocelot! This worked!

Although, it looks weird now that it works :shock: Maybe I should switch back