core/menusystem: update widgets id each time a new widget is added

This commit is contained in:
Kazhnuz 2019-02-13 18:41:16 +01:00
parent 6fb00518bb
commit cad0cbc071

View file

@ -109,6 +109,7 @@ function Menu:addWidget(newwidget)
self.widget.selected = 1 self.widget.selected = 1
end end
table.insert(self.widget.list, newwidget) table.insert(self.widget.list, newwidget)
self:updateWidgetsID()
end end
function Menu:updateWidgets(dt) function Menu:updateWidgets(dt)
@ -119,6 +120,12 @@ function Menu:updateWidgets(dt)
end end
end end
function Menu:updateWidgetsID()
for i,v in ipairs(self.widget.list) do
v.id = i
end
end
function Menu:removeDestroyedWidgets() -- On retire les widgets marquées comme supprimées function Menu:removeDestroyedWidgets() -- On retire les widgets marquées comme supprimées
for i,v in ipairs(self.widget.list) do for i,v in ipairs(self.widget.list) do
if (v.destroyed == true) then if (v.destroyed == true) then