tweak dropdown visuals

This commit is contained in:
jill 2021-09-18 12:16:20 +03:00
parent e6565f5144
commit 3c3cc1c6d7
1 changed files with 8 additions and 2 deletions

View File

@ -3,6 +3,7 @@ local self = {}
local dropdowns = {}
local dropdownValueCache = {}
local dropdownScrollCache = {}
local maxDropdown = 16
@ -178,6 +179,9 @@ function self.render()
love.graphics.rectangle('line', x, y, w, h)
love.graphics.setColor(1, 1, 1, 1 * a)
if i == v.selected then
love.graphics.setColor(0.8, 0.8, 1, 1 * a)
end
love.graphics.print(v.options[i], x + 2, y + 2)
::continue::
@ -206,8 +210,8 @@ function self.mousepressed(x, y, m)
if m == 1 then
self.openDropdown = i
clickedDropdown = true
dropdownScroll = 0
dropdownScrollE = 0
dropdownScroll = dropdownScrollCache[i] or 0
dropdownScrollE = dropdownScrollCache[i] or 0
elseif m == 3 then
dropdowns[i].selected = math.random(1, #dropdowns[i].options)
createUI()
@ -221,6 +225,7 @@ function self.mousepressed(x, y, m)
end
if not clickedDropdown and m == 1 then
dropdownScrollCache[self.openDropdown] = dropdownScroll
self.openDropdown = 0
return true
end
@ -234,6 +239,7 @@ function self.mousereleased(x, y, m)
v.selected = math.floor((y - v.y) / h - dropdownScrollE)
self.openDropdown = 0
dropdownValueCache[v.name] = {selected = v.selected}
dropdownScrollCache[i] = dropdownScroll
createUI()
end
end