turns out 1 element in every dropdown wasnt rendering

and i never knew
This commit is contained in:
jill 2021-09-18 02:04:26 +03:00
parent 05bfac2221
commit 71e06141d0

View file

@ -106,7 +106,7 @@ end
function self.update(dt)
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)
dropdownScrollE = mix(dropdownScrollE, dropdownScroll, dt * 10)
end
@ -117,7 +117,7 @@ function self.render()
for i,v in ipairs(dropdowns) do
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
love.graphics.setColor(0.8, 0.8, 1, love.mouse.isDown(1) and 0.4 or 0.3)
end
@ -136,13 +136,14 @@ function self.render()
y = y + dropdownScrollE * h
local gi = y / h
if gi > maxDropdown or gi < 1 then
if gi > (maxDropdown + 1) or gi < 1 then
goto continue
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
love.graphics.setColor(0.8, 0.8, 1, (love.mouse.isDown(1) and 0.4 or 0.3) * a)
end
@ -160,8 +161,8 @@ function self.render()
-- scrollwheel
if #v.options > maxDropdown then
local displayed = maxDropdown / #v.options
local scroll = math.abs(dropdownScrollE) / (#v.options - maxDropdown)
local displayed = maxDropdown / (#v.options)
local scroll = math.abs(dropdownScrollE) / (#v.options - maxDropdown + 1)
local size = margin
love.graphics.setColor(1, 1, 1, 0.9)