From 3cbb7a137338a8fcdafbb3323e421097bf8dd689 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 10 Feb 2019 11:58:39 +0100 Subject: [PATCH] core/menusystem: fuse MenuSystem and MenuController --- .../core/modules/menusystem/init.lua | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/sonic-boost.love/core/modules/menusystem/init.lua b/sonic-boost.love/core/modules/menusystem/init.lua index fb9bd1b..cbcf8ed 100644 --- a/sonic-boost.love/core/modules/menusystem/init.lua +++ b/sonic-boost.love/core/modules/menusystem/init.lua @@ -1,5 +1,4 @@ -local MenuSystem = {} -local MenuController = Object:extend() +local MenuSystem = Object:extend() local cwd = (...):gsub('%.init$', '') .. "." @@ -14,21 +13,21 @@ MenuSystem.Widget = require(cwd .. "widgets") --local VirtualPad = require "modules.virtualpad" -function MenuController:new() +function MenuSystem:new() self.menus = {} self.virtualpad = game.input --VirtualPad(1) end -function MenuController:reset() +function MenuSystem:reset() self.menus = {} self.virtualpad = game.input --VirtualPad(1) end -function MenuController:addMenu(menu) +function MenuSystem:addMenu(menu) table.insert(self.menus, menu) end -function MenuController:update(dt) +function MenuSystem:update(dt) self:clear() for i,v in ipairs(self.menus) do v.id = i @@ -44,7 +43,7 @@ function MenuController:update(dt) end end -function MenuController:clear() +function MenuSystem:clear() -- On retire les entitées marquées comme supprimées for i,v in ipairs(self.menus) do if (v.destroyed == true) then @@ -53,17 +52,17 @@ function MenuController:clear() end end -function MenuController:updateList() +function MenuSystem:updateList() for i,v in ipairs(self.menus) do v.id = i end end -function MenuController:keyreleased(key, code) +function MenuSystem:keyreleased(key, code) -- TODO:depreciated function end -function MenuController:mousemoved(x, y, dx, dy) +function MenuSystem:mousemoved(x, y, dx, dy) for i,v in ipairs(self.menus) do if (x > v.x) and (x < v.x + v.w) and (y > v.y) and (y < v.y + v.h) then v:mousemoved(x - v.x, y - v.y) @@ -75,7 +74,7 @@ function MenuController:mousemoved(x, y, dx, dy) end end -function MenuController:mousepressed( x, y, button, istouch ) +function MenuSystem:mousepressed( x, y, button, istouch ) for i,v in ipairs(self.menus) do if (x > v.x) and (x < v.x + v.w) and (y > v.y) and (y < v.y + v.h) then v:mousepressed(x - v.x, y - v.y, button, istouch ) @@ -87,13 +86,11 @@ function MenuController:mousepressed( x, y, button, istouch ) end end -function MenuController:draw(dt) -- On dessine les entitées +function MenuSystem:draw(dt) -- On dessine les entitées for i,v in ipairs(self.menus) do v.id = i v:draw(dt) end end -MenuSystem.Controller = MenuController - return MenuSystem