From f7e1beae68627fec22c62ae5cc9194ca4725481a Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 2 Jan 2022 15:18:23 +0100 Subject: [PATCH] fix: make the box of boxedmenu part of its texture --- .../game/modules/gui/boxedmenu.lua | 37 ++++--------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/sonic-radiance.love/game/modules/gui/boxedmenu.lua b/sonic-radiance.love/game/modules/gui/boxedmenu.lua index 6812251..3789d9c 100644 --- a/sonic-radiance.love/game/modules/gui/boxedmenu.lua +++ b/sonic-radiance.love/game/modules/gui/boxedmenu.lua @@ -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) self.paddingLeft = 12 self.paddingRight = 4 + self.canvas.padding = 24 self.cursorTexture = love.graphics.newImage("assets/gui/cursor-menulist.png") self.cursorTransition = 0 @@ -27,35 +28,9 @@ end function BoxedList:update(dt) BoxedList.super.update(self, dt) - self:updateCursorPosition(dt) end -function BoxedList:updateCursorPosition(dt) - 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() +function BoxedList:drawTexture() if (self.isBoxed) then local dy = 8 if (self.smallborder) then @@ -63,9 +38,13 @@ function BoxedList:draw() end local w, h = self.box:getDimensions() 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 - 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 return BoxedList