xalign doesn't seem to be working.

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
User avatar
NocturneLight
Regular
Posts: 163
Joined: Thu Jun 30, 2016 1:20 pm
Projects: Unsound Minds: The Clarevine Epoch
Organization: Reminiscent 64
Tumblr: Reminiscent64
itch: Reminiscent64
Location: Texas
Contact:

xalign doesn't seem to be working.

#1 Post by NocturneLight »

I was trying to find a way of centering input text without using NVL mode and came across this code:

Code: Select all

screen input(prompt):

    window:
        xalign 0.5 #Centered Across
        yalign 0.5 # 75% Down from Top
        has vbox
 
        text prompt:
            yoffset 5
            style "say_dialogue"
            xoffset 10
        input:
            id "input"
            style "input"
            color "#FFFFFF" # Color of Input Text
            yoffset 5
            xoffset 10

I've been tweaking it for who knows how long at this point. yalign has been working as intended but xalign just won't do anything. If I set xalign to 0, it will be on the left side of the screen. If I set xalign to 1 and above, it still stays on the left side of the screen.

I'm not sure what could be causing the problem at this point. I've tried commenting out other xaligns in the code to see if it's being overridden maybe, but that doesn't seem to be the case. Any other ideas of what to check would be appreciated.

I don't know if it'll help any, but this is the text I was trying to center in the first place:

Code: Select all

python:
    
    BelovedName = renpy.input("My Significant Other's name is...")
    BelovedName = BelovedName.strip()

    if not BelovedName:
         BelovedName = "Marion Sinclare"

jw2pfd
Regular
Posts: 87
Joined: Tue Sep 18, 2012 9:55 pm
Location: DFW, TX, USA
Contact:

Re: xalign doesn't seem to be working.

#2 Post by jw2pfd »

My best guess is that the window is stretched to be the full width of the screen. You can try adding a xmaximum value to the window like this:

Code: Select all

screen input(prompt):

    window:
        xmaximum 400   #this value is in pixels, you may need to change it to match the size of whatever your dialogue box's actual width is
        xalign 0.5
        yalign 0.5
        has vbox

       #rest of code....
The value of 400 pixels will probably need to be changed to better fit the actual properties of your dialogue box.

User avatar
NocturneLight
Regular
Posts: 163
Joined: Thu Jun 30, 2016 1:20 pm
Projects: Unsound Minds: The Clarevine Epoch
Organization: Reminiscent 64
Tumblr: Reminiscent64
itch: Reminiscent64
Location: Texas
Contact:

Re: xalign doesn't seem to be working.

#3 Post by NocturneLight »

jw2pfd wrote:My best guess is that the window is stretched to be the full width of the screen. You can try adding a xmaximum value to the window like this:

Code: Select all

screen input(prompt):

    window:
        xmaximum 400   #this value is in pixels, you may need to change it to match the size of whatever your dialogue box's actual width is
        xalign 0.5
        yalign 0.5
        has vbox

       #rest of code....
The value of 400 pixels will probably need to be changed to better fit the actual properties of your dialogue box.

Looks like xmaximum fixed it. Thank you!

Post Reply

Who is online

Users browsing this forum: Google [Bot]