core/menusystem: add a function to update widget size
This commit is contained in:
parent
b417eb5c6a
commit
e9d01d1e65
4 changed files with 23 additions and 6 deletions
|
@ -16,6 +16,11 @@ function FlowBox:new(x,y,w,h,slots_hor,slots_vert)
|
|||
-- soit un multiple du nombre de slot et de leur dimensions
|
||||
end
|
||||
|
||||
function Menu:updateWidgetSize()
|
||||
self.widget.h = math.floor( self.h / slots_vert )
|
||||
self.widget.w = math.floor( self.w / slots_hor )
|
||||
end
|
||||
|
||||
function FlowBox:update(dt)
|
||||
local col, line = self:getCoord(self.widget.selected)
|
||||
local begincol, beginline = self:getCoord(self.begin)
|
||||
|
|
|
@ -10,8 +10,6 @@ function GridBox:new(x,y,w,h,slots_hor,slots_vert)
|
|||
self.slots_hor = slots_hor
|
||||
self.slots_vert = slots_vert
|
||||
self.begin = 1
|
||||
self.widget.h = math.floor( self.h / slots_vert )
|
||||
self.widget.w = math.floor( self.w / slots_hor )
|
||||
self.h = slots_vert * self.widget.h -- On fait en sorte que la hauteur
|
||||
self.w = slots_hor * self.widget.w -- et la largeur
|
||||
-- soit un multiple du nombre de slot et de leur dimensions
|
||||
|
@ -31,6 +29,11 @@ function GridBox:new(x,y,w,h,slots_hor,slots_vert)
|
|||
end
|
||||
end
|
||||
|
||||
function Menu:updateWidgetSize()
|
||||
self.widget.h = math.floor( self.h / slots_vert )
|
||||
self.widget.w = math.floor( self.w / slots_hor )
|
||||
end
|
||||
|
||||
function GridBox:update(dt)
|
||||
self.begin = 1
|
||||
local slotID = self:getSlotbyCoord(self.cursor.x, self.cursor.y)
|
||||
|
|
|
@ -7,12 +7,15 @@ function ListBox:new(x,y,w,h,slots)
|
|||
ListBox.super.new(self, x, y, w, h)
|
||||
self.slots = slots
|
||||
self.begin = 1
|
||||
self.widget.w = self.w
|
||||
self.widget.h = math.floor( self.h / slots )
|
||||
self.h = slots * self.widget.h -- On fait en sorte que la hauteur
|
||||
-- soit un multiple du nombre de slot et de leur hauteur
|
||||
end
|
||||
|
||||
function Menu:updateWidgetSize()
|
||||
self.widget.h = math.floor( self.h / slots )
|
||||
self.widget.w = self.w
|
||||
end
|
||||
|
||||
function ListBox:update(dt)
|
||||
if self.widget.selected < self.begin then
|
||||
self.begin = self.widget.selected
|
||||
|
|
|
@ -11,8 +11,7 @@ function Menu:new(x,y,w,h)
|
|||
self.widget.selected = 0
|
||||
self.widget.selectedPrevious = 0
|
||||
self.widget.cancel = 0
|
||||
self.widget.h = 0
|
||||
self.widget.w = 0
|
||||
self:setWidgetSize()
|
||||
|
||||
self.isDestroyed = false
|
||||
self.haveFocus = false
|
||||
|
@ -32,6 +31,11 @@ function Menu:setCancelWidget(id)
|
|||
self.widget.cancel = #self.widget.list
|
||||
end
|
||||
|
||||
function Menu:updateWidgetSize()
|
||||
self.widget.h = 0
|
||||
self.widget.w = 0
|
||||
end
|
||||
|
||||
function Menu:getWidgetSize(id)
|
||||
return self.widget.h, self.widget.w
|
||||
end
|
||||
|
@ -56,6 +60,8 @@ function Menu:resize(x,y,w,h)
|
|||
self.y = y
|
||||
self.w = w
|
||||
self.h = h
|
||||
|
||||
self:updateWidgetSize()
|
||||
end
|
||||
|
||||
function Menu:destroy()
|
||||
|
|
Loading…
Reference in a new issue