Character-specific Maximum Width for Textbox?

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
noeinan
Eileen-Class Veteran
Posts: 1050
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: daikiraikimi
Github: daikiraikimi
Location: Washington State, USA
Contact:

Character-specific Maximum Width for Textbox?

#1 Post by noeinan » Thu Nov 09, 2017 7:58 pm

I'm using different textbox images for dialogue and thoughts compared to the narrator. However, my dialogue and thought boxes are shorter than the narration, which takes up the whole screen. Is there a way to set a different maximum textbox length in a defined "character" so that I don't have text running out of the lines? (Tried searching around for this, and all I found was the universal gui.dialogue_width variable.)

Code: Select all

define dialogue = Character(
    None,

    window_background = "gui/dialoguebox.png",

    who_font = "PoiretOne-Regular.ttf",
    who_outlines = [(3, "#FF6C03", 0, 0)],
    who_color="#FFD200",
    who_bold = True,
    who_xalign=0.5,
    who_textalign=0.5,

    what_color = "#000000",
    what_xalign=0.5,
    what_textalign=0.5,
    what_layout='subtitle')

define thoughts = Character(
    None,

    window_background = "gui/thoughtbox.png",

    who_font = "PoiretOne-Regular.ttf",
    who_outlines = [(3, "#FF6C03", 0, 0)],
    who_color="#FFD200",
    who_bold = True,
    who_xalign=0.5,
    who_textalign=0.5,

    what_color = "#FFFFFF",
    what_xalign=0.5,
    what_textalign=0.5,
    what_layout='subtitle')

define narrator = Character(None, what_color = "#000000", what_outlines=[( 0, "#A3A3A3", 2, 2 )])
Last edited by noeinan on Thu Nov 09, 2017 9:31 pm, edited 2 times in total.
Image

Image
Image

philat
Eileen-Class Veteran
Posts: 1245
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Character-specific Maximum Width for Textbox?

#2 Post by philat » Thu Nov 09, 2017 9:21 pm

You can add what_xmaximum to a character definition.

User avatar
noeinan
Eileen-Class Veteran
Posts: 1050
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: daikiraikimi
Github: daikiraikimi
Location: Washington State, USA
Contact:

Re: Character-specific Maximum Width for Textbox?

#3 Post by noeinan » Thu Nov 09, 2017 9:24 pm

That works great, thanks! I wasn't having much success googling it on my own. ><
Image

Image
Image

User avatar
noeinan
Eileen-Class Veteran
Posts: 1050
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: daikiraikimi
Github: daikiraikimi
Location: Washington State, USA
Contact:

Re: Character-specific Maximum Width for Textbox?

#4 Post by noeinan » Thu Nov 09, 2017 9:35 pm

Oh, I thought it was working, but after running a few more tests it seems that is only sometimes the case. For longer sentences, it breaks them up properly, but for sentences that are just a little bit too long it runs them outside the textbox. I tried removing "subtitle" (justification) from my code but it didn't fix the issue. If I add more junk text to the end of the line, suddenly it works again, so it seems to have something to do with the text length?

Image

Image

Code: Select all

define dialogue = Character(
    None,

    window_background = "gui/dialoguebox.png",

    who_font = "PoiretOne-Regular.ttf",
    who_outlines = [(3, "#FF6C03", 0, 0)],
    who_color="#FFD200",
    who_bold = True,
    who_xalign=0.5,
    who_textalign=0.5,

    what_color = "#000000",
    what_xmaximum = 950,
    what_xalign=0.5,
    what_textalign=0.5,
    what_layout='subtitle')
Image

Image
Image

User avatar
PyTom
Ren'Py Creator
Posts: 14850
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: Character-specific Maximum Width for Textbox?

#5 Post by PyTom » Sat Nov 11, 2017 12:34 pm

It's hard to tell since the images you posted are scaled down. Is the text on the bottom wider than 950 pixels? Since that really shouldn't be possible in Ren'Py - if it is, it's a bug. (The one exception is when Ren'Py can't break the text, as if it's a long single word.)
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
Imperf3kt
Eileen-Class Veteran
Posts: 1045
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Character-specific Maximum Width for Textbox?

#6 Post by Imperf3kt » Sun Nov 12, 2017 1:03 am

If dialogue is centered and you get tyat effect with Justified and the overlapping line when not using justified, I'd be inclined to check the width of the say window and make sure it is the same size as / smaller than the window background image.
Image

Warning: May contain trace amounts of gratuitous plot.

User avatar
noeinan
Eileen-Class Veteran
Posts: 1050
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: daikiraikimi
Github: daikiraikimi
Location: Washington State, USA
Contact:

Re: Character-specific Maximum Width for Textbox?

#7 Post by noeinan » Sun Nov 12, 2017 10:23 pm

PyTom wrote:
Sat Nov 11, 2017 12:34 pm
It's hard to tell since the images you posted are scaled down. Is the text on the bottom wider than 950 pixels? Since that really shouldn't be possible in Ren'Py - if it is, it's a bug. (The one exception is when Ren'Py can't break the text, as if it's a long single word.)
Yeah, it's wider than 950px. Just pulled it up in my art program to check. Strangely, even some of the ones that are working are wider than 950px... I also ran some tests, and if I change 950 to, say, 900, then it *drastically* reduces the width of dialogue, down to the 500 pixel range. Not sure what is going on here, but it seems to be calculating width using some kind of ratio?

Image
Imperf3kt wrote:
Sun Nov 12, 2017 1:03 am
If dialogue is centered and you get tyat effect with Justified and the overlapping line when not using justified, I'd be inclined to check the width of the say window and make sure it is the same size as / smaller than the window background image.
Well, I actually am trying to make it so that I have different textboxes for when characters are speaking vs the narration. The narrator is supposed to take up more space, and then the dialogue boxes are shorter, and thus need to have the text cut shorter.
Image

Image
Image

User avatar
PyTom
Ren'Py Creator
Posts: 14850
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: Character-specific Maximum Width for Textbox?

#8 Post by PyTom » Thu Nov 16, 2017 11:34 pm

Can you put together a short example of this problem, please? It's kind of hard to figure it out without context. (For example, it's possible the window is being scaled before you take the screenshot.)
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
noeinan
Eileen-Class Veteran
Posts: 1050
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: daikiraikimi
Github: daikiraikimi
Location: Washington State, USA
Contact:

Re: Character-specific Maximum Width for Textbox?

#9 Post by noeinan » Sat Nov 18, 2017 12:19 am

PyTom wrote:
Thu Nov 16, 2017 11:34 pm
Can you put together a short example of this problem, please? It's kind of hard to figure it out without context. (For example, it's possible the window is being scaled before you take the screenshot.)
Sure, I went ahead and made a new game from scratch at 1280x720 resolution, then copied the code I am using to define characters, as well as a bit of the dialogue to help with testing. I'm seeing the same problem in the brand new game, and I've attached it below. (I wasn't 100% sure on what you meant by example, but I hope this is what you need. If not, let me know what I should do instead and I'll do that!)
Attachments
Xmaximum Test.zip
(998.17 KiB) Downloaded 3 times
Image

Image
Image

Post Reply

Who is online

Users browsing this forum: No registered users