1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 04:13:32 +08:00
This commit is contained in:
2024-09-25 20:59:37 +08:00
parent 4534540786
commit 9d795e0ca4
13 changed files with 103 additions and 83 deletions

View File

@@ -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<DysonSpherePatch>
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<DysonSpherePatch>
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<DysonSpherePatch>
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<DysonSpherePatch>
// 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<DysonSpherePatch>
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),

View File

@@ -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<FactoryPatch>
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<FactoryPatch>
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<FactoryPatch>
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<FactoryPatch>
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<FactoryPatch>
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<FactoryPatch>
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<FactoryPatch>
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 = ""
},
];

View File

@@ -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<GamePatch>
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<GamePatch>
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<GamePatch>
[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<GamePatch>
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<GamePatch>
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<GamePatch>
[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<GamePatch>
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<GamePatch>
{
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;

View File

@@ -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<UIVeinDetail>());
_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<UIVeinDetail>());
_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<Image>();
@@ -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<UIVeinDetailNode>());
Object.Destroy(_tipPrefab.GetComponent<UIVeinDetailNode>());
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>();
image.color = new Color(image.color.r, image.color.g, image.color.b, 0.15f);
UnityEngine.Object.Destroy(sliderBg.GetComponent<Slider>());
UnityEngine.Object.Destroy(sliderBg.transform.Find("thumb").gameObject);
UnityEngine.Object.Destroy(sliderBg.transform.Find("speed-text").gameObject);
Object.Destroy(sliderBg.GetComponent<Slider>());
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>();
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<Shadow>());
Object.Destroy(countText.GetComponent<Shadow>());
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<Image>().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<Image>().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<UIIconCountInc>());
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<UIIconCountInc>());
iconObj.name = "carrierIcon" + i;
iconObj.GetComponent<Image>().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<Shadow>());
var countText = Object.Instantiate(infoText, Vector3.zero, Quaternion.identity, iconObj.transform);
Object.Destroy(countText.GetComponent<Shadow>());
countText.name = "carrierTotalCountText";
var text = countText.GetComponent<Text>();
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<Shadow>());
countText = Object.Instantiate(infoText, Vector3.zero, Quaternion.identity, iconObj.transform);
Object.Destroy(countText.GetComponent<Shadow>());
countText.name = "carrierIdleCountText";
text = countText.GetComponent<Text>();
@@ -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>();
stationTip.InitStationTip();
return stationTip;

View File

@@ -312,7 +312,7 @@ public static class TechPatch
}
if (!enough)
{
UIRealtimeTip.Popup("元数据不足".Translate(), true, 0);
UIRealtimeTip.Popup("元数据不足".Translate());
return false;
}