lua add submenu module + cleanup

allows menus + submenus + context menus all with simple tables
menu_t which is a table of strings
func_t which are the corresponding functions to go with those strings

see lua_scripts/submenu_demo.lua

Change-Id: I907b74b4abef0ecbe49f181d0ced6e6d20e94de5
This commit is contained in:
William Wilgus 2021-04-27 23:12:49 -04:00 committed by William Wilgus
parent d5695822a7
commit 63b6281505
8 changed files with 478 additions and 120 deletions

View file

@ -0,0 +1,46 @@
--menu core settings loaded from rockbox user settings
--Bilgus 4/2021
local function get_core_settings()
local rbs_is_loaded = (package.loaded.rbsettings ~= nil)
local s_is_loaded = (package.loaded.settings ~= nil)
require("rbsettings")
require("settings")
rb.metadata = nil -- remove track metadata settings
local rb_settings = rb.settings.dump('global_settings', "system")
local color_table = {}
local talk_table = {}
local list_settings_table = {}
local list_settings = "cursor_style|show_icons|statusbar|scrollbar|scrollbar_width|list_separator_height|backdrop_file|"
for key, value in pairs(rb_settings) do
key = key or ""
if (key:find("color")) then
color_table[key]=value
elseif (key:find("talk")) then
talk_table[key]=value
elseif (list_settings:find(key)) then
list_settings_table[key]=value
end
end
if not s_is_loaded then
rb.settings = nil
package.loaded.settings = nil
end
if not rbs_is_loaded then
rb.system = nil
rb.metadata = nil
package.loaded.rbsettings = nil
end
rb.core_color_table = color_table
rb.core_talk_table = talk_table
rb.core_list_settings_table = list_settings_table
end
get_core_settings()
get_core_settings = nil
package.loaded.menucoresettings = nil
collectgarbage("collect")