From a48ae5ad963e4c23452a2dfaf8dfbd921aecfa86 Mon Sep 17 00:00:00 2001 From: FyisFe Date: Thu, 25 Jun 2026 23:57:58 -0700 Subject: [PATCH] feat: add 'hide sorters too' sub-option for do-not-render feature When enabled (with the parent feature on), sorters are also hidden, leaving only belts and their cargo visible. Hidden sorters also become click-through so clicks reach the belts beneath them. - RenderingPatch: gate InserterRenderer.Render and the RaycastLogic inserter exemption on a new HideSorters flag - FactoryPatch/UXAssist/FactoryConfigProvider: new DoNotRenderEntitiesHideSorters config wired to the flag - UIConfigWindow/I18NKeys: indented sub-checkbox + EN/zh label - README/CHANGELOG: document the sub-option; bump to 1.5.9 --- UXAssist/CHANGELOG.md | 4 ++++ UXAssist/Common/Config/FactoryConfigProvider.cs | 1 + UXAssist/Common/I18NKeys.cs | 2 ++ UXAssist/Patches/Factory/FactoryPatch.cs | 3 +++ UXAssist/Patches/Factory/RenderingPatch.cs | 11 ++++++++++- UXAssist/README.md | 2 ++ UXAssist/UIConfigWindow.cs | 14 +++++++++++++- UXAssist/UXAssist.cs | 2 ++ UXAssist/UXAssist.csproj | 2 +- 9 files changed, 38 insertions(+), 3 deletions(-) diff --git a/UXAssist/CHANGELOG.md b/UXAssist/CHANGELOG.md index c502851..d38f8d6 100644 --- a/UXAssist/CHANGELOG.md +++ b/UXAssist/CHANGELOG.md @@ -3,6 +3,8 @@ ## Changlog +* 1.5.9 + * `Do not render factory entities (except belts and sorters)`: Add sub-option `Hide sorters too` to also hide sorters, leaving only belts visible. * 1.5.8 * `Initialize This Planet`: Fix a possible crash. * `Remember window position and size on last exit`: Remove a window hook that are not useful anymore. @@ -401,6 +403,8 @@ ## 更新日志 +* 1.5.9 + * `不渲染工厂建筑实体(除了传送带和分拣器)`:新增子选项`同时隐藏分拣器`,可一并隐藏分拣器,只保留传送带可见。 * 1.5.8 * `初始化本行星`:修复可能的崩溃。 * `记住上次退出时的窗口位置和大小`:移除不再有用的窗口钩子。 diff --git a/UXAssist/Common/Config/FactoryConfigProvider.cs b/UXAssist/Common/Config/FactoryConfigProvider.cs index e8a390c..bf0fb10 100644 --- a/UXAssist/Common/Config/FactoryConfigProvider.cs +++ b/UXAssist/Common/Config/FactoryConfigProvider.cs @@ -18,6 +18,7 @@ public static class FactoryConfigProvider public static ConfigEntry QuickBuildAndDismantleLabsEnabled => FactoryPatch.QuickBuildAndDismantleLabsEnabled; public static ConfigEntry ProtectVeinsFromExhaustionEnabled => FactoryPatch.ProtectVeinsFromExhaustionEnabled; public static ConfigEntry DoNotRenderEntitiesEnabled => FactoryPatch.DoNotRenderEntitiesEnabled; + public static ConfigEntry DoNotRenderEntitiesHideSortersEnabled => FactoryPatch.DoNotRenderEntitiesHideSortersEnabled; public static ConfigEntry DragBuildPowerPolesEnabled => FactoryPatch.DragBuildPowerPolesEnabled; public static ConfigEntry DragBuildPowerPolesAlternatelyEnabled => FactoryPatch.DragBuildPowerPolesAlternatelyEnabled; public static ConfigEntry AutoConstructButtonEnabled => FactoryPatch.AutoConstructButtonEnabled; diff --git a/UXAssist/Common/I18NKeys.cs b/UXAssist/Common/I18NKeys.cs index 1b37d28..c4704e3 100644 --- a/UXAssist/Common/I18NKeys.cs +++ b/UXAssist/Common/I18NKeys.cs @@ -88,6 +88,7 @@ public static class I18NKeys public const string ProtectVeinsFromExhaustion = "Protect veins from exhaustion"; public const string ProtectVeinsFromExhaustionTips = "Protect veins from exhaustion tips"; public const string DoNotRenderFactoryEntities = "Do not render factory entities"; + public const string HideSortersToo = "Hide sorters too"; public const string DragBuildingPowerPolesInMaximumConnectionRange = "Drag building power poles in maximum connection range"; public const string BuildTeslaTowerAndWirelessPowerTowerAlternately = "Build Tesla Tower and Wireless Power Tower alternately"; public const string AutoConstructButton = "Auto-construct button"; @@ -299,6 +300,7 @@ Close this function to resume mining and pumping, usually when you have enough l """); I18N.Add(DoNotRenderFactoryEntities, "Do not render factory entities (except belts and sorters)", "不渲染工厂建筑实体(除了传送带和分拣器)"); + I18N.Add(HideSortersToo, "Hide sorters too", "同时隐藏分拣器"); I18N.Add(DragBuildingPowerPolesInMaximumConnectionRange, "Drag building power poles in maximum connection range", "拖动建造电线杆时自动使用最大连接距离间隔"); I18N.Add(BuildTeslaTowerAndWirelessPowerTowerAlternately, "Build Tesla Tower and Wireless Power Tower alternately", "交替建造电力感应塔和无线输电塔"); I18N.Add(AutoConstructButton, "Auto-construct button", "自动建造按钮"); diff --git a/UXAssist/Patches/Factory/FactoryPatch.cs b/UXAssist/Patches/Factory/FactoryPatch.cs index 9b01984..979f5d9 100644 --- a/UXAssist/Patches/Factory/FactoryPatch.cs +++ b/UXAssist/Patches/Factory/FactoryPatch.cs @@ -25,6 +25,7 @@ public static class FactoryPatch public static ConfigEntry QuickBuildAndDismantleLabsEnabled; public static ConfigEntry ProtectVeinsFromExhaustionEnabled; public static ConfigEntry DoNotRenderEntitiesEnabled; + public static ConfigEntry DoNotRenderEntitiesHideSortersEnabled; public static ConfigEntry DragBuildPowerPolesEnabled; public static ConfigEntry DragBuildPowerPolesAlternatelyEnabled; public static ConfigEntry AutoConstructButtonEnabled; @@ -112,6 +113,7 @@ public static class FactoryPatch QuickBuildAndDismantleLabsEnabled.SettingChanged += (_, _) => FactoryBuildPatches.QuickBuildAndDismantleLab.Enable(QuickBuildAndDismantleLabsEnabled.Value); ProtectVeinsFromExhaustionEnabled.SettingChanged += (_, _) => VeinProtectionPatch.ProtectVeinsFromExhaustion.Enable(ProtectVeinsFromExhaustionEnabled.Value); DoNotRenderEntitiesEnabled.SettingChanged += (_, _) => RenderingPatch.DoNotRenderEntities.Enable(DoNotRenderEntitiesEnabled.Value); + DoNotRenderEntitiesHideSortersEnabled.SettingChanged += (_, _) => RenderingPatch.DoNotRenderEntities.HideSorters = DoNotRenderEntitiesHideSortersEnabled.Value; DragBuildPowerPolesEnabled.SettingChanged += (_, _) => BuildToolPatch.DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value); DragBuildPowerPolesAlternatelyEnabled.SettingChanged += (_, _) => BuildToolPatch.DragBuildPowerPoles.AlternatelyChanged(); AutoConstructButtonEnabled.SettingChanged += (_, _) => FactoryBuildPatches.AutoConstructPatch.Enable(AutoConstructButtonEnabled.Value); @@ -147,6 +149,7 @@ public static class FactoryPatch FactoryBuildPatches.QuickBuildAndDismantleLab.Enable(QuickBuildAndDismantleLabsEnabled.Value); VeinProtectionPatch.ProtectVeinsFromExhaustion.Enable(ProtectVeinsFromExhaustionEnabled.Value); RenderingPatch.DoNotRenderEntities.Enable(DoNotRenderEntitiesEnabled.Value); + RenderingPatch.DoNotRenderEntities.HideSorters = DoNotRenderEntitiesHideSortersEnabled.Value; BuildToolPatch.DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value); FactoryBuildPatches.AutoConstructPatch.Enable(AutoConstructButtonEnabled.Value); BeltSignalPatch.BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value); diff --git a/UXAssist/Patches/Factory/RenderingPatch.cs b/UXAssist/Patches/Factory/RenderingPatch.cs index cc17b90..8f99f2c 100644 --- a/UXAssist/Patches/Factory/RenderingPatch.cs +++ b/UXAssist/Patches/Factory/RenderingPatch.cs @@ -19,6 +19,8 @@ internal static class RenderingPatch internal class DoNotRenderEntities : PatchImpl { + public static bool HideSorters; + [HarmonyPrefix] [HarmonyPatch(typeof(ObjectRenderer), nameof(ObjectRenderer.Render))] [HarmonyPatch(typeof(DynamicRenderer), nameof(DynamicRenderer.Render))] @@ -27,6 +29,13 @@ internal static class RenderingPatch return false; } + [HarmonyPrefix] + [HarmonyPatch(typeof(InserterRenderer), nameof(InserterRenderer.Render))] + private static bool InserterRenderer_Render_Prefix() + { + return !HideSorters; + } + [HarmonyPrefix] [HarmonyPatch(typeof(LabRenderer), nameof(LabRenderer.Render))] private static bool LabRenderer_Render_Prefix() @@ -69,7 +78,7 @@ internal static class RenderingPatch new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Ldloc_S, 33), new CodeInstruction(OpCodes.Ldloc_S, 35), - Transpilers.EmitDelegate((RaycastLogic l, ColliderData[] colliderPool, int j) => l.factory.entityPool[colliderPool[j].objId].inserterId > 0), + Transpilers.EmitDelegate((RaycastLogic l, ColliderData[] colliderPool, int j) => !HideSorters && l.factory.entityPool[colliderPool[j].objId].inserterId > 0), new CodeInstruction(OpCodes.Brfalse, branch1) ); matcher.Labels.Add(branch2); diff --git a/UXAssist/README.md b/UXAssist/README.md index 8f5ecfe..9cea567 100644 --- a/UXAssist/README.md +++ b/UXAssist/README.md @@ -59,6 +59,7 @@ * Close this function to resume mining and pumping, usually when you have enough level on `Veins Utilization` * Do not render factory entities (except belts and sorters) * This also makes players click though factory entities but belts and sorters + * `Hide sorters too`: also hide sorters, leaving only belts (and their cargo) visible * Drag building power poles in maximum connection range * Auto-construct * Fly to buildings to be contructed automatically @@ -225,6 +226,7 @@ * 关闭此功能以恢复开采,一般是当你在`矿物利用`上有足够的等级时。 * 不渲染工厂建筑实体(除了传送带和分拣器) * 这也使玩家可以点穿工厂实体直接点到传送带和分拣器 + * `同时隐藏分拣器`:连分拣器也一并隐藏,只保留传送带(及其上的货物)可见 * 拖动建造电线杆时自动使用最大连接距离间隔 * 自动建造 * 自动飞向待建造的建筑 diff --git a/UXAssist/UIConfigWindow.cs b/UXAssist/UIConfigWindow.cs index 47519ec..ff69b6a 100644 --- a/UXAssist/UIConfigWindow.cs +++ b/UXAssist/UIConfigWindow.cs @@ -259,7 +259,19 @@ public static class UIConfigWindow x = 0; y += 36f; - wnd.AddCheckBox(x, y, tab2, FactoryConfigProvider.DoNotRenderEntitiesEnabled, I18NKeys.DoNotRenderFactoryEntities); + { + wnd.AddCheckBox(x, y, tab2, FactoryConfigProvider.DoNotRenderEntitiesEnabled, I18NKeys.DoNotRenderFactoryEntities); + y += 27f; + var hideSortersCheckBox = wnd.AddCheckBox(x + 20f, y, tab2, FactoryConfigProvider.DoNotRenderEntitiesHideSortersEnabled, I18NKeys.HideSortersToo, 13); + FactoryConfigProvider.DoNotRenderEntitiesEnabled.SettingChanged += DoNotRenderEntitiesEnabledChanged; + wnd.OnFree += () => { FactoryConfigProvider.DoNotRenderEntitiesEnabled.SettingChanged -= DoNotRenderEntitiesEnabledChanged; }; + DoNotRenderEntitiesEnabledChanged(null, null); + + void DoNotRenderEntitiesEnabledChanged(object o, EventArgs e) + { + hideSortersCheckBox.SetEnable(FactoryConfigProvider.DoNotRenderEntitiesEnabled.Value); + } + } y += 36f; checkBoxForMeasureTextWidth = wnd.AddCheckBox(x, y, tab2, FactoryConfigProvider.ShortcutKeysForBlueprintCopyEnabled, I18NKeys.ShortcutKeysForBlueprintCopyMode); wnd.AddTipsButton2(x + checkBoxForMeasureTextWidth.Width + 5f, y + 6f, tab2, I18NKeys.ShortcutKeysForBlueprintCopyMode, I18NKeys.ShortcutKeysForBlueprintCopyModeTips, "shortcut-keys-for-blueprint-copy-mode-tips"); diff --git a/UXAssist/UXAssist.cs b/UXAssist/UXAssist.cs index 7eae900..76306f2 100644 --- a/UXAssist/UXAssist.cs +++ b/UXAssist/UXAssist.cs @@ -132,6 +132,8 @@ public class UXAssist : BaseUnityPlugin, IModCanSave VeinProtectionPatch.ProtectVeinsFromExhaustion.KeepOilSpeed = Config.Bind("Factory", "KeepOilSpeed", 1.0f, new ConfigDescription("Keep minimal oil speed (< 0.1 to disable)", new AcceptableValueRange(0.0f, 10.0f))).Value; FactoryPatch.DoNotRenderEntitiesEnabled = Config.Bind("Factory", "DoNotRenderEntities", false, "Do not render factory entities"); + FactoryPatch.DoNotRenderEntitiesHideSortersEnabled = Config.Bind("Factory", "DoNotRenderEntitiesHideSorters", false, + "Hide sorters too when not rendering factory entities (leaves only belts visible)"); FactoryPatch.DragBuildPowerPolesEnabled = Config.Bind("Factory", "DragBuildPowerPoles", false, "Drag building power poles in maximum connection range"); FactoryPatch.DragBuildPowerPolesAlternatelyEnabled = Config.Bind("Factory", "DragBuildPowerPolesAlternately", true, diff --git a/UXAssist/UXAssist.csproj b/UXAssist/UXAssist.csproj index e5827b7..0e6d2a6 100644 --- a/UXAssist/UXAssist.csproj +++ b/UXAssist/UXAssist.csproj @@ -3,7 +3,7 @@ org.soardev.uxassist DSP MOD - UXAssist - 1.5.8 + 1.5.9 UXAssist UXAssist true