diff options
Diffstat (limited to 'apps/plugins/lua/include_lua/printmenus.lua')
-rw-r--r-- | apps/plugins/lua/include_lua/printmenus.lua | 91 |
1 files changed, 17 insertions, 74 deletions
diff --git a/apps/plugins/lua/include_lua/printmenus.lua b/apps/plugins/lua/include_lua/printmenus.lua index 3e8f870104..938d99a5ed 100644 --- a/apps/plugins/lua/include_lua/printmenus.lua +++ b/apps/plugins/lua/include_lua/printmenus.lua | |||
@@ -23,74 +23,18 @@ | |||
23 | if not rb.lcd_framebuffer then rb.splash(rb.HZ, "No Support!") return nil end | 23 | if not rb.lcd_framebuffer then rb.splash(rb.HZ, "No Support!") return nil end |
24 | 24 | ||
25 | require("printtable") | 25 | require("printtable") |
26 | require("menucoresettings") --loads user settings from rockbox | ||
26 | 27 | ||
27 | local _clr = require("color") | 28 | local _clr = require("color") |
28 | 29 | ||
30 | |||
29 | local _LCD = rb.lcd_framebuffer() | 31 | local _LCD = rb.lcd_framebuffer() |
30 | 32 | ||
31 | --[[ -- dpad requires: | 33 | --[[ -- dpad requires: |
32 | require("actions") -- Contains rb.actions & rb.contexts | 34 | local BUTTON = require("menubuttons") |
33 | local _timer = require("timer") | 35 | local _timer = require("timer") |
34 | -- Button definitions -- | ||
35 | local CANCEL_BUTTON = rb.actions.PLA_CANCEL | ||
36 | local DOWN_BUTTON = rb.actions.PLA_DOWN | ||
37 | local DOWNR_BUTTON = rb.actions.PLA_DOWN_REPEAT | ||
38 | local EXIT_BUTTON = rb.actions.PLA_EXIT | ||
39 | local LEFT_BUTTON = rb.actions.PLA_LEFT | ||
40 | local LEFTR_BUTTON = rb.actions.PLA_LEFT_REPEAT | ||
41 | local RIGHT_BUTTON = rb.actions.PLA_RIGHT | ||
42 | local RIGHTR_BUTTON = rb.actions.PLA_RIGHT_REPEAT | ||
43 | local SEL_BUTTON = rb.actions.PLA_SELECT | ||
44 | local SELREL_BUTTON = rb.actions.PLA_SELECT_REL | ||
45 | local SELR_BUTTON = rb.actions.PLA_SELECT_REPEAT | ||
46 | local UP_BUTTON = rb.actions.PLA_UP | ||
47 | local UPR_BUTTON = rb.actions.PLA_UP_REPEAT | ||
48 | ]] | 36 | ]] |
49 | -------------------------------------------------------------------------------- | 37 | -------------------------------------------------------------------------------- |
50 | local function get_core_settings() | ||
51 | if rb.core_color_table ~= nil and rb.core_talk_table ~= nil and | ||
52 | rb.core_list_settings_table ~= nil then return end | ||
53 | |||
54 | local rbs_is_loaded = (package.loaded.rbsettings ~= nil) | ||
55 | local s_is_loaded = (package.loaded.settings ~= nil) | ||
56 | |||
57 | require("rbsettings") | ||
58 | require("settings") | ||
59 | rb.metadata = nil -- remove track metadata settings | ||
60 | |||
61 | local rb_settings = rb.settings.dump('global_settings', "system") | ||
62 | local color_table = {} | ||
63 | local talk_table = {} | ||
64 | local list_settings_table = {} | ||
65 | local list_settings = "cursor_style|show_icons|statusbar|scrollbar|scrollbar_width|list_separator_height|backdrop_file|" | ||
66 | for key, value in pairs(rb_settings) do | ||
67 | key = key or "" | ||
68 | if (key:find("color")) then | ||
69 | color_table[key]=value | ||
70 | elseif (key:find("talk")) then | ||
71 | talk_table[key]=value | ||
72 | elseif (list_settings:find(key)) then | ||
73 | list_settings_table[key]=value | ||
74 | end | ||
75 | end | ||
76 | |||
77 | if not s_is_loaded then | ||
78 | rb.settings = nil | ||
79 | package.loaded.settings = nil | ||
80 | end | ||
81 | |||
82 | if not rbs_is_loaded then | ||
83 | rb.system = nil | ||
84 | rb.metadata = nil | ||
85 | package.loaded.rbsettings = nil | ||
86 | end | ||
87 | |||
88 | rb.core_color_table = color_table | ||
89 | rb.core_talk_table = talk_table | ||
90 | rb.core_list_settings_table = list_settings_table | ||
91 | collectgarbage("collect") | ||
92 | end | ||
93 | |||
94 | --[[ cursor style button routine | 38 | --[[ cursor style button routine |
95 | -- left / right are x, xi is increment xir is increment when repeat | 39 | -- left / right are x, xi is increment xir is increment when repeat |
96 | -- up / down are y, yi is increment yir is increment when repeat | 40 | -- up / down are y, yi is increment yir is increment when repeat |
@@ -112,44 +56,44 @@ local function dpad(x, xi, xir, y, yi, yir, timeout, overflow) | |||
112 | while true do | 56 | while true do |
113 | button = rb.get_plugin_action(timeout) | 57 | button = rb.get_plugin_action(timeout) |
114 | 58 | ||
115 | if button == CANCEL_BUTTON then | 59 | if button == BUTTON.CANCEL then |
116 | cancel = 1 | 60 | cancel = 1 |
117 | break; | 61 | break; |
118 | elseif button == EXIT_BUTTON then | 62 | elseif button == BUTTON.EXIT then |
119 | cancel = 1 | 63 | cancel = 1 |
120 | break; | 64 | break; |
121 | elseif button == SEL_BUTTON then | 65 | elseif button == BUTTON.SEL then |
122 | select = 1 | 66 | select = 1 |
123 | timeout = timeout + 1 | 67 | timeout = timeout + 1 |
124 | elseif button == SELR_BUTTON then | 68 | elseif button == BUTTON.SELR then |
125 | select = 2 | 69 | select = 2 |
126 | timeout = timeout + 1 | 70 | timeout = timeout + 1 |
127 | elseif button == SELREL_BUTTON then | 71 | elseif button == BUTTON.SELREL then |
128 | select = -1 | 72 | select = -1 |
129 | timeout = timeout + 1 | 73 | timeout = timeout + 1 |
130 | elseif button == LEFT_BUTTON then | 74 | elseif button == BUTTON.LEFT then |
131 | x_chg = x_chg - xi | 75 | x_chg = x_chg - xi |
132 | if scroll_is_fixed then | 76 | if scroll_is_fixed then |
133 | cancel = 1 | 77 | cancel = 1 |
134 | break; | 78 | break; |
135 | end | 79 | end |
136 | elseif button == LEFTR_BUTTON then | 80 | elseif button == BUTTON.LEFTR then |
137 | x_chg = x_chg - xir | 81 | x_chg = x_chg - xir |
138 | elseif button == RIGHT_BUTTON then | 82 | elseif button == BUTTON.RIGHT then |
139 | x_chg = x_chg + xi | 83 | x_chg = x_chg + xi |
140 | if scroll_is_fixed then | 84 | if scroll_is_fixed then |
141 | select = 1 | 85 | select = 1 |
142 | timeout = timeout + 1 | 86 | timeout = timeout + 1 |
143 | end | 87 | end |
144 | elseif button == RIGHTR_BUTTON then | 88 | elseif button == BUTTON.RIGHTR then |
145 | x_chg = x_chg + xir | 89 | x_chg = x_chg + xir |
146 | elseif button == UP_BUTTON then | 90 | elseif button == BUTTON.UP then |
147 | y_chg = y_chg + yi | 91 | y_chg = y_chg + yi |
148 | elseif button == UPR_BUTTON then | 92 | elseif button == BUTTON.UPR then |
149 | y_chg = y_chg + yir | 93 | y_chg = y_chg + yir |
150 | elseif button == DOWN_BUTTON then | 94 | elseif button == BUTTON.DOWN then |
151 | y_chg = y_chg - yi | 95 | y_chg = y_chg - yi |
152 | elseif button == DOWNR_BUTTON then | 96 | elseif button == BUTTON.DOWNR then |
153 | y_chg = y_chg - yir | 97 | y_chg = y_chg - yir |
154 | elseif timeout >= 0 then--and rb.button_queue_count() < 1 then | 98 | elseif timeout >= 0 then--and rb.button_queue_count() < 1 then |
155 | break; | 99 | break; |
@@ -175,7 +119,6 @@ function print_menu(menu_t, func_t, selected, settings, copy_screen) | |||
175 | if selected then vcur = selected + 1 end | 119 | if selected then vcur = selected + 1 end |
176 | if vcur and vcur <= 1 then vcur = 2 end | 120 | if vcur and vcur <= 1 then vcur = 2 end |
177 | 121 | ||
178 | get_core_settings() | ||
179 | local c_table = rb.core_color_table or {} | 122 | local c_table = rb.core_color_table or {} |
180 | 123 | ||
181 | if not settings then | 124 | if not settings then |
@@ -239,7 +182,7 @@ function print_menu(menu_t, func_t, selected, settings, copy_screen) | |||
239 | if copy_screen == true then _LCD:copy(screen_img) end | 182 | if copy_screen == true then _LCD:copy(screen_img) end |
240 | 183 | ||
241 | if func_t and func_t[i] then | 184 | if func_t and func_t[i] then |
242 | if func_t[i](i, menu_t) == true then break end | 185 | if func_t[i](i, menu_t, func_t) == true then break end |
243 | else | 186 | else |
244 | break | 187 | break |
245 | end | 188 | end |