make copy to clipboard button

This commit is contained in:
jill 2021-09-19 15:04:31 +03:00
parent 0266e2c2e9
commit 15316b918f

View file

@ -24,17 +24,75 @@ function self.createButtons()
local s = {} local s = {}
buttonId = 0 buttonId = 0
insertButton(s, { if mode == modes.mix or mode == modes.preview or mode == modes.multiply then
x = outerpadding, insertButton(s, {
y = love.graphics.getHeight() - outerpadding - fontHeight * 4 - padding * 2 - 32, x = outerpadding,
size = 32, y = love.graphics.getHeight() - outerpadding - fontHeight * 4 - padding * 2 - 32,
name = 'clipboard', size = 32,
displayname = 'Copy to Clipboard', name = 'clipboard',
tooltip = 'Copy to Clipboard', displayname = 'Copy to Clipboard',
func = function() tooltip = 'Copy to Clipboard',
love.system.setClipboardText('ease function goes here') func = function()
end local s = ''
})
local param1 = {}
local param2 = {}
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
local p1 = ''
for i,v in ipairs(param1) do
p1 = p1 .. (i > 1 and (', ' .. v) or v)
end
s = e.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '')
elseif mode == modes.mix then
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
local p1 = ''
for i,v in ipairs(param1) do
p1 = p1 .. (i > 1 and (', ' .. v) or v)
end
local p2 = ''
for i,v in ipairs(param2) do
p2 = p2 .. (i > 1 and (', ' .. v) or v)
end
s = 'mixEase(' .. e1.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '') .. ', ' .. e2.name .. (p2 ~= '' and ('.params(' .. p2 .. ')') or '') .. ', ' .. slider.kvalue('mix') .. ')'
elseif mode == modes.multiply then
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
local p1 = ''
for i,v in ipairs(param1) do
p1 = p1 .. (i > 1 and (', ' .. v) or v)
end
local p2 = ''
for i,v in ipairs(param2) do
p2 = p2 .. (i > 1 and (', ' .. v) or v)
end
s = 'function(x) ' .. e2.name .. (p2 ~= '' and ('.params(' .. p2 .. ')') or '') .. '(' .. e1.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '') .. '(x)) end'
end
love.system.setClipboardText(s)
end
})
end
buttons = s buttons = s
end end