Skip to content

Commit

Permalink
1.3.1 HotFix
Browse files Browse the repository at this point in the history
  • Loading branch information
tinygrox authored Nov 1, 2024
2 parents 0b03e89 + adc7e53 commit 21d4b02
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 242 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# 更新日志 | Changelog

## [1.3.1]

该版本是一次紧急修复

### 更新内容

- 修复了一处会导致 PlanetsideExplorationTechnologies 风电工作不正常的 Bug
- 修复了一处 B9PartSwith 文本缺失括号的问题

- 部分 Patch 的代码重构

## [1.3.0]

本次更新内容:
Expand Down
Binary file not shown.
97 changes: 15 additions & 82 deletions Source/KSP_Chinese_Patches/B9PartSwithPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,100 +19,33 @@ public static IEnumerable<CodeInstruction> 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<BaseField, KSPField>), "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<BaseField, KSPField>), "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<BaseField, KSPField>), "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<BaseField, KSPField>), "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<BaseField, KSPField>), "get_Item", new[] { typeof(string) })),
new CodeInstruction(OpCodes.Ldstr, "部件信息"), // Part Info
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField<KSPField>), nameof(BaseField<KSPField>.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)"))
.SetOperandAndAdvance("质量(干)")
.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<BaseField, KSPField>), "get_Item", new[] { typeof(string) })),
new CodeInstruction(OpCodes.Ldstr, "质量(湿)"), // Mass (Wet)
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField<KSPField>), nameof(BaseField<KSPField>.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<BaseField, KSPField>), "get_Item", new[] { typeof(string) })),
new CodeInstruction(OpCodes.Ldstr, "成本(湿)"), // Cost (Wet)
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField<KSPField>), nameof(BaseField<KSPField>.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<BaseField, KSPField>), "get_Item", new[] { typeof(string) })),
new CodeInstruction(OpCodes.Ldstr, "最高温度"), // Max Temp
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField<KSPField>), nameof(BaseField<KSPField>.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<BaseField, KSPField>), "get_Item", new[] { typeof(string) })),
new CodeInstruction(OpCodes.Ldstr, "表面最高温度"), // Max Skin Temp
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField<KSPField>), nameof(BaseField<KSPField>.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<BaseField, KSPField>), "get_Item", new[] { typeof(string) })),
new CodeInstruction(OpCodes.Ldstr, "撞击可承受"), // Crash Tolerance
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField<KSPField>), nameof(BaseField<KSPField>.guiName)))
);
.SetOperandAndAdvance("成本(干)")
;
return matcher.InstructionEnumeration();
}
public override void LoadAllPatchInfo()
Expand Down
23 changes: 23 additions & 0 deletions Source/KSP_Chinese_Patches/ELPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ELPatches : AbstractPatchBase
{
public override string PatchName => "Extraplanetary Launchpads";
public override string PatchDLLName => "Launchpad";
// 资源显示翻译
public static IEnumerable<CodeInstruction> ELResourceLine_Resource_Patch(IEnumerable<CodeInstruction> codeInstructions)
{
CodeMatcher matcher = new CodeMatcher(codeInstructions).Start();
Expand Down Expand Up @@ -501,6 +502,22 @@ public static IEnumerable<CodeInstruction> RecyclerFSM_get_CurrentState_Patch(IE
;
return matcher.InstructionEnumeration();
}
public static IEnumerable<CodeInstruction> ELShipInfoWindow_SetResource_Patch(IEnumerable<CodeInstruction> 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}秒" };

Expand Down Expand Up @@ -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
),
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static IEnumerable<CodeInstruction> 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
Expand All @@ -115,7 +115,7 @@ public static IEnumerable<CodeInstruction> 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

Expand Down
35 changes: 3 additions & 32 deletions Source/KSP_Chinese_Patches/RasterPropMonitorPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,9 @@ public static IEnumerable<CodeInstruction> 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<BaseField, KSPField>), "get_Item", new[] { typeof(string) })),
new CodeInstruction(OpCodes.Ldstr, "摄像机ID"), // Camera ID:
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField<KSPField>), nameof(BaseField<KSPField>.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<BaseField, KSPField>), "get_Item", new[] { typeof(string) })),
new CodeInstruction(OpCodes.Ldstr, "FOV 范围"), // FOV marker
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField<KSPField>), nameof(BaseField<KSPField>.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<BaseField, KSPField>), "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<BaseField, KSPField>), "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();
}
Expand Down
Loading

0 comments on commit 21d4b02

Please sign in to comment.