This commit is contained in:
Maschell 2018-09-14 10:38:01 +02:00
parent 728593bbfd
commit 44f373d3e2
2 changed files with 10 additions and 10 deletions

View File

@ -43,7 +43,6 @@ WUPSConfigItemMultipleValues::WUPSConfigItemMultipleValues(std::string configID,
valueIndex = 0; valueIndex = 0;
} }
this->callback = callback; this->callback = callback;
} }
@ -52,7 +51,7 @@ WUPSConfigItemMultipleValues::~WUPSConfigItemMultipleValues() {
} }
std::string WUPSConfigItemMultipleValues::getCurrentValueDisplay() { std::string WUPSConfigItemMultipleValues::getCurrentValueDisplay() {
int32_t index = 0; uint32_t index = 0;
for (auto& kv : values) { for (auto& kv : values) {
if(index == valueIndex) { if(index == valueIndex) {
return " " + kv.second; return " " + kv.second;
@ -63,8 +62,8 @@ std::string WUPSConfigItemMultipleValues::getCurrentValueDisplay() {
} }
std::string WUPSConfigItemMultipleValues::getCurrentValueSelectedDisplay() { std::string WUPSConfigItemMultipleValues::getCurrentValueSelectedDisplay() {
int32_t index_max = values.size()-1; uint32_t index_max = values.size()-1;
int32_t index = 0; uint32_t index = 0;
for (auto& kv : values) { for (auto& kv : values) {
if(index == valueIndex) { if(index == valueIndex) {
std::string s; std::string s;
@ -90,21 +89,22 @@ void WUPSConfigItemMultipleValues::onSelected(bool isSelected) {
} }
void WUPSConfigItemMultipleValues::onButtonPressed(WUPSConfigButtons buttons) { void WUPSConfigItemMultipleValues::onButtonPressed(WUPSConfigButtons buttons) {
int32_t previousValue = valueIndex; uint32_t previousValue = valueIndex;
if(buttons & WUPS_CONFIG_BUTTON_LEFT) { if(buttons & WUPS_CONFIG_BUTTON_LEFT) {
valueIndex--; valueIndex--;
if(valueIndex < 0) { if(valueIndex < 0) {
valueIndex = 0; valueIndex = 0;
} }
} }
if(buttons & WUPS_CONFIG_BUTTON_RIGHT) { if(buttons & WUPS_CONFIG_BUTTON_RIGHT && values.size() > 0) {
valueIndex++; valueIndex++;
if(valueIndex > values.size()-1) { if(valueIndex > values.size()-1) {
valueIndex = values.size()-1; valueIndex = values.size()-1;
} }
} }
if(previousValue != valueIndex) { if(previousValue != valueIndex) {
int32_t index = 0; uint32_t index = 0;
for (auto& kv : values) { for (auto& kv : values) {
if(index == valueIndex) { if(index == valueIndex) {
callback(kv.first); callback(kv.first);
@ -124,9 +124,9 @@ std::string WUPSConfigItemMultipleValues::persistValue() {
} }
void WUPSConfigItemMultipleValues::loadValue(std::string persistedValue) { void WUPSConfigItemMultipleValues::loadValue(std::string persistedValue) {
int32_t newValueIndex = std::stoi(persistedValue); uint32_t newValueIndex = std::stoi(persistedValue);
if(newValueIndex != valueIndex) { if(newValueIndex != valueIndex) {
int32_t index = 0; uint32_t index = 0;
for (auto& kv : values) { for (auto& kv : values) {
if(index == newValueIndex) { if(index == newValueIndex) {
valueIndex = newValueIndex; valueIndex = newValueIndex;

View File

@ -49,7 +49,7 @@ public:
private: private:
MultipleValuesChangedCallback callback = NULL; MultipleValuesChangedCallback callback = NULL;
int32_t defaultValue; int32_t defaultValue;
int32_t valueIndex = 0; uint32_t valueIndex = 0;
std::map<int32_t,std::string> values; std::map<int32_t,std::string> values;
}; };