turns out 1 element in every dropdown wasnt rendering
and i never knew
This commit is contained in:
parent
05bfac2221
commit
71e06141d0
1 changed files with 8 additions and 7 deletions
15
dropdown.lua
15
dropdown.lua
|
@ -106,7 +106,7 @@ end
|
||||||
|
|
||||||
function self.update(dt)
|
function self.update(dt)
|
||||||
if self.openDropdown ~= 0 then
|
if self.openDropdown ~= 0 then
|
||||||
dropdownScroll = math.max(dropdownScroll, -(#self.get(self.openDropdown).options - maxDropdown))
|
dropdownScroll = math.max(dropdownScroll, -(#self.get(self.openDropdown).options - maxDropdown + 1))
|
||||||
dropdownScroll = math.min(dropdownScroll, 0)
|
dropdownScroll = math.min(dropdownScroll, 0)
|
||||||
dropdownScrollE = mix(dropdownScrollE, dropdownScroll, dt * 10)
|
dropdownScrollE = mix(dropdownScrollE, dropdownScroll, dt * 10)
|
||||||
end
|
end
|
||||||
|
@ -117,7 +117,7 @@ function self.render()
|
||||||
for i,v in ipairs(dropdowns) do
|
for i,v in ipairs(dropdowns) do
|
||||||
local x, y, w, h = v.x, v.y, v.width, love.graphics.getFont():getHeight() + margin
|
local x, y, w, h = v.x, v.y, v.width, love.graphics.getFont():getHeight() + margin
|
||||||
|
|
||||||
love.graphics.setColor(0, 0, 0, 0.3)
|
love.graphics.setColor(0.06, 0.06, 0.12, 0.3)
|
||||||
if love.mouse.getX() > x and love.mouse.getX() < x + w and love.mouse.getY() > y and love.mouse.getY() < y + h then
|
if love.mouse.getX() > x and love.mouse.getX() < x + w and love.mouse.getY() > y and love.mouse.getY() < y + h then
|
||||||
love.graphics.setColor(0.8, 0.8, 1, love.mouse.isDown(1) and 0.4 or 0.3)
|
love.graphics.setColor(0.8, 0.8, 1, love.mouse.isDown(1) and 0.4 or 0.3)
|
||||||
end
|
end
|
||||||
|
@ -136,13 +136,14 @@ function self.render()
|
||||||
|
|
||||||
y = y + dropdownScrollE * h
|
y = y + dropdownScrollE * h
|
||||||
local gi = y / h
|
local gi = y / h
|
||||||
if gi > maxDropdown or gi < 1 then
|
if gi > (maxDropdown + 1) or gi < 1 then
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
local a = 1 - math.min(math.max((1 - (maxDropdown - gi)) * (1 - (math.abs(dropdownScrollE) /(#v.options - maxDropdown))), 0), 1)
|
-- 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)
|
||||||
|
|
||||||
love.graphics.setColor(0, 0, 0, 0.3 * a)
|
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
|
if mx > x and mx < x + w and my > y and my < y + h then
|
||||||
love.graphics.setColor(0.8, 0.8, 1, (love.mouse.isDown(1) and 0.4 or 0.3) * a)
|
love.graphics.setColor(0.8, 0.8, 1, (love.mouse.isDown(1) and 0.4 or 0.3) * a)
|
||||||
end
|
end
|
||||||
|
@ -160,8 +161,8 @@ function self.render()
|
||||||
-- scrollwheel
|
-- scrollwheel
|
||||||
|
|
||||||
if #v.options > maxDropdown then
|
if #v.options > maxDropdown then
|
||||||
local displayed = maxDropdown / #v.options
|
local displayed = maxDropdown / (#v.options)
|
||||||
local scroll = math.abs(dropdownScrollE) / (#v.options - maxDropdown)
|
local scroll = math.abs(dropdownScrollE) / (#v.options - maxDropdown + 1)
|
||||||
local size = margin
|
local size = margin
|
||||||
|
|
||||||
love.graphics.setColor(1, 1, 1, 0.9)
|
love.graphics.setColor(1, 1, 1, 0.9)
|
||||||
|
|
Loading…
Reference in a new issue