Snippets

SinnyStar [Ren'Py] Say screen style selection

Created by Sinny Star last modified J. Tran
init python:

    # style setting
    persistent.style = "A"

    # style 1: opaque
    namebox1A = Frame("#f00",0,0)
    namebox2A = Frame("#00f",0,0)
    textbox1A = Frame("#ff0",0,0)
    textbox2A = Frame("#0ff",0,0)
    
    # style 2: translucent
    namebox1B = Frame("#f008",0,0)
    namebox2B = Frame("#00f8",0,0)
    textbox1B = Frame("#ff08",0,0)
    textbox2B = Frame("#0ff8",0,0)

screen say(who, what, side_image=None, two_window=True, custom_who_background="say_who_window_background"):

    # Style changer
    frame:
        has vbox
        textbutton "Style 1: opaque" action SetField(persistent, "style", "A")
        textbutton "Style 2: translucent" action SetField(persistent, "style", "B")

    # Decide if we want to use the one-window or two-window varaint.
    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:

        # The two window variant.
        vbox:
            style "say_two_window_vbox"

            if who:            
                window:
                    style "say_who_window"
                    background custom_who_background

                    text who:
                        id "who"
                        
            window:
                id "window"

                has vbox:
                    style "say_vbox"

                text what id "what"
# Characters with argument custom_who_background
# show_ passes the variable over to the say screen
# http://www.renpy.org/doc/html/dialogue.html#Character

define a = Character("Alice",
    show_custom_who_background=ConditionSwitch(
          "persistent.style == 'B'", namebox1B,
          "True", namebox1A,
        )
    )
define b = Character("Bob",
    show_custom_who_background=ConditionSwitch(
          "persistent.style == 'B'", namebox2B,
          "True", namebox2A,
        )
    )
    
label start:

    a "I'm [a]."
    b "I'm [b]."
    
    return

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.