fix params not resetting when switching

This commit is contained in:
jill 2021-09-18 04:28:31 +03:00
parent 0edd69d87d
commit 3e57daa1c8
3 changed files with 9 additions and 12 deletions

View file

@ -68,10 +68,6 @@ function self.createDropdowns()
local param1 = {} local param1 = {}
local param2 = {} local param2 = {}
param1[1] = slider.kvalue('param11')
param1[2] = slider.kvalue('param12')
param2[1] = slider.kvalue('param21')
param2[2] = slider.kvalue('param22')
if d[dropdownId].selected == 1 then -- preview ease if d[dropdownId].selected == 1 then -- preview ease
insertDropdown(d, { insertDropdown(d, {
@ -82,8 +78,8 @@ function self.createDropdowns()
name = 'ease1' name = 'ease1'
}) })
local _e = ease.eases[d[dropdownId].options[d[dropdownId].selected]] local _e = ease.eases[d[dropdownId].options[d[dropdownId].selected]]
param1[1] = param1[1] or (_e.params[1] and _e.params[1].default) or 1 param1[1] = slider.kvalue(_e.name .. 'param11') or (_e.params[1] and _e.params[1].default) or 1
param1[2] = param1[2] or (_e.params[2] and _e.params[2].default) or 1 param1[2] = slider.kvalue(_e.name .. 'param12') or (_e.params[2] and _e.params[2].default) or 1
ease.ease = function(x) ease.ease = function(x)
return _e.f(x, param1[1], param1[2]) return _e.f(x, param1[1], param1[2])
end end
@ -105,10 +101,10 @@ function self.createDropdowns()
local _e1 = ease.eases[d[dropdownId - 1].options[d[dropdownId - 1].selected]] local _e1 = ease.eases[d[dropdownId - 1].options[d[dropdownId - 1].selected]]
local _e2 = ease.eases[d[dropdownId].options[d[dropdownId].selected]] local _e2 = ease.eases[d[dropdownId].options[d[dropdownId].selected]]
param1[1] = param1[1] or (_e1.params[1] and _e1.params[1].default) or 1 param1[1] = slider.kvalue(_e1.name .. 'param11') or (_e1.params[1] and _e1.params[1].default) or 1
param1[2] = param1[2] or (_e1.params[2] and _e1.params[2].default) or 1 param1[2] = slider.kvalue(_e1.name .. 'param12') or (_e1.params[2] and _e1.params[2].default) or 1
param2[1] = param2[1] or (_e2.params[1] and _e2.params[1].default) or 1 param2[1] = slider.kvalue(_e2.name .. 'param21') or (_e2.params[1] and _e2.params[1].default) or 1
param2[2] = param2[2] or (_e2.params[2] and _e2.params[2].default) or 1 param2[2] = slider.kvalue(_e2.name .. 'param22') or (_e2.params[2] and _e2.params[2].default) or 1
ease.ease = ease.mixEase(_e1.f, _e2.f, slider.kvalue('mix'), param1, param2) ease.ease = ease.mixEase(_e1.f, _e2.f, slider.kvalue('mix'), param1, param2)
elseif d[dropdownId].selected == 3 then -- create eases elseif d[dropdownId].selected == 3 then -- create eases
insertDropdown(d, { insertDropdown(d, {

View file

@ -36,6 +36,7 @@ for i,v in pairs(easelib) do
max = 1, max = 1,
min = min, min = min,
i = i, i = i,
name = v[1],
params = params params = params
} }
end end

View file

@ -63,7 +63,7 @@ function self.createSliders()
min = v.min, min = v.min,
max = v.max, max = v.max,
default = v.default, default = v.default,
name = 'param1' .. i, name = ease1.name .. 'param1' .. i,
displayname = 'Parameter ' .. v.name displayname = 'Parameter ' .. v.name
}) })
end end
@ -77,7 +77,7 @@ function self.createSliders()
min = v.min, min = v.min,
max = v.max, max = v.max,
default = v.default, default = v.default,
name = 'param2' .. i, name = ease2.name .. 'param2' .. i,
displayname = 'Parameter ' .. v.name displayname = 'Parameter ' .. v.name
}) })
end end