diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 4651e26..6876ce6 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,5 +1,16 @@ # 更新日志 | Changelog +## [1.3.1] + +该版本是一次紧急修复 + +### 更新内容 + +- 修复了一处会导致 PlanetsideExplorationTechnologies 风电工作不正常的 Bug +- 修复了一处 B9PartSwith 文本缺失括号的问题 + +- 部分 Patch 的代码重构 + ## [1.3.0] 本次更新内容: diff --git a/GameData/0000Tinygrox_CNPatches/_HarmonyCNPatches/KSP_Chinese_Patches.dll b/GameData/0000Tinygrox_CNPatches/_HarmonyCNPatches/KSP_Chinese_Patches.dll index cc8e65b..ac8c14f 100644 Binary files a/GameData/0000Tinygrox_CNPatches/_HarmonyCNPatches/KSP_Chinese_Patches.dll and b/GameData/0000Tinygrox_CNPatches/_HarmonyCNPatches/KSP_Chinese_Patches.dll differ diff --git a/Source/KSP_Chinese_Patches/B9PartSwithPatches.cs b/Source/KSP_Chinese_Patches/B9PartSwithPatches.cs index 5951ffe..23d6622 100644 --- a/Source/KSP_Chinese_Patches/B9PartSwithPatches.cs +++ b/Source/KSP_Chinese_Patches/B9PartSwithPatches.cs @@ -19,51 +19,24 @@ public static IEnumerable ModuleB9PartInfo_SetupGUI_Patch(IEnum { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); - matcher.InsertAndAdvance( + matcher // (base.Fields["showInfo"].uiControlEditor as UI_Toggle).disabledText = "隐藏" // (base.Fields["showInfo"].uiControlEditor as UI_Toggle).enabledText = "显示" // (base.Fields["showInfo"].uiControlFlight as UI_Toggle).disabledText = "隐藏" // (base.Fields["showInfo"].uiControlFlight as UI_Toggle).enabledText = "显示" - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "showInfo"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(BaseField), nameof(BaseField.uiControlEditor))), - new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), - new CodeInstruction(OpCodes.Ldstr, "隐藏"), // Hidden - new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.disabledText))), - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "showInfo"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(BaseField), nameof(BaseField.uiControlEditor))), - new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), - new CodeInstruction(OpCodes.Ldstr, "显示"), // Enabled - new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.enabledText))), - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "showInfo"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(BaseField), nameof(BaseField.uiControlFlight))), - new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), - new CodeInstruction(OpCodes.Ldstr, "隐藏"), // Hidden - new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.disabledText))), - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "showInfo"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(BaseField), nameof(BaseField.uiControlFlight))), - new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), - new CodeInstruction(OpCodes.Ldstr, "显示"), // Enabled - new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.enabledText))), + .InsertAndAdvance(StaticMethods.Field_UIToggle_Instructions("showInfo", "隐藏", "显示")) // base.Fields["showInfo"].guiName = "部件信息" - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "showInfo"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "部件信息"), // Part Info - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))) - ) + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("showInfo", "部件信息")) + // base.Fields["wetMass"].guiName = "质量(湿)" + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("wetMass", "质量(湿)")) + // base.Fields["wetCost"].guiName = "成本(湿)" + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("wetCost", "成本(湿)")) + // base.Fields["maxTemp"].guiName = "最高温度" + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("maxTemp", "最高温度")) + // base.Fields["skinMaxTemp"].guiName = "表面最高温度" + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("skinMaxTemp", "表面最高温度")) + // base.Fields["crashTolerance"].guiName = "撞击可承受" + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("crashTolerance", "撞击可承受")) .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Mass")) .SetOperandAndAdvance("质量") .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Mass (Dry)")) @@ -71,48 +44,8 @@ public static IEnumerable ModuleB9PartInfo_SetupGUI_Patch(IEnum .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Cost")) .SetOperandAndAdvance("成本") .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Cost (Dry)")) - .SetOperandAndAdvance("成本(干") - .InsertAndAdvance( - // base.Fields["wetMass"].guiName = "质量(湿)" - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "wetMass"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "质量(湿)"), // Mass (Wet) - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - // base.Fields["wetCost"].guiName = "成本(湿)" - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "wetCost"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "成本(湿)"), // Cost (Wet) - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - // base.Fields["maxTemp"].guiName = "最高温度" - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "maxTemp"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "最高温度"), // Max Temp - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - // base.Fields["skinMaxTemp"].guiName = "表面最高温度" - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "skinMaxTemp"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "表面最高温度"), // Max Skin Temp - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - // base.Fields["crashTolerance"].guiName = "撞击可承受" - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "crashTolerance"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "撞击可承受"), // Crash Tolerance - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))) - ); + .SetOperandAndAdvance("成本(干)") + ; return matcher.InstructionEnumeration(); } public override void LoadAllPatchInfo() diff --git a/Source/KSP_Chinese_Patches/ELPatches.cs b/Source/KSP_Chinese_Patches/ELPatches.cs index 8ef46c6..b533cd4 100644 --- a/Source/KSP_Chinese_Patches/ELPatches.cs +++ b/Source/KSP_Chinese_Patches/ELPatches.cs @@ -15,6 +15,7 @@ public class ELPatches : AbstractPatchBase { public override string PatchName => "Extraplanetary Launchpads"; public override string PatchDLLName => "Launchpad"; + // 资源显示翻译 public static IEnumerable ELResourceLine_Resource_Patch(IEnumerable codeInstructions) { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -501,6 +502,22 @@ public static IEnumerable RecyclerFSM_get_CurrentState_Patch(IE ; return matcher.InstructionEnumeration(); } + public static IEnumerable ELShipInfoWindow_SetResource_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward + ( + new CodeMatch(OpCodes.Ldfld, AccessTools.Field(AccessTools.TypeByName("ExtraplanetaryLaunchpads.BuildResource"), "name")) + ) + .Advance(1) + .InsertAndAdvance( + new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(ELPatches), nameof(ELPatches.getResourceName), new[] { typeof(string) })) + ) + ; + return matcher.InstructionEnumeration(); + } static string[] time_formats = new[] { "{0:F0}年{1:000}天{2:00}时{3:00}分{4:00}秒", "{1:F0}天{2:00}时{3:00}分{4:00}秒", "{2:F0}时{3:00}分{4:00}秒", "{3:F0}分{4:00}秒", "{4:F0}秒" }; @@ -755,6 +772,12 @@ public override void LoadAllPatchInfo() new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.RecyclerFSM_get_CurrentState_Patch)), PatchType.Transpiler ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELShipInfoWindow"), "SetResource",new[] { AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELTextInfoLine"), AccessTools.TypeByName("ExtraplanetaryLaunchpads.BuildResource") }), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELShipInfoWindow_SetResource_Patch)), + PatchType.Transpiler + ), }; } } diff --git a/Source/KSP_Chinese_Patches/PlanetsideExplorationTechnologiesPatches.cs b/Source/KSP_Chinese_Patches/PlanetsideExplorationTechnologiesPatches.cs index 87a9606..cbad262 100644 --- a/Source/KSP_Chinese_Patches/PlanetsideExplorationTechnologiesPatches.cs +++ b/Source/KSP_Chinese_Patches/PlanetsideExplorationTechnologiesPatches.cs @@ -99,7 +99,7 @@ public static IEnumerable ModulePETTurbine_OnAwake_Patch(IEnume matcher .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("isActive", "开关风轮")) // Toggle Turbine .InsertAndAdvance(StaticMethods.Field_groupDisplayName_Instructions("isActive", "风力发电")) // Wind Turbine - .InsertAndAdvance(StaticMethods.Field_UIToggle_Instructions("isActive", "关", "开")) + .InsertAndAdvance(StaticMethods.Field_UIToggle_Instructions("isActive", "关", "开", flightOnly: true)) .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("flowRateDisplay", "产出电力")) // EC Output .InsertAndAdvance(StaticMethods.Field_groupDisplayName_Instructions("flowRateDisplay", "风力发电")) // Wind Turbine @@ -115,7 +115,7 @@ public static IEnumerable ModulePETTurbine_OnAwake_Patch(IEnume .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("toggleLines", "显示风向")) // Show Wind Direction .InsertAndAdvance(StaticMethods.Field_groupDisplayName_Instructions("toggleLines", "风力发电")) // Wind Turbine - .InsertAndAdvance(StaticMethods.Field_UIToggle_Instructions("toggleLines", "关", "开")) + .InsertAndAdvance(StaticMethods.Field_UIToggle_Instructions("toggleLines", "关", "开", flightOnly: true)) .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("ToggleEVATurbine", "开关风轮")) // Toggle Turbine diff --git a/Source/KSP_Chinese_Patches/RasterPropMonitorPatches.cs b/Source/KSP_Chinese_Patches/RasterPropMonitorPatches.cs index d966f3b..fb50f6a 100644 --- a/Source/KSP_Chinese_Patches/RasterPropMonitorPatches.cs +++ b/Source/KSP_Chinese_Patches/RasterPropMonitorPatches.cs @@ -21,38 +21,9 @@ public static IEnumerable JSIExternalCameraSelector_OnAwake_Pat CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); matcher - .InsertAndAdvance( - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "visibleCameraName"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "摄像机ID"), // Camera ID: - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "showCones"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "FOV 范围"), // FOV marker - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "showCones"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(BaseField), nameof(BaseField.uiControlEditor))), - new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), - new CodeInstruction(OpCodes.Ldstr, "关"), - new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.disabledText))), - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "showCones"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(BaseField), nameof(BaseField.uiControlEditor))), - new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), - new CodeInstruction(OpCodes.Ldstr, "开"), - new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.enabledText))) - ) + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("visibleCameraName", "摄像机ID")) // Camera ID: + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("showCones", "FOV 范围")) // FOV marker + .InsertAndAdvance(StaticMethods.Field_UIToggle_Instructions("showCones", "关", "开", editorOnly: true)) ; return matcher.InstructionEnumeration(); } diff --git a/Source/KSP_Chinese_Patches/RealAntennasPatches.cs b/Source/KSP_Chinese_Patches/RealAntennasPatches.cs index 1362047..0bfbbdc 100644 --- a/Source/KSP_Chinese_Patches/RealAntennasPatches.cs +++ b/Source/KSP_Chinese_Patches/RealAntennasPatches.cs @@ -50,132 +50,27 @@ public static IEnumerable OnAwakePatch(IEnumerable), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "天线"), - //new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Localizer), nameof(Localizer.Format), new[] { typeof(string) })), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), + InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("_enabled", "天线")) // (base.Fields["_enabled"].uiControlEditor as UI_Toggle).disabledText = "禁用"; - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "_enabled"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(BaseField), nameof(BaseField.uiControlEditor))), - new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), - new CodeInstruction(OpCodes.Ldstr, "禁用"), - new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.disabledText))), // (base.Fields["_enabled"].uiControlEditor as UI_Toggle).enabledText = "启用"; - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "_enabled"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(BaseField), nameof(BaseField.uiControlEditor))), - new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), - new CodeInstruction(OpCodes.Ldstr, "启用"), - new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.enabledText))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "Condition"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "状态"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "Gain"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "增益"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "TxPower"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "传输功率 (dBm)"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "TechLevel"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "科技等级"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "RFBand"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "射频基带"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "sActivePowerConsumed"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "功率 (传输)"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "sIdlePowerConsumed"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "功率 (闲置)"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "sAntennaTarget"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "天线指向"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), - new CodeInstruction(OpCodes.Ldstr, "plannerActiveTxTime"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "传输时间"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Events))), - new CodeInstruction(OpCodes.Ldstr, "AntennaTargetGUI"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseEventList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "天线指向"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseEvent), nameof(BaseEvent.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Events))), - new CodeInstruction(OpCodes.Ldstr, "AntennaPlanningGUI"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseEventList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "天线规划"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseEvent), nameof(BaseEvent.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Events))), - new CodeInstruction(OpCodes.Ldstr, "DebugAntenna"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseEventList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "天线调试信息"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseEvent), nameof(BaseEvent.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Events))), - new CodeInstruction(OpCodes.Ldstr, "PermanentShutdownEvent"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseEventList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "永久关停天线"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseEvent), nameof(BaseEvent.guiName))), - - new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Actions))), - new CodeInstruction(OpCodes.Ldstr, "PermanentShutdownAction"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseActionList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "永久关停天线"), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseAction), nameof(BaseEvent.guiName))) - ); + .InsertAndAdvance(StaticMethods.Field_UIToggle_Instructions("_enabled", "禁用", "启用", editorOnly: true)) + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("Condition", "状态")) // Condition + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("Gain", "增益")) // Gain + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("TxPower", "传输功率 (dBm)")) // Transmit Power (dBm) + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("TechLevel", "科技等级")) // Tech Level + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("RFBand", "射频基带")) // RF Band + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("sActivePowerConsumed", "功率 (传输)")) // Power (Active) + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("sIdlePowerConsumed", "功率 (闲置)")) // Power (Idle) + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("sAntennaTarget", "天线指向")) // Antenna Target + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("plannerActiveTxTime", "传输时间")) // Active Transmission Time + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("AntennaTargetGUI", "天线指向")) // Antenna Targeting + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("AntennaPlanningGUI", "天线规划")) // Antenna Planning + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("DebugAntenna", "天线调试信息")) // Debug Antenna + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("PermanentShutdownEvent", "永久关停天线")) // Disable antenna permanently + .InsertAndAdvance(StaticMethods.Action_GuiName_Instructions("PermanentShutdownAction", "永久关停天线")) // Disable antenna permanently + ; return matcher.InstructionEnumeration(); } diff --git a/Source/KSP_Chinese_Patches/StaticMethods.cs b/Source/KSP_Chinese_Patches/StaticMethods.cs index f31fdcd..be64d62 100644 --- a/Source/KSP_Chinese_Patches/StaticMethods.cs +++ b/Source/KSP_Chinese_Patches/StaticMethods.cs @@ -78,9 +78,9 @@ public static CodeInstruction[] Field_groupDisplayName_Instructions(string targe }; } - public static CodeInstruction[] Field_UIToggle_Instructions(string targetField, string disabledText, string enabledText) + public static CodeInstruction[] Field_UIToggle_Instructions(string targetField, string disabledText, string enabledText, bool editorOnly = false, bool flightOnly = false) { - return new CodeInstruction[] + var uiControlEditor = new CodeInstruction[] { new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), @@ -99,7 +99,9 @@ public static CodeInstruction[] Field_UIToggle_Instructions(string targetField, new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), new CodeInstruction(OpCodes.Ldstr, enabledText), new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.enabledText))), - + }; + var uiControlFlight = new CodeInstruction[] + { new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), new CodeInstruction(OpCodes.Ldstr, targetField), @@ -118,6 +120,15 @@ public static CodeInstruction[] Field_UIToggle_Instructions(string targetField, new CodeInstruction(OpCodes.Ldstr, enabledText), new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.enabledText))), }; + List res = new List(); + + if (!flightOnly) + res.AddRange(uiControlEditor); + + if (!editorOnly) + res.AddRange(uiControlFlight); + + return res.ToArray(); } public static CodeInstruction[] Event_GuiName_Instructions(string targetEvent, string guiName) {