Customizing the 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
Rainvillain
Regular
Posts: 76
Joined: Thu Mar 05, 2015 11:27 am
Contact:

Customizing the namebox

#1 Post by Rainvillain »

Hello!

I'm having trouble parsing how to customize and then implementing a namebox (aka a small textbox with a character's name just above the general textbox).

Currently I'm using the default namebox, which I called on by adding the line "show_two_window=True" while defining my characters. That namebox is an identical, scaled down version of the regular textbox.

I want my namebox to be a different from my regular textbox (they are using two different PNG files and have different margins/padding etc. The problem is I don't know where in the script I should customize the namebox.

And then once I've customized that namebox, will I have to use something different than "show_two_window=True" while defining my characters to use it?

I'm still new to Ren'py and I didn't see the answer anywhere online so I thought I'd ask here. :)

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: Customizing the namebox

#2 Post by OokamiKasumi »

Rainvillain wrote: . . . I want my namebox to be a different from my regular textbox (they are using two different PNG files and have different margins/padding etc. The problem is I don't know where in the script I should customize the namebox.

And then once I've customized that namebox, will I have to use something different than "show_two_window=True" while defining my characters to use it?
To use a completely different namebox from the standard, go to options.rpy and directly under your Textbox entry--

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 = Frame("frame.png", 12, 12)

    ## Margin is space surrounding the window, where the background
    ## is not drawn.

    # style.window.left_margin = 6
    # style.window.right_margin = 6
    # style.window.top_margin = 6
    # style.window.bottom_margin = 6

    ## Padding is space inside the window, where the background is
    ## drawn.

    # style.window.left_padding = 6
    # style.window.right_padding = 6
    # style.window.top_padding = 6
    # style.window.bottom_padding = 6

    ## This is the minimum height of the window, including the margins
    ## and padding.

    # style.window.yminimum = 250
-- Add this, and adjust as needed.

Code: Select all

    ###############################################
    ## ---------- Name Box  ---------------------

    style say_label:
        # font "fo/N_E_B.TTF"    
        size 30
        # bold False
        drop_shadow [(1, 1)] 
        drop_shadow_color "#333333" # dk gray
        outlines [(1, "#000000", 1, 1)]  # black   


    ## ----- Frame (expandable) ------------------------
    style say_who_window:
        background Frame("YourNameBox.png", 0, 0)
    
    ## ---- No Frame (Not expandable) ---------------
        # background "YourNameBox.png"

        # margins ---------------------------------
        left_margin 0
        right_margin 0
        top_margin 0
        bottom_margin 0    

        # padding ---------------------------------
        left_padding 30
        right_padding 30
        top_padding 10
        bottom_padding 10

        yminimum 10
        xminimum 10
Make sure you keep the spacing EXACTLY as you see it.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
Rainvillain
Regular
Posts: 76
Joined: Thu Mar 05, 2015 11:27 am
Contact:

Re: Customizing the namebox

#3 Post by Rainvillain »

Hi there! Thanks a lot for the very specific help!
Right now I get the follow error when I try running the game after placing that piece of text in the right spot (with the right spacing) in options.rpy:

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/options.rpy", line 131: invalid syntax
style say_label:
^


Ren'Py Version: Ren'Py 6.18.3.761


Any suggestions? :?

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: Customizing the namebox

#4 Post by OokamiKasumi »

Rainvillain wrote:Hi there! Thanks a lot for the very specific help!
Right now I get the follow error when I try running the game after placing that piece of text in the right spot (with the right spacing) in options.rpy:

Code: Select all

File "game/options.rpy", line 131: invalid syntax
    style say_label:
First, swap the code around to see if style say_label: is the problem, like so:

Code: Select all

    ###############################################
    ## ---------- Name Box  ---------------------

    ## ----- Frame (expandable) ------------------------
    style say_who_window:
        background Frame("YourNameBox.png", 0, 0)
   
    ## ---- No Frame (Not expandable) ---------------
        # background "YourNameBox.png"

        # margins ---------------------------------
        left_margin 0
        right_margin 0
        top_margin 0
        bottom_margin 0   

        # padding ---------------------------------
        left_padding 30
        right_padding 30
        top_padding 10
        bottom_padding 10

        yminimum 10
        xminimum 10

    style say_label:
        # font "fo/N_E_B.TTF"   
        size 30
        # bold False
        drop_shadow [(1, 1)]
        drop_shadow_color "#333333" # dk gray
        outlines [(1, "#000000", 1, 1)]  # black   
The next thing you need to check is if the spacing Matches the section of code BEFORE it.
-- The spacing must Exactly Match the code before it and after it.

Another thing to check is the Style of code.
-- The code I gave you for the NameBox is in the current style, the one being used in screens.rpy. It should be compatible with the old style textbox code, but if there IS a compatibility issue, simply retro-fit the code. In other words, change the NameBox code to match the Old style of coding used for the textbox code.

Another thing you can do is move ALL the textbox code to a whole other tab; a whole different .rpy file and update the whole thing to the new style. Just so you know, this is what I do. Don't forget to ERASE all the textbox code on options.rpy once you do so, or there will be conflicts.

The textbox.rpy page from one of my template games:

Code: Select all

###############################################
##-------------- Textbox ----------------------

init -2:
    style say_dialogue:
        font "fo/BARR1.TTF"
        size 24
        # justify True #Don't use this unless you have already have 'justify' configured in options.rpy!

  ## ----- Dropshadow ----------------
    ## Adds a shadow one pixel to the right and one pixel down
        drop_shadow [(1, 1)] 
        drop_shadow_color "#333333" # dk gray
    style say_vbox:
        xfill True

    style window:
        ## Frame ------------------------
        background  Frame("ui/textbox.png", 0, 0)
        
        ## No Frame --------------------
        # background "ui/textbox.png"

        left_margin 0
        right_margin 0
        top_margin 0
        bottom_margin 55

        left_padding 260
        right_padding 260
        top_padding 50
        bottom_padding 30

        xminimum 1366
        yminimum 185 
    
    ###############################################
    ## ---------- Name Box  ---------------------

    style say_label:
        font "fo/N_E_B.TTF"    
        size 30
        # bold False
        drop_shadow [(1, 1)] 
        drop_shadow_color "#333333" # dk gray
        outlines [(1, "#000000", 1, 1)]  # black   


    ## ----- Frame (expandable) ------------------------
    style say_who_window:
        background Frame("ui/WhoBox.png", 0, 0)
    
    ## ---- No Frame (Not expandable) ---------------
        # background "ui/WhoBox.png"

        # margins ---------------------------------
        left_margin 280
        right_margin 0
        top_margin 0
        bottom_margin -10    

        # padding ---------------------------------
        left_padding 30
        right_padding 30
        top_padding 10
        bottom_padding 10

        yminimum 10
        xminimum 10
    
    ################################################
    # --------------NVL Box ----------------------------  

    # If you want a different Font for your NVL text. 
    style nvl_dialogue:
        font "fo/BARR1.TTF"
    
    # If you want a different Color for your NVL text. 
        # color "#ffffff"
    
    # If you want a different Size for your NVL text. 
        size 24
        justify True

  ## ----- Dropshadow ----------------
    ## Adds a shadow one pixel to the right and one pixel down
        drop_shadow [(1, 1)] 
        drop_shadow_color "#333333" # dk gray

    ## ----------- Framed NVL box ------------------------
    style nvl_window:
        background Frame("ui/NVLbox.png", 0, 0)  
     
    ## ---------- No Frame Nvl Box--------------------
        # background "ui/NVLbox.png"    
     
        # margins ---------------------------------
        top_margin 0
        bottom_margin 13
        left_margin 0
        right_margin 20

        # padding ---------------------------------
        top_padding 140
        bottom_padding 0
        left_padding 910
        right_padding 45

        # menu nvl_menu 

    style nvl_vbox:
        box_spacing 20   

init -2 python hide:
    # config.empty_window = nvl_show_core
    config.nvl_paged_rollback = True
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
Rainvillain
Regular
Posts: 76
Joined: Thu Mar 05, 2015 11:27 am
Contact:

Re: Customizing the namebox

#5 Post by Rainvillain »

Thanks for all your help!

You were right, there was an inconsistency in the styles. I reworded the code you gave me to be in line with the code of the regular textbox, so now it looks like this:

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 = Frame("frametest2.png", 25, 25)

    ## Margin is space surrounding the window, where the background
    ## is not drawn.

    style.window.left_margin = 80
    style.window.right_margin = 80
    # style.window.top_margin = 10
    # style.window.bottom_margin = 10

    ## Padding is space inside the window, where the background is
    ## drawn.

    style.window.left_padding = 20
    style.window.right_padding = 20
    style.window.top_padding = 20
    style.window.bottom_padding = 20

    ## This is the minimum height of the window, including the margins
    ## and padding.

    # style.window.yminimum = 250

 ###############################################
    ## ---------- Name Box  ---------------------

    ## ----- Frame (expandable) ------------------------
    style.say_who_window.background = Frame("frametest2.png", 25, 25)
   
    ## ---- No Frame (Not expandable) ---------------
        # background "YourNameBox.png"

    # margins ---------------------------------
    style.say_who_window.left_margin = 80
    style.say_who_window.right_margin = 80
    #style.say_who_window.top_margin = 0
    #style.say_who_window.bottom_margin = 0   

    # padding ---------------------------------
    style.say_who_window.left_padding = 30
    style.say_who_window.right_padding = 30
    style.say_who_window.top_padding = 10
    style.say_who_window.bottom_padding = 10

    #style.say_who_window.yminimum = 10
    #style.say_who_window.xminimum = 10
    
    style.say_label.font = "DejaVuSans.ttf"
      
    style.say_label.size = 30
...and it works! *knock on wood
Thanks again!

User avatar
Rainvillain
Regular
Posts: 76
Joined: Thu Mar 05, 2015 11:27 am
Contact:

Re: Customizing the namebox

#6 Post by Rainvillain »

Hi there!

I want the margins on my namebox to be dependent on who's speaking (aka: on the left or right side of the screen).

I know I can shift my regular box by adding "window_left_margin=200" into the section where I define a character, but I can't figure out how to tell the namebox window to do the same!
Here is my piece of code from when I defined a character:

Code: Select all

define e = Character('Ennasin', color="#CC0033", window_left_margin=200, show_two_window=True)
This works fine, but when I try adding in something like "say_who_window_left_margin=200" my namebox doesn't change accordingly.
This is what my textbox and namebox look like in 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 = Frame("frametest2.png", 25, 25)

    ## Margin is space surrounding the window, where the background
    ## is not drawn.

    style.window.left_margin = 0
    style.window.right_margin = 200
    # style.window.top_margin = 10
    style.window.bottom_margin = 10

    ## Padding is space inside the window, where the background is
    ## drawn.

    style.window.left_padding = 20
    style.window.right_padding = 20
    style.window.top_padding = 20
    style.window.bottom_padding = 20

    ## This is the minimum height of the window, including the margins
    ## and padding.

    # style.window.yminimum = 250

 ###############################################
    ## ---------- Name Box  ---------------------

    ## ----- Frame (expandable) ------------------------
    style.say_who_window.background = Frame("frametest.png", 25, 25)
   
    ## ---- No Frame (Not expandable) ---------------
        # background "YourNameBox.png"

    # margins ---------------------------------
    style.say_who_window.left_margin = 0
    style.say_who_window.right_margin = 80
    #style.say_who_window.top_margin = 0
    style.say_who_window.bottom_margin = 0   

    # padding ---------------------------------
    style.say_who_window.left_padding = 30
    style.say_who_window.right_padding = 30
    style.say_who_window.top_padding = 10
    style.say_who_window.bottom_padding = 10

    #style.say_who_window.yminimum = 10
    #style.say_who_window.xminimum = 10
    
    style.say_label.font = "DejaVuSans.ttf"
      
    style.say_label.size = 30

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

Re: Customizing the namebox

#7 Post by henvu50 »

How do you make the namebox bold and change it's color?

I tried adding the following to options.rpy, at the bottom. The renpy game started fine when I launcehd it, but the following code had no effect. The size didn't change and the namebox didn't become bold.

Code: Select all

style say_who_window:
  bold True
  size 90

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]