Say "who" text centered?

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
vollschauer
Veteran
Posts: 231
Joined: Sun Oct 11, 2015 9:38 am
Github: vollschauer
Contact:

Say "who" text centered?

#1 Post by vollschauer »

I have searched for ages or maybe it felt just that long, but I couldn't find the answer how to center the text in my say "who" box when using "show_two_window=True" for my characters and a background image.

The image is 180x47 pixel and I want the text/name vertical/horizontal-centered in that box ... how?

Code: Select all

    style.say_who_window.background = "gui/name_area.png" 
    style.say_who_window.xpos = 10
    style.say_who_window.ypos = 74
Also if configure the narrator with "show_two_window=False" my dialog text is not in the correct position :(
This might be easy to solve but I don't get it right now ...


User avatar
vollschauer
Veteran
Posts: 231
Joined: Sun Oct 11, 2015 9:38 am
Github: vollschauer
Contact:

Re: Say "who" text centered?

#3 Post by vollschauer »

Yes, I had a look at this already...and it works pretty well for the "say_dialog".
Unfortunately I wasn't able to apply this to the "say_label" :/

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Say "who" text centered?

#4 Post by Donmai »

Hi, vollschauer. If you're using that styling code, just add

Code: Select all

style say_label is say_dialogue
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
vollschauer
Veteran
Posts: 231
Joined: Sun Oct 11, 2015 9:38 am
Github: vollschauer
Contact:

Re: Say "who" text centered?

#5 Post by vollschauer »

Ok I got it working now and hopefully it's correct and that I understand gui customizing a bit more :D

I made several mistakes:

1. I needed to set the left/right/top/bottom_paddings (i use y/xpadding)
2. to see whats going on it was better to remove the background to see the results
3. I forgot to set the propper x/yminimum plus adding the margins values from the message box...

anyway I was wondering is there some recommendation about the coding style? Should I put everything in the options.rpy:

Code: Select all

    #########################################
    ## These settings let you customize the window containing the
    ## dialogue and narration, by replacing it with an image.

    ## The background of the window. In a Frame, the two numbers
    ## are the size of the left/right and top/bottom borders,
    ## respectively.
    ##
    style.window.background = "gui/message.png" 

    ## Margin is space surrounding the window, where the background is not drawn.
    style.window.left_margin = 12
    style.window.right_margin = 12
    style.window.top_margin = 0
    style.window.bottom_margin = 5

    ## Padding is space inside the window, where the background is drawn.
    style.window.left_padding = 30
    style.window.right_padding = 150
    style.window.top_padding = 19
    style.window.bottom_padding = 5

    ## Adds a shadow one pixel to the right and one pixel down
    style.say_dialogue.drop_shadow = [(2, 3)]

    ## This is the minimum height of the window, including the margins and padding.
    style.window.yminimum = 143 # 138 (hight pixel) + 5 (bottom_margin)

    ## Name box for the two window variant
    style.say_who_window.background = "gui/name.png" #180x47 pixel
    style.say_who_window.xpos = 10 
    style.say_who_window.ypos = 57 
    style.say_who_window.xpadding = 0
    style.say_who_window.ypadding = 0

    style.say_who_window.xminimum = 204 # 180 (width image pixel) + 12 (left_margin) + 12 (right_margin) 
    style.say_who_window.yminimum = 52 # 47 (hight image pixel) + (5 bottom_margin)

    ## Center the text
    style.say_label.xalign = 0.5
    style.say_label.yalign = 0.5

    ## Adds a shadow one pixel to the right and one pixel down
    style.say_label.drop_shadow = [(2, 3)]

    ## Unbold Name
    style.say_label.bold = False
Or is it better to put it in the screens.pry just below "screen say" ?

Code: Select all

init -2:
    style window:
        background "gui/message.png"
        left_margin 12
        right_margin 12
        top_margin 0
        bottom_margin 5
        left_padding 30
        right_padding 150
        top_padding 19
        bottom_padding 5
        yminimum 143 # 138 (hight pixel) + 5 (bottom_margin)

    style say_who_window:
        background "gui/name.png"
        xpos 10
        ypos 57
        xpadding 0
        ypadding 0
        xminimum 204 # 180 (width pixel) + 12 (left_margin) + 12 (right_margin)
        yminimum 52 # 47 (hight pixel) + (5 bottom_margin)
        bold False

    style say_dialogue:
        drop_shadow [(2, 3)]

    style say_label:
        xalign 0.5 # Center the text
        yalign 0.5 # Center the text
        #text_align 0.5
        drop_shadow [(2, 3)]
        bold False
Last edited by vollschauer on Sun Nov 29, 2015 2:14 pm, edited 1 time in total.

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Say "who" text centered?

#6 Post by Donmai »

I don't know if there's a "right" method, but I tend to use the second option (put window specific styles on the respective screen definitions, so it's easier to locate and edit them, if needed).
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], decocloud