Don't show an 'other' option for UI scale unless it's actually selected

This commit is contained in:
2023-01-21 20:15:58 -05:00
parent dda95397ec
commit 577ff1a405
2 changed files with 27 additions and 2 deletions

View File

@@ -1249,6 +1249,31 @@ void pick_preferences() {
else if (ui_map_scale>2.95 && ui_map_scale<3.05) uiMapScale.setSelected("3");
else if (ui_map_scale>3.95 && ui_map_scale<4.05) uiMapScale.setSelected("4");
else uiMapScale.setSelected("other");
if(uiScale.getSelected() == "other") {
auto val = std::to_string(ui_scale);
while(val.length() > 2 && val[val.length() - 1] == val[val.length() - 2]) {
val.pop_back();
}
while(val.length() > 1 && (val.back() == '.' || val.back() == '0')) {
val.pop_back();
}
uiScale["other"].setText("Custom: " + val);
} else {
uiScale["other"].hide();
}
if(uiMapScale.getSelected() == "other") {
auto val = std::to_string(ui_map_scale);
while(val.length() > 2 && val[val.length() - 1] == val[val.length() - 2]) {
val.pop_back();
}
while(val.length() > 1 && (val.back() == '.' || val.back() == '0')) {
val.pop_back();
}
uiMapScale["other"].setText("Custom: " + val);
} else {
uiMapScale["other"].hide();
}
void (*give_help)(short,short,cDialog&) = ::give_help;