Page 1 of 1

[SOLVED] Reposition text box temporarily?

Posted: Sun Sep 11, 2022 2:35 pm
by Semicolonkid
Hello! Simple question, but I've spent a few hours trying to wrap my head around the related answers I've seen and I'm just not getting it.

I'd like to temporarily have the text box display itself at the top of the screen instead of the bottom, and then move it back down again later.

In gui.rpy, there is the line:

Code: Select all

define gui.textbox_yalign = 1.0
If you set this equal to 0.0, the text box is put on top instead of on bottom. Perfect, this is exactly what I want! Except...you can't change this value back and forth at runtime.
I would like to keep the text box on the bottom most of the time, but display it on top every now and then.

Could anyone show me the simplest way to do this? Defining a character or style is fine, I'm just struggling to figure out the syntax for it. Thanks in advance!

Re: Reposition text box temporarily?

Posted: Sun Sep 11, 2022 2:47 pm
by laure44
Here's one simple way:

Code: Select all

default textbox_top = False

# in your say screen, find the window line and add the condition.

    window:
        id "window"
        if textbox_top:
            yalign 0.0

##
label start:
    "Bottom."
    $textbox_top = True
    "Top."
    $textbox_top = False
    "Bottom again."

Re: Reposition text box temporarily?

Posted: Sun Sep 11, 2022 2:56 pm
by Ocelot
There are few ways. Depending on how often you want to do this, you might define a character:
Styling Text and Windows. Keyword arguments beginning with who_, what_, and window_ have their prefix stripped, and are used to style the character name, the spoken text, and the window containing both, respectively.

For example, if a character is given the keyword argument who_color="#c8ffc8", the color of the character's name is changed, in this case to green. window_background="frame.png" sets the background of the window containing this character's dialogue.

Code: Select all

define on_top = Character(window_yalign=0.0)
You can create a function which will create characters based on other characters:

Code: Select all

init python:
    def on_top(char):
        return Character(kind=char, window_yalign=0.0)
# . . .
on_top(my_cool_char) "I am on top!"
You can pass argument to say statement itself:

Code: Select all

my_cool_char "I am on top!" (window_yalign=0.0)

Re: Reposition text box temporarily?

Posted: Sun Sep 11, 2022 3:01 pm
by Semicolonkid
Both of these are exactly what I was looking for!! Thank you both so much!

Re: Reposition text box temporarily?

Posted: Sun Sep 11, 2022 3:11 pm
by Semicolonkid
laure44 wrote: Sun Sep 11, 2022 2:47 pm Here's one simple way:

Code: Select all

default textbox_top = False

# in your say screen, find the window line and add the condition.

    window:
        id "window"
        if textbox_top:
            yalign 0.0

##
label start:
    "Bottom."
    $textbox_top = True
    "Top."
    $textbox_top = False
    "Bottom again."
Okay, I'm running into an issue with this solution, maybe you can clarify what I'm doing wrong.

I went into screens.rpy and found the style code for the dialogue box. Normally it's:

Code: Select all

style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height

    background Image("gui/textbox.png", xalign=0.5, yalign=1.0)
But instead, I changed it to this:

Code: Select all

style window:
    xalign 0.5
    xfill True
    if textbox_top:
        yalign 0.0
    else:
        yalign gui.textbox_yalign
    ysize gui.textbox_height

    background Image("gui/textbox.png", xalign=0.5, yalign=1.0)
(I've defined textbox_top elsewhere)
But when I run it, I get this error:
File "game/screens.rpy", line 543: end of line expected.
if textbox_top:


What am I missing here?

Re: Reposition text box temporarily?

Posted: Sun Sep 11, 2022 3:12 pm
by laure44
Semicolonkid wrote: Sun Sep 11, 2022 3:11 pm What am I missing here?
Pretty sure you can't use conditions in styles, which is why I used it in the say screen directly

Re: Reposition text box temporarily?

Posted: Sun Sep 11, 2022 3:18 pm
by Semicolonkid
laure44 wrote: Sun Sep 11, 2022 3:12 pm
Semicolonkid wrote: Sun Sep 11, 2022 3:11 pm What am I missing here?
Pretty sure you can't use conditions in styles, which is why I used it in the say screen directly
Ohh, I see! That's where I kept getting confused.

IT WORKS!! Thanks again so much!!