From f7e1a27be18dfaa663d16fab9633ca6afb94551d Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Sun, 25 May 2025 10:55:03 +0800 Subject: [PATCH] UXAsisst 1.3.6 --- UXAssist/CHANGELOG.md | 10 +++++++ UXAssist/Functions/FactoryFunctions.cs | 38 ++++++++++++++++++++------ UXAssist/Patches/FactoryPatch.cs | 21 ++++++++++++-- UXAssist/Patches/LogisticsPatch.cs | 9 +++--- UXAssist/UIConfigWindow.cs | 6 ++-- UXAssist/UXAssist.cs | 2 +- UXAssist/UXAssist.csproj | 2 +- UXAssist/package/manifest.json | 2 +- 8 files changed, 69 insertions(+), 21 deletions(-) diff --git a/UXAssist/CHANGELOG.md b/UXAssist/CHANGELOG.md index 4bedeef..cd3dd5f 100644 --- a/UXAssist/CHANGELOG.md +++ b/UXAssist/CHANGELOG.md @@ -3,6 +3,11 @@ ## Changlog +* 1.3.6 + + `Dismantle blueprint selected buildings`: + - Fix a crash on dismantling preview buildings. + - Rename to `Shortcut keys for Blueprint Copy mode`, while adding a shortcut key to select all buildings (Ctrl+A by default). + + `Allow overflow for Logistic Stations and Advanced Mining Machines`: Working for Logistics Control Panel now. * 1.3.5 + `Mod manager profile based save folder`: Fix crash on game startup * 1.3.4 @@ -313,6 +318,11 @@ ## 更新日志 +* 1.3.6 + + `拆除蓝图选中的建筑`: + - 修复了拆除虚影建筑时崩溃的问题 + - 重命名为`蓝图复制模式快捷键`,同时添加了选择所有建筑的快捷键(默认为Ctrl+A) + + `允许物流站和大型采矿机物品溢出`:现在也适用于物流控制面板 * 1.3.5 + `基于mod管理器配置档案的存档文件夹`:修复游戏启动时崩溃的问题 * 1.3.4 diff --git a/UXAssist/Functions/FactoryFunctions.cs b/UXAssist/Functions/FactoryFunctions.cs index bb45310..f63fec5 100644 --- a/UXAssist/Functions/FactoryFunctions.cs +++ b/UXAssist/Functions/FactoryFunctions.cs @@ -87,18 +87,21 @@ public static class FactoryFunctions var stationPool = factory.transport.stationPool; foreach (var objId in buildPreviewsToRemove) { - int stationId = entityPool[objId].stationId; - if (stationId > 0) + if (objId > 0) { - StationComponent sc = stationPool[stationId]; - if (sc.id != stationId) continue; - for (int i = 0; i < sc.storage.Length; i++) + int stationId = entityPool[objId].stationId; + if (stationId > 0) { - int package = player.TryAddItemToPackage(sc.storage[i].itemId, sc.storage[i].count, 0, true, objId); - UIItemup.Up(sc.storage[i].itemId, package); + StationComponent sc = stationPool[stationId]; + if (sc.id != stationId) continue; + for (int i = 0; i < sc.storage.Length; i++) + { + int package = player.TryAddItemToPackage(sc.storage[i].itemId, sc.storage[i].count, 0, true, objId); + UIItemup.Up(sc.storage[i].itemId, package); + } + sc.storage = new StationStore[sc.storage.Length]; + sc.needs = new int[sc.needs.Length]; } - sc.storage = new StationStore[sc.storage.Length]; - sc.needs = new int[sc.needs.Length]; } build.DoDismantleObject(objId); } @@ -108,4 +111,21 @@ public static class FactoryFunctions blueprintCopyTool.ResetBuildPreviews(); blueprintCopyTool.RefreshBlueprintData(); } + + public static void SelectAllBuildingsInBlueprintCopy() + { + var localFactory = GameMain.localPlanet?.factory; + if (localFactory == null) return; + var blueprintCopyTool = GameMain.mainPlayer?.controller?.actionBuild?.blueprintCopyTool; + if (blueprintCopyTool == null || !blueprintCopyTool.active) return; + var entityPool = localFactory.entityPool; + foreach (var entity in entityPool) + { + if (entity.id == 0) continue; + blueprintCopyTool.preSelectObjIds.Add(entity.id); + blueprintCopyTool.selectedObjIds.Add(entity.id); + } + blueprintCopyTool.RefreshBlueprintData(); + blueprintCopyTool.DeterminePreviews(); + } } diff --git a/UXAssist/Patches/FactoryPatch.cs b/UXAssist/Patches/FactoryPatch.cs index 7f280e4..e2b0d3d 100644 --- a/UXAssist/Patches/FactoryPatch.cs +++ b/UXAssist/Patches/FactoryPatch.cs @@ -41,12 +41,13 @@ public class FactoryPatch : PatchImpl public static ConfigEntry LabBufferExtraCountForAdvancedAssemble; public static ConfigEntry LabBufferMaxCountForResearch; public static ConfigEntry ReceiverBufferCount; - public static ConfigEntry DismantleBlueprintSelectionEnabled; + public static ConfigEntry ShortcutKeysForBlueprintCopyEnabled; private static PressKeyBind _doNotRenderEntitiesKey; private static PressKeyBind _offgridfForPathsKey; private static PressKeyBind _cutConveyorBeltKey; private static PressKeyBind _dismantleBlueprintSelectionKey; + private static PressKeyBind _selectAllBuildingsInBlueprintCopyKey; private static int _tankFastFillInAndTakeOutMultiplierRealValue = 2; @@ -88,6 +89,15 @@ public class FactoryPatch : PatchImpl } ); I18N.Add("KEYDismantleBlueprintSelection", "[UXA] Dismantle blueprint selected buildings", "[UXA] 拆除蓝图选中的建筑"); + _selectAllBuildingsInBlueprintCopyKey = KeyBindings.RegisterKeyBinding(new BuiltinKey + { + key = new CombineKey((int)KeyCode.A, CombineKey.CTRL_COMB, ECombineKeyAction.OnceClick, false), + conflictGroup = KeyBindConflict.KEYBOARD_KEYBIND, + name = "SelectAllBuildingsInBlueprintCopy", + canOverride = true + } + ); + I18N.Add("KEYSelectAllBuildingsInBlueprintCopy", "[UXA] Select all buildings in Blueprint Copy Mode", "[UXA] 蓝图复制时选择所有建筑"); BeltSignalsForBuyOut.InitPersist(); ProtectVeinsFromExhaustion.InitConfig(); @@ -182,8 +192,13 @@ public class FactoryPatch : PatchImpl Functions.FactoryFunctions.CutConveyorBelt(cargoTraffic, beltId); } } - if (DismantleBlueprintSelectionEnabled.Value && _dismantleBlueprintSelectionKey.keyValue) - Functions.FactoryFunctions.DismantleBlueprintSelectedBuildings(); + if (ShortcutKeysForBlueprintCopyEnabled.Value) + { + if (_dismantleBlueprintSelectionKey.keyValue) + Functions.FactoryFunctions.DismantleBlueprintSelectedBuildings(); + if (_selectAllBuildingsInBlueprintCopyKey.keyValue) + Functions.FactoryFunctions.SelectAllBuildingsInBlueprintCopy(); + } } public static void Export(BinaryWriter w) diff --git a/UXAssist/Patches/LogisticsPatch.cs b/UXAssist/Patches/LogisticsPatch.cs index 5db61a2..bd55f83 100644 --- a/UXAssist/Patches/LogisticsPatch.cs +++ b/UXAssist/Patches/LogisticsPatch.cs @@ -466,10 +466,11 @@ public static class LogisticsPatch private class AllowOverflowInLogistics : PatchImpl { - private static bool _bludprintPasting; + private static bool _blueprintPasting; // Do not check for overflow when try to send hand items into storages [HarmonyTranspiler] + [HarmonyPatch(typeof(UIControlPanelStationStorage), nameof(UIControlPanelStationStorage.OnItemIconMouseDown))] [HarmonyPatch(typeof(UIStationStorage), nameof(UIStationStorage.OnItemIconMouseDown))] private static IEnumerable UIStationStorage_OnItemIconMouseDown_Transpiler(IEnumerable instructions, ILGenerator generator) { @@ -516,7 +517,7 @@ public static class LogisticsPatch var oldLabels = matcher.Labels; matcher.Labels = []; matcher.InsertAndAdvance( - new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(AllowOverflowInLogistics), nameof(_bludprintPasting))).WithLabels(oldLabels), + new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(AllowOverflowInLogistics), nameof(_blueprintPasting))).WithLabels(oldLabels), new CodeInstruction(OpCodes.Brfalse, label) ); matcher.Advance(9).Labels.Add(label); @@ -527,14 +528,14 @@ public static class LogisticsPatch [HarmonyPatch(typeof(BuildTool_BlueprintPaste), nameof(BuildTool_BlueprintPaste.CreatePrebuilds))] private static void BuildTool_BlueprintPaste_CreatePrebuilds_Prefix() { - _bludprintPasting = true; + _blueprintPasting = true; } [HarmonyPostfix] [HarmonyPatch(typeof(BuildTool_BlueprintPaste), nameof(BuildTool_BlueprintPaste.CreatePrebuilds))] private static void BuildTool_BlueprintPaste_CreatePrebuilds_Postfix() { - _bludprintPasting = false; + _blueprintPasting = false; } } diff --git a/UXAssist/UIConfigWindow.cs b/UXAssist/UIConfigWindow.cs index deb0939..3dd2994 100644 --- a/UXAssist/UIConfigWindow.cs +++ b/UXAssist/UIConfigWindow.cs @@ -121,7 +121,8 @@ public static class UIConfigWindow I18N.Add("Extra buffer count for Self-evolution Labs", "Extra buffer count for Self-evolution Labs", "自演化研究站矩阵额外缓冲数量"); I18N.Add("Buffer count for researching in labs", "Buffer count for researching in labs", "研究站科研模式缓存数量"); I18N.Add("Ray Receiver Graviton Lens buffer count", "Ray Receiver Graviton Lens buffer count", "射线接收器透镜缓冲数量"); - I18N.Add("Dismantle blueprint selected buildings", "Dismantle blueprint selected buildings", "拆除蓝图选中的建筑"); + I18N.Add("Shortcut keys for Blueprint Copy mode", "Shortcut keys for Blueprint Copy mode", "蓝图复制模式快捷键"); + I18N.Add("Shortcut keys for Blueprint Copy mode tips", "You can set 2 shortcut keys in Settings panel:\n 1. Select all buildings\n 2. Dismantle selected buildings", "你可以在设置面板中设置2个快捷键:\n 1. 选择所有建筑\n 2. 拆除选中的建筑"); I18N.Add("Shortcut keys for showing stars' name", "Shortcut keys for showing stars' name", "启用显示所有星系名称的快捷键"); I18N.Add("Auto navigation on sailings", "Auto navigation on sailings", "宇宙航行时自动导航"); I18N.Add("Enable auto-cruise", "Enable auto-cruise", "启用自动巡航"); @@ -406,7 +407,8 @@ public static class UIConfigWindow y += 36f; wnd.AddCheckBox(x, y, tab2, FactoryPatch.DoNotRenderEntitiesEnabled, "Do not render factory entities"); y += 36f; - wnd.AddCheckBox(x, y, tab2, FactoryPatch.DismantleBlueprintSelectionEnabled, "Dismantle blueprint selected buildings"); + checkBoxForMeasureTextWidth = wnd.AddCheckBox(x, y, tab2, FactoryPatch.ShortcutKeysForBlueprintCopyEnabled, "Shortcut keys for Blueprint Copy mode"); + wnd.AddTipsButton2(x + checkBoxForMeasureTextWidth.Width + 5f, y + 6f, tab2, "Shortcut keys for Blueprint Copy mode", "Shortcut keys for Blueprint Copy mode tips", "shortcut-keys-for-blueprint-copy-mode-tips"); y += 36f; wnd.AddCheckBox(x, y, tab2, FactoryPatch.BeltSignalsForBuyOutEnabled, "Belt signals for buy out dark fog items automatically"); diff --git a/UXAssist/UXAssist.cs b/UXAssist/UXAssist.cs index fd365e2..0591df7 100644 --- a/UXAssist/UXAssist.cs +++ b/UXAssist/UXAssist.cs @@ -134,7 +134,7 @@ public class UXAssist : BaseUnityPlugin, IModCanSave FactoryPatch.LabBufferExtraCountForAdvancedAssemble = Config.Bind("Factory", "LabBufferExtraCountForAdvancedAssemble", 3, new ConfigDescription("Extra buffer count for Self-evolution Labs", new AcceptableValueRange(1, 10))); FactoryPatch.LabBufferMaxCountForResearch = Config.Bind("Factory", "LabBufferMaxCountForResearch", 10, new ConfigDescription("Buffer count for researching in labs", new AcceptableValueRange(2, 20))); FactoryPatch.ReceiverBufferCount = Config.Bind("Factory", "ReceiverBufferCount", 1, new ConfigDescription("Ray Receiver Graviton Lens buffer count", new AcceptableValueRange(1, 20))); - FactoryPatch.DismantleBlueprintSelectionEnabled = Config.Bind("Factory", "DismantleBlueprintSelection", false, + FactoryPatch.ShortcutKeysForBlueprintCopyEnabled = Config.Bind("Factory", "DismantleBlueprintSelection", false, "Dismantle blueprint selected buildings"); LogisticsPatch.AutoConfigLogisticsEnabled = Config.Bind("Factory", "AutoConfigLogistics", false, "Auto-config logistic stations"); diff --git a/UXAssist/UXAssist.csproj b/UXAssist/UXAssist.csproj index 0e2c0cd..6caf0d5 100644 --- a/UXAssist/UXAssist.csproj +++ b/UXAssist/UXAssist.csproj @@ -4,7 +4,7 @@ net472 org.soardev.uxassist DSP MOD - UXAssist - 1.3.5 + 1.3.6 true latest UXAssist diff --git a/UXAssist/package/manifest.json b/UXAssist/package/manifest.json index ddbd842..b712103 100644 --- a/UXAssist/package/manifest.json +++ b/UXAssist/package/manifest.json @@ -1,6 +1,6 @@ { "name": "UXAssist", - "version_number": "1.3.5", + "version_number": "1.3.6", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist", "description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁", "dependencies": [