core/menusystem: rework "system" flags for menu
This commit is contained in:
parent
bf77a06741
commit
b1cf66add0
2 changed files with 16 additions and 10 deletions
|
@ -33,7 +33,7 @@ function MenuSystem:update(dt)
|
||||||
v.id = i
|
v.id = i
|
||||||
v:update(dt)
|
v:update(dt)
|
||||||
v:updateWidgets(dt)
|
v:updateWidgets(dt)
|
||||||
if v.focus == true then
|
if v.haveFocus == true then
|
||||||
for k,w in pairs(self.virtualpad.keys) do
|
for k,w in pairs(self.virtualpad.keys) do
|
||||||
if self.virtualpad.keys[k].isPressed then
|
if self.virtualpad.keys[k].isPressed then
|
||||||
v:keyreleased(k)
|
v:keyreleased(k)
|
||||||
|
@ -46,7 +46,7 @@ end
|
||||||
function MenuSystem:clear()
|
function MenuSystem:clear()
|
||||||
-- On retire les entitées marquées comme supprimées
|
-- On retire les entitées marquées comme supprimées
|
||||||
for i,v in ipairs(self.menus) do
|
for i,v in ipairs(self.menus) do
|
||||||
if (v.destroyed == true) then
|
if (v.isDestroyed == true) then
|
||||||
table.remove(self.menus, i)
|
table.remove(self.menus, i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -64,12 +64,14 @@ end
|
||||||
|
|
||||||
function MenuSystem:mousemoved(x, y, dx, dy)
|
function MenuSystem:mousemoved(x, y, dx, dy)
|
||||||
for i,v in ipairs(self.menus) do
|
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
|
if v.isActive then
|
||||||
v:mousemoved(x - v.x, y - v.y)
|
if (x > v.x) and (x < v.x + v.w) and (y > v.y) and (y < v.y + v.h) then
|
||||||
for j,u in ipairs(self.menus) do
|
v:mousemoved(x - v.x, y - v.y)
|
||||||
u.focus = false
|
for j,u in ipairs(self.menus) do
|
||||||
|
u.haveFocus = false
|
||||||
|
end
|
||||||
|
v.haveFocus = true
|
||||||
end
|
end
|
||||||
v.focus = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -89,7 +91,9 @@ end
|
||||||
function MenuSystem:draw(dt) -- On dessine les entitées
|
function MenuSystem:draw(dt) -- On dessine les entitées
|
||||||
for i,v in ipairs(self.menus) do
|
for i,v in ipairs(self.menus) do
|
||||||
v.id = i
|
v.id = i
|
||||||
v:draw(dt)
|
if (v.isVisible) then
|
||||||
|
v:draw(dt)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,10 @@ function Menu:new(x,y,w,h)
|
||||||
self.widget.h = 0
|
self.widget.h = 0
|
||||||
self.widget.w = 0
|
self.widget.w = 0
|
||||||
|
|
||||||
self.isdestroyed = false
|
self.isDestroyed = false
|
||||||
self.focus = false
|
self.haveFocus = false
|
||||||
|
self.isVisible = true
|
||||||
|
self.isActive = true
|
||||||
|
|
||||||
self.sound = {}
|
self.sound = {}
|
||||||
self.sound.asset = nil
|
self.sound.asset = nil
|
||||||
|
|
Loading…
Reference in a new issue