Fix Language Change And Name Collision In Presets

This commit is contained in:
copecone committed 2026-10-14 20:20:06 +09:00
1 parent 27e7327c1e
commit a4dba82729
2 files changed
+31 -7

No files matched your search

+26 -6
View File
@@ -1023,12 +1023,16 @@ internal static class RenderConfigWindow
bool isCurrentPreset = !string.IsNullOrEmpty(_lastLoadedPresetName) &&
string.Equals(_lastLoadedPresetName, name, StringComparison.OrdinalIgnoreCase);
var existing = PresetManager.GetPresets().FirstOrDefault(p => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase));
// A preset with another name can share the file of this name (PresetManager.GetSafeFileName), e.g. "a/b" and "a_b".
var fileName = PresetManager.GetSafeFileName(name);
var existing = PresetManager.GetPresets().FirstOrDefault(p =>
string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase) ||
string.Equals(PresetManager.GetSafeFileName(p.Name), fileName, StringComparison.OrdinalIgnoreCase));
if (existing != null && !isCurrentPreset)
{
CommonWarningDialogUI.ShowDialog(
LocalizationManager.Get("ui.render_config.preset_overwrite_title"),
LocalizationManager.Get("ui.render_config.preset_overwrite_desc", name),
LocalizationManager.Get("ui.render_config.preset_overwrite_desc", existing.Name),
new DialogButton(
LocalizationManager.Get("ui.render_config.confirm"),
() => DoSavePreset(name, config)
@@ -1190,12 +1194,28 @@ internal static class RenderConfigWindow
{
if (_configWindow == null) return;
if (_presetDropdown != null)
if (_presetDropdown == null) return;
// The preset names are not localized, the Custom label is. The list is rebuilt from the preset names
// (which drops the Custom label of the previous language), then the label is decided from the values:
// the Custom label of the new language only when the values differ from the last loaded preset.
var names = PresetManager.GetPresets().Select(p => p.Name).ToList();
if (names.Count == 0)
{
var cur = _presetDropdown.Value;
var isCustom = cur == "(Modified)" || cur == "(수정됨)" || cur == CustomPresetLabel;
ReloadPresetDropdown(isCustom ? CustomPresetLabel : cur);
_presetDropdown.SetValues(new List<string> { CustomPresetLabel });
_presetDropdown.Set(CustomPresetLabel, false);
UpdateDeleteButtonState();
return;
}
_presetDropdown.SetValues(names);
var loadedName = _lastLoadedPresetName;
if (!string.IsNullOrEmpty(loadedName) && names.Contains(loadedName))
{
_presetDropdown.Set(loadedName, false);
}
UpdatePresetLabel(UiConfig);
}
private static string GetVersionText()