Can't justify text in a screen with a hidden background to the right.

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
Packmule
Newbie
Posts: 8
Joined: Fri Mar 02, 2018 11:37 am
Contact:

Can't justify text in a screen with a hidden background to the right.

#1 Post by Packmule »

I have an area on screen where I plan to show the player's total money (iu, for interstellar unit), the number appears inside a screen with the background hidden to show the graphic beneath, but the number increases justified to the left and I'd like it justified to the right. Does justifying text in a screen simply not work when there's only one line of text? Also, un-hashing the last bit of code does not solve the problem. Not a super big problem, but it's annoying. Please help?

Code: Select all

screen default_moneyscreen():

    default iu = 100

    zorder 101
    frame:
        background None
        xalign 0.138 ypos 8
        vbox:
            text "{font=fonts/RobotoCondensed-BoldItalic.ttf}{size=25}[iu]{/size}{/font}":
                color "#ebf5e5"
                #text_align 1.0

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Can't justify text in a screen with a hidden background to the right.

#2 Post by Remix »

Is the vbox resizing or are there other items in that vbox to lock its width? Maybe use the area (xpos, ypos, width, height) style on the vbox.
Anyway:

Code: Select all

screen default_moneyscreen():

    default iu = 100

    zorder 101
    frame:
        background None
        xalign 0.138 ypos 8
        vbox:
            text "{size=25}[iu: 5d]{/size}": # format pad
                color "#ebf5e5"
                xalign 1.0 # align the right edge of the text to the right side of the vbox
                xanchor 1.0
            textbutton "+10" action SetScreenVariable(name='iu', value=iu+10)
            textbutton "-10" action SetScreenVariable(name='iu', value=iu-10)
            textbutton "+1000" action SetScreenVariable(name='iu', value=iu+1000)
            textbutton "-1000" action SetScreenVariable(name='iu', value=iu-1000)
Probably best to set a width to the vbox and use xanchor and xalign.
Note: You can use format inside [] ( the : 5d means make the integer 5 characters wide, padded with spaces, :06d would zero pad to 6 digits). Probably more useful for zeros than spaces unless using monospaced fonts
Frameworks & Scriptlets:

Packmule
Newbie
Posts: 8
Joined: Fri Mar 02, 2018 11:37 am
Contact:

Re: Can't justify text in a screen with a hidden background to the right.

#3 Post by Packmule »

Thanks! While I couldn't right-justify it, your help at least allowed me to mostly center the digits and I think it'll look pretty good.

Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot]