core/menusystem: make menu register themselves

This commit is contained in:
Kazhnuz 2019-02-10 21:14:31 +01:00
parent 1dfb2a1f70
commit 464a1309c2
5 changed files with 17 additions and 9 deletions

View file

@ -3,8 +3,8 @@ local Menu = require(cwd .. "parent")
FlowBox = Menu:extend() FlowBox = Menu:extend()
function FlowBox:new(x,y,w,h,slots_hor,slots_vert) function FlowBox:new(controller, x,y,w,h,slots_hor,slots_vert)
ListBox.super.new(self, x, y, w, h) ListBox.super.new(self, controller, x, y, w, h)
self.slots = slots_hor * slots_vert self.slots = slots_hor * slots_vert
self.slots_hor = slots_hor self.slots_hor = slots_hor
self.slots_vert = slots_vert self.slots_vert = slots_vert

View file

@ -4,8 +4,8 @@ local Menu = require(cwd .. "parent")
GridBox = Menu:extend() GridBox = Menu:extend()
function GridBox:new(x,y,w,h,slots_hor,slots_vert) function GridBox:new(controller, x,y,w,h,slots_hor,slots_vert)
ListBox.super.new(self, x, y, w, h) ListBox.super.new(self, controller, x, y, w, h)
self.slots = slots_hor * slots_vert self.slots = slots_hor * slots_vert
self.slots_hor = slots_hor self.slots_hor = slots_hor
self.slots_vert = slots_vert self.slots_vert = slots_vert

View file

@ -3,8 +3,8 @@ local Menu = require(cwd .. "parent")
ListBox = Menu:extend() ListBox = Menu:extend()
function ListBox:new(x,y,w,h,slots) function ListBox:new(controller, x,y,w,h,slots)
ListBox.super.new(self, x, y, w, h) ListBox.super.new(self, controller, x, y, w, h)
self.slots = slots self.slots = slots
self.begin = 1 self.begin = 1
self.h = slots * self.widget.h -- On fait en sorte que la hauteur self.h = slots * self.widget.h -- On fait en sorte que la hauteur

View file

@ -1,6 +1,8 @@
local Menu = Object:extend() 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.x = x
self.y = y self.y = y
self.w = w self.w = w
@ -25,6 +27,12 @@ function Menu:new(x,y,w,h)
self.canvas = {} self.canvas = {}
self.canvas.texture = nil self.canvas.texture = nil
self.canvas.needRedraw = true self.canvas.needRedraw = true
self:register()
end
function Menu:register()
self.controller:addMenu(self)
end end
function Menu:setCancelWidget(id) function Menu:setCancelWidget(id)

View file

@ -3,8 +3,8 @@ local Menu = require(cwd .. "parent")
local TextMenu = Menu:extend() local TextMenu = Menu:extend()
function TextMenu:new(x, y, font, slots) function TextMenu:new(controller, x, y, font, slots)
TextMenu.super.new(self, x, y, 0, 0) TextMenu.super.new(self, controller, x, y, 0, 0)
self.ox = x self.ox = x
self.oy = y self.oy = y
self.font = font self.font = font