Fix Custom Preset Label Handling On Language Change

This commit is contained in:
copecone committed 2026-10-14 22:55:00 +09:00
1 parent 8e0639aafa
commit c56175bbc8
1 file changed
+23 -15
+23 -15
View File
@@ -39,7 +39,7 @@ internal static class RenderConfigWindow
/// </summary>
private static RenderConfig? _uiConfig;
private static RenderConfig UiConfig => _uiConfig ??= new RenderConfig();
private static RenderConfig UIConfig => _uiConfig ??= new RenderConfig();
// Controls cache for validation & sync
private static O5Slider? _renderFpsSlider;
@@ -120,7 +120,7 @@ internal static class RenderConfigWindow
ReloadPresetDropdown(GlobalSettings.Current.LastPresetName);
}
var config = UiConfig;
var config = UIConfig;
ApplyConfigToUI(config);
SetWindowActive(true);
@@ -133,7 +133,7 @@ internal static class RenderConfigWindow
var (_, scrollContent, _) =
O5Factory.ScrollView(ctx, content, spacing: 10f, padding: 8f);
var config = UiConfig;
var config = UIConfig;
EnsureDefaultConfig(config);
double[] renderFpsSnap = { 23.976, 24, 29.97, 30, 59.94, 60, 144,
@@ -843,7 +843,7 @@ internal static class RenderConfigWindow
private static void TryGoRender()
{
var config = UiConfig;
var config = UIConfig;
SyncUItoConfig(config);
// The encoders use 4:2:0 chroma subsampling, which needs an even width and height.
@@ -967,6 +967,13 @@ internal static class RenderConfigWindow
}
}
/// <summary>
/// Whether the text is the Custom label of any language. A preset with such a name could not be told apart
/// from the Custom entry of the dropdown after a language change.
/// </summary>
private static bool IsCustomPresetLabel(string text) =>
text == CustomPresetLabel || text == "(Modified)" || text == "(수정됨)";
private static string CustomPresetLabel => LocalizationManager.Get("ui.render_config.preset_custom");
private static void MarkConfigModified()
@@ -1018,7 +1025,7 @@ internal static class RenderConfigWindow
SyncUItoConfig(config);
var name = _presetNameInput?.Value.Trim();
if (string.IsNullOrWhiteSpace(name) || name == CustomPresetLabel)
if (string.IsNullOrWhiteSpace(name) || IsCustomPresetLabel(name))
{
CommonWarningDialogUI.ShowDialog(
LocalizationManager.Get("ui.render_config.validation_title"),
@@ -1200,13 +1207,10 @@ internal static class RenderConfigWindow
private static void OnLanguageChanged(SystemLanguage language)
{
if (_configWindow == null) return;
if (_configWindow == null || _presetDropdown == null) return;
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.
// The preset names are not localized, only the Custom label is. A dropdown value that is not a preset name
// is the Custom label (of the previous language), which is shown only while the values are modified.
var names = PresetManager.GetPresets().Select(p => p.Name).ToList();
if (names.Count == 0)
{
@@ -1216,14 +1220,18 @@ internal static class RenderConfigWindow
return;
}
var current = _presetDropdown.Value;
var isModified = string.IsNullOrEmpty(current) || !names.Contains(current);
_presetDropdown.SetValues(names);
var loadedName = _lastLoadedPresetName;
if (!string.IsNullOrEmpty(loadedName) && names.Contains(loadedName))
if (isModified)
{
_presetDropdown.Set(loadedName, false);
MarkConfigModified();
return;
}
UpdatePresetLabel(UiConfig);
_presetDropdown.Set(current, false);
UpdateDeleteButtonState();
}
private static string GetVersionText()