From 44bf09aa8821514d8d7b1a8565f5a16261e1bfae Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Mon, 11 Feb 2019 20:04:24 +0100 Subject: [PATCH] core/menusystem: declare slots variables before calling the parent new() --- sonic-boost.love/core/modules/menusystem/flowbox.lua | 6 +++--- sonic-boost.love/core/modules/menusystem/grid.lua | 6 +++--- sonic-boost.love/core/modules/menusystem/listbox.lua | 4 ++-- sonic-boost.love/core/modules/menusystem/textmenu.lua | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sonic-boost.love/core/modules/menusystem/flowbox.lua b/sonic-boost.love/core/modules/menusystem/flowbox.lua index 4bbe6c8..9446f8e 100644 --- a/sonic-boost.love/core/modules/menusystem/flowbox.lua +++ b/sonic-boost.love/core/modules/menusystem/flowbox.lua @@ -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) diff --git a/sonic-boost.love/core/modules/menusystem/grid.lua b/sonic-boost.love/core/modules/menusystem/grid.lua index 44e08d1..30a00a9 100644 --- a/sonic-boost.love/core/modules/menusystem/grid.lua +++ b/sonic-boost.love/core/modules/menusystem/grid.lua @@ -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) diff --git a/sonic-boost.love/core/modules/menusystem/listbox.lua b/sonic-boost.love/core/modules/menusystem/listbox.lua index 9bbedee..ab7a7d5 100644 --- a/sonic-boost.love/core/modules/menusystem/listbox.lua +++ b/sonic-boost.love/core/modules/menusystem/listbox.lua @@ -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 diff --git a/sonic-boost.love/core/modules/menusystem/textmenu.lua b/sonic-boost.love/core/modules/menusystem/textmenu.lua index 76a91d8..6703039 100644 --- a/sonic-boost.love/core/modules/menusystem/textmenu.lua +++ b/sonic-boost.love/core/modules/menusystem/textmenu.lua @@ -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()