From acff196baebfa4d8c5a41a51ec875c1eefa2a35d Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Mon, 8 Jan 2024 23:07:56 +0800 Subject: [PATCH] mark obsolete --- LabOpt/README.md | 2 ++ README.md | 2 ++ UXAssist/UXAssist.cs | 27 +++++++++++++++++++++++++++ UXAssist/UXAssist.csproj | 2 +- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/LabOpt/README.md b/LabOpt/README.md index 5fa2a37..f3628dd 100644 --- a/LabOpt/README.md +++ b/LabOpt/README.md @@ -1,7 +1,9 @@ # LabOpt #### Performance optimizations for Matrix Labs +#### Marked as obsoleted temporarily, needs more investigation about LabComponent's mechanism #### 优化研究站性能 +#### 暂时标识为过期,需要更多关于LabComponent机制的研究 ## Updates * 0.3.6 diff --git a/README.md b/README.md index 352638d..47ac48a 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,9 @@ Some tweaks for mecha drones and build functions(Successor to FastDrones MOD) # [LabOpt](LabOpt) Performance optimizations for Matrix Labs +Marked as obsoleted temporarily, needs more investigation about LabComponent's mechanism 优化研究站性能 +暂时标识为过期,需要更多关于LabComponent机制的研究 # [PoolOpt](PoolOpt) diff --git a/UXAssist/UXAssist.cs b/UXAssist/UXAssist.cs index fc4ec27..ead8bc2 100644 --- a/UXAssist/UXAssist.cs +++ b/UXAssist/UXAssist.cs @@ -281,4 +281,31 @@ public class UXAssist : BaseUnityPlugin buildings[i].index = i; } } + + // Can set belt icon tag to float, and increase maximum belt icon tag length to 8 + [HarmonyPostfix] + [HarmonyPatch(typeof(UIBeltWindow), nameof(UIBeltWindow._OnCreate))] + private static void UIBeltWindow_OnCreate_Postfix(UIBeltWindow __instance) + { + __instance.iconTagCountInput.contentType = InputField.ContentType.DecimalNumber; + __instance.iconTagCountInput.characterLimit = 8; + } + + [HarmonyTranspiler] + [HarmonyPatch(typeof(UIBeltWindow), nameof(UIBeltWindow._OnUpdate))] + private static IEnumerable UIBeltWindow_OnUpdate_Transpiler(IEnumerable instructions, ILGenerator generator) + { + var matcher = new CodeMatcher(instructions, generator); + matcher.End().MatchBack(false, + new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIBeltWindow), nameof(UIBeltWindow.iconTagCountInput))), + new CodeMatch(ci => ci.opcode == OpCodes.Ldloca || ci.opcode == OpCodes.Ldloca_S), + new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(float), nameof(float.ToString), [])) + ); + matcher.Advance(2).InsertAndAdvance( + new CodeInstruction(OpCodes.Ldstr, "G8") + ).Set( + OpCodes.Call, AccessTools.Method(typeof(float), nameof(float.ToString), [typeof(string)]) + ); + return matcher.InstructionEnumeration(); + } } diff --git a/UXAssist/UXAssist.csproj b/UXAssist/UXAssist.csproj index 1d0acac..884de59 100644 --- a/UXAssist/UXAssist.csproj +++ b/UXAssist/UXAssist.csproj @@ -15,7 +15,7 @@ - +