From 2741069bc742f4079fa890aea8827961ef5f1c54 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Fri, 24 May 2024 21:30:25 +0800 Subject: [PATCH] UXAssist 1.0.25 --- CheatEnabler/FactoryPatch.cs | 32 +++++++++++++----------------- CheatEnabler/UIConfigWindow.cs | 1 + CheatEnabler/package/manifest.json | 2 +- UXAssist/FactoryPatch.cs | 11 +++++++--- UXAssist/README.md | 4 ++++ UXAssist/UXAssist.csproj | 2 +- UXAssist/package/manifest.json | 2 +- 7 files changed, 30 insertions(+), 24 deletions(-) diff --git a/CheatEnabler/FactoryPatch.cs b/CheatEnabler/FactoryPatch.cs index 8d7ed73..e734464 100644 --- a/CheatEnabler/FactoryPatch.cs +++ b/CheatEnabler/FactoryPatch.cs @@ -1292,16 +1292,21 @@ public static class FactoryPatch if (enable) { _patch ??= Harmony.CreateAndPatchAll(typeof(GreaterPowerUsageInLogistics)); - return; } - - _patch?.UnpatchSelf(); - _patch = null; + else + { + _patch?.UnpatchSelf(); + _patch = null; + } + var window = UIRoot.instance?.uiGame?.stationWindow; + if (window == null) return; + window._Close(); + window.maxMiningSpeedSlider.maxValue = enable ? 27f : 20f; } [HarmonyTranspiler] - [HarmonyPatch(typeof(UIStationWindow), nameof(UIStationWindow._OnInit))] - private static IEnumerable UIStationWindow__OnInit_Transpiler(IEnumerable instructions, ILGenerator generator) + [HarmonyPatch(typeof(UIStationWindow), nameof(UIStationWindow.OnStationIdChange))] + private static IEnumerable UIStationWindow_OnStationIdChange_Transpiler(IEnumerable instructions, ILGenerator generator) { var matcher = new CodeMatcher(instructions, generator); matcher.Start().Insert( @@ -1310,16 +1315,7 @@ public static class FactoryPatch { window.maxMiningSpeedSlider.maxValue = 27f; }) - ); - return matcher.InstructionEnumeration(); - } - - [HarmonyTranspiler] - [HarmonyPatch(typeof(UIStationWindow), nameof(UIStationWindow.OnStationIdChange))] - private static IEnumerable UIStationWindow_OnStationIdChange_Transpiler(IEnumerable instructions, ILGenerator generator) - { - var matcher = new CodeMatcher(instructions, generator); - matcher.MatchForward(false, + ).MatchForward(false, new CodeMatch(OpCodes.Ldarg_0), new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIStationWindow), nameof(UIStationWindow.maxChargePowerSlider))), new CodeMatch(ci => ci.IsLdloc()), @@ -1344,9 +1340,9 @@ public static class FactoryPatch window.maxChargePowerSlider.maxValue = maxSliderValue + 9; window.maxChargePowerSlider.minValue = maxWorkEnergy / 500000L; if (workEnergyPerTick <= maxWorkEnergy) - window.maxChargePowerSlider.value = workEnergyPerTick / 50000L; + window.maxChargePowerSlider.Set(workEnergyPerTick / 50000L, false); else - window.maxChargePowerSlider.value = maxSliderValue + (workEnergyPerTick - 1) / maxWorkEnergy + 1; + window.maxChargePowerSlider.Set(maxSliderValue + (workEnergyPerTick - 1) / maxWorkEnergy + 1, false); }) ); diff --git a/CheatEnabler/UIConfigWindow.cs b/CheatEnabler/UIConfigWindow.cs index 0bb6e78..681d10d 100644 --- a/CheatEnabler/UIConfigWindow.cs +++ b/CheatEnabler/UIConfigWindow.cs @@ -112,6 +112,7 @@ public static class UIConfigWindow x += 180f; y += 6f; var tip1 = MyWindow.AddTipsButton(x, y, tab2, "Belt signal alt format", "Belt signal alt format tips", "belt-signal-alt-format-tips"); + x = 0f; y += 30f; MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.GreaterPowerUsageInLogisticsEnabled, "Increase maximum power usage in Logistic Stations and Advanced Mining Machines"); diff --git a/CheatEnabler/package/manifest.json b/CheatEnabler/package/manifest.json index 8797b17..f66a672 100644 --- a/CheatEnabler/package/manifest.json +++ b/CheatEnabler/package/manifest.json @@ -5,6 +5,6 @@ "description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测", "dependencies": [ "xiaoye97-BepInEx-5.4.17", - "soarqin-UXAssist-1.0.23" + "soarqin-UXAssist-1.0.24" ] } diff --git a/UXAssist/FactoryPatch.cs b/UXAssist/FactoryPatch.cs index c7c288f..c3ae3d3 100644 --- a/UXAssist/FactoryPatch.cs +++ b/UXAssist/FactoryPatch.cs @@ -1574,6 +1574,7 @@ public static class FactoryPatch new CodeMatch(OpCodes.Ldc_I4_0), new CodeMatch(OpCodes.Brtrue)); var branch1 = (Label)matcher.Advance(1).Operand; + var branch2 = generator.DefineLabel(); matcher.Start().MatchForward(false, new CodeMatch(OpCodes.Call), new CodeMatch(ci => ci.IsStloc()), @@ -1584,12 +1585,16 @@ public static class FactoryPatch new CodeMatch(ci => ci.IsLdloc()), new CodeMatch(ci => ci.Branches(out _)), new CodeMatch(OpCodes.Ldarg_0) - ).Advance(8).Insert( + ).Advance(8).InsertAndAdvance( new CodeInstruction(OpCodes.Ldloc_S, 45), - new CodeInstruction(OpCodes.Ldloc_S, 47), - new CodeInstruction(OpCodes.Or), + new CodeInstruction(OpCodes.Brtrue, branch2), + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Ldloc_S, 33), + new CodeInstruction(OpCodes.Ldloc_S, 35), + Transpilers.EmitDelegate((RaycastLogic l, ColliderData[] colliderPool, int j) => l.factory.entityPool[colliderPool[j].objId].inserterId > 0), new CodeInstruction(OpCodes.Brfalse, branch1) ); + matcher.Labels.Add(branch2); return matcher.InstructionEnumeration(); } } diff --git a/UXAssist/README.md b/UXAssist/README.md index 9573447..5079275 100644 --- a/UXAssist/README.md +++ b/UXAssist/README.md @@ -4,6 +4,8 @@ #### 一些提升用户体验的功能和补丁 ## Changlog +* 1.0.25 + + Fix an issue that building entites can not be clicked through when `Do not render factory entities (except belts and sorters)` is enabled * 1.0.24 + Changes to `Do not render factory entities (except belts and sorters)` - Add shortcut key in config panel to toggle this function @@ -183,6 +185,8 @@ * [CruiseAssist](https://dsp.thunderstore.io/package/tanu/CruiseAssist/) and its extension [AutoPilot](https://dsp.thunderstore.io/package/tanu/AutoPilot/): `Auto navigation on sailings` and `Auto-cruise` implementations ## 更新日志 +* 1.0.25 + + 修复了`不渲染工厂建筑实体(除了传送带和分拣器)`启用时无法点穿工厂实体的问题 * 1.0.24 + `不渲染工厂建筑实体(除了传送带和分拣器)`的改动 - 在配置面板中添加了一个快捷键来切换此功能 diff --git a/UXAssist/UXAssist.csproj b/UXAssist/UXAssist.csproj index a1aa836..d90456b 100644 --- a/UXAssist/UXAssist.csproj +++ b/UXAssist/UXAssist.csproj @@ -4,7 +4,7 @@ net472 org.soardev.uxassist DSP MOD - UXAssist - 1.0.24 + 1.0.25 true latest UXAssist diff --git a/UXAssist/package/manifest.json b/UXAssist/package/manifest.json index 04108ec..4e4807b 100644 --- a/UXAssist/package/manifest.json +++ b/UXAssist/package/manifest.json @@ -1,6 +1,6 @@ { "name": "UXAssist", - "version_number": "1.0.24", + "version_number": "1.0.25", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist", "description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁", "dependencies": [