Is there a way to have a "flush" alignment for text?

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.
Message
Author
User avatar
asatiir
Regular
Posts: 86
Joined: Tue Oct 01, 2013 6:04 pm
Completed: Within the Walls (Twine)
Projects: Roses Will Rise
Organization: Asatiir's Tales
Skype: asatiir
itch: asatiir
Location: Dubai, UAE
Contact:

Is there a way to have a "flush" alignment for text?

#1 Post by asatiir »

I've been searching for this for a few hours today and I can't seem to get the right term for it.
There are scenes in my game that involve reading pieces of text off paper and books, I wanted to align the text in a way where the text is centered on the screen but aligned to the left, mimicking the format of a book.

Example:

Image

is there a possible way to do this? I already got the text in the center of the screen.
Image
Image

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Is there a way to have a "flush" alignment for text?

#2 Post by Elmiwisa »

Then that means the text is still aligned left, just having offset padding on both side.
Put the textbox in a bigger container (like a window) and set the xoffset xpadding of the container; then set text_align of the textbox to the left.
edit: opps wrong property name
Last edited by Elmiwisa on Tue Oct 29, 2013 5:34 pm, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Is there a way to have a "flush" alignment for text?

#3 Post by PyTom »

Actually, you don't even need to do that. Just set text_align 0.0 xalign 0.5 and you're set.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
asatiir
Regular
Posts: 86
Joined: Tue Oct 01, 2013 6:04 pm
Completed: Within the Walls (Twine)
Projects: Roses Will Rise
Organization: Asatiir's Tales
Skype: asatiir
itch: asatiir
Location: Dubai, UAE
Contact:

Re: Is there a way to have a "flush" alignment for text?

#4 Post by asatiir »

I am doing that, but is there a way to have the text be aligned to the right left (whoops) while being on the center of the screen?
Last edited by asatiir on Tue Oct 29, 2013 4:45 pm, edited 2 times in total.
Image
Image

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Is there a way to have a "flush" alignment for text?

#5 Post by trooper6 »

how you want the text aligned in controlled by the text_align statement. If you want it aligned left, you make it text_align 0.0, if you want it aligned right, you make it text_align 1.0. Or anything in between.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Is there a way to have a "flush" alignment for text?

#6 Post by Elmiwisa »

Eh I think PyTom's solution will do what you described, literally to the letter. Setting xalign 0.5 will indeed make your text to be at the center, and text_align 0.0 will indeed make your text left aligned.
But I think that's not what you are actually asking for. I think what you're asking for is to make the text aligned, but have equal empty space on left and right side. Hence the method I described above. Oh and I fixed it, it should be xpadding not xoffset.

User avatar
asatiir
Regular
Posts: 86
Joined: Tue Oct 01, 2013 6:04 pm
Completed: Within the Walls (Twine)
Projects: Roses Will Rise
Organization: Asatiir's Tales
Skype: asatiir
itch: asatiir
Location: Dubai, UAE
Contact:

Re: Is there a way to have a "flush" alignment for text?

#7 Post by asatiir »

Following some of your solutions, this is what I came up with:

Code: Select all

$ reading = Character(None,
                            what_size=35,
                            what_outlines=[(3, "#000000", 2, 2), (3, "#000000", 0, 0)],
                            what_layout="subtitle",
                            what_xalign=0.5,
                            what_text_align=0,
                            window_background=None,
                            window_yminimum=0,
                            window_xfill=True,
                            window_xalign=0.5)
Result:
Image

Is there a way to place the text here?
Image
Image
Image

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Is there a way to have a "flush" alignment for text?

#8 Post by trooper6 »

Maybe you want NVL mode for reader?

http://www.renpy.org/doc/html/nvl_mode.html
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
asatiir
Regular
Posts: 86
Joined: Tue Oct 01, 2013 6:04 pm
Completed: Within the Walls (Twine)
Projects: Roses Will Rise
Organization: Asatiir's Tales
Skype: asatiir
itch: asatiir
Location: Dubai, UAE
Contact:

Re: Is there a way to have a "flush" alignment for text?

#9 Post by asatiir »

It seemed similar to what I have in mind, I'll try it out in a bit, thank you!
Image
Image

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Is there a way to have a "flush" alignment for text?

#10 Post by Elmiwisa »

If you just want that happen in a few special instance, which I think is what you are trying to do, I think my method would be better. It's a more general method that work everywhere. The reason why it did not work when you try is because well, the say statement text box is already set to display text at the bottom of the screen by default, which you did not change. You should have show a Text instead, perhaps with a screen.
Here is an example of using screen:

Code: Select all

screen textbook:
    frame:
        style_group "textbook"
        text content
init -2 python:
    style.textbook_frame.background="#ffffff" #whatever background you want, perhaps something that look like a book page
    style.textbook_frame.align=(0.5,0.0)
    style.textbook_frame.xpadding=200 #size of empty space on each side
    style.textbook_text.text_align=0.0 #left aligned
    style.textbook_text.color="#000000"
    #more customization...
Then to display those you do something like:

Code: Select all

    show screen textbook(content="HWÆT, WE GAR-DEna in geardagum, þeodcyninga þrym gefrunon,hu ða æþelingas ellen fremedon!")
    "You found a page that appeared to be Beowulf's."
    hide screen textbook

User avatar
asatiir
Regular
Posts: 86
Joined: Tue Oct 01, 2013 6:04 pm
Completed: Within the Walls (Twine)
Projects: Roses Will Rise
Organization: Asatiir's Tales
Skype: asatiir
itch: asatiir
Location: Dubai, UAE
Contact:

Re: Is there a way to have a "flush" alignment for text?

#11 Post by asatiir »

Elmiwisa: yes it is for certain instances, I tried your method and this is the error I got.

Code: Select all

While running game code:
  File "game/withinthewalls1.rpy", line 354, in script
  File "renpy/common/000statements.rpy", line 510, in python
SyntaxError: EOL while scanning string literal (game/withinthewalls1.rpy, line 354)
Image
Image

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Is there a way to have a "flush" alignment for text?

#12 Post by Elmiwisa »

Eh, I'm guessing my example is a bit problematic, maybe your machine can't read these character. Just replace HWÆT, WE GAR-DEna in geardagum, þeodcyninga þrym gefrunon,hu ða æþelingas ellen fremedon! with whatever you want.

User avatar
asatiir
Regular
Posts: 86
Joined: Tue Oct 01, 2013 6:04 pm
Completed: Within the Walls (Twine)
Projects: Roses Will Rise
Organization: Asatiir's Tales
Skype: asatiir
itch: asatiir
Location: Dubai, UAE
Contact:

Re: Is there a way to have a "flush" alignment for text?

#13 Post by asatiir »

I used my own text instead of the example you gave, actually.
Image
Image

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Is there a way to have a "flush" alignment for text?

#14 Post by Elmiwisa »

In that case, it's your text that cause problem. This is probably a good time to mention that Ren'Py don't consistently handle multi-line string well, and people have had trouble with that before. I'm guessing that's the cause of your problem. Instead of a new line, use "\n". For example:

Code: Select all

    show screen textbook(content="Line 1\nLine 2\nLine 3")
Oh and there is another way too that don't need "\n":

Code: Select all

    show screen textbook(content=u"""Line1
Line 2
Line 3""")
Basically, open the quote using the u""" and end using """ and also make sure that starting from 2nd line you indent all the way to the left otherwise you will have some extra space in your text.

User avatar
asatiir
Regular
Posts: 86
Joined: Tue Oct 01, 2013 6:04 pm
Completed: Within the Walls (Twine)
Projects: Roses Will Rise
Organization: Asatiir's Tales
Skype: asatiir
itch: asatiir
Location: Dubai, UAE
Contact:

Re: Is there a way to have a "flush" alignment for text?

#15 Post by asatiir »

Maybe that's why! I've been using {p}{/p} to make new lines! will try it now.


Edit: Okay, got it to work, but it didn't come out the way I had in mind, not completely anyway. I'll see if I can adjust it through the settings, thanks!
Image
Image

Post Reply

Who is online

Users browsing this forum: Bing [Bot]