From 3e57daa1c82f41486e68e2ad5d2001396110913a Mon Sep 17 00:00:00 2001 From: jill Date: Sat, 18 Sep 2021 04:28:31 +0300 Subject: [PATCH] fix params not resetting when switching --- dropdown.lua | 16 ++++++---------- ease.lua | 1 + slider.lua | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/dropdown.lua b/dropdown.lua index 4fd2e46..36b84fa 100644 --- a/dropdown.lua +++ b/dropdown.lua @@ -68,10 +68,6 @@ function self.createDropdowns() local param1 = {} 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 insertDropdown(d, { @@ -82,8 +78,8 @@ function self.createDropdowns() name = 'ease1' }) 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[2] = param1[2] or (_e.params[2] and _e.params[2].default) or 1 + 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 ease.ease = function(x) return _e.f(x, param1[1], param1[2]) end @@ -105,10 +101,10 @@ function self.createDropdowns() local _e1 = ease.eases[d[dropdownId - 1].options[d[dropdownId - 1].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[2] = param1[2] 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[2] = param2[2] or (_e2.params[2] and _e2.params[2].default) or 1 + 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 ease.ease = ease.mixEase(_e1.f, _e2.f, slider.kvalue('mix'), param1, param2) elseif d[dropdownId].selected == 3 then -- create eases insertDropdown(d, { diff --git a/ease.lua b/ease.lua index fd5dfec..8a5fbce 100644 --- a/ease.lua +++ b/ease.lua @@ -36,6 +36,7 @@ for i,v in pairs(easelib) do max = 1, min = min, i = i, + name = v[1], params = params } end diff --git a/slider.lua b/slider.lua index 0953a0b..fd880a6 100644 --- a/slider.lua +++ b/slider.lua @@ -63,7 +63,7 @@ function self.createSliders() min = v.min, max = v.max, default = v.default, - name = 'param1' .. i, + name = ease1.name .. 'param1' .. i, displayname = 'Parameter ' .. v.name }) end @@ -77,7 +77,7 @@ function self.createSliders() min = v.min, max = v.max, default = v.default, - name = 'param2' .. i, + name = ease2.name .. 'param2' .. i, displayname = 'Parameter ' .. v.name }) end