[SOLVED] Textbox stretching when adding custom namebox

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
Laniessa
Veteran
Posts: 251
Joined: Wed Feb 09, 2011 11:10 am
Completed: CDC, Cerulean, WBW, Helena's Flowers
Projects: Chomp Chomp, WaV
Tumblr: adirosa
Deviantart: adirosa
Contact:

[SOLVED] Textbox stretching when adding custom namebox

#1 Post 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!
Last edited by Laniessa on Tue Mar 14, 2017 5:36 am, edited 1 time in total.

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: Textbox stretching when trying to add custom namebox

#2 Post by indoneko »

How did you define Cassidy's character?
My avatar is courtesy of Mellanthe

User avatar
Laniessa
Veteran
Posts: 251
Joined: Wed Feb 09, 2011 11:10 am
Completed: CDC, Cerulean, WBW, Helena's Flowers
Projects: Chomp Chomp, WaV
Tumblr: adirosa
Deviantart: adirosa
Contact:

Re: Textbox stretching when trying to add custom namebox

#3 Post 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

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: Textbox stretching when trying to add custom namebox

#4 Post 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
Attachments
autofit textbox, complete with avatar photo
autofit textbox, complete with avatar photo
My avatar is courtesy of Mellanthe

User avatar
Laniessa
Veteran
Posts: 251
Joined: Wed Feb 09, 2011 11:10 am
Completed: CDC, Cerulean, WBW, Helena's Flowers
Projects: Chomp Chomp, WaV
Tumblr: adirosa
Deviantart: adirosa
Contact:

Re: Textbox stretching when trying to add custom namebox

#5 Post 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
larger font/text size
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

Post Reply

Who is online

Users browsing this forum: Ocelot, Semrush [Bot]