WTS/game/scripts/gui/say.rpy
2024-05-23 18:08:39 +01:00

418 lines
13 KiB
Plaintext

init offset = -1
screen nvl(dialogue, items=None):
null
# init python:
# import re
# def text_inner_thought(string, pattern=re.compile(r"\(([^)]+)\)")):
# return re.findall(pattern, string)
# 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_image=None, icon=None):
style_prefix "say"
layer "interface"
zorder 0
if states.settings.interface_hidden:
use hider
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)
# Ren'py hard crashes without textbox windows,
# this is the workaround that just works.
if states.settings.interface_hidden:
yoffset 1000
if who:
window:
id "namebox"
style "namebox"
text who id "who" style "who"
text what id "what" style "what"
use quickbox
add SideImage()
screen hider():
variant "pc"
if states.settings.interface_hidden:
button action ToggleVariable("states.settings.interface_hidden", True, False) style "empty"
window:
id "hider"
style "hider"
style_prefix "hider"
textbutton "󰈈" action ToggleVariable("states.settings.interface_hidden", True, False) tooltip _("Unhide Interface")
default states.settings.quickbox_expanded = True
default states.settings.interface_hidden = False
default states.settings.interface_alpha = 0.5
screen quickbox():
variant "pc"
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") # Hide Interface (\F0209)
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("preferences") tooltip _("Game Options") # Settings (\F0493)
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"
selected_hover_color "#ffffff"
outlines [(2, "#000000", 1, 1)]
size 24
style textbox:
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)
style what:
xpos 0.5
ypos 10
xsize 500
xoffset -240
color "#fff"
outlines [(2, "#000000", 1, 1)]
hinting "bytecode"
size 24
justify True
style namebox:
ysize 22 # Halved due to oversampling
padding (32, 0, 32, 0)
fit_first True
xpos 0.5
yalign 1.0
xanchor 0.0
offset (-320, -125)
background Transform(Frame(Image("gui/creamy_pumpkin_pie/namebox.png", oversample=4), 32, 0, 32, 0, tile=True), alpha=0.5)
style who:
color "#EA8E61"
outlines [(2, "#000000", 1, 1)]
hinting "auto"
font gui.bold_font
size 32
style quickbox is namebox:
padding (32, 0, 32, 0)
xanchor 1.0
xoffset 320
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
screen choice(items):
style_prefix "choice"
layer "interface"
zorder 1
variant "pc"
# default max_progress = max(len(e.kwargs.get("progress", [])) for e in items)
default has_icons = any(x is not None for x in [e.kwargs.get("icon", None) for e in items])
# add Image("gui/creamy_pumpkin_pie/fade_top.png", oversample=2) alpha 0.5
vbox:
at gui_choice_show_hide
for i, entry in enumerate(items, 1):
$ scale = (1.0 * (32 / max(32, len(entry.caption))))
$ icon = entry.kwargs.get("icon", None)
$ progress = entry.kwargs.get("progress", None)
vbox:
spacing 2
button:
action entry.action
if i < 10 and entry.action:
keysym ("K_"+str(i), "K_KP"+str(i))
text "[i]" style "choice_number":
at gui_perspective
hbox:
null width 16
at gui_perspective, gui_perspective_hover
# if progress:
# for j in range(max_progress):
# if j < len(progress):
# add progress[j] xysize (32, 32)
# else:
# null width 32
if has_icons:
if icon:
add icon xysize (32, 32) xcenter 12 yalign 1.0 yoffset -4
else:
null width 32
text entry.caption size 32 * scale
if progress:
bar value StaticValue(progress[0], progress[1]) offset (-16, 22)
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_say_show_hide(what):
show_cancels_hide True
on show:
alpha 0
zoom 1.05
pause 0.1
easein 0.1 zoom 1.00 alpha 1
on replace:
alpha 1.0
zoom 1.0
on hide:
# easeout 0.1 zoom 0.95 alpha 0
function renpy.partial(gui_say_hide, what)
init python:
def gui_say_hide(what, trans, st, at):
if st > 0.1:
return None
if any(x in what for x in ("{w}", "{w=", "{nw}", "{p}", "{p=")):
return None
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
transform gui_choice_show_hide:
show_cancels_hide True
on start:
events False
xoffset -100
alpha 0
pause 0.1
easein 0.1 alpha 1 xoffset 0
events True
on hide:
easeout 0.2 alpha 0 xoffset 100
style choice_vbox is vbox
style choice_button is button
style choice_button_text is button_text
style choice_vbox:
xalign 0.5
yanchor 1.0
ypos 0.75
spacing 10
style choice_hbox:
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
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)
# define blacklist_screens = {"say", "letter", "bld1"}
# define choice_width = int(config.screen_width/2)
# screen choice(items, menu_yalign=.6):
# tag menu
# zorder 0
# layer "interface"
# style_prefix gui.theme("menu")
# default blacklist_tags = set(get_character_tag(x) for x in states.dolls)
# # Dont add the fade if character or saybox is present (They have their own triggers for fading)
# if not any(renpy.get_screen(x) for x in blacklist_screens) and not any(renpy.showing(x, layer="screens") for x in blacklist_tags):
# add "interface/bld.webp" at fade_hide(0.15)
# window at fade_show_hide(0.15):
# style "empty"
# xalign .5
# yalign menu_yalign
# vbox:
# spacing 0
# default max_progress = max(len(e.kwargs.get("progress", [])) for e in items)
# for i, entry in enumerate(items, 1):
# $ style_part = entry.kwargs.get("style", None)
# button:
# xsize choice_width
# ypadding 5
# action entry.action
# sensitive bool(entry.action)
# if i < 10 and entry.action:
# keysym ("K_"+str(i), "K_KP"+str(i))
# fixed:
# style "empty"
# if style_part:
# style_prefix gui.theme(f"{style_part}_menu")
# fit_first "height"
# text entry.caption:
# xsize choice_width-120 # Leave enough margin for number and icon
# align (0.5, 0.5)
# if i < 10 and entry.action:
# text "{size=-2}[i].{/size}" xpos 5 yalign 0.5
# $ icon = entry.kwargs.get("icon", None)
# if icon:
# add icon xcenter 40 yalign 0.5
# $ progress = entry.kwargs.get("progress", None)
# if progress:
# hbox:
# spacing 2
# xpos choice_width - 5
# xanchor 1.
# yalign .5
# for i in range(max_progress):
# if i < len(progress):
# add progress[i]
# else:
# null width 21 # Assume icon width
# style menu_text is default:
# hover_color "#fff"
# text_align 0.5
# outlines [(1, "#00000080", 1, 0)]
# style dark_menu_text:
# color "#9b8d84"
# insensitive_color "#6c625c"
# style light_menu_text:
# color "#f9d592"
# insensitive_color "#ae9566"
# style dark_disabled_menu_text:
# color "#6c625c"
# style light_disabled_menu_text:
# color "#ae9566"
# style menu_button is default:
# activate_sound "sounds/qubodup-click1.ogg"
# hover_sound "sounds/qubodup-hover1.ogg"
# style dark_menu_button:
# background "#5d5151e6"
# hover_background "#897e75"
# insensitive_background "#9e8449"
# style light_menu_button:
# background "#ac8d5ae6"
# hover_background "#97681f"
# insensitive_background "#d1a02eb3"
# 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":
style gui.theme("say_dialogue")