59 lines
1.6 KiB
Plaintext
59 lines
1.6 KiB
Plaintext
|
screen tooltip():
|
||
|
layer "interface"
|
||
|
tag tooltip
|
||
|
zorder 5
|
||
|
style_prefix "tooltip"
|
||
|
|
||
|
default last_tooltip = ""
|
||
|
|
||
|
if settings.get("tooltip"):
|
||
|
$ mouseclick = any(pygame.mouse.get_pressed()[:3])
|
||
|
|
||
|
# Do not remove the empty string from the statement below,
|
||
|
# it is a rare case when the save file gets updated but the old tooltip
|
||
|
# and its scope defaults last_tooltip to None value
|
||
|
# because it was previously unknown at the runtime,
|
||
|
# and we cannot hide the screen fast enough, causing a hard crash.
|
||
|
# This ensures it never happens.
|
||
|
$ tooltip = GetTooltip() or last_tooltip or ""
|
||
|
$ last_tooltip = tooltip
|
||
|
|
||
|
showif GetTooltip() and not mouseclick:
|
||
|
$ x, y = renpy.get_mouse_pos()
|
||
|
$ xflip = x > 980
|
||
|
$ yflip = y > 500
|
||
|
$ xanchor = 1.0 if xflip else 0.0
|
||
|
$ yanchor = 1.0 if yflip else 0.0
|
||
|
$ xoffset = 11 if xflip else 0
|
||
|
$ yoffset = 14 if yflip else 0
|
||
|
|
||
|
window:
|
||
|
id tooltip
|
||
|
at tooltip_follow((x+xoffset, y+yoffset), (xanchor, yanchor))
|
||
|
text "[tooltip]"
|
||
|
|
||
|
style tooltip_window is empty:
|
||
|
background "#00000080"
|
||
|
padding (12, 6)
|
||
|
xmaximum 300
|
||
|
|
||
|
style tooltip_text is default:
|
||
|
color "#fff"
|
||
|
size 10
|
||
|
outlines [(1, "#00000080", 1, 0)]
|
||
|
|
||
|
init python:
|
||
|
config.per_frame_screens.append("tooltip")
|
||
|
|
||
|
transform tooltip_follow(pos, anchor):
|
||
|
on start:
|
||
|
alpha 0.0
|
||
|
|
||
|
on show:
|
||
|
anchor anchor
|
||
|
pos pos
|
||
|
linear 0.1 alpha 1.0
|
||
|
|
||
|
on hide:
|
||
|
linear 0.1 alpha 0.0
|