From 8d70ce8862e8421bdc98f098d167b610c73afbc8 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Tue, 23 Jun 2026 21:41:24 +0800 Subject: [PATCH] refactor: use localization constants at remaining call sites --- .../Functions/DysonSphere/DysonSphereResolver.cs | 6 +++--- .../Functions/DysonSphere/FrameRemovalFunctions.cs | 2 +- .../DysonSphere/ShellCompletionFunctions.cs | 2 +- CheatEnabler/Functions/PlayerFunctions.cs | 12 ++++++------ CheatEnabler/Localization.cs | 4 ++-- CheatEnabler/Patches/Factory/FactoryPatch.cs | 8 ++++---- UXAssist/Functions/TechFunctions.cs | 6 +++--- UXAssist/Functions/UI/AutoConstructUI.cs | 2 +- UXAssist/Functions/WindowFunctions.cs | 10 +++++----- UXAssist/Patches/GamePatch.cs | 4 ++-- UXAssist/UIConfigWindow.cs | 4 ++-- 11 files changed, 30 insertions(+), 30 deletions(-) diff --git a/CheatEnabler/Functions/DysonSphere/DysonSphereResolver.cs b/CheatEnabler/Functions/DysonSphere/DysonSphereResolver.cs index 6dea11a..596dbd5 100644 --- a/CheatEnabler/Functions/DysonSphere/DysonSphereResolver.cs +++ b/CheatEnabler/Functions/DysonSphere/DysonSphereResolver.cs @@ -28,7 +28,7 @@ public static class DysonSphereResolver var star = GameMain.localStar; if (star == null) { - UIMessageBox.Show(Localization.CheatEnabler.Translate(), "You are not in any system.".Translate(), Localization.OK.Translate(), UIMessageBox.ERROR, null); + UIMessageBox.Show(Localization.CheatEnabler.Translate(), Localization.YouAreNotInAnySystem.Translate(), Localization.OK.Translate(), UIMessageBox.ERROR, null); } return star; } @@ -40,12 +40,12 @@ public static class DysonSphereResolver var sphere = GameMain.data?.dysonSpheres[star.index]; if (sphere == null) { - UIMessageBox.Show(Localization.CheatEnabler.Translate(), string.Format("There is no Dyson Sphere data on \"{0}\".".Translate(), star.displayName), Localization.OK.Translate(), UIMessageBox.ERROR, null); + UIMessageBox.Show(Localization.CheatEnabler.Translate(), string.Format(Localization.ThereIsNoDysonSphereDataOn0.Translate(), star.displayName), Localization.OK.Translate(), UIMessageBox.ERROR, null); return null; } if (requireLayer && sphere.layerCount == 0) { - UIMessageBox.Show(Localization.CheatEnabler.Translate(), string.Format("There is no Dyson Sphere shell on \"{0}\".".Translate(), star.displayName), Localization.OK.Translate(), UIMessageBox.ERROR, null); + UIMessageBox.Show(Localization.CheatEnabler.Translate(), string.Format(Localization.ThereIsNoDysonSphereShellOn0.Translate(), star.displayName), Localization.OK.Translate(), UIMessageBox.ERROR, null); return null; } return (sphere, star); diff --git a/CheatEnabler/Functions/DysonSphere/FrameRemovalFunctions.cs b/CheatEnabler/Functions/DysonSphere/FrameRemovalFunctions.cs index 1484974..cfe6dff 100644 --- a/CheatEnabler/Functions/DysonSphere/FrameRemovalFunctions.cs +++ b/CheatEnabler/Functions/DysonSphere/FrameRemovalFunctions.cs @@ -17,7 +17,7 @@ public static class FrameRemovalFunctions if (resolved == null) return; var (dysonSphere, star) = resolved.Value; - UIMessageBox.Show(Localization.CheatEnabler.Translate(), string.Format("This will remove all frames on \"{0}\". Are you sure?".Translate(), star.displayName), Localization.Cancel.Translate(), Localization.OK.Translate(), UIMessageBox.QUESTION, null, () => + UIMessageBox.Show(Localization.CheatEnabler.Translate(), string.Format(Localization.ThisWillRemoveAllFramesOn0AreYouSure.Translate(), star.displayName), Localization.Cancel.Translate(), Localization.OK.Translate(), UIMessageBox.QUESTION, null, () => { var totalFrameSpInfo = AccessTools.Field(typeof(DysonSphereLayer), "totalFrameSP"); diff --git a/CheatEnabler/Functions/DysonSphere/ShellCompletionFunctions.cs b/CheatEnabler/Functions/DysonSphere/ShellCompletionFunctions.cs index 52d54fc..3351c7a 100644 --- a/CheatEnabler/Functions/DysonSphere/ShellCompletionFunctions.cs +++ b/CheatEnabler/Functions/DysonSphere/ShellCompletionFunctions.cs @@ -17,7 +17,7 @@ public static class ShellCompletionFunctions if (resolved == null) return; var (dysonSphere, star) = resolved.Value; - UIMessageBox.Show(Localization.CheatEnabler.Translate(), string.Format("This will complete all Dyson Sphere shells on \"{0}\". Are you sure?".Translate(), star.displayName), Localization.Cancel.Translate(), Localization.OK.Translate(), UIMessageBox.QUESTION, null, () => + UIMessageBox.Show(Localization.CheatEnabler.Translate(), string.Format(Localization.ThisWillCompleteAllDysonSphereShellsOn0InstantlyAreYouSure.Translate(), star.displayName), Localization.Cancel.Translate(), Localization.OK.Translate(), UIMessageBox.QUESTION, null, () => { var totalNodeSpInfo = AccessTools.Field(typeof(DysonSphereLayer), "totalNodeSP"); var totalFrameSpInfo = AccessTools.Field(typeof(DysonSphereLayer), "totalFrameSP"); diff --git a/CheatEnabler/Functions/PlayerFunctions.cs b/CheatEnabler/Functions/PlayerFunctions.cs index 3d5669b..f16bafe 100644 --- a/CheatEnabler/Functions/PlayerFunctions.cs +++ b/CheatEnabler/Functions/PlayerFunctions.cs @@ -89,10 +89,10 @@ public static class PlayerFunctions if (itemCnt.All(cnt => cnt == 0)) { - UIMessageBox.Show("Remove all metadata consumption records".Translate(), "NoMetadataConsumptionRecord".Translate(), "OK".Translate(), UIMessageBox.INFO); + UIMessageBox.Show(Localization.RemoveAllMetadataConsumptionRecords.Translate(), Localization.NoMetadataConsumptionRecord.Translate(), Localization.OK.Translate(), UIMessageBox.INFO); return; } - var msg = "ClearAllMetadataConsumptionDetails".Translate(); + var msg = Localization.ClearAllMetadataConsumptionDetails.Translate(); for (var i = 0; i < itemCnt.Length; i++) { if (itemCnt[i] > 0) @@ -100,7 +100,7 @@ public static class PlayerFunctions msg += $"\n {LDB.items.Select(i + ItemIds.HydrogenFuelRod).propertyName} x{itemCnt[i]}"; } } - UIMessageBox.Show("Remove all metadata consumption records".Translate(), msg, "Cancel".Translate(), "OK".Translate(), UIMessageBox.QUESTION, null, () => + UIMessageBox.Show(Localization.RemoveAllMetadataConsumptionRecords.Translate(), msg, Localization.Cancel.Translate(), Localization.OK.Translate(), UIMessageBox.QUESTION, null, () => { foreach (var data in propertySystem.propertyDatas) { @@ -126,7 +126,7 @@ public static class PlayerFunctions var clusterPropertyData = propertySystem.propertyDatas.FirstOrDefault(cpd => cpd.seedKey == seedKey); if (clusterPropertyData == null) { - UIMessageBox.Show("Remove metadata consumption record in current game".Translate(), "NoMetadataConsumptionRecord".Translate(), "OK".Translate(), UIMessageBox.INFO); + UIMessageBox.Show(Localization.RemoveMetadataConsumptionRecordInCurrentGame.Translate(), Localization.NoMetadataConsumptionRecord.Translate(), Localization.OK.Translate(), UIMessageBox.INFO); return; } var currentGamePropertyData = GameMain.data.history.propertyData; @@ -140,7 +140,7 @@ public static class PlayerFunctions UIMessageBox.Show("Remove metadata consumption record in current game".Translate(), "NoMetadataConsumptionRecord".Translate(), "OK".Translate(), UIMessageBox.INFO); return; } - var msg = "ClearCurrentMetadataConsumptionDetails".Translate(); + var msg = Localization.ClearCurrentMetadataConsumptionDetails.Translate(); for (var i = 0; i < itemCnt.Length; i++) { if (itemCnt[i] > 0) @@ -148,7 +148,7 @@ public static class PlayerFunctions msg += $"\n {LDB.items.Select(i + ItemIds.HydrogenFuelRod).propertyName} x{itemCnt[i]}"; } } - UIMessageBox.Show("Remove metadata consumption record in current game".Translate(), msg, "Cancel".Translate(), "OK".Translate(), UIMessageBox.QUESTION, null, () => + UIMessageBox.Show(Localization.RemoveMetadataConsumptionRecordInCurrentGame.Translate(), msg, Localization.Cancel.Translate(), Localization.OK.Translate(), UIMessageBox.QUESTION, null, () => { for (var i = 0; i < clusterPropertyData.totalConsumption.Count; i++) { diff --git a/CheatEnabler/Localization.cs b/CheatEnabler/Localization.cs index 8f68fea..0cc0047 100644 --- a/CheatEnabler/Localization.cs +++ b/CheatEnabler/Localization.cs @@ -8,7 +8,7 @@ public static class Localization public const string YouAreNotInAnySystem = "You are not in any system."; public const string ThereIsNoDysonSphereShellOn0 = "There is no Dyson Sphere shell on \"{0}\"."; public const string ThereIsNoDysonSphereDataOn0 = "There is no Dyson Sphere data on \"{0}\"."; - public const string ThisWillCompleteAllDysonSphereShellsOn0InstantlyAreYouSure = "This will complete all Dyson Sphere shells on \"{0}\" instantly. Are you sure?"; + public const string ThisWillCompleteAllDysonSphereShellsOn0InstantlyAreYouSure = "This will complete all Dyson Sphere shells on \"{0}\". Are you sure?"; public const string ThisWillRemoveAllFramesOn0AreYouSure = "This will remove all frames on \"{0}\". Are you sure?"; public const string NoPrecalculatedShellFoundForRadius0 = "No precalculated shell found for radius {0}."; public const string ClearAllMetadataConsumptionDetails = "ClearAllMetadataConsumptionDetails"; @@ -98,7 +98,7 @@ public static class Localization I18N.Add(YouAreNotInAnySystem, "You are not in any system.", "你不在任何星系中"); I18N.Add(ThereIsNoDysonSphereShellOn0, "There is no Dyson Sphere shell on \"{0}\".", "“{0}”上没有可建造的戴森壳"); I18N.Add(ThereIsNoDysonSphereDataOn0, "There is no Dyson Sphere data on \"{0}\".", "“{0}”上没有戴森球数据"); - I18N.Add(ThisWillCompleteAllDysonSphereShellsOn0InstantlyAreYouSure, "This will complete all Dyson Sphere shells on \"{0}\" instantly. Are you sure?", "这将立即完成“{0}”上的所有戴森壳。你确定吗?"); + I18N.Add(ThisWillCompleteAllDysonSphereShellsOn0InstantlyAreYouSure, "This will complete all Dyson Sphere shells on \"{0}\". Are you sure?", "这将完成“{0}”上的所有戴森壳。你确定吗?"); I18N.Add(ThisWillRemoveAllFramesOn0AreYouSure, "This will remove all frames on \"{0}\". Are you sure?", "这将移除“{0}”上的所有框架。你确定吗?"); I18N.Add(NoPrecalculatedShellFoundForRadius0, "No precalculated shell found for radius {0}.", "没有找到适合半径 {0} 的预计算壳面"); I18N.Add(ClearAllMetadataConsumptionDetails, """ diff --git a/CheatEnabler/Patches/Factory/FactoryPatch.cs b/CheatEnabler/Patches/Factory/FactoryPatch.cs index f839a5f..c4cd009 100644 --- a/CheatEnabler/Patches/Factory/FactoryPatch.cs +++ b/CheatEnabler/Patches/Factory/FactoryPatch.cs @@ -123,7 +123,7 @@ public class FactoryPatch : PatchImpl NoConditionEnabled.Value = !NoConditionEnabled.Value; if (!DSPGame.IsMenuDemo && GameMain.isRunning) { - UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead((NoConditionEnabled.Value ? "NoConditionOn" : "NoConditionOff").Translate()); + UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead((NoConditionEnabled.Value ? Localization.NoConditionOn : Localization.NoConditionOff).Translate()); } } if (_noCollisionKey.keyValue) @@ -131,7 +131,7 @@ public class FactoryPatch : PatchImpl NoCollisionEnabled.Value = !NoCollisionEnabled.Value; if (!DSPGame.IsMenuDemo && GameMain.isRunning) { - UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead((NoCollisionEnabled.Value ? "NoCollisionOn" : "NoCollisionOff").Translate()); + UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead((NoCollisionEnabled.Value ? Localization.NoCollisionOn : Localization.NoCollisionOff).Translate()); } } } @@ -248,11 +248,11 @@ public class FactoryPatch : PatchImpl { if (NoConditionEnabled.Value) { - w.criticalWarningTexts = "Build without condition is enabled!".Translate() + "\r\n"; + w.criticalWarningTexts = Localization.BuildWithoutConditionIsEnabled.Translate() + "\r\n"; } else if (NoCollisionEnabled.Value) { - w.criticalWarningTexts = "No collision is enabled!".Translate() + "\r\n"; + w.criticalWarningTexts = Localization.NoCollisionIsEnabled.Translate() + "\r\n"; } } ) diff --git a/UXAssist/Functions/TechFunctions.cs b/UXAssist/Functions/TechFunctions.cs index b5ab1c3..67a9bb2 100644 --- a/UXAssist/Functions/TechFunctions.cs +++ b/UXAssist/Functions/TechFunctions.cs @@ -204,7 +204,7 @@ public static class TechFunctions UnlockWithPropertiesImmediately(); return; } - var msg = "Do you want to use metadata to buyout the following tech?".Translate(); + var msg = I18NKeys.DoYouWantToUseMetadataToBuyoutTheFollowingTech.Translate(); if (techList.Count <= 10) { @@ -227,13 +227,13 @@ public static class TechFunctions } msg += "\n\n"; - msg += "The following is the required metadata for buyout:".Translate(); + msg += I18NKeys.TheFollowingIsTheRequiredMetadataForBuyout.Translate(); foreach (var consumption in properties) { if (consumption.Value <= 0) continue; msg += $"\n {LDB.items.Select(consumption.Key).propertyName}x{consumption.Value}"; } - UIMessageBox.Show("Batch buyout tech".Translate(), msg, I18NKeys.Cancel.Translate(), I18NKeys.OK.Translate(), UIMessageBox.QUESTION, null, UnlockWithPropertiesImmediately); + UIMessageBox.Show(I18NKeys.BatchBuyoutTech.Translate(), msg, I18NKeys.Cancel.Translate(), I18NKeys.OK.Translate(), UIMessageBox.QUESTION, null, UnlockWithPropertiesImmediately); return; void AddToMsg(ref string str, Tuple tuple) diff --git a/UXAssist/Functions/UI/AutoConstructUI.cs b/UXAssist/Functions/UI/AutoConstructUI.cs index 5f2e5f4..696fc38 100644 --- a/UXAssist/Functions/UI/AutoConstructUI.cs +++ b/UXAssist/Functions/UI/AutoConstructUI.cs @@ -99,6 +99,6 @@ internal static class AutoConstructUI public static void UpdateConstructCountText(int count) { if (ConstructCountText == null) return; - ConstructCountText.text = String.Format("Buildings to construct: {0}".Translate(), count); + ConstructCountText.text = String.Format(I18NKeys.BuildingsToConstruct0.Translate(), count); } } diff --git a/UXAssist/Functions/WindowFunctions.cs b/UXAssist/Functions/WindowFunctions.cs index 1573711..f16613f 100644 --- a/UXAssist/Functions/WindowFunctions.cs +++ b/UXAssist/Functions/WindowFunctions.cs @@ -50,11 +50,11 @@ public static class WindowFunctions { return priority switch { - WinApi.HIGH_PRIORITY_CLASS => "High".Translate(), - WinApi.ABOVE_NORMAL_PRIORITY_CLASS => "Above Normal".Translate(), - WinApi.NORMAL_PRIORITY_CLASS => "Normal".Translate(), - WinApi.BELOW_NORMAL_PRIORITY_CLASS => "Below Normal".Translate(), - WinApi.IDLE_PRIORITY_CLASS => "Idle".Translate(), + WinApi.HIGH_PRIORITY_CLASS => I18NKeys.High.Translate(), + WinApi.ABOVE_NORMAL_PRIORITY_CLASS => I18NKeys.AboveNormal.Translate(), + WinApi.NORMAL_PRIORITY_CLASS => I18NKeys.Normal.Translate(), + WinApi.BELOW_NORMAL_PRIORITY_CLASS => I18NKeys.BelowNormal.Translate(), + WinApi.IDLE_PRIORITY_CLASS => I18NKeys.Idle.Translate(), _ => I18NKeys.Unknown.Translate() }; } diff --git a/UXAssist/Patches/GamePatch.cs b/UXAssist/Patches/GamePatch.cs index b4e767b..c201c30 100644 --- a/UXAssist/Patches/GamePatch.cs +++ b/UXAssist/Patches/GamePatch.cs @@ -133,13 +133,13 @@ public class GamePatch : PatchImpl if (_speedDownKey.keyValue) { GameUpsFactor.Value = Maths.Clamp(Math.Round((GameUpsFactor.Value - 0.5) * 2.0) / 2.0, 0.1, 10.0); - UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead(string.Format("Logical frame rate: {0}x".Translate(), GameUpsFactor.Value)); + UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead(string.Format(I18NKeys.LogicalFrameRate0X.Translate(), GameUpsFactor.Value)); } if (_speedUpKey.keyValue) { GameUpsFactor.Value = Maths.Clamp(Math.Round((GameUpsFactor.Value + 0.5) * 2.0) / 2.0, 0.1, 10.0); - UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead(string.Format("Logical frame rate: {0}x".Translate(), GameUpsFactor.Value)); + UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead(string.Format(I18NKeys.LogicalFrameRate0X.Translate(), GameUpsFactor.Value)); } } diff --git a/UXAssist/UIConfigWindow.cs b/UXAssist/UIConfigWindow.cs index 4393113..47519ec 100644 --- a/UXAssist/UIConfigWindow.cs +++ b/UXAssist/UIConfigWindow.cs @@ -536,8 +536,8 @@ public static class UIConfigWindow void AddApplyButton(float rowY, string objName, UnityAction onClick) => AddApplyButtonAt(applyBtnX, rowY, objName, onClick); void AddCategoryApplyButton(float catY, string objName, UnityAction onClick) => - wnd.AddFlatButton(applyAllBtnX, catY + 7f, tab3, "Apply all config to planet", applyBtnFontSize, objName, onClick).WithSize(applyAllBtnWidth, applyBtnHeight) - .WithFontSize(applyBtnFontSize).WithTip("Apply all config to planet tips".Translate()); + wnd.AddFlatButton(applyAllBtnX, catY + 7f, tab3, I18NKeys.ApplyAllConfigToPlanet, applyBtnFontSize, objName, onClick).WithSize(applyAllBtnWidth, applyBtnHeight) + .WithFontSize(applyBtnFontSize).WithTip(I18NKeys.ApplyAllConfigToPlanetTips.Translate()); AddCategoryApplyButton(dispenserCatY, "btn-apply-all-dispenser", LogisticsPatch.ApplyAllDispenser); AddCategoryApplyButton(battleBaseCatY, "btn-apply-all-battle-base", LogisticsPatch.ApplyAllBattleBase);