fix: make the box of boxedmenu part of its texture
This commit is contained in:
parent
e35d89f21e
commit
f7e1beae68
1 changed files with 8 additions and 29 deletions
|
@ -7,6 +7,7 @@ function BoxedList:new(name, x, y, w, slotNumber, isBoxed, smallborder)
|
||||||
BoxedList.super.new(self, name, "small", x, y, w, slotNumber, 0)
|
BoxedList.super.new(self, name, "small", x, y, w, slotNumber, 0)
|
||||||
self.paddingLeft = 12
|
self.paddingLeft = 12
|
||||||
self.paddingRight = 4
|
self.paddingRight = 4
|
||||||
|
self.canvas.padding = 24
|
||||||
|
|
||||||
self.cursorTexture = love.graphics.newImage("assets/gui/cursor-menulist.png")
|
self.cursorTexture = love.graphics.newImage("assets/gui/cursor-menulist.png")
|
||||||
self.cursorTransition = 0
|
self.cursorTransition = 0
|
||||||
|
@ -27,35 +28,9 @@ end
|
||||||
|
|
||||||
function BoxedList:update(dt)
|
function BoxedList:update(dt)
|
||||||
BoxedList.super.update(self, dt)
|
BoxedList.super.update(self, dt)
|
||||||
self:updateCursorPosition(dt)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function BoxedList:updateCursorPosition(dt)
|
function BoxedList:drawTexture()
|
||||||
local relativecursor = self.widget.selected - self.view.firstSlot
|
|
||||||
|
|
||||||
local transition = self.cursorTransition - relativecursor
|
|
||||||
if math.abs(transition) < 0.1 then
|
|
||||||
self.cursorTransition = relativecursor
|
|
||||||
else
|
|
||||||
local speed = dt * 45
|
|
||||||
local movement = ((relativecursor) - (self.cursorTransition))
|
|
||||||
self.cursorTransition = (self.cursorTransition) + movement * speed
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function BoxedList:drawCursor()
|
|
||||||
local x, y = self:getCursorPosition()
|
|
||||||
love.graphics.draw(self.cursorTexture, x, y)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BoxedList:getCursorPosition()
|
|
||||||
local addition = self.lineHeight
|
|
||||||
local x = self.x + 6
|
|
||||||
local y = self.y + ((self.cursorTransition) * addition) + 1
|
|
||||||
return x, y
|
|
||||||
end
|
|
||||||
|
|
||||||
function BoxedList:draw()
|
|
||||||
if (self.isBoxed) then
|
if (self.isBoxed) then
|
||||||
local dy = 8
|
local dy = 8
|
||||||
if (self.smallborder) then
|
if (self.smallborder) then
|
||||||
|
@ -63,9 +38,13 @@ function BoxedList:draw()
|
||||||
end
|
end
|
||||||
local w, h = self.box:getDimensions()
|
local w, h = self.box:getDimensions()
|
||||||
local diff = (w-self.w)/2
|
local diff = (w-self.w)/2
|
||||||
love.graphics.draw(self.box, self.x - self.ox - diff, self.y - self.oy - dy)
|
love.graphics.draw(self.box, self.canvas.padding - diff, self.canvas.padding - dy)
|
||||||
end
|
end
|
||||||
BoxedList.super.draw(self)
|
BoxedList.super.drawTexture(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BoxedList:drawGraphicalCursor(x, y, w, h)
|
||||||
|
love.graphics.draw(self.cursorTexture, x, y + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
return BoxedList
|
return BoxedList
|
||||||
|
|
Loading…
Reference in a new issue