feat: add everything needed for fancymenus

This commit is contained in:
Kazhnuz 2021-08-28 18:58:38 +02:00
parent ae13c1d5ae
commit 4daa0b16eb
2 changed files with 14 additions and 9 deletions

View file

@ -79,24 +79,25 @@ end
-- DRAW FUNCTIONS
-- draw the menu and the rest of content.
function ListBox:getListPart(relativeNumber)
return 0, (relativeNumber) * self.widgetSize.h, self.w, self.widgetSize.h
end
function ListBox:drawTexture()
self.view:updateFirstSlot(self.widget:getSelected())
local widgety = self.canvas.padding
local listWidget = self.widget:getList(self.view.firstSlot, self.view.slotNumber)
for _, widget in ipairs(listWidget) do
widget:drawWidget(self.canvas.padding, widgety, self.w, self.widgetSize.h)
widgety = widgety + self.widgetSize.h
for i, widget in ipairs(listWidget) do
local x, y, w, h = self:getListPart(i - 1)
self:drawWidgetBackground(x + self.canvas.padding, y + self.canvas.padding, w, h)
widget:drawWidget(x + self.canvas.padding, y + self.canvas.padding, w, h)
end
end
function ListBox:getGraphicalCursorPosition()
self.view:updateFirstSlot(self.widget:getSelected())
local w, h = self:getWidgetSize()
local y = (self.widget:getSelected() - self.view.firstSlot) * h
local x, y, w, h = self:getListPart(self.widget:getSelected() - self.view.firstSlot)
return self.x - self.ox,self.y + y - self.oy, w, h
return self.x - self.ox + x,self.y + y - self.oy, w, h
end
return ListBox

View file

@ -166,6 +166,10 @@ function Menu:drawCanvas()
end
function Menu:drawWidgetBackground(x, y, w, h)
end
-- WIDGET FUNCTIONS
-- Handle widgets of the functions