|
|
@ -318,7 +318,7 @@ function Dispatcher:getNameFromItem(item, location, settings)
|
|
|
|
return T(settingsList[item].title, amount)
|
|
|
|
return T(settingsList[item].title, amount)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function Dispatcher:addItem(menu, location, settings, section)
|
|
|
|
function Dispatcher:addItem(caller, menu, location, settings, section)
|
|
|
|
for _, k in ipairs(dispatcher_menu_order) do
|
|
|
|
for _, k in ipairs(dispatcher_menu_order) do
|
|
|
|
if settingsList[k][section] == true and
|
|
|
|
if settingsList[k][section] == true and
|
|
|
|
(settingsList[k].condition == nil or settingsList[k].condition)
|
|
|
|
(settingsList[k].condition == nil or settingsList[k].condition)
|
|
|
@ -338,6 +338,7 @@ function Dispatcher:addItem(menu, location, settings, section)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
location[settings][k] = true
|
|
|
|
location[settings][k] = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
caller.updated = true
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
separator = settingsList[k].separator,
|
|
|
|
separator = settingsList[k].separator,
|
|
|
@ -366,6 +367,7 @@ function Dispatcher:addItem(menu, location, settings, section)
|
|
|
|
location[settings] = {}
|
|
|
|
location[settings] = {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
location[settings][k] = spin.value
|
|
|
|
location[settings][k] = spin.value
|
|
|
|
|
|
|
|
caller.updated = true
|
|
|
|
if touchmenu_instance then
|
|
|
|
if touchmenu_instance then
|
|
|
|
touchmenu_instance:updateItems()
|
|
|
|
touchmenu_instance:updateItems()
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -376,6 +378,7 @@ function Dispatcher:addItem(menu, location, settings, section)
|
|
|
|
hold_callback = function(touchmenu_instance)
|
|
|
|
hold_callback = function(touchmenu_instance)
|
|
|
|
if location[settings] ~= nil and location[settings][k] ~= nil then
|
|
|
|
if location[settings] ~= nil and location[settings][k] ~= nil then
|
|
|
|
location[settings][k] = nil
|
|
|
|
location[settings][k] = nil
|
|
|
|
|
|
|
|
caller.updated = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
end,
|
|
|
|
end,
|
|
|
@ -407,6 +410,7 @@ function Dispatcher:addItem(menu, location, settings, section)
|
|
|
|
location[settings] = {}
|
|
|
|
location[settings] = {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
location[settings][k] = spin.value
|
|
|
|
location[settings][k] = spin.value
|
|
|
|
|
|
|
|
caller.updated = true
|
|
|
|
if touchmenu_instance then
|
|
|
|
if touchmenu_instance then
|
|
|
|
touchmenu_instance:updateItems()
|
|
|
|
touchmenu_instance:updateItems()
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -417,6 +421,7 @@ function Dispatcher:addItem(menu, location, settings, section)
|
|
|
|
hold_callback = function(touchmenu_instance)
|
|
|
|
hold_callback = function(touchmenu_instance)
|
|
|
|
if location[settings] ~= nil and location[settings][k] ~= nil then
|
|
|
|
if location[settings] ~= nil and location[settings][k] ~= nil then
|
|
|
|
location[settings][k] = nil
|
|
|
|
location[settings][k] = nil
|
|
|
|
|
|
|
|
caller.updated = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if touchmenu_instance then
|
|
|
|
if touchmenu_instance then
|
|
|
|
touchmenu_instance:updateItems()
|
|
|
|
touchmenu_instance:updateItems()
|
|
|
@ -439,6 +444,7 @@ function Dispatcher:addItem(menu, location, settings, section)
|
|
|
|
location[settings] = {}
|
|
|
|
location[settings] = {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
location[settings][k] = settingsList[k].args[i]
|
|
|
|
location[settings][k] = settingsList[k].args[i]
|
|
|
|
|
|
|
|
caller.updated = true
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -454,6 +460,7 @@ function Dispatcher:addItem(menu, location, settings, section)
|
|
|
|
hold_callback = function(touchmenu_instance)
|
|
|
|
hold_callback = function(touchmenu_instance)
|
|
|
|
if location[settings] ~= nil and location[settings][k] ~= nil then
|
|
|
|
if location[settings] ~= nil and location[settings][k] ~= nil then
|
|
|
|
location[settings][k] = nil
|
|
|
|
location[settings][k] = nil
|
|
|
|
|
|
|
|
caller.updated = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if touchmenu_instance then
|
|
|
|
if touchmenu_instance then
|
|
|
|
touchmenu_instance:updateItems()
|
|
|
|
touchmenu_instance:updateItems()
|
|
|
@ -469,13 +476,14 @@ end
|
|
|
|
--[[--
|
|
|
|
--[[--
|
|
|
|
Add a submenu to edit which items are dispatched
|
|
|
|
Add a submenu to edit which items are dispatched
|
|
|
|
arguments are:
|
|
|
|
arguments are:
|
|
|
|
1) the table representing the submenu (can be empty)
|
|
|
|
1) the caller so dispatcher can set the updated flag
|
|
|
|
2) the object (table) in which the settings table is found
|
|
|
|
2) the table representing the submenu (can be empty)
|
|
|
|
3) the name of the settings table
|
|
|
|
3) the object (table) in which the settings table is found
|
|
|
|
|
|
|
|
4) the name of the settings table
|
|
|
|
example usage:
|
|
|
|
example usage:
|
|
|
|
Dispatcher.addSubMenu(sub_items, self.data, "profile1")
|
|
|
|
Dispatcher.addSubMenu(self, sub_items, self.data, "profile1")
|
|
|
|
--]]--
|
|
|
|
--]]--
|
|
|
|
function Dispatcher:addSubMenu(menu, location, settings)
|
|
|
|
function Dispatcher:addSubMenu(caller, menu, location, settings)
|
|
|
|
if not Dispatcher.initialized then Dispatcher:init() end
|
|
|
|
if not Dispatcher.initialized then Dispatcher:init() end
|
|
|
|
table.insert(menu, {
|
|
|
|
table.insert(menu, {
|
|
|
|
text = _("Nothing"),
|
|
|
|
text = _("Nothing"),
|
|
|
@ -485,6 +493,7 @@ function Dispatcher:addSubMenu(menu, location, settings)
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
callback = function(touchmenu_instance)
|
|
|
|
callback = function(touchmenu_instance)
|
|
|
|
location[settings] = {}
|
|
|
|
location[settings] = {}
|
|
|
|
|
|
|
|
caller.updated = true
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -496,8 +505,7 @@ function Dispatcher:addSubMenu(menu, location, settings)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, section in ipairs(section_list) do
|
|
|
|
for _, section in ipairs(section_list) do
|
|
|
|
local submenu = {}
|
|
|
|
local submenu = {}
|
|
|
|
-- pass caller's context
|
|
|
|
Dispatcher:addItem(caller, submenu, location, settings, section[1])
|
|
|
|
Dispatcher:addItem(submenu, location, settings, section[1])
|
|
|
|
|
|
|
|
table.insert(menu, {
|
|
|
|
table.insert(menu, {
|
|
|
|
text = section[2],
|
|
|
|
text = section[2],
|
|
|
|
checked_func = function()
|
|
|
|
checked_func = function()
|
|
|
@ -514,6 +522,7 @@ function Dispatcher:addSubMenu(menu, location, settings)
|
|
|
|
for k, _ in pairs(location[settings]) do
|
|
|
|
for k, _ in pairs(location[settings]) do
|
|
|
|
if settingsList[k][section[1]] == true then
|
|
|
|
if settingsList[k][section[1]] == true then
|
|
|
|
location[settings][k] = nil
|
|
|
|
location[settings][k] = nil
|
|
|
|
|
|
|
|
caller.updated = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|