Skip to content

Commit

Permalink
fix longrun of setttingsDialog with setValue for TTS
Browse files Browse the repository at this point in the history
  • Loading branch information
Apaczer committed Dec 4, 2023
1 parent bdd3da9 commit 673c4c5
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 38 deletions.
12 changes: 6 additions & 6 deletions src/menusettingbool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &title, const st
MenuSetting(gmenu2x, title, description), _ivalue(value) {
_value = NULL;
originalValue = *value != 0;
setValue(this->value());
setValue(this->value(), 0);
initButton();
}

MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &title, const string &description, bool *value):
MenuSetting(gmenu2x, title, description), _value(value) {
_ivalue = NULL;
originalValue = *value;
setValue(this->value());
setValue(this->value(), 0);
initButton();
}

Expand Down Expand Up @@ -65,24 +65,24 @@ uint32_t MenuSettingBool::manageInput() {
}

void MenuSettingBool::toggle() {
setValue(!value());
setValue(!value(), 1);
}

void MenuSettingBool::current() {
setValue(value());
setValue(value(), 1);
}

void MenuSettingBool::setValue(int value) {
setValue(value != 0);
}

void MenuSettingBool::setValue(bool value) {
void MenuSettingBool::setValue(bool value, bool readValue) {
if (_value == NULL)
*_ivalue = value;
else
*_value = value;
strvalue = value ? "ON" : "OFF";
gmenu2x->allyTTS(strvalue.c_str(), SLOW_GAP_TTS, SLOW_SPEED_TTS, 0);
if (readValue) gmenu2x->allyTTS(strvalue.c_str(), SLOW_GAP_TTS, SLOW_SPEED_TTS, 0);
}

bool MenuSettingBool::value() {
Expand Down
2 changes: 1 addition & 1 deletion src/menusettingbool.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MenuSettingBool : public MenuSetting {
virtual bool edited();

void setValue(int value);
void setValue(bool value);
void setValue(bool value, bool readValue);
bool value();
void current();
};
Expand Down
18 changes: 9 additions & 9 deletions src/menusettingint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using fastdelegate::MakeDelegate;
MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, const string &title, const string &description, int *value, int def, int min, int max, int delta):
MenuSetting(gmenu2x, title, description), _value(value), def(def), min(min), max(max), delta(delta), off(false) {
originalValue = *value;
setValue(evalIntConf(value, def, min, max));
setValue(evalIntConf(value, def, min, max), 0);

//Delegates
// ButtonAction actionInc = MakeDelegate(this, &MenuSettingInt::inc);
Expand Down Expand Up @@ -63,27 +63,27 @@ void MenuSettingInt::draw(int y) {
uint32_t MenuSettingInt::manageInput() {
if (gmenu2x->input[LEFT]) dec();
else if (gmenu2x->input[RIGHT]) inc();
else if (gmenu2x->input[DEC]) setValue(value() - 10 * delta);
else if (gmenu2x->input[INC]) setValue(value() + 10 * delta);
else if (gmenu2x->input[DEC]) setValue(value() - 10 * delta, 1);
else if (gmenu2x->input[INC]) setValue(value() + 10 * delta, 1);
else if (gmenu2x->input[MENU]) setDefault();
else if (gmenu2x->input[MODIFIER]) current();

return 0; // SD_NO_ACTION
}

void MenuSettingInt::inc() {
setValue(value() + delta);
setValue(value() + delta, 1);
}

void MenuSettingInt::dec() {
setValue(value() - delta);
setValue(value() - delta, 1);
}

void MenuSettingInt::current() {
setValue(*_value);
setValue(*_value, 1);
}

void MenuSettingInt::setValue(int value) {
void MenuSettingInt::setValue(int value, bool readValue) {
if (off && *_value < value && value <= offValue)
*_value = offValue + 1;
else if (off && *_value > value && value <= offValue)
Expand All @@ -98,11 +98,11 @@ void MenuSettingInt::setValue(int value) {
ss << *_value;
strvalue = "";
ss >> strvalue;
gmenu2x->allyTTS(strvalue.c_str(), SLOW_GAP_TTS, SLOW_SPEED_TTS, 0);
if (readValue) gmenu2x->allyTTS(strvalue.c_str(), SLOW_GAP_TTS, SLOW_SPEED_TTS, 0);
}

void MenuSettingInt::setDefault() {
setValue(def);
setValue(def, 1);
}

int MenuSettingInt::value() {
Expand Down
2 changes: 1 addition & 1 deletion src/menusettingint.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MenuSettingInt : public MenuSetting {
virtual void draw(int);
virtual bool edited();

virtual void setValue(int value);
virtual void setValue(int value, bool readValue);
virtual void setDefault();

int value();
Expand Down
22 changes: 11 additions & 11 deletions src/menusettingmultiint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ MenuSettingMultiInt::MenuSettingMultiInt(GMenu2X *gmenu2x, const string &title,
this->min = min;
this->max = max;

setValue(evalIntConf(choices[selection], def, min, max));
setValue(evalIntConf(choices[selection], def, min, max), 0);

//Delegates
ButtonAction actionInc = MakeDelegate(this, &MenuSettingMultiInt::inc);
Expand Down Expand Up @@ -90,53 +90,53 @@ int MenuSettingMultiInt::reverseLookup(int value) {
void MenuSettingMultiInt::inc() {
if(selection < selection_max && choices[selection + 1] <= max) {
selection = selection + 1;
setValue(choices[selection]);
setValue(choices[selection], 1);
}
}

void MenuSettingMultiInt::inc2x() {
if(selection < selection_max && ((choices[selection + 1] < max) || (choices[selection + 2] == max))) {
selection = selection + 2;
setValue(choices[selection]);
setValue(choices[selection], 1);
} else if(selection < selection_max && choices[selection + 1] == max) {
selection = selection + 1;
setValue(choices[selection]);
setValue(choices[selection], 1);
}
}

void MenuSettingMultiInt::dec() {
if(selection > 0 && choices[selection - 1] >= min) {
selection = selection - 1;
setValue(choices[selection]);
setValue(choices[selection], 1);
}
}

void MenuSettingMultiInt::dec2x() {
if(selection > 0 && ((choices[selection - 1] > min) || (choices[selection - 2] == min))) {
selection = selection - 2;
setValue(choices[selection]);
setValue(choices[selection], 1);
} else if(selection > 0 && choices[selection - 1] == min) {
selection = selection - 1;
setValue(choices[selection]);
setValue(choices[selection], 1);
}
}

void MenuSettingMultiInt::current() {
setValue(*_value);
setValue(*_value, 1);
}

void MenuSettingMultiInt::setValue(int value) {
void MenuSettingMultiInt::setValue(int value, bool readValue) {
*_value = value;
stringstream ss;
ss << *_value;
strvalue = "";
ss >> strvalue;
gmenu2x->allyTTS(strvalue.c_str(), MEDIUM_GAP_TTS, MEDIUM_SPEED_TTS, 0);
if (readValue) gmenu2x->allyTTS(strvalue.c_str(), MEDIUM_GAP_TTS, MEDIUM_SPEED_TTS, 0);
}

void MenuSettingMultiInt::setDefault() {
selection = reverseLookup(def);
setValue(choices[selection]);
setValue(choices[selection], 1);
}

int MenuSettingMultiInt::value() {
Expand Down
2 changes: 1 addition & 1 deletion src/menusettingmultiint.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MenuSettingMultiInt : public MenuSetting {
virtual void draw(int);
virtual bool edited();

virtual void setValue(int value);
virtual void setValue(int value, bool readValue);
virtual void setDefault();

int value();
Expand Down
14 changes: 7 additions & 7 deletions src/menusettingmultistring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using std::find;

MenuSettingMultiString::MenuSettingMultiString(GMenu2X *gmenu2x, const string &title, const string &description, string *value, const vector<string> *choices, msms_onchange_t onChange, msms_onselect_t onSelect):
MenuSettingStringBase(gmenu2x, title, description, value), choices(choices), onChange(onChange), onSelect(onSelect) {
setSel(find(choices->begin(), choices->end(), *value) - choices->begin());
setSel(find(choices->begin(), choices->end(), *value) - choices->begin(), 0);

if (choices->size() > 1) {
btn = new IconButton(gmenu2x, "dpad", gmenu2x->tr["Change"]);
Expand Down Expand Up @@ -57,25 +57,25 @@ uint32_t MenuSettingMultiString::manageInput() {
currentSel();
}
else if (gmenu2x->input[MENU]) {
setSel(0);
setSel(0, 1);
return this->onChange && this->onChange();
}
return 0; // SD_NO_ACTION
}

void MenuSettingMultiString::incSel() {
setSel(selected + 1);
setSel(selected + 1, 1);
}

void MenuSettingMultiString::decSel() {
setSel(selected - 1);
setSel(selected - 1, 1);
}

void MenuSettingMultiString::currentSel() {
setSel(selected);
setSel(selected, 1);
}

void MenuSettingMultiString::setSel(int sel) {
void MenuSettingMultiString::setSel(int sel, bool readValue) {
if (sel < 0) {
sel = choices->size()-1;
} else if (sel >= (int)choices->size()) {
Expand All @@ -85,7 +85,7 @@ void MenuSettingMultiString::setSel(int sel) {

setValue((*choices)[sel]);

gmenu2x->allyTTS(value().c_str(), MEDIUM_GAP_TTS, MEDIUM_SPEED_TTS, 0);
if (readValue) gmenu2x->allyTTS(value().c_str(), MEDIUM_GAP_TTS, MEDIUM_SPEED_TTS, 0);
}

void MenuSettingMultiString::draw(int y) {
Expand Down
2 changes: 1 addition & 1 deletion src/menusettingmultistring.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MenuSettingMultiString : public MenuSettingStringBase {

void incSel();
void decSel();
void setSel(int sel);
void setSel(int sel, bool readValue);
void currentSel();

msms_onchange_t onChange;
Expand Down
1 change: 0 additions & 1 deletion src/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ bool SettingsDialog::exec() {
gmenu2x->allyTTS(readSetting.c_str(), MEDIUM_GAP_TTS, MEDIUM_SPEED_TTS, 0);

while (loop) {
// TODO: fix longrun of setttingsDialog with TTS
bool ally = false;
gmenu2x->menu->initLayout();
gmenu2x->font->setSize(gmenu2x->skinConfInt["fontSize"])->setColor(gmenu2x->skinConfColors[COLOR_FONT])->setOutlineColor(gmenu2x->skinConfColors[COLOR_FONT_OUTLINE]);
Expand Down

0 comments on commit 673c4c5

Please sign in to comment.