From 464a1309c2f67e6b0580657207a8ba6a20a0ac52 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 10 Feb 2019 21:14:31 +0100 Subject: [PATCH] core/menusystem: make menu register themselves --- sonic-boost.love/core/modules/menusystem/flowbox.lua | 4 ++-- sonic-boost.love/core/modules/menusystem/grid.lua | 4 ++-- sonic-boost.love/core/modules/menusystem/listbox.lua | 4 ++-- sonic-boost.love/core/modules/menusystem/parent.lua | 10 +++++++++- sonic-boost.love/core/modules/menusystem/textmenu.lua | 4 ++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/sonic-boost.love/core/modules/menusystem/flowbox.lua b/sonic-boost.love/core/modules/menusystem/flowbox.lua index ad75cce..7b032a0 100644 --- a/sonic-boost.love/core/modules/menusystem/flowbox.lua +++ b/sonic-boost.love/core/modules/menusystem/flowbox.lua @@ -3,8 +3,8 @@ local Menu = require(cwd .. "parent") FlowBox = Menu:extend() -function FlowBox:new(x,y,w,h,slots_hor,slots_vert) - ListBox.super.new(self, x, y, w, h) +function FlowBox:new(controller, x,y,w,h,slots_hor,slots_vert) + ListBox.super.new(self, controller, x, y, w, h) self.slots = slots_hor * slots_vert self.slots_hor = slots_hor self.slots_vert = slots_vert diff --git a/sonic-boost.love/core/modules/menusystem/grid.lua b/sonic-boost.love/core/modules/menusystem/grid.lua index 77b465e..cf5501a 100644 --- a/sonic-boost.love/core/modules/menusystem/grid.lua +++ b/sonic-boost.love/core/modules/menusystem/grid.lua @@ -4,8 +4,8 @@ local Menu = require(cwd .. "parent") GridBox = Menu:extend() -function GridBox:new(x,y,w,h,slots_hor,slots_vert) - ListBox.super.new(self, x, y, w, h) +function GridBox:new(controller, x,y,w,h,slots_hor,slots_vert) + ListBox.super.new(self, controller, x, y, w, h) self.slots = slots_hor * slots_vert self.slots_hor = slots_hor self.slots_vert = slots_vert diff --git a/sonic-boost.love/core/modules/menusystem/listbox.lua b/sonic-boost.love/core/modules/menusystem/listbox.lua index fa1d5eb..533941d 100644 --- a/sonic-boost.love/core/modules/menusystem/listbox.lua +++ b/sonic-boost.love/core/modules/menusystem/listbox.lua @@ -3,8 +3,8 @@ local Menu = require(cwd .. "parent") ListBox = Menu:extend() -function ListBox:new(x,y,w,h,slots) - ListBox.super.new(self, x, y, w, h) +function ListBox:new(controller, x,y,w,h,slots) + ListBox.super.new(self, controller, x, y, w, h) self.slots = slots self.begin = 1 self.h = slots * self.widget.h -- On fait en sorte que la hauteur diff --git a/sonic-boost.love/core/modules/menusystem/parent.lua b/sonic-boost.love/core/modules/menusystem/parent.lua index 1c4c09b..7476716 100644 --- a/sonic-boost.love/core/modules/menusystem/parent.lua +++ b/sonic-boost.love/core/modules/menusystem/parent.lua @@ -1,6 +1,8 @@ local Menu = Object:extend() -function Menu:new(x,y,w,h) +function Menu:new(controller, x,y,w,h) + self.controller = controller + self.x = x self.y = y self.w = w @@ -25,6 +27,12 @@ function Menu:new(x,y,w,h) self.canvas = {} self.canvas.texture = nil self.canvas.needRedraw = true + + self:register() +end + +function Menu:register() + self.controller:addMenu(self) end function Menu:setCancelWidget(id) diff --git a/sonic-boost.love/core/modules/menusystem/textmenu.lua b/sonic-boost.love/core/modules/menusystem/textmenu.lua index 39f2d20..e4ae7e8 100644 --- a/sonic-boost.love/core/modules/menusystem/textmenu.lua +++ b/sonic-boost.love/core/modules/menusystem/textmenu.lua @@ -3,8 +3,8 @@ local Menu = require(cwd .. "parent") local TextMenu = Menu:extend() -function TextMenu:new(x, y, font, slots) - TextMenu.super.new(self, x, y, 0, 0) +function TextMenu:new(controller, x, y, font, slots) + TextMenu.super.new(self, controller, x, y, 0, 0) self.ox = x self.oy = y self.font = font