From 3846de37bb3712268f0bd3cd13f0e36fa4ccf4a8 Mon Sep 17 00:00:00 2001 From: Sad Pencil Date: Sun, 5 Dec 2021 04:45:22 +0800 Subject: [PATCH] update feature TranslationUpdateCheck --- Ra2CsfToolsGUI/MainWindow.xaml.cs | 52 +++++++------------------------ 1 file changed, 11 insertions(+), 41 deletions(-) diff --git a/Ra2CsfToolsGUI/MainWindow.xaml.cs b/Ra2CsfToolsGUI/MainWindow.xaml.cs index 61f8b0f..cdb13a4 100644 --- a/Ra2CsfToolsGUI/MainWindow.xaml.cs +++ b/Ra2CsfToolsGUI/MainWindow.xaml.cs @@ -718,7 +718,7 @@ private void TranslationUpdateCheck_SaveIniFile_Click(object sender, RoutedEvent // add upstream info to .ini var ini = GetNewIniFileFromCsfFile(newCsf); - foreach (var labelName in upstreamLabelKeys) + foreach (var labelName in allLabelKeys) { bool translationExist = ini.Sections.ContainsSection(labelName); if (!translationExist) @@ -748,51 +748,21 @@ private void TranslationUpdateCheck_SaveIniFile_Click(object sender, RoutedEvent } } - if (diffDict.ContainsKey(labelName)) + if (transOld.ContainsKey(labelName)) { - bool oldTransExist = oldTransDict.TryGetValue(labelName, out var oldTransValue); - bool newTransExist = newTransDict.TryGetValue(labelName, out var newTransValue); - - if (newUpstreamDict.Keys.Contains(labelName)) + Debug.Assert(transOld.ContainsKey(labelName)); + foreach ((var iLine, var value) in transOld[labelName]) { - if ((!newTransExist) || (!(((oldTransExist && oldTransValue != newTransValue) || (!oldTransExist))))) - { - Debug.Assert(newCsf.Labels.ContainsKey(labelName)); - Debug.Assert(newCsf.Labels[labelName] == TranslationNeededPlaceholder); - - if (oldTransExist) - { - Debug.Assert(transOld.ContainsKey(labelName)); - foreach ((var iLine, var value) in transOld[labelName]) - { - _ = labelSection.AddKey(GetIniLabelCustomKeyName("TranslationOld", iLine), value); - } - } - - if (newTransExist) - { - foreach ((var iLine, var value) in transNew[labelName]) - { - _ = labelSection.AddKey(GetIniLabelCustomKeyName("TranslationNew", iLine), value); - } - } - } + _ = labelSection.AddKey(GetIniLabelCustomKeyName("TranslationOld", iLine), value); } - else - { - if (newTransExist) - { - Debug.Assert(newCsf.Labels.ContainsKey(labelName)); - Debug.Assert(newCsf.Labels[labelName] == TranslationDeleteNeededPlaceholder); + } - Debug.Assert(transNew.ContainsKey(labelName)); - foreach ((var iLine, var value) in transNew[labelName]) - { - _ = labelSection.AddKey(GetIniLabelCustomKeyName("TranslationNew", iLine), value); - } - } + if (transNew.ContainsKey(labelName)) + { + foreach ((var iLine, var value) in transNew[labelName]) + { + _ = labelSection.AddKey(GetIniLabelCustomKeyName("TranslationNew", iLine), value); } - } }