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.y = y
|
||||||
self.w = w
|
self.w = w
|
||||||
self.h = h
|
self.h = h
|
||||||
self.listWidget = {}
|
|
||||||
self.selected = 0
|
self.widget = {}
|
||||||
self.selectedPrevious = 0
|
self.widget.list = {}
|
||||||
|
self.widget.selected = 0
|
||||||
|
self.widget.selectedPrevious = 0
|
||||||
|
self.widget.cancel = 0
|
||||||
|
|
||||||
self.destroyed = false
|
self.destroyed = false
|
||||||
self.focus = false
|
self.focus = false
|
||||||
|
@ -22,13 +25,13 @@ function Menu:new(x,y,w,h)
|
||||||
self.canvas.needRedraw = true
|
self.canvas.needRedraw = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function Menu:setLastWidgetCancel()
|
function Menu:setCancelWidget(id)
|
||||||
self.cancel = #self.listWidget
|
self.widget.cancel = #self.widget.list
|
||||||
end
|
end
|
||||||
|
|
||||||
function Menu:cancelAction()
|
function Menu:cancelAction()
|
||||||
if (self.cancel ~= 0) then
|
if (self.widget.cancel ~= 0) then
|
||||||
self.listWidget[self.cancel]:action()
|
self.widget.list[self.widget.cancel]:action()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,8 +40,8 @@ function Menu:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Menu:empty()
|
function Menu:empty()
|
||||||
self.listWidget = {}
|
self.widget.list = {}
|
||||||
self.cancel = 0
|
self.widget.cancel = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function Menu:resize(x,y,w,h)
|
function Menu:resize(x,y,w,h)
|
||||||
|
@ -80,41 +83,41 @@ function Menu:mousepressed( x, y, button, istouch )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Menu:addWidget(newwidget)
|
function Menu:addWidget(newwidget)
|
||||||
if #self.listWidget == 0 then
|
if #self.widget.list == 0 then
|
||||||
self.selected = 1
|
self.widget.selected = 1
|
||||||
end
|
end
|
||||||
table.insert(self.listWidget, newwidget)
|
table.insert(self.widget.list, newwidget)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Menu:updateWidgets(dt)
|
function Menu:updateWidgets(dt)
|
||||||
self:clearWidgets()
|
self:clearWidgets()
|
||||||
for i,v in ipairs(self.listWidget) do
|
for i,v in ipairs(self.widget.list) do
|
||||||
v.id = i
|
v.id = i
|
||||||
v:update(dt)
|
v:update(dt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Menu:clearWidgets() -- On retire les widgets marquées comme supprimées
|
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
|
if (v.destroyed == true) then
|
||||||
table.remove(self.listWidget, i)
|
table.remove(self.widget.list, i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Menu:setCursor(cursorid)
|
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
|
end
|
||||||
|
|
||||||
function Menu:moveCursor(new_selected)
|
function Menu:moveCursor(new_selected)
|
||||||
self:playSelectSound()
|
self:playSelectSound()
|
||||||
if new_selected < 1 then
|
if new_selected < 1 then
|
||||||
self.selected = #self.listWidget + new_selected
|
self.widget.selected = #self.widget.list + new_selected
|
||||||
else
|
else
|
||||||
if new_selected > #self.listWidget then
|
if new_selected > #self.widget.list then
|
||||||
self.selected = new_selected - #self.listWidget
|
self.widget.selected = new_selected - #self.widget.list
|
||||||
else
|
else
|
||||||
self.selected = new_selected
|
self.widget.selected = new_selected
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.canvas.needRedraw = true
|
self.canvas.needRedraw = true
|
||||||
|
|
Loading…
Reference in a new issue