马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
一个挺好用的小脚本~~
[RenPy] 纯文本查看 复制代码 init -1500 python:
class MouseTooltip(Tooltip, renpy.Displayable):
"""
A Tooltip whose x/y position follows the mouse's.
"""
action = Action
def __init__(self, default, padding=None, *args, **kwargs):
super(renpy.Displayable, self).__init__(*args, **kwargs)
self.default = default
self.value = default
self.padding = padding or {}
self.pad_x = padding.get('x', 0)
self.pad_y = padding.get('y', 0)
self.x = 0
self.y = 0
def render(self, width, height, st, at):
# Only Text() displayables have a size method
try:
w, h = self.value.size()
except AttributeError:
child_render = renpy.render(self.value, width, height, st, at)
w, h = child_render.get_size()
render = renpy.Render(w, h)
render.place(self.value, x=self.x + self.pad_x, y=self.y + self.pad_y)
return render
def event(self, ev, x, y, st):
self.x = x
self.y = y
renpy.redraw(self, 0)
default mtt = MouseTooltip(Text(""), padding={"x": 10, "y": -10})
label start:
call screen tooltip_test
return
screen tooltip_test:
add mtt
vbox:
textbutton "One.":
action Return(1)
hovered mtt.Action(Text("The loneliest number."))
textbutton "Two.":
action Return(2)
hovered mtt.Action(Text("Is what it takes."))
textbutton "Three.":
action Return(3)
hovered mtt.Action(Text("A crowd."))
textbutton "Hearts.":
action Return(3)
hovered mtt.Action(Image("char/arrow_confident.png"))
|