How to display long texts without breaking renpy? (closed)

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
Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

How to display long texts without breaking renpy? (closed)

#1 Post by Ryue »

With normal and nvl mode I've time and again run into the trouble that either long texts or multiline texts break the screen (aka overflowing the screen where the text is in).

As example here:
Image

The code is as simple as this:

Code: Select all

## The script of the game goes in this file.

## Declare characters used by this game. The color argument colorizes the name
## of the character.

define e = Character('Eileen')


## The game starts here.

label start:

    ## Show a background. This uses a placeholder by default, but you can add a
    ## file (named either "bg room.png" or "bg room.jpg") to the images
    ## directory to show it.

    scene bg room

    ## This shows a character sprite. A placeholder is used, but you can replace
    ## it by adding a file named "eileen happy.png" to the images directory.

    show eileen happy

    ## These display lines of dialogue.

    "Hello, world. this is a multiline test. so please ignore it for the time being. thank you very very very much! Hello, world. this is a multiline test. so please ignore it for the time being. thank you very very very much! Hello, world. this is a multiline test. so please ignore it for the time being. thank you very very very much! Hello, world. this is a multiline test. so please ignore it for the time being. thank you very very very much!"

    e "You've created a new Ren'Py game."

    e "Once you add a story, pictures, and music, you can release it to the world!"

    ## This ends the game.

    return
Now In the past I've dealt with it by using a method that splits the say into multiple says, ... BUT it broke lint (thus I couldn't say any longer how many words I had, nor could I extract my dialogue). And there was fear from other programmers that there are more side effects than only that.

So my question here is: Is there any method to handle this without breaking renpy? Or do I really have to stick to 1 line says and narrations ?
Last edited by Ryue on Tue Nov 22, 2016 11:21 am, edited 1 time in total.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to display long texts without breaking renpy?

#2 Post by xela »

Ryue wrote:So my question here is: Is there any method to handle this without breaking renpy? Or do I really have to stick to 1 line says and narrations ?
If you feel that it's takes too much effort to test if really long text that you want to put into your game fits into your default window:

1) Style the window to expand vertically on longer text.

2) Figure out the max size for the text that can fit your default window and check if the rendered size of the incoming text fits those parameters (loading "what" in the say screen into appropriately styled Text class and get it's size parameter). If text does not fit, do a for loop reducing it's size and retest on every -1 decrease. Those calculations should be lightning fast and player would never notice.

========================================>>>
But honestly... best way is to just test whenever you're typing a long text. We've been working on a freelance open sourced project for years with a lot of people helping out with code, texts, resources and content, this issue never came up once, how difficult can it really be to test any line that confused you by it's size by placing it right after label start in your project? Feels like a natural, safe and intuitive solution.

NVL mode is a bit more confusing, maybe you can shove it into viewport or something?
Like what we're doing? Support us at:
Image

Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

Re: How to display long texts without breaking renpy?

#3 Post by Ryue »

@Xela
My problem is that I need to display narration text and also multiple says on the same screen (so that the player can read through both of them). As I'm using mostly text.
With normal mode (adv) the vanilla does not support that. NVL does support that but breaks as soon as you get a second line for 1 single say statement.

To comment on your posts:
1. How so? Didn't see anything so far that allows that (I think....hopefully not in one of the tests that failed for nvl)
2. That was my original attempt....it sadly failed utterly because you also need to take the printed text size into acount (as an "i" is not always an i). That was the first hurdle. The second was ..... you have to implement a whole block word algorithm....as else it ends this way:

"this is a long"
test that
fails utterly
"
You see how bad the words are "wrapped" above? that is what I had as a result back then :/

Your third solution: That is a bit problematic as I would have to give the editor fully formated text (as I'm editing after tests to reduce rewrite costs).......and then he edits and......my whole text needs to be rewritten thanks to 3 words changed that comepletely throw the on screen format I had out of the window.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to display long texts without breaking renpy?

#4 Post by xela »

1) It's the simplest styling where you set minimum but not maximum for the window, unless we're talking about different things.

2) I do not understand what you're talking about here either, however you display the text, you should always be able to get the size it will be rendered at. What the text looks like should not matter. I didn't suggest you count letters in it, I suggested to load it into Text class and try getting it's size. If you style it right, it should work but it will require a bit of coding effort.
Like what we're doing? Support us at:
Image

Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

Re: How to display long texts without breaking renpy?

#5 Post by Ryue »

xela wrote:1) It's the simplest styling where you set minimum but not maximum for the window, unless we're talking about different things.

2) I do not understand what you're talking about here either, however you display the text, you should always be able to get the size it will be rendered at. What the text looks like should not matter. I didn't suggest you count letters in it, I suggested to load it into Text class and try getting it's size. If you style it right, it should work but it will require a bit of coding effort.
1.) and how do you do that for the default nvl window (defined in options.rpy)

Code: Select all

screen nvl(dialogue, items=None):

    window:
        style "nvl_window"

        has vbox:
            spacing gui.nvl_spacing

        ## Displays dialogue in either a vpgrid or the vbox.
        if gui.nvl_height:

            vpgrid:
                cols 1
                yinitial 1.0

                use nvl_dialogue(dialogue)

        else:

            use nvl_dialogue(dialogue)

        ## Displays the menu, if given. The menu may be displayed incorrectly if
        ## config.narrator_menu is set to True, as it is above.
        for i in items:

            textbutton i.caption:
                action i.action
                style "nvl_button"

    add SideImage() xalign 0.0 yalign 1.0
2.) I talked about that variant with someone a few months ago. From what I heard you should never try to do that in nvl (it seems it will end up in a few hundred lines of code there from what I gathered)

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

Re: How to display long texts without breaking renpy?

#6 Post by philat »

I guess my first question is, why are you even trying to put blocks and blocks of text in a visual novel? Part of the point of visual novels is, well, the visuals. Walls of text detract from the visuals and as an added bonus usually look terrible on a screen anyway -- I would imagine you would be better served from a delivery standpoint by breaking it up into a style more suited for the medium. It doesn't have to be ONE line, but it really shouldn't be seven either.

For your question, if you don't mind the textbox size changing, wouldn't the easiest solution just be to have the ADV window be resizable? xela mentioned this with yminimum -- in the new default gui, it's set to ysize (which is equivalent to setting both yminimum and ymaximum to the same value), but if you change that to yminimum, the window will scale if there is more text in it.

Code: Select all

style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    # ysize gui.textbox_height <- change this
    yminimum gui.textbox_height

    background Image("gui/textbox.png", xalign=0.5, yalign=1.0) # also change this to a Frame to make the textbox image scale

Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

Re: How to display long texts without breaking renpy?

#7 Post by Ryue »

Will try it in a bit. As to your question. My novel will have no sprites so it's more a text novel with a few VHS in between than anything else

Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

Re: How to display long texts without breaking renpy?

#8 Post by Ryue »

philat wrote:I guess my first question is, why are you even trying to put blocks and blocks of text in a visual novel? Part of the point of visual novels is, well, the visuals. Walls of text detract from the visuals and as an added bonus usually look terrible on a screen anyway -- I would imagine you would be better served from a delivery standpoint by breaking it up into a style more suited for the medium. It doesn't have to be ONE line, but it really shouldn't be seven either.

For your question, if you don't mind the textbox size changing, wouldn't the easiest solution just be to have the ADV window be resizable? xela mentioned this with yminimum -- in the new default gui, it's set to ysize (which is equivalent to setting both yminimum and ymaximum to the same value), but if you change that to yminimum, the window will scale if there is more text in it.

Code: Select all

style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    # ysize gui.textbox_height <- change this
    yminimum gui.textbox_height

    background Image("gui/textbox.png", xalign=0.5, yalign=1.0) # also change this to a Frame to make the textbox image scale
Ah just saw you were talking about ADV mode. There the problem does not occur very often (almost not at all) as in adv mode you only have 1 "say" at a time on the screen :/

Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

Re: How to display long texts without breaking renpy?

#9 Post by Ryue »

Ok I think we can close this. As I just found out while trying to test a few things.....the CURRENT version of renpy....I ran into the problem originally 2-3 months ago.... has made some changes to the NVL mode screen code and that has eliminated the multiline problem (with 2-3 line texts) :)

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ocelot