WTS/game/scripts/gui/say.rpy

350 lines
10 KiB
Plaintext
Raw Normal View History

2022-05-16 23:48:22 +00:00
init offset = -1
screen nvl(dialogue, items=None):
null
2024-05-14 20:54:03 +00:00
# init python:
# import re
# def text_inner_thought(string, pattern=re.compile(r"\(([^)]+)\)")):
# return re.findall(pattern, string)
2024-05-21 17:45:06 +00:00
# default _next_say_who = None
# init python:
# def next_who(*args, **kwargs):
# # Unfortunately does not work because '_last_say_who' is a lie. It points to the currently run statement.
# if not hasattr(renpy.store, "_next_say_who", ):
# return
# global _next_say_who
# scry = renpy.scry().next()
# _next_say_who = scry.who.__name__ if scry and scry.who else None
# config.all_character_callbacks.append(next_who)
screen say(who, what, side_doll=None, icon=None):
2024-05-14 20:54:03 +00:00
style_prefix "say"
layer "interface"
zorder 0
2024-04-23 18:25:17 +00:00
2024-05-14 20:54:03 +00:00
if states.settings.interface_hidden:
use hider
2024-05-14 20:54:03 +00:00
window:
id "textbox"
style "textbox"
# Ren'py will flicker the box on {w} tags,
# so we use a func.
at gui_say_show_hide(what)
2024-05-19 20:00:48 +00:00
2024-05-14 20:54:03 +00:00
# Ren'py hard crashes without textbox windows,
# this is the workaround that just works.
if states.settings.interface_hidden:
yoffset 1000
2024-04-23 18:25:17 +00:00
if who:
2024-05-14 20:54:03 +00:00
2024-04-23 18:25:17 +00:00
window:
id "namebox"
style "namebox"
2024-05-14 20:54:03 +00:00
text who id "who" style "who"
2022-05-16 23:48:22 +00:00
2024-05-14 20:54:03 +00:00
text what id "what" style "what"
2022-05-16 23:48:22 +00:00
2024-05-14 20:54:03 +00:00
use quickbox
2022-05-16 23:48:22 +00:00
# Note: Weird quirk. As per documentation;
# Keyword arguments passed to the say character
# beginning with ``show_`` have the prefix
# stripped off, and are passed to the screen as arguments. For
# example, the value of ``show_myflag`` will become the value of
# the ``myflag`` variable in the screen. (The ``myflag`` variable isn't
# used by default, but can be used by a custom say screen.)
if side_doll:
add side_doll
else:
add SideImage()
2022-05-16 23:48:22 +00:00
2024-05-14 20:54:03 +00:00
screen hider():
if states.settings.interface_hidden:
button action ToggleVariable("states.settings.interface_hidden", True, False) style "empty"
2022-05-16 23:48:22 +00:00
2024-05-14 20:54:03 +00:00
window:
id "hider"
style "hider"
style_prefix "hider"
textbutton "󰈈" action ToggleVariable("states.settings.interface_hidden", True, False) tooltip _("Unhide Interface")
2022-05-16 23:48:22 +00:00
2024-05-14 20:54:03 +00:00
default states.settings.quickbox_expanded = True
default states.settings.interface_hidden = False
default states.settings.interface_alpha = 0.5
2022-05-16 23:48:22 +00:00
2024-05-14 20:54:03 +00:00
screen quickbox():
window:
id "quickbox"
style "quickbox"
style_prefix "quickbox"
hbox:
xalign 1.0
if states.settings.quickbox_expanded:
textbutton "󰈉" action ToggleVariable("states.settings.interface_hidden", True, False) tooltip _("Hide Interface") keysym "K_h" # Hide Interface (\F0209)
2024-05-14 20:54:03 +00:00
textbutton "󰇚" action QuickSave() tooltip _("Quick Save") # File Save (\F01DA)
textbutton "󰕒" action QuickLoad() tooltip _("Quick Load") # File Load (\F0552)
textbutton "󰁪" action Preference("auto-forward", "toggle") tooltip _("Auto-Forward Dialogue") # Autoplay (\F18F2)
textbutton "󰒓" action ShowMenu("navigation") tooltip _("Game Options") # Settings (\F0493)
2024-05-14 20:54:03 +00:00
textbutton "󰮫" action ToggleVariable("states.settings.quickbox_expanded", True, False) tooltip _("Toggle Quick Action Box") # Menu (\F0BAB)
style quickbox_button
style quickbox_button_text:
font gui.glyph_font
color "#bbbbbb"
hover_color "#ffffff"
selected_color "#EA8E61"
2024-05-21 19:51:31 +00:00
selected_hover_color "#ffffff"
2024-05-21 00:58:08 +00:00
outlines [(2, "#000000", 1, 1)]
size 24
2024-05-14 20:54:03 +00:00
style textbox:
2024-05-21 00:58:08 +00:00
ysize 125
align (0.5, 1.0)
background Transform(Image("gui/creamy_pumpkin_pie/textbox.png", xalign=0.5, yalign=1.0, oversample=4), alpha=0.5)
2024-05-14 20:54:03 +00:00
style what:
2024-05-19 20:00:48 +00:00
xpos 0.5
2024-05-21 00:58:08 +00:00
ypos 10
xsize 500
xoffset -240
2024-05-14 20:54:03 +00:00
color "#fff"
2024-05-21 00:58:08 +00:00
outlines [(2, "#000000", 1, 1)]
2024-05-14 20:54:03 +00:00
hinting "bytecode"
2024-05-21 00:58:08 +00:00
size 24
2024-05-14 20:54:03 +00:00
justify True
style namebox:
2024-05-21 00:58:08 +00:00
ysize 22 # Halved due to oversampling
padding (32, 0, 32, 0)
2024-05-14 20:54:03 +00:00
fit_first True
xpos 0.5
yalign 1.0
xanchor 0.0
2024-05-21 00:58:08 +00:00
offset (-320, -125)
background Transform(Frame(Image("gui/creamy_pumpkin_pie/namebox.png", oversample=4), 32, 0, 32, 0, tile=True), alpha=0.5)
2024-05-14 20:54:03 +00:00
style who:
color "#EA8E61"
2024-05-21 00:58:08 +00:00
outlines [(2, "#000000", 1, 1)]
2024-05-14 20:54:03 +00:00
hinting "auto"
font gui.bold_font
2024-05-21 00:58:08 +00:00
size 32
2024-05-14 20:54:03 +00:00
style quickbox is namebox:
2024-05-21 00:58:08 +00:00
padding (32, 0, 32, 0)
2024-05-14 20:54:03 +00:00
xanchor 1.0
2024-05-21 00:58:08 +00:00
xoffset 320
2024-05-14 20:54:03 +00:00
style hider is namebox:
align (0.5, 1.0)
offset (0, 0)
padding (50, 0, 50, 0)
style hider_button is quickbox_button
style hider_button_text is quickbox_button_text
2024-05-20 23:08:41 +00:00
screen choice(items):
style_prefix "choice"
2024-05-15 22:02:05 +00:00
layer "interface"
2024-05-20 23:08:41 +00:00
zorder 1
variant "pc"
2022-05-16 23:48:22 +00:00
2024-05-20 23:08:41 +00:00
default has_icons = any(x is not None for x in [e.kwargs.get("icon", None) for e in items])
2024-05-29 21:16:58 +00:00
default columns = math.ceil(len(items) / 12)
2022-05-16 23:48:22 +00:00
key "K_h" action ToggleVariable("states.settings.interface_hidden", True, False)
if states.settings.interface_hidden:
use hider
2024-05-29 21:16:58 +00:00
hbox:
if states.settings.interface_hidden:
yoffset 1000
2024-05-21 01:27:21 +00:00
at gui_choice_show_hide
2024-05-29 21:16:58 +00:00
for column in range(columns):
2024-05-20 23:08:41 +00:00
vbox:
2024-05-29 21:16:58 +00:00
$ start_index = column * 12
$ end_index = start_index + 12
2024-05-29 21:16:58 +00:00
for i, entry in enumerate(items[start_index:end_index], 1):
$ scale = (1.0 * (28 / max(28, len(entry.caption))))
$ icon = entry.kwargs.get("icon", None)
$ progress = entry.kwargs.get("progress", None)
button:
action entry.action
# Handle columns
if columns > 1:
xmaximum (config.screen_width // columns)
2022-05-16 23:48:22 +00:00
2024-05-29 21:16:58 +00:00
if i < 10 and entry.action:
keysym ("K_"+str(i), "K_KP"+str(i))
2022-05-16 23:48:22 +00:00
2024-05-29 21:16:58 +00:00
text "[i+start_index]" style "choice_number":
at gui_perspective
2024-05-20 23:08:41 +00:00
2024-05-29 21:16:58 +00:00
hbox:
null width 16
at gui_perspective, gui_perspective_hover
2024-05-20 23:08:41 +00:00
2024-05-29 21:16:58 +00:00
if has_icons:
if icon:
add icon xysize (32, 32) xcenter 12 yalign 1.0 yoffset -4
else:
null width 32
2024-05-20 23:08:41 +00:00
2024-05-29 21:16:58 +00:00
text entry.caption size 32 * scale
2024-05-20 23:08:41 +00:00
2024-05-29 21:16:58 +00:00
if progress:
bar value StaticValue(progress[0], progress[1]) offset (-16, 22)
2024-05-29 21:16:58 +00:00
if progress[0] == progress[1]:
text _("{wave}{size=20}Done!{/size}{/wave}") style "choice_progress" at transform:
rotate 12.5
gui_hover
2024-05-20 23:08:41 +00:00
transform gui_perspective:
perspective True
matrixanchor (0.5, 0.0)
matrixtransform RotateMatrix(45.0, -12.5, 0.0)
transform gui_perspective_hover:
perspective True
on hover:
easein 0.1 matrixtransform ScaleMatrix(1.05, 1.05, 1.05)
easeout 0.1 matrixtransform ScaleMatrix(1.0, 1.0, 1.0)
transform gui_hover:
subpixel True
zoom 1.0
xzoom 1.0
anchor (0.5, 0.5)
on hover:
easein 0.1 zoom 1.05 xzoom 1.1
easeout 0.1 zoom 1.0 xzoom 1.0
transform gui_say_show_hide(what):
show_cancels_hide True
on show:
2024-05-21 00:58:08 +00:00
alpha 0
zoom 1.05
2024-05-21 01:07:48 +00:00
pause 0.1
2024-05-21 00:58:08 +00:00
easein 0.1 zoom 1.00 alpha 1
on replace:
alpha 1.0
zoom 1.0
2024-05-21 00:58:08 +00:00
on hide:
# easeout 0.1 zoom 0.95 alpha 0
function renpy.partial(gui_say_hide, what)
2024-05-21 17:45:06 +00:00
init python:
def gui_say_hide(what, trans, st, at):
if st > 0.1:
return None
2024-05-21 17:45:06 +00:00
2024-05-23 17:08:39 +00:00
if any(x in what for x in ("{w}", "{w=", "{nw}", "{p}", "{p=")):
return None
2024-05-21 17:45:06 +00:00
warper = _warper.easein(st / 0.1)
trans.alpha = renpy.atl.interpolate(warper, 1.0, 0.0, renpy.atl.PROPERTIES["alpha"])
trans.zoom = renpy.atl.interpolate(warper, 1.0, 0.95, renpy.atl.PROPERTIES["zoom"])
return 0.01
2024-05-21 17:45:06 +00:00
2024-05-21 01:27:21 +00:00
transform gui_choice_show_hide:
show_cancels_hide True
2024-05-21 01:27:21 +00:00
on start:
2024-05-21 01:28:55 +00:00
events False
2024-05-21 01:27:21 +00:00
xoffset -100
alpha 0
pause 0.1
easein 0.1 alpha 1 xoffset 0
2024-05-21 01:28:55 +00:00
events True
2024-05-21 01:27:21 +00:00
on hide:
easeout 0.2 alpha 0 xoffset 100
2024-05-20 23:08:41 +00:00
style choice_vbox is vbox
style choice_button is button
style choice_button_text is button_text
style choice_vbox:
2024-05-29 21:16:58 +00:00
align (0.5, 1.0)
2024-05-20 23:08:41 +00:00
spacing 10
style choice_hbox:
2024-05-29 21:16:58 +00:00
xalign 0.5
yanchor 1.0
ypos 0.75
2024-05-20 23:08:41 +00:00
spacing 2
style choice_button:
ysize 24
xmaximum 0.6
xalign 0.5
padding (48, 0, 24, 0)
background Transform(Frame(Image("gui/creamy_pumpkin_pie/choice.png", oversample=4), 24, 0, 24, 0, tile=True, xmaximum=0.9, xalign=0.5), matrixcolor=SaturationMatrix(0.0))
hover_background Fixed(
Frame(Image("gui/creamy_pumpkin_pie/choice_arrow.png", oversample=4), 48, 0, 96, 0, tile=True, xoffset=8),
Frame(Image("gui/creamy_pumpkin_pie/choice.png", oversample=4), 24, 0, 24, 0, tile=True, xmaximum=0.9, xalign=0.5)
)
style choice_text:
color "#dddddd"
hover_color "#ffffff"
outlines [(1, "#000000", 1, 2), (1, "#000000", 0, 1), (1, "#000000", 0, 0)]
hinting "bytecode"
size 32
2022-05-16 23:48:22 +00:00
2024-05-20 23:08:41 +00:00
style choice_number is choice_text:
offset (0, 5)
size 16
style choice_bar is empty:
ysize 10
left_bar Transform(Frame(Image("gui/creamy_pumpkin_pie/choice_bar_full.png", oversample=4), 24, 0, 24, 0, tile=True), matrixcolor=SaturationMatrix(0.5))
hover_left_bar Frame(Image("gui/creamy_pumpkin_pie/choice_bar_full.png", oversample=4), 24, 0, 24, 0, tile=True)
right_bar Frame(Image("gui/creamy_pumpkin_pie/choice_bar_empty.png", oversample=4), 24, 0, 24, 0, tile=True)
style choice_progress:
pos (520, 15)
2022-05-16 23:48:22 +00:00
# Input screen
#
# This screen is used to display renpy.input. The prompt parameter is used to
# pass a text prompt in.
#
# This screen must create an input displayable with id "input" to accept the
# various input parameters.
#
# https://www.renpy.org/doc/html/screen_special.html#input
screen input(prompt):
zorder 30
style_prefix "say"
window:
id "window"
style gui.theme("say_window")
if prompt:
window:
style gui.theme("namebox")
text prompt:
style gui.theme("say_label")
input id "input":
2024-05-20 23:08:41 +00:00
style gui.theme("say_dialogue")