diff --git a/UXAssist/Functions/WindowFunctions.cs b/UXAssist/Functions/WindowFunctions.cs index 1b63d01..c07c241 100644 --- a/UXAssist/Functions/WindowFunctions.cs +++ b/UXAssist/Functions/WindowFunctions.cs @@ -1,9 +1,9 @@ using System; -using System.Diagnostics; using System.Runtime.InteropServices; using BepInEx.Configuration; using UnityEngine; using UXAssist.Common; +using UXAssist.Patches; namespace UXAssist.Functions; @@ -33,6 +33,11 @@ public static class WindowFunctions public static void Init() { + I18N.Add("Cores: {0}\nThreads: {1}", "Cores: {0}\nThreads: {1}", "内核数: {0}\n线程数: {1}"); + I18N.Add("\nP-Cores: {0}\nE-Cores: {1}", "\nP-Cores: {0}\nE-Cores: {1}", "\n性能核心: {0}\n能效核心: {1}"); + I18N.Add("\nPriority: {0}", "\nProcess priority: {0}", "\n进程优先级: {0}"); + I18N.Add("\nEnabled CPUs: ", "\nEnabled CPUs: ", "\n使用的CPU: "); + I18N.Add("Unknown", "Unknown", "未知"); ProcessorDetails = WinApi.GetLogicalProcessorDetails(); } @@ -45,7 +50,7 @@ public static class WindowFunctions { _oldWndProc = WinApi.SetWindowLongPtr(gameWnd, WinApi.GWLP_WNDPROC, Marshal.GetFunctionPointerForDelegate(wndProc)); } - Patches.GamePatch.LoadLastWindowRect.MoveWindowPosition(true); + GamePatch.LoadLastWindowRect.MoveWindowPosition(true); ProcessPriority.SettingChanged += (_, _) => WinApi.SetPriorityClass(WinApi.GetCurrentProcess(), ProrityFlags[ProcessPriority.Value]); WinApi.SetPriorityClass(WinApi.GetCurrentProcess(), ProrityFlags[ProcessPriority.Value]); @@ -104,7 +109,7 @@ public static class WindowFunctions break; case WinApi.WM_MOVING: if (_gameLoaded) break; - var rect = Patches.GamePatch.LastWindowRect.Value; + var rect = GamePatch.LastWindowRect.Value; if (rect is { z: 0f, w: 0f }) break; var x = Mathf.RoundToInt(rect.x); var y = Mathf.RoundToInt(rect.y); @@ -115,7 +120,7 @@ public static class WindowFunctions break; case WinApi.WM_SIZING: if (_gameLoaded) break; - rect = Patches.GamePatch.LastWindowRect.Value; + rect = GamePatch.LastWindowRect.Value; if (rect is { z: 0f, w: 0f }) break; x = Mathf.RoundToInt(rect.x); y = Mathf.RoundToInt(rect.y); @@ -132,25 +137,38 @@ public static class WindowFunctions return WinApi.CallWindowProc(_oldWndProc, hWnd, uMsg, wParam, lParam); } + private static string GetPriorityName(int priority) + { + return priority switch + { + WinApi.HIGH_PRIORITY_CLASS => "High".Translate(), + WinApi.ABOVE_NORMAL_PRIORITY_CLASS => "Above Normal".Translate(), + WinApi.NORMAL_PRIORITY_CLASS => "Normal".Translate(), + WinApi.BELOW_NORMAL_PRIORITY_CLASS => "Below Normal".Translate(), + WinApi.IDLE_PRIORITY_CLASS => "Idle".Translate(), + _ => "Unknown".Translate() + }; + } + public static void ShowCPUInfo() { - var details = WinApi.GetLogicalProcessorDetails(); - var msg = $"Cores: {details.CoreCount}\nThreads: {details.ThreadCount}"; + var details = ProcessorDetails; + var msg = string.Format("Cores: {0}\nThreads: {1}".Translate(), details.CoreCount, details.ThreadCount); var hybrid = details.HybridArchitecture; if (hybrid) { - msg += $"\nP-Cores: {details.PerformanceCoreCount}\nE-Cores: {details.EfficiencyCoreCount}"; + msg += string.Format("\nP-Cores: {0}\nE-Cores: {1}".Translate(), details.PerformanceCoreCount, details.EfficiencyCoreCount); } var handle = WinApi.GetCurrentProcess(); - var prio = (ProcessPriorityClass)WinApi.GetPriorityClass(handle); - msg += $"\nPriority: {prio}"; + var prio = GetPriorityName(WinApi.GetPriorityClass(handle)); + msg += string.Format("\nPriority: {0}".Translate(), prio); var aff = 0UL; if (WinApi.GetProcessAffinityMask(handle, out var processMask, out var systemMask)) - aff = (ulong)processMask & (ulong)systemMask; + aff = processMask & systemMask; - msg += $"\nEnabled CPUs: "; + msg += "\nEnabled CPUs: ".Translate(); var first = true; for (var i = 0; aff != 0UL; i++) { @@ -173,7 +191,7 @@ public static class WindowFunctions aff >>= 1; } - UIMessageBox.Show("CPU Info".Translate(), msg, "OK".Translate(), -1); + UIMessageBox.Show("CPU Info".Translate(), msg, "确定".Translate(), -1); } public static void SetWindowTitle() diff --git a/UXAssist/ModsCompat/AuxilaryfunctionWrapper.cs b/UXAssist/ModsCompat/AuxilaryfunctionWrapper.cs index dc8704c..d9b35c5 100644 --- a/UXAssist/ModsCompat/AuxilaryfunctionWrapper.cs +++ b/UXAssist/ModsCompat/AuxilaryfunctionWrapper.cs @@ -1,4 +1,5 @@ using System; +using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using UXAssist.Patches; @@ -12,7 +13,7 @@ public static class AuxilaryfunctionWrapper public static void Start(Harmony harmony) { - if (!BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(AuxilaryfunctionGuid, out var pluginInfo)) return; + if (!Chainloader.PluginInfos.TryGetValue(AuxilaryfunctionGuid, out var pluginInfo)) return; var assembly = pluginInfo.Instance.GetType().Assembly; try { diff --git a/UXAssist/ModsCompat/BulletTimeWrapper.cs b/UXAssist/ModsCompat/BulletTimeWrapper.cs index f93f1f1..de1df1c 100644 --- a/UXAssist/ModsCompat/BulletTimeWrapper.cs +++ b/UXAssist/ModsCompat/BulletTimeWrapper.cs @@ -1,7 +1,5 @@ -using System.Collections.Generic; -using System.Reflection.Emit; +using BepInEx.Bootstrap; using HarmonyLib; -using UXAssist.Common; namespace UXAssist.ModsCompat; @@ -12,6 +10,6 @@ public static class BulletTimeWrapper public static void Start(Harmony _) { - HasBulletTime = BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(BulletTimeGuid, out var _); + HasBulletTime = Chainloader.PluginInfos.TryGetValue(BulletTimeGuid, out var _); } } diff --git a/UXAssist/Patches/DysonSpherePatch.cs b/UXAssist/Patches/DysonSpherePatch.cs index 7a251ca..717c56a 100644 --- a/UXAssist/Patches/DysonSpherePatch.cs +++ b/UXAssist/Patches/DysonSpherePatch.cs @@ -3,6 +3,7 @@ using System.Reflection; using System.Reflection.Emit; using BepInEx.Configuration; using HarmonyLib; +using UnityEngine.UI; using UXAssist.Common; namespace UXAssist.Patches; @@ -428,7 +429,7 @@ public class DysonSpherePatch: PatchImpl new CodeInstruction(OpCodes.Ldarg_2), new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonSwarm), nameof(DysonSwarm.starData))), new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StarData), nameof(StarData.index))), - new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(StopEjectOnNodeComplete.AnyNodeForAbsorb))), + new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(AnyNodeForAbsorb))), new CodeInstruction(OpCodes.And) ); return matcher.InstructionEnumeration(); @@ -446,7 +447,7 @@ public class DysonSpherePatch: PatchImpl matcher.Labels = []; matcher.Insert( new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels), - new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(StopEjectOnNodeComplete.UpdateNodeForAbsorbOnSpChange))) + new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(UpdateNodeForAbsorbOnSpChange))) ); return matcher.InstructionEnumeration(); } @@ -467,7 +468,7 @@ public class DysonSpherePatch: PatchImpl new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode._cpReq))) ).Advance(6).Insert( new CodeInstruction(OpCodes.Ldarg_0), - new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(StopEjectOnNodeComplete.UpdateNodeForAbsorbOnCpChange))) + new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(UpdateNodeForAbsorbOnCpChange))) ); return matcher.InstructionEnumeration(); } @@ -483,7 +484,7 @@ public class DysonSpherePatch: PatchImpl // this.stateText.text = "轨道未设置".Translate(); new CodeMatch(OpCodes.Ldstr, "待机"), new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(Localization), nameof(Localization.Translate))), - new CodeMatch(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(UnityEngine.UI.Text), nameof(UnityEngine.UI.Text.text))) + new CodeMatch(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(Text), nameof(Text.text))) ).InsertAndAdvance( // if (StopEjectOnNodeComplete.AnyNodeForAbsorb(this.starData.index)) new CodeInstruction(OpCodes.Ldarg_0), @@ -491,7 +492,7 @@ public class DysonSpherePatch: PatchImpl new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(FactorySystem), nameof(FactorySystem.planet))), new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(PlanetData), nameof(PlanetData.star))), new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StarData), nameof(StarData.index))), - new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(StopEjectOnNodeComplete.AnyNodeForAbsorb))), + new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(AnyNodeForAbsorb))), new CodeInstruction(OpCodes.Brfalse, label1) ).Advance(1).InsertAndAdvance( new CodeInstruction(OpCodes.Br, label2), diff --git a/UXAssist/Patches/FactoryPatch.cs b/UXAssist/Patches/FactoryPatch.cs index b8454df..d6ee016 100644 --- a/UXAssist/Patches/FactoryPatch.cs +++ b/UXAssist/Patches/FactoryPatch.cs @@ -8,6 +8,7 @@ using BepInEx.Configuration; using CommonAPI.Systems; using HarmonyLib; using UnityEngine; +using UnityEngine.UI; using UXAssist.Common; namespace UXAssist.Patches; @@ -566,7 +567,7 @@ public class FactoryPatch : PatchImpl matcher.MatchForward(false, new CodeMatch(OpCodes.Ldarg_0), new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIEntityBriefInfo), nameof(UIEntityBriefInfo.entityNameText))), - new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(UnityEngine.UI.Text), nameof(UnityEngine.UI.Text.preferredWidth))) + new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Text), nameof(Text.preferredWidth))) ); matcher.InsertAndAdvance( new CodeInstruction(OpCodes.Ldarg_0), @@ -1479,7 +1480,7 @@ public class FactoryPatch : PatchImpl Name = "存储单元", GridIndex = 3601, IconPath = "assets/signal/memory.png", - _iconSprite = Util.LoadEmbeddedSprite($"assets/signal/memory.png", assembly), + _iconSprite = Util.LoadEmbeddedSprite("assets/signal/memory.png", assembly), SID = "" }, new SignalProto @@ -1488,7 +1489,7 @@ public class FactoryPatch : PatchImpl Name = "能量碎片", GridIndex = 3602, IconPath = "assets/signal/energy-fragment.png", - _iconSprite = Util.LoadEmbeddedSprite($"assets/signal/energy-fragment.png", assembly), + _iconSprite = Util.LoadEmbeddedSprite("assets/signal/energy-fragment.png", assembly), SID = "" }, new SignalProto @@ -1497,7 +1498,7 @@ public class FactoryPatch : PatchImpl Name = "硅基神经元", GridIndex = 3603, IconPath = "assets/signal/silicon-neuron.png", - _iconSprite = Util.LoadEmbeddedSprite($"assets/signal/silicon-neuron.png", assembly), + _iconSprite = Util.LoadEmbeddedSprite("assets/signal/silicon-neuron.png", assembly), SID = "" }, new SignalProto @@ -1506,7 +1507,7 @@ public class FactoryPatch : PatchImpl Name = "负熵奇点", GridIndex = 3604, IconPath = "assets/signal/negentropy.png", - _iconSprite = Util.LoadEmbeddedSprite($"assets/signal/negentropy.png", assembly), + _iconSprite = Util.LoadEmbeddedSprite("assets/signal/negentropy.png", assembly), SID = "" }, new SignalProto @@ -1515,7 +1516,7 @@ public class FactoryPatch : PatchImpl Name = "物质重组器", GridIndex = 3605, IconPath = "assets/signal/reassembler.png", - _iconSprite = Util.LoadEmbeddedSprite($"assets/signal/reassembler.png", assembly), + _iconSprite = Util.LoadEmbeddedSprite("assets/signal/reassembler.png", assembly), SID = "" }, new SignalProto @@ -1524,7 +1525,7 @@ public class FactoryPatch : PatchImpl Name = "虚粒子", GridIndex = 3606, IconPath = "assets/signal/virtual-particle.png", - _iconSprite = Util.LoadEmbeddedSprite($"assets/signal/virtual-particle.png", assembly), + _iconSprite = Util.LoadEmbeddedSprite("assets/signal/virtual-particle.png", assembly), SID = "" }, ]; diff --git a/UXAssist/Patches/GamePatch.cs b/UXAssist/Patches/GamePatch.cs index 32a7f0d..344701c 100644 --- a/UXAssist/Patches/GamePatch.cs +++ b/UXAssist/Patches/GamePatch.cs @@ -7,6 +7,7 @@ using CommonAPI.Systems; using HarmonyLib; using UnityEngine; using UXAssist.Common; +using UXAssist.Functions; namespace UXAssist.Patches; @@ -70,7 +71,7 @@ public class GamePatch: PatchImpl I18N.Add("KEYUPSSpeedUp", "Increase logical frame rate", "提升逻辑帧率"); I18N.Add("Logical frame rate: {0}x", "Logical frame rate: {0}x", "逻辑帧速率: {0}x"); - Functions.WindowFunctions.SetWindowTitle(); + WindowFunctions.SetWindowTitle(); EnableWindowResizeEnabled.SettingChanged += (_, _) => EnableWindowResize.Enable(EnableWindowResizeEnabled.Value); LoadLastWindowRectEnabled.SettingChanged += (_, _) => LoadLastWindowRect.Enable(LoadLastWindowRectEnabled.Value); @@ -134,7 +135,7 @@ public class GamePatch: PatchImpl private static void RefreshSavePath() { - var profileName = Functions.WindowFunctions.ProfileName; + var profileName = WindowFunctions.ProfileName; if (profileName == null) return; if (UIRoot.instance.loadGameWindow.gameObject.activeSelf) @@ -162,7 +163,7 @@ public class GamePatch: PatchImpl [HarmonyPrefix, HarmonyPatch(typeof(GameMain), nameof(GameMain.HandleApplicationQuit))] private static void GameMain_HandleApplicationQuit_Prefix() { - var wnd = Functions.WindowFunctions.FindGameWindow(); + var wnd = WindowFunctions.FindGameWindow(); if (wnd == IntPtr.Zero) return; WinApi.GetWindowRect(wnd, out var rect); LastWindowRect.Value = new Vector4(rect.Left, rect.Top, Screen.width, Screen.height); @@ -175,7 +176,7 @@ public class GamePatch: PatchImpl protected override void OnEnable() { - var wnd = Functions.WindowFunctions.FindGameWindow(); + var wnd = WindowFunctions.FindGameWindow(); if (wnd == IntPtr.Zero) { Enable(false); @@ -189,7 +190,7 @@ public class GamePatch: PatchImpl protected override void OnDisable() { - var wnd = Functions.WindowFunctions.FindGameWindow(); + var wnd = WindowFunctions.FindGameWindow(); if (wnd == IntPtr.Zero) return; @@ -202,7 +203,7 @@ public class GamePatch: PatchImpl [HarmonyPatch(typeof(UIOptionWindow), nameof(UIOptionWindow.ApplyOptions))] private static void UIOptionWindow_ApplyOptions_Postfix() { - var wnd = Functions.WindowFunctions.FindGameWindow(); + var wnd = WindowFunctions.FindGameWindow(); if (wnd == IntPtr.Zero) return; if (_enabled) WinApi.SetWindowLong(wnd, WinApi.GWL_STYLE, @@ -276,7 +277,7 @@ public class GamePatch: PatchImpl public static void MoveWindowPosition(bool setResolution = false) { if (Screen.fullScreenMode is FullScreenMode.ExclusiveFullScreen or FullScreenMode.FullScreenWindow or FullScreenMode.MaximizedWindow || GameMain.isRunning) return; - var wnd = Functions.WindowFunctions.FindGameWindow(); + var wnd = WindowFunctions.FindGameWindow(); if (wnd == IntPtr.Zero) return; var rect = LastWindowRect.Value; if (rect is { z: 0f, w: 0f }) return; @@ -315,7 +316,7 @@ public class GamePatch: PatchImpl { if (_loaded || Screen.fullScreenMode is FullScreenMode.ExclusiveFullScreen or FullScreenMode.FullScreenWindow or FullScreenMode.MaximizedWindow) return; _loaded = true; - var wnd = Functions.WindowFunctions.FindGameWindow(); + var wnd = WindowFunctions.FindGameWindow(); if (wnd == IntPtr.Zero) return; var rect = LastWindowRect.Value; if (rect is { z: 0f, w: 0f }) return; diff --git a/UXAssist/Patches/LogisticsPatch.cs b/UXAssist/Patches/LogisticsPatch.cs index 1d19f90..5563961 100644 --- a/UXAssist/Patches/LogisticsPatch.cs +++ b/UXAssist/Patches/LogisticsPatch.cs @@ -9,6 +9,7 @@ using UnityEngine.EventSystems; using UnityEngine.Serialization; using UnityEngine.UI; using UXAssist.Common; +using Object = UnityEngine.Object; namespace UXAssist.Patches; @@ -524,11 +525,11 @@ public static class LogisticsPatch public static void InitGUI() { - _stationTipRoot = UnityEngine.Object.Instantiate(GameObject.Find("UI Root/Overlay Canvas/In Game/Scene UIs/Vein Marks"), + _stationTipRoot = Object.Instantiate(GameObject.Find("UI Root/Overlay Canvas/In Game/Scene UIs/Vein Marks"), GameObject.Find("UI Root/Overlay Canvas/In Game/Scene UIs").transform); _stationTipRoot.name = "stationTip"; - UnityEngine.Object.Destroy(_stationTipRoot.GetComponent()); - _tipPrefab = UnityEngine.Object.Instantiate(GameObject.Find("UI Root/Overlay Canvas/In Game/Scene UIs/Vein Marks/vein-tip-prefab"), _stationTipRoot.transform); + Object.Destroy(_stationTipRoot.GetComponent()); + _tipPrefab = Object.Instantiate(GameObject.Find("UI Root/Overlay Canvas/In Game/Scene UIs/Vein Marks/vein-tip-prefab"), _stationTipRoot.transform); _tipPrefab.name = "tipPrefab"; var sliderBgPrefab = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Station Window/storage-box-0/slider-bg"); var image = _tipPrefab.GetComponent(); @@ -539,14 +540,14 @@ public static class LogisticsPatch rectTrans.localPosition = new Vector3(200f, 800f, 0); rectTrans.sizeDelta = new Vector2(150f, 160f); rectTrans.pivot = new Vector2(0.5f, 0.5f); - UnityEngine.Object.Destroy(_tipPrefab.GetComponent()); + Object.Destroy(_tipPrefab.GetComponent()); var infoText = _tipPrefab.transform.Find("info-text").gameObject; for (var index = 0; index < StorageSlotCount; ++index) { var y = -5f - 35f * index; var iconTrans = _tipPrefab.transform.Find("icon"); - var itemIcon = UnityEngine.Object.Instantiate(iconTrans.gameObject, new Vector3(0, 0, 0), Quaternion.identity, _tipPrefab.transform); + var itemIcon = Object.Instantiate(iconTrans.gameObject, new Vector3(0, 0, 0), Quaternion.identity, _tipPrefab.transform); itemIcon.name = "icon" + index; rectTrans = (RectTransform)itemIcon.transform; rectTrans.sizeDelta = new Vector2(30f, 30f); @@ -555,7 +556,7 @@ public static class LogisticsPatch rectTrans.pivot = new Vector2(0f, 1f); rectTrans.anchoredPosition3D = new Vector3(0, y, 0); - var sliderBg = UnityEngine.Object.Instantiate(sliderBgPrefab.gameObject, new Vector3(0, 0, 0), Quaternion.identity, _tipPrefab.transform); + var sliderBg = Object.Instantiate(sliderBgPrefab.gameObject, new Vector3(0, 0, 0), Quaternion.identity, _tipPrefab.transform); sliderBg.name = "sliderBg" + index; rectTrans = (RectTransform)sliderBg.transform; rectTrans.sizeDelta = new Vector2(StorageSliderWidth, StorageSliderHeight); @@ -583,12 +584,12 @@ public static class LogisticsPatch rectTrans.localPosition = new Vector3(0f, 0f, 0f); image = rectTrans.GetComponent(); image.color = new Color(image.color.r, image.color.g, image.color.b, 0.15f); - UnityEngine.Object.Destroy(sliderBg.GetComponent()); - UnityEngine.Object.Destroy(sliderBg.transform.Find("thumb").gameObject); - UnityEngine.Object.Destroy(sliderBg.transform.Find("speed-text").gameObject); + Object.Destroy(sliderBg.GetComponent()); + Object.Destroy(sliderBg.transform.Find("thumb").gameObject); + Object.Destroy(sliderBg.transform.Find("speed-text").gameObject); sliderBg.gameObject.SetActive(false); - var countText = UnityEngine.Object.Instantiate(infoText, Vector3.zero, Quaternion.identity, _tipPrefab.transform); + var countText = Object.Instantiate(infoText, Vector3.zero, Quaternion.identity, _tipPrefab.transform); countText.name = "countText" + index; var text = countText.GetComponent(); text.fontSize = 18; @@ -600,9 +601,9 @@ public static class LogisticsPatch rectTrans.anchorMin = new Vector2(0f, 1f); rectTrans.pivot = new Vector2(0f, 1f); rectTrans.anchoredPosition3D = new Vector3(30f, y, 0); - UnityEngine.Object.Destroy(countText.GetComponent()); + Object.Destroy(countText.GetComponent()); - var stateLocal = UnityEngine.Object.Instantiate(iconTrans.gameObject, new Vector3(0, 0, 0), Quaternion.identity, _tipPrefab.transform); + var stateLocal = Object.Instantiate(iconTrans.gameObject, new Vector3(0, 0, 0), Quaternion.identity, _tipPrefab.transform); stateLocal.name = "iconLocal" + index; stateLocal.GetComponent().material = null; rectTrans = (RectTransform)stateLocal.transform; @@ -611,7 +612,7 @@ public static class LogisticsPatch rectTrans.anchorMin = new Vector2(0f, 1f); rectTrans.pivot = new Vector2(0f, 1f); rectTrans.anchoredPosition3D = new Vector3(102f, y, 0); - var stateRemote = UnityEngine.Object.Instantiate(iconTrans.gameObject, new Vector3(0, 0, 0), Quaternion.identity, _tipPrefab.transform); + var stateRemote = Object.Instantiate(iconTrans.gameObject, new Vector3(0, 0, 0), Quaternion.identity, _tipPrefab.transform); stateRemote.name = "iconRemote" + index; stateRemote.GetComponent().material = null; rectTrans = (RectTransform)stateRemote.transform; @@ -624,12 +625,12 @@ public static class LogisticsPatch for (var i = 0; i < CarrierSlotCount; i++) { - var iconObj = UnityEngine.Object.Instantiate(GameObject.Find("UI Root/Overlay Canvas/In Game/Top Tips/Entity Briefs/brief-info-top/brief-info/content/icons/icon"), + var iconObj = Object.Instantiate(GameObject.Find("UI Root/Overlay Canvas/In Game/Top Tips/Entity Briefs/brief-info-top/brief-info/content/icons/icon"), new Vector3(0, 0, 0), Quaternion.identity, _tipPrefab.transform); - UnityEngine.Object.Destroy(iconObj.transform.Find("count-text").gameObject); - UnityEngine.Object.Destroy(iconObj.transform.Find("bg").gameObject); - UnityEngine.Object.Destroy(iconObj.transform.Find("inc").gameObject); - UnityEngine.Object.Destroy(iconObj.GetComponent()); + Object.Destroy(iconObj.transform.Find("count-text").gameObject); + Object.Destroy(iconObj.transform.Find("bg").gameObject); + Object.Destroy(iconObj.transform.Find("inc").gameObject); + Object.Destroy(iconObj.GetComponent()); iconObj.name = "carrierIcon" + i; iconObj.GetComponent().sprite = LogisticsExtraItemSprites[i]; @@ -640,8 +641,8 @@ public static class LogisticsPatch rectTrans.pivot = new Vector2(0f, 1f); rectTrans.anchoredPosition3D = new Vector3(0f, -180f, 0); - var countText = UnityEngine.Object.Instantiate(infoText, Vector3.zero, Quaternion.identity, iconObj.transform); - UnityEngine.Object.Destroy(countText.GetComponent()); + var countText = Object.Instantiate(infoText, Vector3.zero, Quaternion.identity, iconObj.transform); + Object.Destroy(countText.GetComponent()); countText.name = "carrierTotalCountText"; var text = countText.GetComponent(); text.fontSize = 22; @@ -657,8 +658,8 @@ public static class LogisticsPatch if (i >= CarrierSlotCount - 1) continue; - countText = UnityEngine.Object.Instantiate(infoText, Vector3.zero, Quaternion.identity, iconObj.transform); - UnityEngine.Object.Destroy(countText.GetComponent()); + countText = Object.Instantiate(infoText, Vector3.zero, Quaternion.identity, iconObj.transform); + Object.Destroy(countText.GetComponent()); countText.name = "carrierIdleCountText"; text = countText.GetComponent(); @@ -691,7 +692,7 @@ public static class LogisticsPatch } else { - UnityEngine.Object.Destroy(stationTip); + Object.Destroy(stationTip); } } @@ -707,7 +708,7 @@ public static class LogisticsPatch return result; } - var tempTip = UnityEngine.Object.Instantiate(_tipPrefab, _stationTipRoot.transform); + var tempTip = Object.Instantiate(_tipPrefab, _stationTipRoot.transform); var stationTip = tempTip.AddComponent(); stationTip.InitStationTip(); return stationTip; diff --git a/UXAssist/Patches/TechPatch.cs b/UXAssist/Patches/TechPatch.cs index 10cb0fc..2ef6d49 100644 --- a/UXAssist/Patches/TechPatch.cs +++ b/UXAssist/Patches/TechPatch.cs @@ -312,7 +312,7 @@ public static class TechPatch } if (!enough) { - UIRealtimeTip.Popup("元数据不足".Translate(), true, 0); + UIRealtimeTip.Popup("元数据不足".Translate()); return false; } diff --git a/UXAssist/UI/MyComboBox.cs b/UXAssist/UI/MyComboBox.cs index 935358d..98b8437 100644 --- a/UXAssist/UI/MyComboBox.cs +++ b/UXAssist/UI/MyComboBox.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Security.Cryptography; using BepInEx.Configuration; using UnityEngine; using UnityEngine.UI; diff --git a/UXAssist/UI/MyKeyBinder.cs b/UXAssist/UI/MyKeyBinder.cs index 0a60282..3fd2082 100644 --- a/UXAssist/UI/MyKeyBinder.cs +++ b/UXAssist/UI/MyKeyBinder.cs @@ -112,7 +112,7 @@ public class MyKeyBinder : MonoBehaviour setTheKeyToggle.isOn = false; Reset(); } - else if (!this.inputUIButton.highlighted) + else if (!inputUIButton.highlighted) { setTheKeyToggle.isOn = false; Reset(); @@ -173,7 +173,7 @@ public class MyKeyBinder : MonoBehaviour { if (Input.GetKey(modKey)) { - mod += "+" + modKey.ToString(); + mod += "+" + modKey; } } diff --git a/UXAssist/UI/MyWindow.cs b/UXAssist/UI/MyWindow.cs index ed95241..4da36c1 100644 --- a/UXAssist/UI/MyWindow.cs +++ b/UXAssist/UI/MyWindow.cs @@ -1,8 +1,8 @@ using System; -using HarmonyLib; using System.Collections.Generic; using System.Globalization; using BepInEx.Configuration; +using HarmonyLib; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; diff --git a/UXAssist/UIConfigWindow.cs b/UXAssist/UIConfigWindow.cs index 33c3bd8..9f25acc 100644 --- a/UXAssist/UIConfigWindow.cs +++ b/UXAssist/UIConfigWindow.cs @@ -1,9 +1,10 @@ using System; using UnityEngine; -using UXAssist.UI; using UXAssist.Common; using UXAssist.Functions; +using UXAssist.ModsCompat; using UXAssist.Patches; +using UXAssist.UI; namespace UXAssist; @@ -47,7 +48,8 @@ public static class UIConfigWindow I18N.Add("First 8 CPUs", "First 8 CPUs", "前8个CPU"); I18N.Add("First CPU only", "First CPU only", "仅第一个CPU"); I18N.Add("All P-Cores", "All P-Cores", "所有性能(P)核心"); - I18N.Add("All E-Cores", "All E-Cores", "所有效率(E)核心"); + I18N.Add("All E-Cores", "All E-Cores", "所有能效(E)核心"); + I18N.Add("CPU Info", "CPU Info", "CPU信息"); I18N.Add("Unlimited interactive range", "Unlimited interactive range", "无限交互距离"); I18N.Add("Night Light", "Sunlight at night", "夜间日光灯"); I18N.Add("Angle X:", "Angle X:", "入射角度X:"); @@ -179,12 +181,7 @@ public static class UIConfigWindow wnd.AddInputField(x + 2f, y, 200f, tab1, GamePatch.DefaultProfileName, 15, "input-profile-save-folder"); y += 18f; } - /* - x = 400f; - y = 10f; - wnd.AddButton(x, y, tab1, "Show CPU Info", 16, "button-show-cpu-info", WindowFunctions.ShowCPUInfo); - */ - if (!ModsCompat.BulletTimeWrapper.HasBulletTime) + if (!BulletTimeWrapper.HasBulletTime) { y += 36f; txt = wnd.AddText2(x + 2f, y, tab1, "Logical Frame Rate", 15, "game-frame-rate"); @@ -213,6 +210,8 @@ public static class UIConfigWindow affinities[2] = details.ThreadCount > 16 ? "First 8 CPUs" : "First CPU only"; y += 36f; wnd.AddComboBox(x + 2f, y, tab1, "Enabled CPUs").WithItems(affinities).WithSize(200f, 0f).WithConfigEntry(WindowFunctions.ProcessAffinity); + y += 36f; + ((RectTransform)wnd.AddButton(x, y, tab1, "CPU Info", 16, "button-show-cpu-info", WindowFunctions.ShowCPUInfo).transform).sizeDelta = new Vector2(100f, 25f); var tab2 = wnd.AddTab(trans, "Planet/Factory"); x = 0f; @@ -288,14 +287,14 @@ public static class UIConfigWindow var cb1 = wnd.AddCheckBox(x + 20f, y, tab2, LogisticsPatch.RealtimeLogisticsInfoPanelBarsEnabled, "Show status bars for storage items", 13); EventHandler anySettingsChanged = (_, _) => { - if (ModsCompat.AuxilaryfunctionWrapper.ShowStationInfo == null) + if (AuxilaryfunctionWrapper.ShowStationInfo == null) { cb0.SetEnable(true); cb1.SetEnable(LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.Value); return; } - var on = !ModsCompat.AuxilaryfunctionWrapper.ShowStationInfo.Value; + var on = !AuxilaryfunctionWrapper.ShowStationInfo.Value; cb0.SetEnable(on); cb1.SetEnable(on & LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.Value); if (!on) @@ -303,10 +302,10 @@ public static class UIConfigWindow LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.Value = false; } }; - if (ModsCompat.AuxilaryfunctionWrapper.ShowStationInfo != null) + if (AuxilaryfunctionWrapper.ShowStationInfo != null) { - ModsCompat.AuxilaryfunctionWrapper.ShowStationInfo.SettingChanged += anySettingsChanged; - wnd.OnFree += () => { ModsCompat.AuxilaryfunctionWrapper.ShowStationInfo.SettingChanged -= anySettingsChanged; }; + AuxilaryfunctionWrapper.ShowStationInfo.SettingChanged += anySettingsChanged; + wnd.OnFree += () => { AuxilaryfunctionWrapper.ShowStationInfo.SettingChanged -= anySettingsChanged; }; } LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.SettingChanged += anySettingsChanged; wnd.OnFree += () => { LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.SettingChanged -= anySettingsChanged; }; @@ -415,7 +414,6 @@ public static class UIConfigWindow uiGame.CloseEnemyBriefInfo(); uiGame.OpenCommunicatorWindow(5); }); - return; } private static void UpdateUI() diff --git a/UXAssist/UXAssist.cs b/UXAssist/UXAssist.cs index b85b6ef..6bb8e98 100644 --- a/UXAssist/UXAssist.cs +++ b/UXAssist/UXAssist.cs @@ -3,6 +3,7 @@ using System.IO; using System.Reflection; using BepInEx; using BepInEx.Configuration; +using BepInEx.Logging; using CommonAPI; using CommonAPI.Systems; using crecheng.DSPModSave; @@ -13,6 +14,7 @@ using UXAssist.Common; using UXAssist.Functions; using UXAssist.Patches; using UXAssist.UI; +using Util = UXAssist.Common.Util; namespace UXAssist; @@ -22,7 +24,7 @@ namespace UXAssist; [BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)] public class UXAssist : BaseUnityPlugin, IModCanSave { - public new static readonly BepInEx.Logging.ManualLogSource Logger = + public new static readonly ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME); private static bool _configWinInitialized; @@ -171,10 +173,10 @@ public class UXAssist : BaseUnityPlugin, IModCanSave UIConfigWindow.Init(); - _patches = Common.Util.GetTypesFiltered(Assembly.GetExecutingAssembly(), + _patches = Util.GetTypesFiltered(Assembly.GetExecutingAssembly(), t => string.Equals(t.Namespace, "UXAssist.Patches", StringComparison.Ordinal) || string.Equals(t.Namespace, "UXAssist.Functions", StringComparison.Ordinal)); _patches?.Do(type => type.GetMethod("Init")?.Invoke(null, null)); - _compats = Common.Util.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "UXAssist.ModsCompat"); + _compats = Util.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "UXAssist.ModsCompat"); _compats?.Do(type => type.GetMethod("Init")?.Invoke(null, null)); I18N.Apply();