tweak dropdown visuals
This commit is contained in:
parent
e6565f5144
commit
3c3cc1c6d7
1 changed files with 8 additions and 2 deletions
10
dropdown.lua
10
dropdown.lua
|
@ -3,6 +3,7 @@ local self = {}
|
||||||
local dropdowns = {}
|
local dropdowns = {}
|
||||||
|
|
||||||
local dropdownValueCache = {}
|
local dropdownValueCache = {}
|
||||||
|
local dropdownScrollCache = {}
|
||||||
|
|
||||||
local maxDropdown = 16
|
local maxDropdown = 16
|
||||||
|
|
||||||
|
@ -178,6 +179,9 @@ function self.render()
|
||||||
love.graphics.rectangle('line', x, y, w, h)
|
love.graphics.rectangle('line', x, y, w, h)
|
||||||
|
|
||||||
love.graphics.setColor(1, 1, 1, 1 * a)
|
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)
|
love.graphics.print(v.options[i], x + 2, y + 2)
|
||||||
|
|
||||||
::continue::
|
::continue::
|
||||||
|
@ -206,8 +210,8 @@ function self.mousepressed(x, y, m)
|
||||||
if m == 1 then
|
if m == 1 then
|
||||||
self.openDropdown = i
|
self.openDropdown = i
|
||||||
clickedDropdown = true
|
clickedDropdown = true
|
||||||
dropdownScroll = 0
|
dropdownScroll = dropdownScrollCache[i] or 0
|
||||||
dropdownScrollE = 0
|
dropdownScrollE = dropdownScrollCache[i] or 0
|
||||||
elseif m == 3 then
|
elseif m == 3 then
|
||||||
dropdowns[i].selected = math.random(1, #dropdowns[i].options)
|
dropdowns[i].selected = math.random(1, #dropdowns[i].options)
|
||||||
createUI()
|
createUI()
|
||||||
|
@ -221,6 +225,7 @@ function self.mousepressed(x, y, m)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not clickedDropdown and m == 1 then
|
if not clickedDropdown and m == 1 then
|
||||||
|
dropdownScrollCache[self.openDropdown] = dropdownScroll
|
||||||
self.openDropdown = 0
|
self.openDropdown = 0
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -234,6 +239,7 @@ function self.mousereleased(x, y, m)
|
||||||
v.selected = math.floor((y - v.y) / h - dropdownScrollE)
|
v.selected = math.floor((y - v.y) / h - dropdownScrollE)
|
||||||
self.openDropdown = 0
|
self.openDropdown = 0
|
||||||
dropdownValueCache[v.name] = {selected = v.selected}
|
dropdownValueCache[v.name] = {selected = v.selected}
|
||||||
|
dropdownScrollCache[i] = dropdownScroll
|
||||||
createUI()
|
createUI()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue