Snippets

SinnyStar [Ren'Py] Say screen style selection

Updated by J. Tran

File screens.rpy Modified

  • Ignore whitespace
  • Hide word diff
 init python:
 
     # style setting
-    persistent.style = "1"
-
-    # style 1: red
-    namebox1 = Frame("#f00c",0,0)
-    textbox1 = Frame("#ff0c",0,0)
-
-    # style 2: blue
-    namebox2 = Frame("#00fc",0,0)
-    textbox2 = Frame("#0ffc",0,0)
-
-init:
-    # Namebox
-    style namebox1_window is say_who_window:
-        background namebox1
-    style textbox2_window:
-        background textbox2
-
-    # Textbox
-    style textbox1_window:
-        background textbox1
-    style namebox2_window is say_who_window:
-        background namebox2
-        
-screen say(who, what, side_image=None, two_window=False):
+    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: red" action SetField(persistent, "style", "1")
-        textbutton "Style 2: blue" action SetField(persistent, "style", "2")
+        textbutton "Style 1: opaque" action SetField(persistent, "style", "A")
+        textbutton "Style 2: translucent" action SetField(persistent, "style", "B")
 
-    # The two window variant.
-    vbox:
-        style "say_two_window_vbox"
-        if who:
-            window:
-                # style "say_who_window"
-                if persistent.style == "1":
-                    style_group "namebox1"
-                else:
-                    style_group "namebox2"
-                
-                text who:
-                    id "who"
+    # Decide if we want to use the one-window or two-window varaint.
+    if not two_window:
 
+        # The one window variant.        
         window:
             id "window"
-            if persistent.style == "1":
-                style_group "textbox1"
-            else:
-                style_group "textbox2"
-                    
-            vbox:
+
+            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"

File script.rpy Added

  • Ignore whitespace
  • Hide word diff
+# 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
Created by J. Tran

File screens.rpy Added

  • Ignore whitespace
  • Hide word diff
+init python:
+
+    # style setting
+    persistent.style = "1"
+
+    # style 1: red
+    namebox1 = Frame("#f00c",0,0)
+    textbox1 = Frame("#ff0c",0,0)
+
+    # style 2: blue
+    namebox2 = Frame("#00fc",0,0)
+    textbox2 = Frame("#0ffc",0,0)
+
+init:
+    # Namebox
+    style namebox1_window is say_who_window:
+        background namebox1
+    style textbox2_window:
+        background textbox2
+
+    # Textbox
+    style textbox1_window:
+        background textbox1
+    style namebox2_window is say_who_window:
+        background namebox2
+        
+screen say(who, what, side_image=None, two_window=False):
+
+    # Style changer
+    frame:
+        has vbox
+        textbutton "Style 1: red" action SetField(persistent, "style", "1")
+        textbutton "Style 2: blue" action SetField(persistent, "style", "2")
+
+    # The two window variant.
+    vbox:
+        style "say_two_window_vbox"
+        if who:
+            window:
+                # style "say_who_window"
+                if persistent.style == "1":
+                    style_group "namebox1"
+                else:
+                    style_group "namebox2"
+                
+                text who:
+                    id "who"
+
+        window:
+            id "window"
+            if persistent.style == "1":
+                style_group "textbox1"
+            else:
+                style_group "textbox2"
+                    
+            vbox:
+                style "say_vbox"
+
+                text what id "what"
HTTPS SSH

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