core/menusystem: rename widget variables in the parent
This commit is contained in:
parent
679abb46ec
commit
db1a219336
1 changed files with 23 additions and 20 deletions
|
@ -5,9 +5,12 @@ function Menu:new(x,y,w,h)
|
|||
self.y = y
|
||||
self.w = w
|
||||
self.h = h
|
||||
self.listWidget = {}
|
||||
self.selected = 0
|
||||
self.selectedPrevious = 0
|
||||
|
||||
self.widget = {}
|
||||
self.widget.list = {}
|
||||
self.widget.selected = 0
|
||||
self.widget.selectedPrevious = 0
|
||||
self.widget.cancel = 0
|
||||
|
||||
self.destroyed = false
|
||||
self.focus = false
|
||||
|
@ -22,13 +25,13 @@ function Menu:new(x,y,w,h)
|
|||
self.canvas.needRedraw = true
|
||||
end
|
||||
|
||||
function Menu:setLastWidgetCancel()
|
||||
self.cancel = #self.listWidget
|
||||
function Menu:setCancelWidget(id)
|
||||
self.widget.cancel = #self.widget.list
|
||||
end
|
||||
|
||||
function Menu:cancelAction()
|
||||
if (self.cancel ~= 0) then
|
||||
self.listWidget[self.cancel]:action()
|
||||
if (self.widget.cancel ~= 0) then
|
||||
self.widget.list[self.widget.cancel]:action()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,8 +40,8 @@ function Menu:update(dt)
|
|||
end
|
||||
|
||||
function Menu:empty()
|
||||
self.listWidget = {}
|
||||
self.cancel = 0
|
||||
self.widget.list = {}
|
||||
self.widget.cancel = 0
|
||||
end
|
||||
|
||||
function Menu:resize(x,y,w,h)
|
||||
|
@ -80,41 +83,41 @@ function Menu:mousepressed( x, y, button, istouch )
|
|||
end
|
||||
|
||||
function Menu:addWidget(newwidget)
|
||||
if #self.listWidget == 0 then
|
||||
self.selected = 1
|
||||
if #self.widget.list == 0 then
|
||||
self.widget.selected = 1
|
||||
end
|
||||
table.insert(self.listWidget, newwidget)
|
||||
table.insert(self.widget.list, newwidget)
|
||||
end
|
||||
|
||||
function Menu:updateWidgets(dt)
|
||||
self:clearWidgets()
|
||||
for i,v in ipairs(self.listWidget) do
|
||||
for i,v in ipairs(self.widget.list) do
|
||||
v.id = i
|
||||
v:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
function Menu:clearWidgets() -- On retire les widgets marquées comme supprimées
|
||||
for i,v in ipairs(self.listWidget) do
|
||||
for i,v in ipairs(self.widget.list) do
|
||||
if (v.destroyed == true) then
|
||||
table.remove(self.listWidget, i)
|
||||
table.remove(self.widget.list, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Menu:setCursor(cursorid)
|
||||
self.selected = cursorid --math.max(1, math.min(cursorid, #self.listWidget))
|
||||
self.widget.selected = cursorid --math.max(1, math.min(cursorid, #self.widget.list))
|
||||
end
|
||||
|
||||
function Menu:moveCursor(new_selected)
|
||||
self:playSelectSound()
|
||||
if new_selected < 1 then
|
||||
self.selected = #self.listWidget + new_selected
|
||||
self.widget.selected = #self.widget.list + new_selected
|
||||
else
|
||||
if new_selected > #self.listWidget then
|
||||
self.selected = new_selected - #self.listWidget
|
||||
if new_selected > #self.widget.list then
|
||||
self.widget.selected = new_selected - #self.widget.list
|
||||
else
|
||||
self.selected = new_selected
|
||||
self.widget.selected = new_selected
|
||||
end
|
||||
end
|
||||
self.canvas.needRedraw = true
|
||||
|
|
Loading…
Reference in a new issue