forked from SilverStudioGames/WTS
Tooltip improvements and bug fixes
* Disabled tooltips on android devices * Improved screen boundary detection to avoid overflow * Improved readability and padding * Fixed the existence of tooltip parameter causing massive lag spikes on hover/unhover events (even when tooltips were disabled) by patching the related engine focus function
This commit is contained in:
parent
2e0dbeb8c4
commit
f29f8aecfe
@ -1,20 +1,20 @@
|
||||
default _tooltip = None
|
||||
|
||||
screen tooltip():
|
||||
layer "interface"
|
||||
tag tooltip
|
||||
zorder 5
|
||||
style_prefix "tooltip"
|
||||
|
||||
$ tooltip = GetTooltip()
|
||||
|
||||
if settings.get("tooltip") and tooltip:
|
||||
if settings.get("tooltip") and _tooltip:
|
||||
window:
|
||||
id tooltip
|
||||
id "tooltip"
|
||||
at tooltip_follow
|
||||
text "[tooltip]"
|
||||
text "[_tooltip]"
|
||||
|
||||
style tooltip_window is empty:
|
||||
background "#00000080"
|
||||
padding (12, 6)
|
||||
padding (18, 12)
|
||||
xmaximum 300
|
||||
|
||||
style tooltip_text is default:
|
||||
@ -30,12 +30,22 @@ init python:
|
||||
|
||||
def tooltip_func(trans, st, at):
|
||||
x, y = renpy.get_mouse_pos()
|
||||
xanchor = 1.0 if (x > 980) else 0.0
|
||||
yanchor = 1.0 if (y > 500) else 0.0
|
||||
xoffset = 11 if xanchor else 0
|
||||
yoffset = 14 if yanchor else 0
|
||||
|
||||
if trans.pos is not (x, y):
|
||||
cw, ch = trans.child.window_size
|
||||
|
||||
xanchor = 1.0 if (x + int(cw)) > (config.screen_width) else 0.0
|
||||
yanchor = 1.0 if (y + int(ch)) > (config.screen_height) else 0.0
|
||||
|
||||
xoffset = 18 if xanchor else 0
|
||||
yoffset = 24 if yanchor else 0
|
||||
trans.pos = (x, y)
|
||||
trans.anchor = (xanchor, yanchor)
|
||||
trans.offset = (xoffset, yoffset)
|
||||
|
||||
return 0
|
||||
|
||||
if not renpy.android:
|
||||
|
||||
config.always_shown_screens.append("tooltip")
|
||||
config.per_frame_screens.append("tooltip")
|
||||
|
@ -1,21 +1,14 @@
|
||||
|
||||
# The game starts here
|
||||
label start:
|
||||
if not renpy.android:
|
||||
show screen tooltip
|
||||
|
||||
python:
|
||||
version = version_float()
|
||||
|
||||
renpy.block_rollback()
|
||||
|
||||
jump start_wt
|
||||
|
||||
label start_quick:
|
||||
if not renpy.android:
|
||||
show screen tooltip
|
||||
|
||||
python:
|
||||
version = version_float()
|
||||
game.difficulty = 2
|
||||
ton_friendship = 5
|
||||
sna_friendship = 5
|
||||
@ -27,10 +20,8 @@ label start_quick:
|
||||
jump skip_to_hermione
|
||||
|
||||
label start_dev:
|
||||
if not renpy.android:
|
||||
show screen tooltip
|
||||
|
||||
python:
|
||||
version = version_float()
|
||||
game.difficulty = 2
|
||||
game.cheats = True
|
||||
game.gold = 100000
|
||||
|
@ -86,3 +86,40 @@ python early hide:
|
||||
return rv
|
||||
|
||||
renpy.list_files = _list_files
|
||||
|
||||
# Default focus behaviour restarts the interaction whenever
|
||||
# any element that contains a tooltip is being hovered or unhovered.
|
||||
# Restarting interactions in a short timespan causes massive lag spikes,
|
||||
# in order to fix it, we'll refresh just the tooltip screen and skip the rest.
|
||||
|
||||
def set_focused(widget, arg, screen):
|
||||
global _tooltip
|
||||
renpy.display.focus.argument = arg
|
||||
renpy.display.focus.screen_of_focused = screen
|
||||
|
||||
if screen is not None:
|
||||
renpy.display.focus.screen_of_focused_names = { screen.screen_name[0], screen.tag }
|
||||
else:
|
||||
renpy.display.focus.screen_of_focused_names = set()
|
||||
|
||||
renpy.game.context().scene_lists.focused = widget
|
||||
renpy.display.tts.displayable(widget)
|
||||
|
||||
# Figure out the tooltip.
|
||||
|
||||
_tooltip = widget._get_tooltip() if widget else None
|
||||
|
||||
# setattr(renpy.store, "widget", widget) # DEBUG
|
||||
|
||||
# if renpy.display.focus.tooltip != new_tooltip:
|
||||
# renpy.display.focus.tooltip = new_tooltip
|
||||
# renpy.display.focus.capture_focus("tooltip")
|
||||
|
||||
# renpy.exports.restart_interaction()
|
||||
|
||||
# if renpy.display.focus.tooltip is not None:
|
||||
# renpy.display.focus.last_tooltip = renpy.display.focus.tooltip
|
||||
# renpy.display.focus.screen_of_last_focused_names = renpy.display.focus.screen_of_focused_names
|
||||
|
||||
renpy.display.focus.set_focused = set_focused
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user