Two text windows displaying at the same time

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
unmei
Newbie
Posts: 3
Joined: Fri Apr 27, 2012 11:47 pm
Contact:

Two text windows displaying at the same time

#1 Post by unmei »

From reading this and this, I've gathered that having two text boxes, side by side, displaying text at the same time, is not doable in the current build of Ren'Py (at least not with the instructions given in the first thread), since the "interact=True/False" bit doesn't seem to be working properly (and I have no clue how to use the screen function to hack around it, as mentioned in the second thread, because I'm very new to this). This being the case, I've settled for having to advance the two frames one after the other. However, I've found two problems with this as well:

1) When one of the text boxes isn't in use, it disappears.
This is nice for all instances outside of the scene in question, but this is a mechanic that is used pretty heavily in this one scene, and it's a bit jarring to have text boxes popping in and out for several minutes.

2) The show_two_window=True code works fine for the left box, but the name window for the right box pops up in the same spot as the one for the left box.
I can work around this by simply removing the code and having it display the character names inside the text box, but I prefer having the two windows for aesthetic reasons.

A small sample of my code for reference:

Code: Select all

init :
    $ narr_left = Character(None, window_right_margin=400, show_two_window=True, show_who_window_properties={ "xpos" : 0.0  })
    $ narr_right = Character(None, window_left_margin=400, show_two_window=True, show_who_window_properties={ "xpos" : 0.5  })
    $ A_Left = Character("A", window_right_margin=400, show_two_window=True, show_who_window_properties={ "xpos": 0.0 })
    $ B_Right = Character("B", window_left_margin=400, show_two_window=True, show_who_window_properties={ "xpos":0.5 })


label start:
    narr_left "blahblahblah"
    narr_right "blahblah"

    A_Left "Huh?"
    B_Right "Eh?"

    return

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Two text windows displaying at the same time

#2 Post by Alex »

From second link
http://lemmasoft.renai.us/forums/viewto ... 23#p188971

So, it could look like

Code: Select all

screen left_speaker:
    default x = ""
    default new_screen = False
    
    frame:
        background None
        xpos 0.0 yalign 1.0
        yminimum 200
        
        vbox:
            text "Left_char" color "#c8ffc8"
            text x
        
    on "show" action If (new_screen, Hide("right_speaker"), Return("1") )
    on "replace" action If (new_screen, Hide("right_speaker"), Return("1") )


         
screen right_speaker:
    default x = ""
    default new_screen = False
    
    frame:
        background None
        xpos 0.5 yalign 1.0
        yminimum 200
    
        vbox:
            text "Right_char" size 25
            text x
    
    on "show" action If (new_screen, Hide("left_speaker"), Return("1") )
    on "replace" action If (new_screen, Hide("left_speaker"), Return("1") )

label start:  
    scene black
    show screen left_speaker (x="Hi!")
    $ renpy.pause()
    show screen right_speaker(x="Heloooo!")
    $ renpy.pause()
    show screen right_speaker(x="Howdy?", new_screen=True)
    $ renpy.pause()
    show screen left_speaker(x="Ok!")
    $ renpy.pause()
    hide screen left_speaker
    hide screen right_speaker
Not elegant at all, but seems to work.

As for changing character's name box position - it is possible to add a bunch of additional variables into say screen and set them while character declaration.
in "screens.rpy"

Code: Select all

screen say:
... ... ...
    default who_xalign = 0.0

    # Decide if we want to use the one-window or two-window varaint.
    if not two_window:
        
... ... ...

    else:

        # The two window variant.
        vbox:
            style "say_two_window_vbox"

            if who:            
                window:
                    style "say_who_window"
                    xalign who_xalign

... ... ...
in "script.rpy"

Code: Select all

define e = Character('Eileen_left', color="#c8ffc8", window_right_margin=400,show_two_window=True, show_who_xalign= 0.0)       # the name of variable is prefixed with show_
define ee = Character('Eileen_right', color="#c8ffc8", window_left_margin=420,show_two_window=True, show_who_xalign= 0.5)

unmei
Newbie
Posts: 3
Joined: Fri Apr 27, 2012 11:47 pm
Contact:

Re: Two text windows displaying at the same time

#3 Post by unmei »

Thanks Alex! That was really helpful. Still not exactly what I want, but much better than what I had scraped together.

As a note, though, I changed the frame for the left window to:

Code: Select all

screen left_speaker:
    default x = ""
    default new_screen = False
    
    frame:
        background None
        xpos 0.0 yalign 1.0
        yminimum 200
        xmaximum 400
as otherwise, the text from the left frame ends up running beneath the right frame.

Also, for my purposes, I used a total of four screen functions to account for the two narrated sections and the two spoken sections of the scene. This is a bit cumbersome looking, so is there a more streamlined way to do this?

Post Reply

Who is online

Users browsing this forum: Google [Bot]