1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 00:53:39 +08:00

UXAssist: some fixes

This commit is contained in:
2025-10-04 16:26:38 +08:00
parent 5a6cfb18c9
commit a183485286
3 changed files with 73 additions and 27 deletions

View File

@@ -7,6 +7,8 @@
* `Build Tesla Tower and Wireless Power Tower alternately`: * `Build Tesla Tower and Wireless Power Tower alternately`:
* Fix wrong implementation for latest game patch. * Fix wrong implementation for latest game patch.
* Cannot use Tesla Tower as start Power Tower now, due to new rectangular area build mechanism. * Cannot use Tesla Tower as start Power Tower now, due to new rectangular area build mechanism.
* `Planet Vein Untilization`: Support mods that add new vein types.
* `Real-time logistic stations info panel`: Try to fix possible crash.
* 1.4.2 * 1.4.2
* Fixed a crash issue. * Fixed a crash issue.
* 1.4.1 * 1.4.1
@@ -348,6 +350,8 @@
* `交替建造电力感应塔和无线输电塔`: * `交替建造电力感应塔和无线输电塔`:
* 修复了在最新游戏补丁中的错误实现 * 修复了在最新游戏补丁中的错误实现
* 由于新的矩形建造机制,现在无法使用电力感应塔作为起始电塔 * 由于新的矩形建造机制,现在无法使用电力感应塔作为起始电塔
* `宇宙视图矿脉数量显示`兼容添加矿脉类型的mod
* `物流站实时信息面板`:尝试修复可能的崩溃问题
* 1.4.2 * 1.4.2
* 修复了一个崩溃问题 * 修复了一个崩溃问题
* 1.4.1 * 1.4.1

View File

@@ -719,6 +719,7 @@ public static class LogisticsPatch
{ {
private static StationTip[] _stationTips = new StationTip[16]; private static StationTip[] _stationTips = new StationTip[16];
private static readonly StationTip[] StationTipsRecycle = new StationTip[128]; private static readonly StationTip[] StationTipsRecycle = new StationTip[128];
private static readonly Sprite[] StateSprite = [null, null, null];
private static int _stationTipsRecycleCount; private static int _stationTipsRecycleCount;
private static GameObject _stationTipsRoot; private static GameObject _stationTipsRoot;
private static GameObject _tipPrefab; private static GameObject _tipPrefab;
@@ -1003,6 +1004,10 @@ public static class LogisticsPatch
tipIconPrefab.gameObject.SetActive(false); tipIconPrefab.gameObject.SetActive(false);
_tipPrefab.SetActive(false); _tipPrefab.SetActive(false);
_stationTipsRoot.SetActive(false); _stationTipsRoot.SetActive(false);
StateSprite[0] = Util.LoadEmbeddedSprite("assets/icon/keep.png");
StateSprite[1] = Util.LoadEmbeddedSprite("assets/icon/out.png");
StateSprite[2] = Util.LoadEmbeddedSprite("assets/icon/in.png");
} }
private static void RecycleStationTips() private static void RecycleStationTips()
@@ -1187,7 +1192,6 @@ public static class LogisticsPatch
} }
} }
public class StationTip : MonoBehaviour public class StationTip : MonoBehaviour
{ {
[FormerlySerializedAs("RectTransform")] [FormerlySerializedAs("RectTransform")]
@@ -1231,13 +1235,6 @@ public static class LogisticsPatch
public ELogisticStorage RemoteState; public ELogisticStorage RemoteState;
} }
private static readonly Sprite[] StateSprite =
[
Util.LoadEmbeddedSprite("assets/icon/keep.png"),
Util.LoadEmbeddedSprite("assets/icon/out.png"),
Util.LoadEmbeddedSprite("assets/icon/in.png")
];
private enum EStationTipLayout private enum EStationTipLayout
{ {
None, None,

View File

@@ -1,11 +1,13 @@
namespace UXAssist.Patches; namespace UXAssist.Patches;
using Common; using System.Linq;
using HarmonyLib; using HarmonyLib;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using BepInEx.Configuration; using BepInEx.Configuration;
using Common;
using GameLogicProc = Common.GameLogic;
[PatchGuid(PluginInfo.PLUGIN_GUID)] [PatchGuid(PluginInfo.PLUGIN_GUID)]
public class UIPatch : PatchImpl<UIPatch> public class UIPatch : PatchImpl<UIPatch>
@@ -19,6 +21,7 @@ public class UIPatch : PatchImpl<UIPatch>
public static void Start() public static void Start()
{ {
GameLogicProc.OnGameBegin += PlanetVeinUtilization.OnGameBegin;
Enable(true); Enable(true);
Functions.UIFunctions.InitMenuButtons(); Functions.UIFunctions.InitMenuButtons();
PlanetVeinUtilization.Enable(PlanetVeinUtilizationEnabled.Value); PlanetVeinUtilization.Enable(PlanetVeinUtilizationEnabled.Value);
@@ -28,30 +31,66 @@ public class UIPatch : PatchImpl<UIPatch>
{ {
PlanetVeinUtilization.Enable(false); PlanetVeinUtilization.Enable(false);
Enable(false); Enable(false);
GameLogicProc.OnGameBegin -= PlanetVeinUtilization.OnGameBegin;
} }
private class PlanetVeinUtilization : PatchImpl<PlanetVeinUtilization> private class PlanetVeinUtilization : PatchImpl<PlanetVeinUtilization>
{ {
private static readonly VeinTypeInfo[] planetVeinCount = new VeinTypeInfo[(int)EVeinType.Max]; private static VeinTypeInfo[] planetVeinCount = null;
private static readonly VeinTypeInfo[] starVeinCount = new VeinTypeInfo[(int)EVeinType.Max]; private static VeinTypeInfo[] starVeinCount = null;
private static readonly Dictionary<int, bool> tmpGroups = []; private static readonly Dictionary<int, bool> tmpGroups = [];
public static void OnGameBegin()
{
if (planetVeinCount != null)
{
foreach (VeinTypeInfo vti in planetVeinCount)
{
if (vti.textCtrl != null)
{
Object.Destroy(vti.textCtrl.gameObject);
}
}
planetVeinCount = null;
}
if (starVeinCount != null)
{
foreach (VeinTypeInfo vti in starVeinCount)
{
if (vti.textCtrl != null)
{
Object.Destroy(vti.textCtrl.gameObject);
}
}
starVeinCount = null;
}
var maxVeinId = LDB.veins.dataArray.Max(vein => vein.ID);
planetVeinCount = new VeinTypeInfo[maxVeinId + 1];
starVeinCount = new VeinTypeInfo[maxVeinId + 1];
InitializeVeinCountArray(planetVeinCount);
InitializeVeinCountArray(starVeinCount);
}
protected override void OnEnable() protected override void OnEnable()
{ {
InitializeVeinCountArray(planetVeinCount); if (planetVeinCount != null)
InitializeVeinCountArray(starVeinCount);
foreach (VeinTypeInfo vti in planetVeinCount)
{ {
vti.Reset(); foreach (VeinTypeInfo vti in planetVeinCount)
vti.textCtrl?.gameObject.SetActive(true); {
vti.Reset();
vti.textCtrl?.gameObject.SetActive(true);
}
UIPlanetDetail_RefreshDynamicProperties_Postfix(UIRoot.instance.uiGame.planetDetail);
} }
UIPlanetDetail_RefreshDynamicProperties_Postfix(UIRoot.instance.uiGame.planetDetail); if (starVeinCount != null)
foreach (VeinTypeInfo vti in starVeinCount)
{ {
vti.Reset(); foreach (VeinTypeInfo vti in starVeinCount)
vti.textCtrl?.gameObject.SetActive(true); {
vti.Reset();
vti.textCtrl?.gameObject.SetActive(true);
}
UIStarDetail_RefreshDynamicProperties_Postfix(UIRoot.instance.uiGame.starDetail);
} }
UIStarDetail_RefreshDynamicProperties_Postfix(UIRoot.instance.uiGame.starDetail);
} }
private static Vector2 GetAdjustedSizeDelta(Vector2 origSizeDelta) private static Vector2 GetAdjustedSizeDelta(Vector2 origSizeDelta)
@@ -61,15 +100,21 @@ public class UIPatch : PatchImpl<UIPatch>
protected override void OnDisable() protected override void OnDisable()
{ {
foreach (VeinTypeInfo vti in planetVeinCount) if (planetVeinCount != null)
{ {
vti.Reset(); foreach (VeinTypeInfo vti in planetVeinCount)
vti.textCtrl?.gameObject.SetActive(false); {
vti.Reset();
vti.textCtrl?.gameObject.SetActive(false);
}
} }
foreach (VeinTypeInfo vti in starVeinCount) if (starVeinCount != null)
{ {
vti.Reset(); foreach (VeinTypeInfo vti in starVeinCount)
vti.textCtrl?.gameObject.SetActive(false); {
vti.Reset();
vti.textCtrl?.gameObject.SetActive(false);
}
} }
} }