Parse positioned tooltips correctly

This commit is contained in:
luk3yx 2021-03-09 10:27:26 +13:00
parent e9302239fb
commit df9e9e93a5
4 changed files with 34 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -495,6 +495,12 @@ tooltip:
- [tooltip_text, string]
- [bgcolor, string]
- [fontcolor, string]
- - - [x, number]
- [y, number]
- - [w, number]
- [h, number]
- [tooltip_text, string]
- [bgcolor, string]
- - [gui_element_name, string]
- [tooltip_text, string]
- [bgcolor, string]
@ -504,15 +510,9 @@ tooltip:
- - [w, number]
- [h, number]
- [tooltip_text, string]
- [bgcolor, string]
- - [gui_element_name, string]
- [tooltip_text, string]
- [bgcolor, string]
- - - [x, number]
- [y, number]
- - [w, number]
- [h, number]
- [tooltip_text, string]
- - [gui_element_name, string]
- [tooltip_text, string]
vertlabel:

View File

@ -140,6 +140,17 @@ def _textlist_hook(params):
yield params[:5]
return ()
# Swap order of tooltip definitions around to fix position parsing
@hook('tooltip', passive=True)
def _tooltip_hook(params):
if params[0][0] == 'gui_element_name':
params[0] = [('x', 'number'), ('y', 'number')]
params.insert(1, [('w', 'number'), ('h', 'number')])
else:
params[0] = ('gui_element_name', 'string')
del params[1]
return ()
# Work around inconsistent documentation for model[]
@hook('model')
def _model_hook(params):

View File

@ -84,6 +84,8 @@ local fs = [[
bgcolor[blue]
bgcolor[blue;true]
bgcolor[blue;both;green]
tooltip[1,2;3,4;text]
tooltip[elem;text;bgcolor]
]]
fs = ('\n' .. fs):gsub('\n[ \n]*', '')
@ -186,6 +188,20 @@ test_parse_unparse(fs, {
fullscreen = "both",
fbgcolor = "green",
},
{
type = "tooltip",
x = 1,
y = 2,
w = 3,
h = 4,
tooltip_text = "text",
},
{
type = "tooltip",
gui_element_name = "elem",
tooltip_text = "text",
bgcolor = "bgcolor",
},
})
local function permutations(elem_s, elem, ...)