SavePresetDialog: Check max path length for input preset name

+ Add default suffix for "Palette 1" for mode markers
This commit is contained in:
YuSanka 2022-12-21 12:59:34 +01:00
parent b90e109b41
commit dffca9c54a
2 changed files with 12 additions and 1 deletions

View file

@ -18,7 +18,7 @@ namespace GUI {
//static ModePaletteComboBox::PalettesMap MODE_PALETTES =
static std::vector<std::pair<std::string, std::vector<std::string>>> MODE_PALETTES =
{
{ L("Palette 1"), { "#7DF028", "#FFDC00", "#E70000" } },
{ L("Palette 1 (default)"), { "#7DF028", "#FFDC00", "#E70000" } },
{ L("Palette 2"), { "#FC766A", "#B0B8B4", "#184A45" } },
{ L("Palette 3"), { "#567572", "#964F4C", "#696667" } },
{ L("Palette 4"), { "#DA291C", "#56A8CB", "#53A567" } },

View file

@ -185,6 +185,17 @@ void SavePresetDialog::Item::update()
m_valid_type = ValidationType::NoValid;
}
#ifdef __WXMSW__
const int max_path_length = MAX_PATH;
#else
const int max_path_length = 255;
#endif
if (m_valid_type == ValidationType::Valid && m_presets->path_from_name(m_preset_name).length() >= max_path_length) {
info_line = _L("The name is too long.");
m_valid_type = ValidationType::NoValid;
}
if (m_valid_type == ValidationType::Valid && m_preset_name.find_first_of(' ') == 0) {
info_line = _L("The name cannot start with space character.");
m_valid_type = ValidationType::NoValid;