From 64f9aee06b9cd09950d57fda9d6f79e168e5c8d6 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Sat, 20 Jun 2026 15:20:59 +0800 Subject: [PATCH] fix: logistic storage overflow reset when switching stations in panel --- UXAssist/Patches/LogisticsPatch.cs | 34 ++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/UXAssist/Patches/LogisticsPatch.cs b/UXAssist/Patches/LogisticsPatch.cs index 4e71767..a466dae 100644 --- a/UXAssist/Patches/LogisticsPatch.cs +++ b/UXAssist/Patches/LogisticsPatch.cs @@ -487,6 +487,8 @@ public static class LogisticsPatch private static long _nextKeyTick; private static bool _skipNextUIStationStorageEvent; private static bool _skipNextUIControlPanelStationStorageEvent; + private static bool _refreshingUIStationStorage; + private static bool _refreshingUIControlPanelStationStorage; private static bool UpdateKeyPressed(KeyCode code) { @@ -627,11 +629,39 @@ public static class LogisticsPatch } } + [HarmonyPrefix] + [HarmonyPatch(typeof(UIStationStorage), "RefreshValues")] + private static void UIStationStorage_RefreshValues_Prefix() + { + _refreshingUIStationStorage = true; + } + + [HarmonyPostfix] + [HarmonyPatch(typeof(UIStationStorage), "RefreshValues")] + private static void UIStationStorage_RefreshValues_Postfix() + { + _refreshingUIStationStorage = false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(UIControlPanelStationStorage), "RefreshValues")] + private static void UIControlPanelStationStorage_RefreshValues_Prefix() + { + _refreshingUIControlPanelStationStorage = true; + } + + [HarmonyPostfix] + [HarmonyPatch(typeof(UIControlPanelStationStorage), "RefreshValues")] + private static void UIControlPanelStationStorage_RefreshValues_Postfix() + { + _refreshingUIControlPanelStationStorage = false; + } + [HarmonyPrefix] [HarmonyPatch(typeof(UIStationStorage), nameof(UIStationStorage.OnMaxSliderValueChange))] private static bool UIStationStorage_OnMaxSliderValueChange_Prefix() { - if (!_skipNextUIStationStorageEvent) return true; + if (!_refreshingUIStationStorage && !_skipNextUIStationStorageEvent) return true; _skipNextUIStationStorageEvent = false; return false; } @@ -640,7 +670,7 @@ public static class LogisticsPatch [HarmonyPatch(typeof(UIControlPanelStationStorage), nameof(UIControlPanelStationStorage.OnMaxSliderValueChange))] private static bool UIControlPanelStationStorage_OnMaxSliderValueChange_Prefix() { - if (!_skipNextUIControlPanelStationStorageEvent) return true; + if (!_refreshingUIControlPanelStationStorage && !_skipNextUIControlPanelStationStorageEvent) return true; _skipNextUIControlPanelStationStorageEvent = false; return false; }