core/menusystem: declare slots variables before calling the parent new()

This commit is contained in:
Kazhnuz 2019-02-11 20:04:24 +01:00
parent e3cc372340
commit 44bf09aa88
4 changed files with 9 additions and 9 deletions

View file

@ -4,10 +4,10 @@ local Menu = require(cwd .. "parent")
FlowBox = Menu:extend()
function FlowBox:new(menusystem, name, x, y, w, h, slots_hor, slots_vert)
ListBox.super.new(self, menusystem, name, x, y, w, h)
self.slots = slots_hor * slots_vert
self.slots_hor = slots_hor
self.slots_vert = slots_vert
ListBox.super.new(self, menusystem, name, x, y, w, h)
self.begin = 1
self.widget.h = math.floor( self.h / slots_vert )
self.widget.w = math.floor( self.w / slots_hor )
@ -17,8 +17,8 @@ function FlowBox:new(menusystem, name, x, y, w, h, slots_hor, slots_vert)
end
function FlowBox:updateWidgetSize()
self.widget.h = math.floor( self.h / slots_vert )
self.widget.w = math.floor( self.w / slots_hor )
self.widget.h = math.floor( self.h / self.slots_vert )
self.widget.w = math.floor( self.w / self.slots_hor )
end
function FlowBox:update(dt)

View file

@ -5,10 +5,10 @@ local Menu = require(cwd .. "parent")
GridBox = Menu:extend()
function GridBox:new(menusystem, name, x, y, w, h, slots_hor, slots_vert)
GridBox.super.new(self, menusystem, name, x, y, w, h)
self.slots = slots_hor * slots_vert
self.slots_hor = slots_hor
self.slots_vert = slots_vert
GridBox.super.new(self, menusystem, name, x, y, w, h)
self.begin = 1
self.h = slots_vert * self.widget.h -- On fait en sorte que la hauteur
self.w = slots_hor * self.widget.w -- et la largeur
@ -30,8 +30,8 @@ function GridBox:new(menusystem, name, x, y, w, h, slots_hor, slots_vert)
end
function GridBox:updateWidgetSize()
self.widget.h = math.floor( self.h / slots_vert )
self.widget.w = math.floor( self.w / slots_hor )
self.widget.h = math.floor( self.h / self.slots_vert )
self.widget.w = math.floor( self.w / self.slots_hor )
end
function GridBox:update(dt)

View file

@ -4,15 +4,15 @@ local Menu = require(cwd .. "parent")
ListBox = Menu:extend()
function ListBox:new(menusystem, name, x, y, w, h, slots)
ListBox.super.new(self, menusystem, name, x, y, w, h)
self.slots = slots
ListBox.super.new(self, menusystem, name, x, y, w, h)
self.begin = 1
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 ListBox:updateWidgetSize()
self.widget.h = math.floor( self.h / slots )
self.widget.h = math.floor( self.h / self.slots )
self.widget.w = self.w
end

View file

@ -4,13 +4,13 @@ local Menu = require(cwd .. "parent")
local TextMenu = Menu:extend()
function TextMenu:new(menusystem, name, x, y, font, slots)
self.slots = slots
TextMenu.super.new(self, menusystem, name, x, y, 0, 0)
self.ox = x
self.oy = y
self.font = font
self.align = "left"
self.slots = slots
self.begin = 1
self:getBoundingBox()