mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-02-04 19:02:18 +08:00
some fixes
This commit is contained in:
@@ -397,7 +397,9 @@ public static class LogisticsPatch
|
|||||||
var storage = stationEntry.station?.storage;
|
var storage = stationEntry.station?.storage;
|
||||||
if (storage == null) return;
|
if (storage == null) return;
|
||||||
var itemId = storage.Length > slot ? storage[slot].itemId : 0;
|
var itemId = storage.Length > slot ? storage[slot].itemId : 0;
|
||||||
var controlPanelWindow = UIRoot.instance?.uiGame?.controlPanelWindow;
|
var uiRoot = UIRoot.instance;
|
||||||
|
if (!uiRoot) return;
|
||||||
|
var controlPanelWindow = uiRoot.uiGame?.controlPanelWindow;
|
||||||
if (controlPanelWindow == null) return;
|
if (controlPanelWindow == null) return;
|
||||||
var filterPanel = controlPanelWindow.filterPanel;
|
var filterPanel = controlPanelWindow.filterPanel;
|
||||||
if (filterPanel == null) return;
|
if (filterPanel == null) return;
|
||||||
@@ -487,7 +489,8 @@ public static class LogisticsPatch
|
|||||||
|
|
||||||
public static void Enable(bool on)
|
public static void Enable(bool on)
|
||||||
{
|
{
|
||||||
_stationTipRoot?.SetActive(on);
|
if (_stationTipRoot)
|
||||||
|
_stationTipRoot.SetActive(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EnableBars(bool on)
|
public static void EnableBars(bool on)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using BepInEx.Configuration;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using UXAssist.Common;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace UXAssist.UI;
|
namespace UXAssist.UI;
|
||||||
@@ -420,21 +421,14 @@ public class MyWindowWithTabs : MyWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MyWindowManager
|
public class MyWindowManager
|
||||||
{
|
{
|
||||||
private static readonly List<ManualBehaviour> Windows = new(4);
|
private static readonly List<ManualBehaviour> Windows = new(4);
|
||||||
private static bool _initialized;
|
private static bool _initialized;
|
||||||
private static Harmony _patch;
|
|
||||||
|
|
||||||
public static void Init()
|
public static void Enable(bool on)
|
||||||
{
|
{
|
||||||
_patch ??= Harmony.CreateAndPatchAll(typeof(Patch));
|
Patch.Enable(on);
|
||||||
}
|
|
||||||
|
|
||||||
public static void Uninit()
|
|
||||||
{
|
|
||||||
_patch?.UnpatchSelf();
|
|
||||||
_patch = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T CreateWindow<T>(string name, string title = "") where T : MyWindow
|
public static T CreateWindow<T>(string name, string title = "") where T : MyWindow
|
||||||
@@ -495,8 +489,24 @@ public static class MyWindowManager
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static class Patch
|
public class Patch: PatchImpl<Patch>
|
||||||
{
|
{
|
||||||
|
protected override void OnEnable()
|
||||||
|
{
|
||||||
|
InitAllWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void InitAllWindows()
|
||||||
|
{
|
||||||
|
if (_initialized) return;
|
||||||
|
if (!UIRoot.instance) return;
|
||||||
|
foreach (var win in Windows)
|
||||||
|
{
|
||||||
|
win._Init(win.data);
|
||||||
|
}
|
||||||
|
_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//_Create -> _Init
|
//_Create -> _Init
|
||||||
[HarmonyPostfix, HarmonyPatch(typeof(UIGame), "_OnCreate")]
|
[HarmonyPostfix, HarmonyPatch(typeof(UIGame), "_OnCreate")]
|
||||||
@@ -520,13 +530,7 @@ public static class MyWindowManager
|
|||||||
[HarmonyPostfix, HarmonyPatch(typeof(UIRoot), nameof(UIRoot._OnOpen))]
|
[HarmonyPostfix, HarmonyPatch(typeof(UIRoot), nameof(UIRoot._OnOpen))]
|
||||||
public static void UIRoot__OnOpen_Postfix()
|
public static void UIRoot__OnOpen_Postfix()
|
||||||
{
|
{
|
||||||
if (_initialized) return;
|
InitAllWindows();
|
||||||
foreach (var win in Windows)
|
|
||||||
{
|
|
||||||
win._Init(win.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
_initialized = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -156,11 +156,8 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
|||||||
I18N.Add("KEYToggleAutoCruise", "Toggle auto-cruise", "切换自动巡航");
|
I18N.Add("KEYToggleAutoCruise", "Toggle auto-cruise", "切换自动巡航");
|
||||||
|
|
||||||
// UI Patches
|
// UI Patches
|
||||||
UIPatch.Enable(true);
|
|
||||||
|
|
||||||
GameLogic.Enable(true);
|
GameLogic.Enable(true);
|
||||||
|
|
||||||
MyWindowManager.Init();
|
|
||||||
UIConfigWindow.Init();
|
UIConfigWindow.Init();
|
||||||
|
|
||||||
_patches = Common.Util.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "UXAssist.Patches");
|
_patches = Common.Util.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "UXAssist.Patches");
|
||||||
@@ -172,6 +169,9 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
|||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
MyWindowManager.Enable(true);
|
||||||
|
UIPatch.Enable(true);
|
||||||
|
|
||||||
_patches?.Do(type => type.GetMethod("Start")?.Invoke(null, null));
|
_patches?.Do(type => type.GetMethod("Start")?.Invoke(null, null));
|
||||||
var patch = UIPatch.GetHarmony();
|
var patch = UIPatch.GetHarmony();
|
||||||
ModsCompat.AuxilaryfunctionWrapper.Init(patch);
|
ModsCompat.AuxilaryfunctionWrapper.Init(patch);
|
||||||
@@ -182,10 +182,9 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
|||||||
{
|
{
|
||||||
_patches?.Do(type => type.GetMethod("Uninit")?.Invoke(null, null));
|
_patches?.Do(type => type.GetMethod("Uninit")?.Invoke(null, null));
|
||||||
|
|
||||||
MyWindowManager.Uninit();
|
|
||||||
|
|
||||||
GameLogic.Enable(false);
|
|
||||||
UIPatch.Enable(false);
|
UIPatch.Enable(false);
|
||||||
|
MyWindowManager.Enable(false);
|
||||||
|
GameLogic.Enable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
@@ -244,13 +243,18 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
|||||||
{
|
{
|
||||||
private static GameObject _buttonOnPlanetGlobe;
|
private static GameObject _buttonOnPlanetGlobe;
|
||||||
|
|
||||||
// Add config button to main menu
|
protected override void OnEnable()
|
||||||
[HarmonyPostfix, HarmonyPatch(typeof(UIRoot), nameof(UIRoot.OpenMainMenuUI))]
|
{
|
||||||
public static void UIRoot_OpenMainMenuUI_Postfix()
|
InitMenuButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void InitMenuButtons()
|
||||||
{
|
{
|
||||||
if (_initialized) return;
|
if (_initialized) return;
|
||||||
|
var uiRoot = UIRoot.instance;
|
||||||
|
if (!uiRoot) return;
|
||||||
{
|
{
|
||||||
var mainMenu = UIRoot.instance.uiMainMenu;
|
var mainMenu = uiRoot.uiMainMenu;
|
||||||
var src = mainMenu.newGameButton;
|
var src = mainMenu.newGameButton;
|
||||||
var parent = src.transform.parent;
|
var parent = src.transform.parent;
|
||||||
var btn = Instantiate(src, parent);
|
var btn = Instantiate(src, parent);
|
||||||
@@ -273,9 +277,9 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
|||||||
btn.button.onClick.AddListener(ToggleConfigWindow);
|
btn.button.onClick.AddListener(ToggleConfigWindow);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
var panel = UIRoot.instance.uiGame.planetGlobe;
|
var panel = uiRoot.uiGame.planetGlobe;
|
||||||
var src = panel.button2;
|
var src = panel.button2;
|
||||||
var sandboxMenu = UIRoot.instance.uiGame.sandboxMenu;
|
var sandboxMenu = uiRoot.uiGame.sandboxMenu;
|
||||||
var icon = sandboxMenu.categoryButtons[6].transform.Find("icon")?.GetComponent<Image>()?.sprite;
|
var icon = sandboxMenu.categoryButtons[6].transform.Find("icon")?.GetComponent<Image>()?.sprite;
|
||||||
var b = Instantiate(src, src.transform.parent);
|
var b = Instantiate(src, src.transform.parent);
|
||||||
_buttonOnPlanetGlobe = b.gameObject;
|
_buttonOnPlanetGlobe = b.gameObject;
|
||||||
@@ -304,6 +308,13 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
|||||||
}
|
}
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add config button to main menu
|
||||||
|
[HarmonyPostfix, HarmonyPatch(typeof(UIRoot), nameof(UIRoot._OnOpen))]
|
||||||
|
public static void UIRoot__OnOpen_Postfix()
|
||||||
|
{
|
||||||
|
InitMenuButtons();
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(typeof(UIPlanetGlobe), nameof(UIPlanetGlobe.DistributeButtons))]
|
[HarmonyPatch(typeof(UIPlanetGlobe), nameof(UIPlanetGlobe.DistributeButtons))]
|
||||||
|
|||||||
Reference in New Issue
Block a user