Page 1 of 1

[SOLVED] Textbox stretching when adding custom namebox

Posted: Sun Mar 12, 2017 3:33 am
by Laniessa
Hello! I'm trying to add a custom namebox for 2 of the 4 textbox types I have in my game.
screenshot0003.png
This is the issue right now. I want the textbox to expand upwards based on the amount of content, and it does this just fine without the custom namebox:
screenshot0004.png
The current code in screens.rpy to try and add the namebox is this:

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:
        id "window"

        text what id "what"

        if who == "Cassidy":
            add "gui/Cassidyplate.png" xalign 2.01 yalign -0.11 
If I remove the last two lines, I can get the other screenshot.

Ideally, I want to get something like the textbox on the right in this mock:
ingame screen1.png
Any help is appreciated, thank you!

Re: Textbox stretching when trying to add custom namebox

Posted: Sun Mar 12, 2017 6:55 pm
by indoneko
How did you define Cassidy's character?

Re: Textbox stretching when trying to add custom namebox

Posted: Sun Mar 12, 2017 9:29 pm
by Laniessa

Code: Select all

define c = Character('Cassidy', window_background=Frame("gui/cassidybox_50.png", 50, 50),
    window_left_margin = 765,
    window_right_margin = 350,
    window_bottom_margin = 239,
    window_left_padding = 45,
    window_right_padding = 200,
    window_top_padding = 40,
    window_bottom_padding = 40,
    window_yminimum = 140,
    window_yalign = 1.0,
    what_xpos = 45,
    what_xalign = 0.0,
    what_xsize = 540
    #say_who_window_background = "gui/cassidyplate.png"
)
This is how I have it now, since the default textbox looks like this:
screenshot0008.png

Re: Textbox stretching when trying to add custom namebox

Posted: Mon Mar 13, 2017 8:57 am
by indoneko
Ok... here's the code. You might need to tweak the numbers to fit your own screen...

in Script.rpy :

Code: Select all

image faceplate:
    "gui/eileen_orb.png"  # enter your sprite's face pic here
    xalign 1.35
    yalign 0.55
    
define cas = Character('Cassidy', 
    window_background=Frame("gui/textbox1.png", 50, 50),
    window_left_margin = 365,
    window_right_margin = 100,
    window_bottom_margin = 100,
    window_top_margin = 100,
    window_left_padding = 45,
    window_right_padding = 200,
    window_top_padding = 30,
    window_bottom_padding = 30,
    window_yminimum = 140,
    window_yalign = 0.3,
    what_xpos = 40,
    what_xalign = 0.0,
    what_yalign = 0.5,
    what_xsize = 540,
    show_namebox_type="faceplate"
    )
in screens.rpy :

Code: Select all

screen say(who, what, namebox_type=None):
    style_prefix "say"
    window:
        id "window"
        window:
            text what id "what"
            id "nbox"    
            if namebox_type is not None:
                background namebox_type
Good luck~ :3

Re: Textbox stretching when trying to add custom namebox

Posted: Tue Mar 14, 2017 5:34 am
by Laniessa
I got it working!!! Thank you so much! I had to fiddle around with some things first so I'm going to explain then in case someone else has the same issues!

First, the screenshots now that I have them working now!! ^0^
screenshot0013.png
screenshot0012.png
larger font/text size
It works with different text sizes and fonts too!

The most important reason why it wasn't initially working for me is that I had a bunch of styling on my 'window', which was causing issues like, uh, this:
screenshot0016.png
So I went and found them in my screens.rpy and commented them all out:

Code: Select all

#style window:
    #xalign 0.5
    #xfill True
    #yalign gui.textbox_yalign
    #ysize gui.textbox_height
    #left_margin 561
    #right_margin 561
    #bottom_margin 239
    #left_padding 130
    #bottom_padding 40
    #right_padding 130
    #top_padding 40
    #yminimum 140
    #background Frame("gui/narration_50.png", 50, 50)
I can probably get rid of them now, but I'm keeping the numbers so I can code the narration box later.

After that, I just had to position the namebox! I decided to use xpos/ypos for this because that's easier for me to comprehend, so I got:

Code: Select all

image cassidyname:
    "gui/cassidyplate.png"
    xpos 568
    ypos -55
And now it's working perfectly!!! Thank you so much <3