跳到主要内容

说明框(tooltip)

游标停在按钮上时跳出的说明框。说明文字写在按钮的 tooltip:,或由插件提供;画面的 tooltip 区段决定说明框长什么样。没有写 tooltip: 的画面不显示说明框。

最小例子​

把下面的内容存成 plugins/CloudUI/screens/tooltip_demo.yml:

portrait:
enabled: false
camera:
animation: false
tooltip:
frame: proxy/tooltip.png
border: 24
width: 380
padding: 20
font: text
title-size: 22
size: 16
title-height: 36
line-height: 24
color: '#E2EEF4'
elements:
quest:
type: button
image: main/tile.png
hover: main/tile_hover.png
x: 878
y: 300
hit: [882, 304, 156, 182]
tooltip:
- '每日任务'
- '&7每天早上六点重置'
- '&7完成后可以领取奖励'
click:
left: ['message: <gray>你点了每日任务']
quest-name:
type: text
text: '任务'
font: title
size: 26
color: '#E2EEF4'
align: center
x: 960
y: 412
close:
type: button
image: main/close.png
hover: main/close_hover.png
x: 842
y: 524
hit: [846, 528, 228, 44]
click:
left: ['close']

在游戏里怎么看到​

  1. 文件放进 plugins/CloudUI/screens/。
  2. 执行 /cui reload。
  3. 执行 /cui open tooltip_demo,把游标停在「任务」卡片上。

游标旁边跳出说明框:第一行「每日任务」是标题,字比较大;下面两行是灰色的说明。「关闭」按钮没有写 tooltip:,停在上面不会跳。

按钮的 tooltip: 是一个列表,第一行当标题,其余每项一行,可以用 & 颜色码和变量。

两种样式​

style 决定说明框怎么画:

  • frame:一张九宫格外框图片拉伸成说明框的大小。写了 frame: 而没写 style 时就是这种。
  • card:卡片。物品图标在左上的框里转,名称在旁边,下面一条分隔线,两道流光沿外框绕行(1.6.0 起)。没写 frame: 也没写 style 时就是这种。

config.yml 的 tooltip.style 默认是 card,这时所有画面的说明框都画成卡片,上面的例子看到的也是卡片。想照每个画面自己的写法(frame 的画面用拉伸外框),把它改成 screen。

卡片的写法:

tooltip:
style: card
art: tooltip/default
icon: 64
spin: 90
lights: 2
speed: 250
title-color: '#F2E6C4'

把这一段换掉例子里的 tooltip: 区段,/cui reload 后就是卡片样式。卡片用的图放在 plugins/CloudUI/images/tooltip/<样式名>/,内置 default。

全部选项​

两种样式都有的:

选项默认说明
style看有没有 frameframe 或 card,写别的会报错
width320(卡片 400)说明框宽度,至少 64
padding20(卡片 28)文字离外框的距离
fonttext字体
title-size24第一行(标题)的字体大小
size16其余行的字体大小
line-height25每行的高度
title-height40标题行的高度
max-lines14(卡片 32)最多几行(1–32)
gap14与游标的距离
color#E2EEF4文字颜色,#RRGGBB
title-color同 color标题颜色

frame 样式用的:

选项默认说明
frame必填九宫格外框图片,相对 plugins/CloudUI/images/ 的路径
border16外框九宫格的边宽

card 样式用的:

选项默认说明
arttooltip/default卡片图所在的文件夹(images/ 下),里面有 top.png、middle.png、bottom.png、divider.png、well.png 和流光图
icon64左上物品图标的大小(0–128),0 = 不放图标
spin90图标每秒转几度
lights2绕外框的流光数量(0–2)
speed250流光每秒走几像素(20–2000)

常见问题​

游标停在按钮上什么都没跳。 先看画面有没有 tooltip: 区段,没有就不显示。再看按钮自己有没有写 tooltip: 列表。

/cui reload 提示 elements.tooltip.frame is required。 style: frame 一定要写 frame: 图片。不想准备外框图就改用 style: card。

写了 frame 外框,游戏里却是卡片。 config.yml 的 tooltip.style 是 card 时一律画成卡片。改成 screen 再 /cui reload。

0:000:00