revise param algorithm in buttons

makes copy to clipboard more compact, less unnecessary params
This commit is contained in:
jill 2021-09-19 19:38:48 +03:00
parent 171e5e69f4
commit e3ddf63823

View file

@ -14,6 +14,14 @@ function self.kget(key)
end
end
local function nillify(tab) -- dumb hack. turns `false` into `nil`
local t = {}
for i,v in ipairs(tab) do
if v then table.insert(t, v) end
end
return t
end
local buttonId
local function insertButton(tab, f)
buttonId = buttonId + 1
@ -41,11 +49,11 @@ function self.createButtons()
if mode == modes.preview then
local e = ease.eases[dropdown.kselected('ease1')]
param1[1] = slider.kvalue(e.name .. 'param11') or (e.params[1] and e.params[1].default) or 1
param1[2] = slider.kvalue(e.name .. 'param12') or (e.params[2] and e.params[2].default) or 1
param1[1] = (slider.kvalue(e.name .. 'param11') ~= (e1.params[1] and e1.params[1].default) and slider.kvalue(e.name .. 'param11'))
param1[2] = (slider.kvalue(e.name .. 'param12') ~= e.params[2].default and slider.kvalue(e.name .. 'param12'))
local p1 = ''
for i,v in ipairs(param1) do
for i,v in ipairs(nillify(param1)) do
p1 = p1 .. (i > 1 and (', ' .. v) or v)
end
@ -54,17 +62,17 @@ function self.createButtons()
local e1 = ease.eases[dropdown.kselected('ease1')]
local e2 = ease.eases[dropdown.kselected('ease2')]
param1[1] = slider.kvalue(e1.name .. 'param11') or (e1.params[1] and e1.params[1].default) or 1
param1[2] = slider.kvalue(e1.name .. 'param12') or (e1.params[2] and e1.params[2].default) or 1
param2[1] = slider.kvalue(e2.name .. 'param21') or (e2.params[1] and e2.params[1].default) or 1
param2[2] = slider.kvalue(e2.name .. 'param22') or (e2.params[2] and e2.params[2].default) or 1
param1[1] = (slider.kvalue(e1.name .. 'param11') ~= (e1.params[1] and e1.params[1].default) and slider.kvalue(e1.name .. 'param11'))
param1[2] = (slider.kvalue(e1.name .. 'param12') ~= (e1.params[2] and e1.params[2].default) and slider.kvalue(e1.name .. 'param12'))
param2[1] = (slider.kvalue(e2.name .. 'param21') ~= (e2.params[1] and e2.params[1].default) and slider.kvalue(e2.name .. 'param11'))
param2[2] = (slider.kvalue(e2.name .. 'param22') ~= (e2.params[2] and e2.params[2].default) and slider.kvalue(e2.name .. 'param12'))
local p1 = ''
for i,v in ipairs(param1) do
for i,v in ipairs(nillify(param1)) do
p1 = p1 .. (i > 1 and (', ' .. v) or v)
end
local p2 = ''
for i,v in ipairs(param2) do
for i,v in ipairs(nillify(param2)) do
p2 = p2 .. (i > 1 and (', ' .. v) or v)
end
@ -73,17 +81,17 @@ function self.createButtons()
local e1 = ease.eases[dropdown.kselected('ease1')]
local e2 = ease.eases[dropdown.kselected('ease2')]
param1[1] = slider.kvalue(e1.name .. 'param11') or (e1.params[1] and e1.params[1].default) or 1
param1[2] = slider.kvalue(e1.name .. 'param12') or (e1.params[2] and e1.params[2].default) or 1
param2[1] = slider.kvalue(e2.name .. 'param21') or (e2.params[1] and e2.params[1].default) or 1
param2[2] = slider.kvalue(e2.name .. 'param22') or (e2.params[2] and e2.params[2].default) or 1
param1[1] = (slider.kvalue(e1.name .. 'param11') ~= (e1.params[1] and e1.params[1].default) and slider.kvalue(e1.name .. 'param11'))
param1[2] = (slider.kvalue(e1.name .. 'param12') ~= (e1.params[2] and e1.params[2].default) and slider.kvalue(e1.name .. 'param12'))
param2[1] = (slider.kvalue(e2.name .. 'param21') ~= (e2.params[1] and e2.params[1].default) and slider.kvalue(e2.name .. 'param11'))
param2[2] = (slider.kvalue(e2.name .. 'param22') ~= (e2.params[2] and e2.params[2].default) and slider.kvalue(e2.name .. 'param12'))
local p1 = ''
for i,v in ipairs(param1) do
for i,v in ipairs(nillify(param1)) do
p1 = p1 .. (i > 1 and (', ' .. v) or v)
end
local p2 = ''
for i,v in ipairs(param2) do
for i,v in ipairs(nillify(param2)) do
p2 = p2 .. (i > 1 and (', ' .. v) or v)
end