From 29a6e00417da054ec38dd9bf72e15f4cb5cca757 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Thu, 12 Oct 2023 17:20:30 +0800 Subject: [PATCH] some fixes --- CheatEnabler/CheatEnabler.cs | 1 - CheatEnabler/README.md | 16 +++++---- UXAssist/PlanetPatch.cs | 1 - UXAssist/README.md | 15 ++++++-- UXAssist/UI/MyWindow.cs | 19 ++++++++--- UXAssist/UXAssist.cs | 62 +++++++++++++++++++++++----------- UXAssist/UXAssist.csproj | 2 +- UXAssist/package/manifest.json | 2 +- 8 files changed, 81 insertions(+), 37 deletions(-) diff --git a/CheatEnabler/CheatEnabler.cs b/CheatEnabler/CheatEnabler.cs index a36e3cc..f797212 100644 --- a/CheatEnabler/CheatEnabler.cs +++ b/CheatEnabler/CheatEnabler.cs @@ -1,5 +1,4 @@ using BepInEx; -using UXAssist.Common; namespace CheatEnabler; diff --git a/CheatEnabler/README.md b/CheatEnabler/README.md index 1a083ab..cffab87 100644 --- a/CheatEnabler/README.md +++ b/CheatEnabler/README.md @@ -5,22 +5,24 @@ ## Changlog * 2.3.1 - + Add UXAssist to dependencies in manifest. + + Add UXAssist to dependencies in manifest. * 2.3.0 + Move some functions to an individual mod: [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) - + Depends on [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) now, so that config panel is unified with UXAssist. + + Depends on [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) now, so that config panel is unified with UXAssist. + + Remove `LCtrl+A` from Dev Shortcuts, to avoid misoperation. + + Infinite bots/drones/vessels in `Architect mode` now. * 2.2.7 + New function: `Construct only nodes but frames` + Opening config panel does not close inventory panel now - + Remove `Input direction conflict` check while using `Remove some build conditions` + + Remove `Input direction conflict` check while using `Remove some build conditions` + Fix a bug that prevents `Belt signal alt format` from switching number formats for current belt signals * 2.2.6 - + New function: `Stop ejectors when available nodes are all filled up` + + New function: `Stop ejectors when available nodes are all filled up` + Fix a bug that absorb solar sails on unfinised nodes * 2.2.5 + Skip all intermediate states and absorb solar sails instantly while enable `Quick absorb`, `Skip bullet period` and `Skip absorption period` at the same time. + Fix a problem that `Quick absorb` does not absorb all solar sails instantly when most nodes are full. - + Fix crash while using with some mods + + Fix crash while using with some mods * 2.2.4 + New function: `Enable player actions in globe view` + Fix UI bug @@ -100,6 +102,8 @@ * 2.3.0 + 将部分功能移动到单独的mod:[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) + 现在依赖[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist),因此配置面板与UXAssist合并 + + 从开发模式快捷键中移除`LCtrl+A`,以避免误操作 + + 现在`建筑师模式`中配送机/物流机/物流船也无限了 * 2.2.7 + 新功能:`只建造节点不建造框架` + 打开设置面板时不再关闭背包面板 @@ -145,7 +149,7 @@ * 配置面板复用UXAssist,打开UXAssist配置面板后带有星号(*)的分页是CheatEnabler的配置 * 标题界面和行星小地图旁也有按钮呼出主面板。 * 功能: - + 常规: + + 常规: + 启用开发模式快捷键(使用说明见设置面板) + 屏蔽异常检测 + 使用组合键解锁科技(Ctrl/Alt/Shift) diff --git a/UXAssist/PlanetPatch.cs b/UXAssist/PlanetPatch.cs index 4544a22..6a10f59 100644 --- a/UXAssist/PlanetPatch.cs +++ b/UXAssist/PlanetPatch.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Reflection.Emit; -using System.Threading; using BepInEx.Configuration; using HarmonyLib; diff --git a/UXAssist/README.md b/UXAssist/README.md index 548205a..070594a 100644 --- a/UXAssist/README.md +++ b/UXAssist/README.md @@ -1,9 +1,12 @@ # UXAssist -#### Some functions and patches for better user experience +#### Some functions and patches for better user experience #### 一些提升用户体验的功能和补丁 ## Changlog +* 1.0.1 + + Fix config button text and tips while returning to title menu. + + Add a patch to fix the bug that warning popup on `Veins Utilization` upgraded to level 8000+ * 1.0.0 + Initial release + Functions moved from [MechaDronesTweaks](https://dsp.thunderstore.io/package/soarqin/MechaDronesTweaks/) and [CheatEnabler](https://dsp.thunderstore.io/package/soarqin/CheatEnabler/) @@ -12,8 +15,10 @@ * Press `` LAlt+`(BackQuote) `` to call up the config panel. You can change the shortcut on the panel. * There are also buttons on title screen and planet minimap area to call up the config panel. -* Features: +* Patches: + Strict hotkey dectection for build menu, thus building hotkeys(0~9, F1~F10, X, U) are not triggered while holding Ctrl/Alt/Shift. + + Fix a bug that warning popup on `Veins Utilization` upgraded to level 8000+ +* Features: + Unlimited interactive range + Sunlight at night + Remove some build conditions @@ -40,6 +45,8 @@ * [LSTM](https://github.com/hetima/DSP_LSTM) & [PlanetFinder](https://github.com/hetima/DSP_PlanetFinder): UI implementations ## 更新日志 +* 1.0.1 + + 修复了返回标题界面后设置按钮文本和提示信息不正确的问题 * 1.0.0 + 初始版本 + 从[MechaDronesTweaks](https://dsp.thunderstore.io/package/soarqin/MechaDronesTweaks/)和[CheatEnabler](https://dsp.thunderstore.io/package/soarqin/CheatEnabler/)移动了部分功能过来 @@ -48,8 +55,10 @@ * 按 `` 左Alt+`(反引号) `` 键呼出主面板,可以在面板上修改快捷键。 * 标题界面和行星小地图旁也有按钮呼出主面板。 -* 功能: +* 补丁: + 更严格的建造菜单热键检测,因此在按住Ctrl/Alt/Shift时不再会触发建造热键(0~9, F1~F10, X, U) + + 修复了`矿物利用`升级到8000级以上时弹出警告的bug +* 功能: + 无限交互距离 + 夜间日光灯 + 移除部分不影响游戏逻辑的建造条件 diff --git a/UXAssist/UI/MyWindow.cs b/UXAssist/UI/MyWindow.cs index 0d358bd..fe59a5a 100644 --- a/UXAssist/UI/MyWindow.cs +++ b/UXAssist/UI/MyWindow.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; -using Object = UnityEngine.Object; namespace UXAssist.UI; @@ -305,15 +304,27 @@ public static class MyWindowManager { private static readonly List Windows = new(4); private static bool _initialized; + private static Harmony _patch; + public static void Init() + { + _patch ??= Harmony.CreateAndPatchAll(typeof(Patch)); + } + + public static void Uninit() + { + _patch?.UnpatchSelf(); + _patch = null; + } + public static T CreateWindow(string name, string title = "") where T : MyWindow { var srcWin = UIRoot.instance.uiGame.tankWindow; var src = srcWin.gameObject; - var go = Object.Instantiate(src, UIRoot.instance.uiGame.transform.parent); + var go = GameObject.Instantiate(src, UIRoot.instance.uiGame.transform.parent); go.name = name; go.SetActive(false); - Object.Destroy(go.GetComponent()); + GameObject.Destroy(go.GetComponent()); var win = go.AddComponent() as MyWindow; if (win == null) return null; @@ -332,7 +343,7 @@ public static class MyWindowManager } else if (child.name != "shadow" && child.name != "panel-bg") { - Object.Destroy(child); + GameObject.Destroy(child); } } diff --git a/UXAssist/UXAssist.cs b/UXAssist/UXAssist.cs index f756c3e..1b6378b 100644 --- a/UXAssist/UXAssist.cs +++ b/UXAssist/UXAssist.cs @@ -17,12 +17,9 @@ public class UXAssist : BaseUnityPlugin BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME); public static ConfigEntry Hotkey; - private static bool _configWinInitialized = false; + private static bool _configWinInitialized; private static MyConfigWindow _configWin; - - private static Harmony _windowPatch; private static Harmony _patch; - private static bool _initialized; private void Awake() @@ -54,9 +51,9 @@ public class UXAssist : BaseUnityPlugin I18N.Apply(); // UI Patch - _windowPatch ??= Harmony.CreateAndPatchAll(typeof(UI.MyWindowManager.Patch)); _patch ??= Harmony.CreateAndPatchAll(typeof(UXAssist)); + MyWindowManager.Init(); UIConfigWindow.Init(); FactoryPatch.Init(); PlanetPatch.Init(); @@ -70,11 +67,10 @@ public class UXAssist : BaseUnityPlugin PlayerPatch.Uninit(); PlanetPatch.Uninit(); FactoryPatch.Uninit(); + MyWindowManager.Uninit(); _patch?.UnpatchSelf(); _patch = null; - _windowPatch?.UnpatchSelf(); - _windowPatch = null; } private void Update() @@ -88,6 +84,7 @@ public class UXAssist : BaseUnityPlugin FactoryPatch.NightLight.LateUpdate(); } + // Add config button to main menu [HarmonyPostfix, HarmonyPatch(typeof(UIRoot), nameof(UIRoot.OpenMainMenuUI))] public static void UIRoot_OpenMainMenuUI_Postfix() { @@ -146,6 +143,7 @@ public class UXAssist : BaseUnityPlugin _initialized = true; } + // Check for noModifier while pressing hotkeys on build bar [HarmonyTranspiler] [HarmonyPatch(typeof(UIBuildMenu), nameof(UIBuildMenu._OnUpdate))] private static IEnumerable UIBuildMenu__OnUpdate_Transpiler(IEnumerable instructions, ILGenerator generator) @@ -165,24 +163,25 @@ public class UXAssist : BaseUnityPlugin return matcher.InstructionEnumeration(); } + // Patch to fix bug that warning popup on VeinUtil upgraded to level 8000+ [HarmonyTranspiler] - [HarmonyPatch(typeof(UIButton), nameof(UIButton.LateUpdate))] - private static IEnumerable UIButton_LateUpdate_Transpiler(IEnumerable instructions, ILGenerator generator) + [HarmonyPatch(typeof(ABN_VeinsUtil), nameof(ABN_VeinsUtil.CheckValue))] + private static IEnumerable ABN_VeinsUtil_CheckValue_Transpiler(IEnumerable instructions, ILGenerator generator) { var matcher = new CodeMatcher(instructions, generator); matcher.MatchForward(false, - new CodeMatch(OpCodes.Ldloc_2), - new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Component), nameof(Component.gameObject))), - new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(GameObject), nameof(GameObject.activeSelf))) + new CodeMatch(OpCodes.Ldelem_R8), + new CodeMatch(OpCodes.Conv_R4), + new CodeMatch(OpCodes.Add), + new CodeMatch(OpCodes.Stloc_1) ); - var labels = matcher.Labels; - matcher.Labels = null; - matcher.Insert( - new CodeInstruction(OpCodes.Ldloc_2).WithLabels(labels), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Component), nameof(Component.transform))), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Transform), nameof(Transform.parent))), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Transform), nameof(Transform.parent))), - new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(Transform), nameof(Transform.SetAsLastSibling))) + // loc1 = Mathf.Round(n * 1000f) / 1000f; + matcher.Advance(3).Insert( + new CodeInstruction(OpCodes.Ldc_R4, 1000f), + new CodeInstruction(OpCodes.Mul), + new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Mathf), nameof(Mathf.Round))), + new CodeInstruction(OpCodes.Ldc_R4, 1000f), + new CodeInstruction(OpCodes.Div) ); return matcher.InstructionEnumeration(); } @@ -205,4 +204,27 @@ public class UXAssist : BaseUnityPlugin _configWin.Open(); } } + + // Bring popup tip window to top layer + [HarmonyTranspiler] + [HarmonyPatch(typeof(UIButton), nameof(UIButton.LateUpdate))] + private static IEnumerable UIButton_LateUpdate_Transpiler(IEnumerable instructions, ILGenerator generator) + { + var matcher = new CodeMatcher(instructions, generator); + matcher.MatchForward(false, + new CodeMatch(OpCodes.Ldloc_2), + new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Component), nameof(Component.gameObject))), + new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(GameObject), nameof(GameObject.activeSelf))) + ); + var labels = matcher.Labels; + matcher.Labels = null; + matcher.Insert( + new CodeInstruction(OpCodes.Ldloc_2).WithLabels(labels), + new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Component), nameof(Component.transform))), + new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Transform), nameof(Transform.parent))), + new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Transform), nameof(Transform.parent))), + new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(Transform), nameof(Transform.SetAsLastSibling))) + ); + return matcher.InstructionEnumeration(); + } } diff --git a/UXAssist/UXAssist.csproj b/UXAssist/UXAssist.csproj index b6cbe38..56df52b 100644 --- a/UXAssist/UXAssist.csproj +++ b/UXAssist/UXAssist.csproj @@ -4,7 +4,7 @@ net472 org.soardev.uxassist DSP MOD - UXAssist - 1.0.0 + 1.0.1 true latest UXAssist diff --git a/UXAssist/package/manifest.json b/UXAssist/package/manifest.json index 6dc8af5..8f2d556 100644 --- a/UXAssist/package/manifest.json +++ b/UXAssist/package/manifest.json @@ -1,6 +1,6 @@ { "name": "UXAssist", - "version_number": "1.0.0", + "version_number": "1.0.1", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist", "description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁", "dependencies": [