Centering the Character Name inside the say_who_window

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
Peach
Regular
Posts: 41
Joined: Tue Apr 01, 2014 2:40 pm
Contact:

Centering the Character Name inside the say_who_window

#1 Post by Peach » Tue Apr 15, 2014 6:48 pm

Hellohello... It´s me again.

Apparently I can´t seem to get this to work, even though I´ve spent hours researching and trying around, changing my code a few million times XD

I´m using a two-window version of the say_window, with the say_who_window ontop of it and want to center the Character name within the say_who_window so that I can use a bigger background image for different sized Names without having to realign them every time.

Tried using xalign 0.5 as I´ve read countless of times, but no matter where I place it, it doesn´t move the Text to the right position :( From what I´ve tested it seems to me that the code interprets the say_who_window as double the size of the actual image I use. when I set xpos to 0.5 it draws the Character Name at the end of the image. When I use xalign 0.5 it... doesn´t look different than when I use no positioning at all.

in scripts.rpy:

Code: Select all

define l = Character('Lucienne', image='lucienne', show_two_window=True)
in screens.rpy:

Code: Select all

style say_label:
        xalign 0.5
        text_align 0.5

screen say:

    # Defaults for side_image and two_window
    default side_image = None
    default two_window = True

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

        # The one window variant.
        window:
            id "window"
            
            has vbox: 
                style "say_vbox"

            if who:
                text who id "who"

            text what id "what"

    else:
        
        fixed:       
            window:
                id "window"

                has vbox:
                    style "say_vbox"

                text what id "what"

            if who:
                window:
                    ypos 415 
                    style "say_who_window"
                    text who:
                        id "who"

    # If there's a side image, display it above the text.
    if side_image:
        add side_image
    else:
        add SideImage() xalign 0.0 yalign 1.0

    # Use the quick menu.
    # use quick_menu

in options.rpy:

Code: Select all

    style.window.background = "images/Textbox3.png"
    style.say_who_window.background = "images/Namebox.png"
    
    style.say_who_window.left_margin = 80
    style.say_who_window.top_padding = 5
    #style.window.right_margin = 0
    #style.window.top_margin = 0
    #style.window.bottom_margin = 0

    style.say_window.left_padding = 90
    style.say_window.right_padding = 90
    style.say_window.top_padding = 30
    style.say_window.bottom_padding = 30

    style.say_label.outlines = [(1, "#000", 0, 0)]
    style.say_label.color = "#fff"
    style.say_label.font = "VINERITC.ttf"
    style.say_label.bold = False
    style.say_label.size = 25
    style.say_dialogue.outlines = [(1, "#fff", 0, 0)]

    style.default.font = "HTOWERT.ttf"
    style.default.size = 22
    style.default.color = "#000000"
the style say_label was my latest attempt, but it didn´t produce anything new... I can add pictures of my experimenting on demand, right now I´m too tired after trying to beat this demon all day :S

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Centering the Character Name inside the say_who_window

#2 Post by PyTom » Tue Apr 15, 2014 11:25 pm

I think the problem here is that the who window is the wrong size. Even though you see the background as being the right size, the window is smaller (the background is escaping the window bounds, since it's not a Frame).

I haven't tested it, but you probably want something like:

Code: Select all

style window:
    background Frame("images/Textbox3.png", 0, 0)
        
style say_who_window:
    background Frame("images/Namebox.png", 0, 0)
    left_margin 80
    top_padding 5

style say_window:
    left_padding 90
    right_padding 90
    top_padding 30
    bottom_padding 30

    # This will make the window expand to fill the width of the screen.
    xfill True

style say_label:
    outlines [(1, "#000", 0, 0)]
    color "#fff"
    font "VINERITC.ttf"
    bold False
    size 25
    
    # This will center the text.
    xalign 0.5

style say_dialogue:
    outlines [(1, "#fff", 0, 0)]

style default:
    font "HTOWERT.ttf"
    size 22
    style.default.color "#000000"
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Peach
Regular
Posts: 41
Joined: Tue Apr 01, 2014 2:40 pm
Contact:

Re: Centering the Character Name inside the say_who_window

#3 Post by Peach » Wed Apr 16, 2014 4:58 am

I have no idea what you did, but thank you. Man! So I can use a prefitted image for Frames too, I didn´t know that.

Also for showing me this nifty, much cleaner way to organize styles!

henvu50
Veteran
Posts: 322
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: Centering the Character Name inside the say_who_window

#4 Post by henvu50 » Wed Aug 22, 2018 7:46 am

Does anyone know how to make the namebox font text bold and change it's font color?

Post Reply

Who is online

Users browsing this forum: Google [Bot], span4ev