mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-08-05 15:10:23 +08:00
refactor: centralize localization keys and remove runtime Chinese literals
This commit is contained in:
@@ -23,9 +23,6 @@ public static class EpicDifficulty
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
I18N.Add("究极少", "Micro", "究极少");
|
||||
I18N.Add("史诗难度", "Epic Difficulty !!", "史诗难度 !!");
|
||||
I18N.Apply();
|
||||
Enabled.SettingChanged += (_, _) => Enable(Enabled.Value);
|
||||
Enable(Enabled.Value);
|
||||
}
|
||||
@@ -139,18 +136,18 @@ public static class EpicDifficulty
|
||||
text = resourceMultiplier switch
|
||||
{
|
||||
< 100f and > 0.1f => resourceMultiplier + "x",
|
||||
>= 100f => "无限".Translate(),
|
||||
< 0.09f => "究极少".Translate(),
|
||||
< 0.11f => "极少".Translate(),
|
||||
>= 100f => Localization.Unlimited.Translate(),
|
||||
< 0.09f => Localization.Micro.Translate(),
|
||||
< 0.11f => Localization.Scarce.Translate(),
|
||||
_ => text
|
||||
};
|
||||
__instance.resourceMultiplierText.text = text;
|
||||
__instance.propertyMultiplierText.text = "元数据生成倍率".Translate() + " " + __instance.gameDesc.propertyMultiplier.ToString("P0");
|
||||
__instance.propertyMultiplierText.text = Localization.PropertyMultiplier.Translate() + " " + __instance.gameDesc.propertyMultiplier.ToString("P0");
|
||||
__instance.addrText.text = __instance.gameDesc.clusterString;
|
||||
var showDifficultTip = resourceMultiplier < 0.11f && !__instance.gameDesc.isSandboxMode;
|
||||
__instance.difficultTipGroup.SetActive(showDifficultTip);
|
||||
if (!showDifficultTip) return false;
|
||||
__instance.difficultTipGroup.transform.Find("difficult-tip-text").GetComponent<Text>().text = (resourceMultiplier < 0.09f ? "史诗难度" : "非常困难").Translate();
|
||||
__instance.difficultTipGroup.transform.Find("difficult-tip-text").GetComponent<Text>().text = (resourceMultiplier < 0.09f ? Localization.EpicDifficultyLabel : Localization.VeryHard).Translate();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using UXAssist.Common;
|
||||
|
||||
namespace UniverseGenTweaks;
|
||||
|
||||
public static class Localization
|
||||
{
|
||||
public const string Micro = "Micro";
|
||||
public const string EpicDifficultyLabel = "Epic Difficulty !!";
|
||||
public const string VeryHard = "Very Hard";
|
||||
public const string StarDistanceMin = "Star Distance Min";
|
||||
public const string StepDistanceMin = "Step Distance Min";
|
||||
public const string StepDistanceMax = "Step Distance Max";
|
||||
public const string Flatness = "Flatness";
|
||||
public const string UniverseGen = "UniverseGen";
|
||||
public const string BirthStar = "Birth Star";
|
||||
public const string EnableMoreSettingsOnUniverseGen = "Enable more settings on UniverseGen";
|
||||
public const string RequiresGameRestartToTakeEffect = "* Requires game restart to take effect";
|
||||
public const string MaximumStarCount = "Maximum star count";
|
||||
public const string EnableEpicDifficulty = "Enable Epic difficulty";
|
||||
public const string ResourceMultiplier = "Resource multiplier";
|
||||
public const string OilMultiplierRelativeToVeryHard = "Oil multiplier (relative to Very Hard)";
|
||||
public const string SiliconTitaniumOnBirthPlanet = "Silicon/Titanium on birth planet";
|
||||
public const string FireIceOnBirthPlanet = "Fire ice on birth planet";
|
||||
public const string KimberliteOnBirthPlanet = "Kimberlite on birth planet";
|
||||
public const string FractalSiliconOnBirthPlanet = "Fractal silicon on birth planet";
|
||||
public const string OrganicCrystalOnBirthPlanet = "Organic crystal on birth planet";
|
||||
public const string OpticalGratingCrystalOnBirthPlanet = "Optical grating crystal on birth planet";
|
||||
public const string SpiniformStalagmiteCrystalOnBirthPlanet = "Spiniform stalagmite crystal on birth planet";
|
||||
public const string UnipolarMagnetOnBirthPlanet = "Unipolar magnet on birth planet";
|
||||
public const string BirthPlanetIsSolidFlatNoWaterAtAll = "Birth planet is solid flat (no water at all)";
|
||||
public const string BirthStarHasHighLuminosity = "Birth star has high luminosity";
|
||||
public const string PropertyMultiplier = "Property multiplier";
|
||||
public const string Unlimited = "Unlimited";
|
||||
public const string Scarce = "Scarce";
|
||||
public const string AggressivenessNormal = "Normal";
|
||||
public const string AggressivenessSittingDuck = "Sitting Duck";
|
||||
public const string AggressivenessNegative = "Negative";
|
||||
public const string AggressivenessRampage = "Rampage";
|
||||
public const string AggressivenessAggressive = "Aggressive";
|
||||
public const string AggressivenessPassive = "Passive";
|
||||
public const string DifficultyValueFormat = "Difficulty value: {0}";
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
I18N.Add(Micro, "Micro", "究极少");
|
||||
I18N.Add(EpicDifficultyLabel, "Epic Difficulty !!", "史诗难度 !!");
|
||||
I18N.Add(VeryHard, "Very Hard", "非常困难");
|
||||
I18N.Add(StarDistanceMin, "Star Distance Min", "恒星最小距离");
|
||||
I18N.Add(StepDistanceMin, "Step Distance Min", "步进最小距离");
|
||||
I18N.Add(StepDistanceMax, "Step Distance Max", "步进最大距离");
|
||||
I18N.Add(Flatness, "Flatness", "扁平度");
|
||||
I18N.Add(UniverseGen, "UniverseGen", "宇宙生成");
|
||||
I18N.Add(BirthStar, "Birth Star", "母星系");
|
||||
I18N.Add(EnableMoreSettingsOnUniverseGen, "Enable more settings on UniverseGen", "启用更多宇宙生成设置");
|
||||
I18N.Add(RequiresGameRestartToTakeEffect, "* Requires game restart to take effect", "* 需要重启游戏才能生效");
|
||||
I18N.Add(MaximumStarCount, "Maximum star count", "最大恒星数");
|
||||
I18N.Add(EnableEpicDifficulty, "Enable Epic difficulty", "启用史诗难度");
|
||||
I18N.Add(ResourceMultiplier, "Resource multiplier", "资源倍率");
|
||||
I18N.Add(OilMultiplierRelativeToVeryHard, "Oil multiplier (relative to Very Hard)", "石油倍率(相对于非常困难)");
|
||||
I18N.Add(SiliconTitaniumOnBirthPlanet, "Silicon/Titanium on birth planet", "母星有硅和钛");
|
||||
I18N.Add(FireIceOnBirthPlanet, "Fire ice on birth planet", "母星有可燃冰");
|
||||
I18N.Add(KimberliteOnBirthPlanet, "Kimberlite on birth planet", "母星有金伯利矿");
|
||||
I18N.Add(FractalSiliconOnBirthPlanet, "Fractal silicon on birth planet", "母星有分形硅");
|
||||
I18N.Add(OrganicCrystalOnBirthPlanet, "Organic crystal on birth planet", "母星有有机晶体");
|
||||
I18N.Add(OpticalGratingCrystalOnBirthPlanet, "Optical grating crystal on birth planet", "母星有光栅石");
|
||||
I18N.Add(SpiniformStalagmiteCrystalOnBirthPlanet, "Spiniform stalagmite crystal on birth planet", "母星有刺笋结晶");
|
||||
I18N.Add(UnipolarMagnetOnBirthPlanet, "Unipolar magnet on birth planet", "母星有单极磁石");
|
||||
I18N.Add(BirthPlanetIsSolidFlatNoWaterAtAll, "Birth planet is solid flat (no water at all)", "母星是纯平的(没有水)");
|
||||
I18N.Add(BirthStarHasHighLuminosity, "Birth star has high luminosity", "母星系恒星高亮");
|
||||
I18N.Add(PropertyMultiplier, "Property multiplier", "元数据生成倍率");
|
||||
I18N.Add(Unlimited, "Unlimited", "无限");
|
||||
I18N.Add(Scarce, "Scarce", "极少");
|
||||
I18N.Add(AggressivenessNormal, "Normal", "正常");
|
||||
I18N.Add(AggressivenessSittingDuck, "Sitting Duck", "活靶子");
|
||||
I18N.Add(AggressivenessNegative, "Negative", "消极");
|
||||
I18N.Add(AggressivenessRampage, "Rampage", "狂暴");
|
||||
I18N.Add(AggressivenessAggressive, "Aggressive", "积极");
|
||||
I18N.Add(AggressivenessPassive, "Passive", "被动");
|
||||
I18N.Add(DifficultyValueFormat, "Difficulty value: {0}", "难度系数值:{0}");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
@@ -147,12 +147,12 @@ public static class CombatSettingsPatch
|
||||
};
|
||||
text = (int)(__instance.aggresiveSlider.value + 0.5f) switch
|
||||
{
|
||||
0 => "活靶子".Translate(),
|
||||
1 => "被动".Translate(),
|
||||
2 => "消极".Translate(),
|
||||
3 => "正常".Translate(),
|
||||
4 => "积极".Translate(),
|
||||
5 => "狂暴".Translate(),
|
||||
0 => Localization.AggressivenessSittingDuck.Translate(),
|
||||
1 => Localization.AggressivenessPassive.Translate(),
|
||||
2 => Localization.AggressivenessNegative.Translate(),
|
||||
3 => Localization.AggressivenessNormal.Translate(),
|
||||
4 => Localization.AggressivenessAggressive.Translate(),
|
||||
5 => Localization.AggressivenessRampage.Translate(),
|
||||
_ => text
|
||||
};
|
||||
__instance.aggresiveText.text = text;
|
||||
@@ -305,11 +305,11 @@ public static class CombatSettingsPatch
|
||||
var gameDesc = new GameDesc();
|
||||
var difficulty = __instance.combatSettings.difficulty;
|
||||
var text2 = difficulty >= 9.9999f ? difficulty.ToString("0.00") : difficulty.ToString("0.000");
|
||||
__instance.difficultyText.text = string.Format("难度系数值".Translate(), text2);
|
||||
__instance.difficultyText.text = string.Format(Localization.DifficultyValueFormat.Translate(), text2);
|
||||
__instance.difficultTipGroupDF.SetActive((__instance.combatSettings.aggressiveLevel == EAggressiveLevel.Rampage && difficulty > 4.5f) || difficulty > 6f);
|
||||
__instance.gameDesc.CopyTo(gameDesc);
|
||||
gameDesc.combatSettings = __instance.combatSettings;
|
||||
__instance.propertyMultiplierText.text = "元数据生成倍率".Translate() + " " + gameDesc.propertyMultiplier.ToString("0%");
|
||||
__instance.propertyMultiplierText.text = Localization.PropertyMultiplier.Translate() + " " + gameDesc.propertyMultiplier.ToString("0%");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using HarmonyLib;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UXAssist.Common;
|
||||
@@ -27,11 +27,6 @@ public static class GalaxySelectUIPatch
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
I18N.Add("恒星最小距离", "Star Distance Min", "恒星最小距离");
|
||||
I18N.Add("步进最小距离", "Step Distance Min", "步进最小距离");
|
||||
I18N.Add("步进最大距离", "Step Distance Max", "步进最大距离");
|
||||
I18N.Add("扁平度", "Flatness", "扁平度");
|
||||
I18N.Apply();
|
||||
MoreSettings.Enabled.SettingChanged += OnEnabledChanged;
|
||||
Enable(MoreSettings.Enabled.Value);
|
||||
}
|
||||
@@ -70,10 +65,10 @@ public static class GalaxySelectUIPatch
|
||||
CreateSliderWithText(__instance.starCountSlider, out _minStepTitle, out _minStepSlider, out _minStepText, out var minStepLocalizer);
|
||||
CreateSliderWithText(__instance.starCountSlider, out _maxStepTitle, out _maxStepSlider, out _maxStepText, out var maxStepLocalizer);
|
||||
CreateSliderWithText(__instance.starCountSlider, out _flattenTitle, out _flattenSlider, out _flattenText, out var flattenLocalizer);
|
||||
minDistLocalizer.stringKey = "恒星最小距离";
|
||||
minStepLocalizer.stringKey = "步进最小距离";
|
||||
maxStepLocalizer.stringKey = "步进最大距离";
|
||||
flattenLocalizer.stringKey = "扁平度";
|
||||
minDistLocalizer.stringKey = Localization.StarDistanceMin;
|
||||
minStepLocalizer.stringKey = Localization.StepDistanceMin;
|
||||
maxStepLocalizer.stringKey = Localization.StepDistanceMax;
|
||||
flattenLocalizer.stringKey = Localization.Flatness;
|
||||
|
||||
_minDistTitle.name = "min-dist";
|
||||
_minStepTitle.name = "min-step";
|
||||
|
||||
@@ -11,25 +11,6 @@ public static class UIConfigWindow
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
I18N.Add("UniverseGen", "UniverseGen", "宇宙生成");
|
||||
I18N.Add("Birth Star", "Birth Star", "母星系");
|
||||
I18N.Add("Enable more settings on UniverseGen", "Enable more settings on UniverseGen", "启用更多宇宙生成设置");
|
||||
I18N.Add("* Requires game restart to take effect", "* Requires game restart to take effect", "* 需要重启游戏才能生效");
|
||||
I18N.Add("Maximum star count", "Maximum star count", "最大恒星数");
|
||||
I18N.Add("Enable Epic difficulty", "Enable Epic difficulty", "启用史诗难度");
|
||||
I18N.Add("Resource multiplier", "Resource multiplier", "资源倍率");
|
||||
I18N.Add("Oil multiplier (relative to Very Hard)", "Oil multiplier (relative to Very Hard)", "石油倍率(相对于非常困难)");
|
||||
I18N.Add("Silicon/Titanium on birth planet", "Silicon/Titanium on birth planet", "母星有硅和钛");
|
||||
I18N.Add("Fire ice on birth planet", "Fire ice on birth planet", "母星有可燃冰");
|
||||
I18N.Add("Kimberlite on birth planet", "Kimberlite on birth planet", "母星有金伯利矿");
|
||||
I18N.Add("Fractal silicon on birth planet", "Fractal silicon on birth planet", "母星有分形硅");
|
||||
I18N.Add("Organic crystal on birth planet", "Organic crystal on birth planet", "母星有有机晶体");
|
||||
I18N.Add("Optical grating crystal on birth planet", "Optical grating crystal on birth planet", "母星有光栅石");
|
||||
I18N.Add("Spiniform stalagmite crystal on birth planet", "Spiniform stalagmite crystal on birth planet", "母星有刺笋结晶");
|
||||
I18N.Add("Unipolar magnet on birth planet", "Unipolar magnet on birth planet", "母星有单极磁石");
|
||||
I18N.Add("Birth planet is solid flat (no water at all)", "Birth planet is solid flat (no water at all)", "母星是纯平的(没有水)");
|
||||
I18N.Add("Birth star has high luminosity", "Birth star has high luminosity", "母星系恒星高亮");
|
||||
I18N.Apply();
|
||||
MyConfigWindow.OnUICreated += CreateUI;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Reflection;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using crecheng.DSPModSave;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Common.GameConstants;
|
||||
using UXAssist.Common.ModFeatures;
|
||||
|
||||
@@ -19,6 +20,8 @@ public class UniverseGenTweaks : BaseUnityPlugin, IModCanSave
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
I18N.Init();
|
||||
|
||||
MoreSettings.Enabled = Config.Bind("MoreSettings", "Enabled", true, "Enable more settings on Universe Generation");
|
||||
MoreSettings.MaxStarCount = Config.Bind("MoreSettings", "MaxStarCount", UniverseGenConstants.DefaultMaxStarCount,
|
||||
new ConfigDescription($"({UniverseGenConstants.MinStarCount} ~ {UniverseGenConstants.MaxStarCount})\nMaximum star count for Universe Generation, enable MoreSettings.Enabled to take effect",
|
||||
@@ -53,9 +56,12 @@ public class UniverseGenTweaks : BaseUnityPlugin, IModCanSave
|
||||
BirthPlanetPatch.HighLuminosityBirthStar = Config.Bind("Birth", "HighLuminosityBirthStar", false,
|
||||
"Birth star has high luminosity");
|
||||
|
||||
Localization.Register();
|
||||
UIConfigWindow.Init();
|
||||
ModFeatureRegistry.Discover(Assembly.GetExecutingAssembly());
|
||||
ModFeatureRegistry.InitAll();
|
||||
|
||||
I18N.Apply();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
|
||||
Reference in New Issue
Block a user