@ -19,32 +19,40 @@ function optionsutil.showValues(configurable, option, prefix)
local default = G_reader_settings : readSetting ( prefix .. " _ " .. option.name )
local default = G_reader_settings : readSetting ( prefix .. " _ " .. option.name )
local current = configurable [ option.name ]
local current = configurable [ option.name ]
local value_default , value_current
local value_default , value_current
local suffix = option.name_text_suffix or " "
if option.name == " screen_mode " then
if option.name == " screen_mode " then
current = Screen : getScreenMode ( )
current = Screen : getScreenMode ( )
end
end
local arg_table = { }
if option.toggle and option.values then
if option.toggle and option.values then
-- build a table so we can see if current/default settings map
-- to a known setting with a name (in option.toggle)
local arg_table = { }
for i = 1 , # option.values do
for i = 1 , # option.values do
arg_table [ option.values [ i ] ] = option.toggle [ i ]
local val = option.values [ i ]
-- flatten table to a string for easy lookup via arg_table
if type ( val ) == " table " then val = table.concat ( val , " , " ) end
arg_table [ val ] = option.toggle [ i ]
end
end
end
if not default then
default = _ ( " not set " )
if option.toggle and option.values then
value_current = current
current = arg_table [ current ]
if not current then current = value_current end
end
elseif option.toggle and option.values then
value_current = current
value_current = current
value_default = default
if type ( current ) == " table " then current = table.concat ( current , " , " ) end
default = arg_table [ default ]
current = arg_table [ current ]
current = arg_table [ current ]
if not default then default = value_default end
if not current then
if not current then current = value_current end
current = option.name_text_true_values and _ ( " custom " ) or value_current
end
end
if option.labels and option.values then
if option.show_true_value_func then
value_current = option.show_true_value_func ( value_current )
end
if default then
value_default = default
if type ( default ) == " table " then default = table.concat ( default , " , " ) end
default = arg_table [ default ]
if not default then
default = option.name_text_true_values and _ ( " custom " ) or value_default
end
if option.show_true_value_func then
value_default = option.show_true_value_func ( value_default )
end
end
elseif option.labels and option.values then
if option.more_options_param and option.more_options_param . value_table then
if option.more_options_param and option.more_options_param . value_table then
if option.more_options_param . args_table then
if option.more_options_param . args_table then
for k , v in pairs ( option.more_options_param . args_table ) do
for k , v in pairs ( option.more_options_param . args_table ) do
@ -55,7 +63,7 @@ function optionsutil.showValues(configurable, option, prefix)
end
end
end
end
current = option.more_options_param . value_table [ current ]
current = option.more_options_param . value_table [ current ]
if default ~= _ ( " not set " ) then
if default then
if option.more_options_param . args_table then
if option.more_options_param . args_table then
for k , v in pairs ( option.more_options_param . args_table ) do
for k , v in pairs ( option.more_options_param . args_table ) do
if v == default then
if v == default then
@ -67,7 +75,7 @@ function optionsutil.showValues(configurable, option, prefix)
default = option.more_options_param . value_table [ default ]
default = option.more_options_param . value_table [ default ]
end
end
else
else
if default ~= _ ( " not set " ) then
if default then
for i = 1 , # option.labels do
for i = 1 , # option.labels do
if default == option.values [ i ] then
if default == option.values [ i ] then
default = option.labels [ i ]
default = option.labels [ i ]
@ -82,21 +90,30 @@ function optionsutil.showValues(configurable, option, prefix)
end
end
end
end
end
end
elseif option.show_true_value_func and option.values then
current = option.show_true_value_func ( current )
if default then
default = option.show_true_value_func ( default )
end
end
if not default then
default = _ ( " not set " )
end
end
local help_text = " "
local help_text = " "
if option.help_text then
if option.help_text then
help_text = T ( " \n %1 \n " , option.help_text )
help_text = T ( " \n %1 \n " , option.help_text )
end
end
local text
local text
if option.name_text_true_values and option.toggle and option.values and value_default then
if option.name_text_true_values and option.toggle and option.values then
text = T ( _ ( " %1: \n %2 \n Current value: %3 (%6%5) \n Default value: %4 (%7%5) " ) , option.name_text , help_text ,
if value_default then
current , default , suffix , value_current , value_default )
text = T ( _ ( " %1 \n %2 \n Current value: %3 (%4) \n Default value: %5 (%6) " ) , option.name_text , help_text ,
elseif option.name_text_true_values and option.toggle and option.values and not value_default then
current , value_current , default , value_default )
text = T ( _ ( " %1 \n %2 \n Current value: %3 (%6%5) \n Default value: %4 " ) , option.name_text , help_text ,
else
current , default , suffix , value_current )
text = T ( _ ( " %1 \n %2 \n Current value: %3 (%4) \n Default value: %5 " ) , option.name_text , help_text ,
current , value_current , default )
end
else
else
text = T ( _ ( " %1 \n %2 \n Current value: %3%5 \n Default value: %4%5 " ) , option.name_text , help_text ,
text = T ( _ ( " %1 \n %2 \n Current value: %3 \n Default value: %4 " ) , option.name_text , help_text , current , default )
current , default , suffix )
end
end
UIManager : show ( InfoMessage : new { text = text } )
UIManager : show ( InfoMessage : new { text = text } )
end
end