diff --git a/conf.lua b/conf.lua index f9c66a3..e4d7dda 100644 --- a/conf.lua +++ b/conf.lua @@ -1,5 +1,18 @@ function love.conf(t) + t.identity = 'box-of-eases' + t.version = '11.3' + t.window.resizable = true t.window.title = 'Box of Eases' t.window.icon = 'logo.png' + t.window.msaa = 5 + + t.modules.audio = false + t.modules.data = false + t.modules.joystick = false + t.modules.math = false + t.modules.physics = false + t.modules.sound = false + t.modules.thread = false + t.modules.video = false end diff --git a/dropdown.lua b/dropdown.lua index 11904cd..8fe72dd 100644 --- a/dropdown.lua +++ b/dropdown.lua @@ -48,6 +48,7 @@ local function insertDropdown(tab, f) dropdownId = dropdownId + 1 f.selected = (self.kget(f.name) or dropdownValueCache[f.name] or {selected = 1}).selected f.selected = (f.selected - 1) % #f.options + 1 + f.open = (self.kget(f.name) or {open = 0}).open return table.insert(tab, f) end function self.createDropdowns() @@ -110,6 +111,14 @@ function self.update(dt) dropdownScroll = math.min(dropdownScroll, 0) dropdownScrollE = mix(dropdownScrollE, dropdownScroll, dt * 10) end + + for i, v in ipairs(dropdowns) do + if i == self.openDropdown then + v.open = mix(v.open, 1, dt * 14) + else + v.open = mix(v.open, 0, dt * 20) + end + end end function self.render() @@ -127,21 +136,21 @@ function self.render() love.graphics.rectangle('line', x, y, w, h) love.graphics.print(self.selected(i), x + margin/2, y + margin/2) - love.graphics.rectangle('line', x + w - h, y, h, h) + -- love.graphics.rectangle('line', x + w - h, y, h, h) love.graphics.polygon('line', x + w - h/2 + 0.3 * h, y + h/2 - 0.3 * h, x + w - h/2 - 0.3 * h, y + h/2 - 0.3 * h, x + w - h/2, y + h/2 + 0.3 * h) - if self.openDropdown == i then + if self.openDropdown == i or v.open > 0.01 then for i,o in ipairs(v.options) do - local x, y, w, h = x, y + i * h, w, h + local x, y, w, h = x, y + ((i - 1) * v.open + 1) * h, w, h * v.open - y = y + dropdownScrollE * h + y = y + dropdownScrollE * h * v.open local gi = y / h if gi > (maxDropdown + 1) or gi < 1 then goto continue end -- help - local a = (1 - math.min(math.max((1 - (maxDropdown - gi)) * (1 - (math.abs(dropdownScrollE) / (#v.options - maxDropdown + 1))), 0), 1)) * math.max(math.min(gi - 1, 1), 0) + local a = (1 - math.min(math.max((1 - (maxDropdown - gi)) * (1 - (math.abs(dropdownScrollE) / (#v.options - maxDropdown + 1))), 0), 1)) * math.max(math.min(gi - 1, 1), 0) * v.open love.graphics.setColor(0.06, 0.06, 0.12, 0.3 * a) if mx > x and mx < x + w and my > y and my < y + h then @@ -165,8 +174,8 @@ function self.render() local scroll = math.abs(dropdownScrollE) / (#v.options - maxDropdown + 1) local size = margin - love.graphics.setColor(1, 1, 1, 0.9) - love.graphics.rectangle('fill', x + w - size, y + h + scroll * (1 - displayed) * (maxDropdown - 1) * h, size, displayed * (maxDropdown - 1) * h) + love.graphics.setColor(1, 1, 1, 0.9 * v.open) + love.graphics.rectangle('fill', x + w - size, y + h + scroll * (1 - displayed) * (maxDropdown - 1) * h * v.open, size, displayed * (maxDropdown - 1) * h * v.open) end end end diff --git a/graph.lua b/graph.lua index 0ae893d..4937438 100644 --- a/graph.lua +++ b/graph.lua @@ -3,6 +3,10 @@ local self = {} local quality = 256 local graph = {} +self.touchtimer = 0 + +local timer = 0 + function self.update(dt) for i = 1, quality do local a = (i - 1) / (quality - 1) @@ -18,6 +22,22 @@ function self.update(dt) end graph[i] = mix(v, b, math.min(dt * 18, 1)) end + self.touchtimer = mix(self.touchtimer, 0, dt * 2) + + -- lots of math just for the timer + -- may need to abstract this out, somehow + -- todo + local sw, sh = love.graphics.getDimensions() + local csize = 10 -- preview point size + local size = math.min((sw - outerpadding) - ((dropdown.kget('ease2') or dropdown.kget('ease1')).x + dropdownWidth + padding), sh - outerpadding * 2 - padding * 3 - csize) + local x, y, w, h = sw - outerpadding - size, outerpadding, size, size + local mx, my = love.mouse.getPosition() + + if not (love.mouse.isDown(1) and mx > x and mx < x + w and my > y and my < y + h) then + timer = (timer + dt) % 2 + else + timer = mix(timer, (mx - x) / w, dt * 14) + end end function self.render() @@ -43,12 +63,12 @@ function self.render() -- mixease point if mode == 2 then - love.graphics.setColor(1, 1, 1, 0.8) - love.graphics.line(x + margin + mixpoint * w, y, x + margin + mixpoint * w, y + h) + love.graphics.setColor(1, 1, 1, 0.2 + self.touchtimer * 0.6) + love.graphics.line(x + margin + oldmixpoint * w, y, x + margin + oldmixpoint * w, y + h) end -- preview point - local t = love.timer.getTime() % 1 + local t = timer % 1 love.graphics.setColor(0.4, 0.4, 1, 0.4) love.graphics.line(x + margin + t * w, y, x + margin + t * w, y + h) @@ -81,7 +101,7 @@ function self.render() local a1 = ease.ease(t) local a2 = ease.ease(math.max(math.min(t - 0.1, 1), 0)) local da = a1 - if love.timer.getTime() % 2 < 1 and math.floor(ease.ease(0) + 0.5) ~= math.floor(ease.ease(1) + 0.5) then + if timer % 2 > 1 and math.floor(ease.ease(0) + 0.5) ~= math.floor(ease.ease(1) + 0.5) then da = 1 - da end if minEase then diff --git a/main.lua b/main.lua index a7faa9b..9449a50 100644 --- a/main.lua +++ b/main.lua @@ -94,6 +94,7 @@ function love.draw() if mx > x and mx < x + w and my > y and my < y + h and love.mouse.isDown(1) and dropdown.openDropdown == 0 then mixpoint = (mx - x) / w + graph.touchtimer = 1 dropdown.createDropdowns() end end