mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 09:21:18 +02:00
CMenuOptionNumberChooser: expand localize functionality for any number
This commit is contained in:
@@ -1612,8 +1612,7 @@ void CMenuOptionNumberChooser::init( const neutrino_locale_t& lName,
|
||||
lower_bound = min_value;
|
||||
upper_bound = max_value;
|
||||
display_offset = print_offset;
|
||||
localized_value = special_value;
|
||||
localized_value_name = special_value_name;
|
||||
setLocalizedValue (special_value, special_value_name);
|
||||
observ = Observ;
|
||||
slider_on = sliderOn;
|
||||
|
||||
@@ -1677,18 +1676,24 @@ int CMenuOptionNumberChooser::paint(bool selected)
|
||||
const char * l_option;
|
||||
char option_value[40];
|
||||
|
||||
if ((localized_value_name == NONEXISTANT_LOCALE) || ((*optionValue) != localized_value))
|
||||
for (size_t i = 0; i < localized.size(); i++)
|
||||
{
|
||||
if (numberFormatFunction) {
|
||||
std::string s = numberFormatFunction(*optionValue + display_offset);
|
||||
strncpy(option_value, s.c_str(), sizeof(option_value));
|
||||
} else
|
||||
sprintf(option_value, numberFormat.c_str(), *optionValue + display_offset);
|
||||
l_option = option_value;
|
||||
if ((localized[i].value_name == NONEXISTANT_LOCALE) || ((*optionValue) != localized[i].value))
|
||||
{
|
||||
if (numberFormatFunction) {
|
||||
std::string s = numberFormatFunction(*optionValue + display_offset);
|
||||
strncpy(option_value, s.c_str(), sizeof(option_value));
|
||||
} else
|
||||
sprintf(option_value, numberFormat.c_str(), *optionValue + display_offset);
|
||||
l_option = option_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
l_option = g_Locale->getText(localized[i].value_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
l_option = g_Locale->getText(localized_value_name);
|
||||
|
||||
|
||||
//paint item
|
||||
prepareItem(selected, height);
|
||||
|
||||
|
@@ -323,8 +323,13 @@ private:
|
||||
|
||||
int display_offset;
|
||||
|
||||
int localized_value;
|
||||
neutrino_locale_t localized_value_name;
|
||||
typedef struct localized_value_t
|
||||
{
|
||||
int value;
|
||||
neutrino_locale_t value_name;
|
||||
} localized_value_struct_t;
|
||||
std::vector<localized_value_t> localized;
|
||||
|
||||
bool slider_on;
|
||||
bool numeric_input;
|
||||
CChangeObserver * observ;
|
||||
@@ -362,8 +367,7 @@ private:
|
||||
void setNumberFormat(std::string format) { numberFormat = format; }
|
||||
void setNumberFormat(std::string (*fun)(int)) { numberFormatFunction = fun; }
|
||||
void setNumericInput(bool _numeric_input) { numeric_input = _numeric_input; }
|
||||
void setLocalizedValue(int special_value) { localized_value = special_value; }
|
||||
void setLocalizedValueName(neutrino_locale_t special_value_name) { localized_value_name = special_value_name; }
|
||||
void setLocalizedValue(int special_value, neutrino_locale_t special_value_name) { localized.push_back({special_value, special_value_name}); }
|
||||
};
|
||||
|
||||
class CMenuOptionChooserOptions
|
||||
|
Reference in New Issue
Block a user