mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-11-29 10:48:56 -08:00
cfg: trim surrounding whitespace in options tab (#935)
## Link to GitHub Issue or related Pull Request, if one exists n/a ## Description of change Remove leading and trailing whitespace for some commonly used options (EA server URL, pcbid, etc) to prevent users copy-pasting wrong text. ## Testing cfg only
This commit is contained in:
1 parent
ce87d20f25
commit
ae7d169b3f
3 files changed
+16
-3
No files matched your search
@@ -48,6 +48,8 @@ struct OptionDefinition {
|
||||
std::string file_extension = "";
|
||||
|
||||
std::string quick_setting_category = "";
|
||||
|
||||
bool trim_whitespace = false;
|
||||
};
|
||||
|
||||
class Option {
|
||||
|
||||
@@ -138,6 +138,7 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
||||
.setting_name = "example.com:8083",
|
||||
.category = "Network",
|
||||
.quick_setting_category = "Network",
|
||||
.trim_whitespace = true,
|
||||
};
|
||||
c[launcher::Options::PCBID] = {
|
||||
.title = "PCBID",
|
||||
@@ -148,6 +149,7 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
||||
.category = "Network",
|
||||
.sensitive = true,
|
||||
.quick_setting_category = "Network",
|
||||
.trim_whitespace = true,
|
||||
};
|
||||
c[launcher::Options::Player1Card] = {
|
||||
.title = "Player 1 Card",
|
||||
@@ -159,6 +161,7 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
||||
.sensitive = true,
|
||||
.picker = OptionPickerType::EACard,
|
||||
.quick_setting_category = "Network",
|
||||
.trim_whitespace = true,
|
||||
};
|
||||
c[launcher::Options::Player2Card] = {
|
||||
.title = "Player 2 Card",
|
||||
@@ -170,6 +173,7 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
||||
.sensitive = true,
|
||||
.picker = OptionPickerType::EACard,
|
||||
.quick_setting_category = "Network",
|
||||
.trim_whitespace = true,
|
||||
};
|
||||
c[launcher::Options::Player1PinMacro] = {
|
||||
.title = "Player 1 PIN Macro",
|
||||
|
||||
@@ -5282,9 +5282,16 @@ namespace overlay::windows {
|
||||
ImGui::InputTextWithHint("", hint, buffer, sizeof(buffer) - 1);
|
||||
// would like to use IsItemDeactivatedAfterEdit but can't handle the case when window is closed while editing
|
||||
if (ImGui::IsItemEdited()) {
|
||||
this->options_dirty = true;
|
||||
option.value = buffer;
|
||||
::Config::getInstance().updateBinding(games_list[games_selected], option);
|
||||
// trim whitespace to prevent copy/paste errors
|
||||
auto value = definition.trim_whitespace ?
|
||||
strtrim(buffer) : std::string(buffer);
|
||||
|
||||
if (option.value != value) {
|
||||
this->options_dirty = true;
|
||||
option.value = std::move(value);
|
||||
::Config::getInstance().updateBinding(games_list[games_selected], option);
|
||||
}
|
||||
|
||||
}
|
||||
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
||||
ImGui::HelpTooltip(definition.desc.c_str());
|
||||
|
||||
Reference in new issue
Block a user