From d11817d4c3c6941154ff7c01cff566c6a7712f7f Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Thu, 29 Aug 2024 21:58:41 +0800 Subject: [PATCH] Work in progress --- CheatEnabler/CHANGELOG.md | 409 ++++++++++++++-------------- CheatEnabler/DysonSpherePatch.cs | 4 +- CheatEnabler/UIConfigWindow.cs | 87 +++--- UXAssist/CHANGELOG.md | 21 +- UXAssist/DysonSpherePatch.cs | 162 ++++++++++- UXAssist/FactoryPatch.cs | 281 +------------------ UXAssist/LogisticsPatch.cs | 454 +++++++++++++++++++++++++++++++ UXAssist/README.md | 14 +- UXAssist/UI/MyCheckbox.cs | 5 +- UXAssist/UI/MyConfigWindow.cs | 3 +- UXAssist/UI/MyWindow.cs | 79 +++++- UXAssist/UIConfigWindow.cs | 95 ++++--- UXAssist/UXAssist.cs | 18 +- UXAssist/UXAssist.csproj | 2 +- UXAssist/package/manifest.json | 3 +- 15 files changed, 1034 insertions(+), 603 deletions(-) create mode 100644 UXAssist/LogisticsPatch.cs diff --git a/CheatEnabler/CHANGELOG.md b/CheatEnabler/CHANGELOG.md index 8765021..138a541 100644 --- a/CheatEnabler/CHANGELOG.md +++ b/CheatEnabler/CHANGELOG.md @@ -1,242 +1,243 @@ ## Changlog -* 2.3.22 - + Fix `Pump Anywhere` -* 2.3.21 - + `Retrieve/Place items from/to remote planets on logistics control panel`: Items are put back to player's inventory when a slot is removed from the logistics station on remote planet. - + `Dev Shortcuts`: Camera Pose related shortcurts are working now. -* 2.3.20 - + New feature: `Retrieve/Place items from/to remote planets on logistics control panel` -* 2.3.19 - + New features: - + `Remove all metadata consumption records` - + `Remove metadata consumption record in current game` - + `Clear metadata flag which bans achievements` -* 2.3.18 - + New features: - + `Teleport to outer space`, this will teleport you to the outer space which is 50 LYs far from the farthest star. - + `Teleport to selected astronomical` - + Fix logic of `Unlock techs with key-modifiers`. - + `No condition build` does not hide rotation info of belts now. -* 2.3.17 - + Make compatible with game version 0.10.30.23292 -* 2.3.16 - + Add 2 options to `Belt signal item generation`: - - `Count generations as production in statistics` - - `Count removals as consumption in statistics` - + New feature: `Increase maximum power usage in Logistic Stations and Advanced Mining Machines` - - Logistic Stations: Increased max charging power to 3GW(ILS) and 600MW(PLS) (10x of original) - - Advanced Mining Machines: Increased max mining speed to 1000% -* 2.3.15 - + New features: - - `Instant teleport (like that in Sandbox mode)` - - `Mecha and Drones/Fleets invicible` - - `Buildings invicible` -* 2.3.14 - + Remove default shortcut key for `No condition build` and `No collision`, to avoid misoperation. You can still set them in system settings window manually if needed. - + Fix translation issue. -* 2.3.13 - + Fix a bug that shortcuts are not working and have display issue on settings window. -* 2.3.12 - + Add a shortcut to toggle `No collision`, you can modify the shortcut on system settings window. - + Add realtime tips when toggling `No condition build` and `No collision` with shortcuts. -* 2.3.11 - + Add a shortcut to toggle `No condition build`, you can modify the shortcut on system settings window. This depends on [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) 1.0.15 or later. -* 2.3.10 - + Fix following functions not working in new game updates: - - `Pump Anywhere` - - `Terraform without enough soil piles` -* 2.3.9 - + Support game version 0.10.28.21219 -* 2.3.8 - + Fix a crash on starting new games while `Finish build immediately` is enabled. - + Fix UI button width. -* 2.3.7 - + Support game version 0.10.28.20759 - + Fix belt signal that items' generation speed is not fit to number set sometimes. -* 2.3.6 - + Support for UXAssist's new function within `Finish build immediately`. - + Add a warning message when `Build without condition` is enabled. - + Fix an issue in `Finish build immediately` that some buildings are not finished immediately. -* 2.3.5 - + Fix another crash in `Skip bullet period`. -* 2.3.4 - + Use new tab layout of UXAssist 1.0.2 - + Minor bug fixes -* 2.3.3 - + Fix a crash in `Skip bullet period`. - + Unlock techs with Alt unlocks VeinUtil to 10000 instead of 7200 now, as bug fixed in UXAssist. -* 2.3.2 - + Birth star options moved to [UniverseGenTweaks](https://dsp.thunderstore.io/package/soarqin/UniverseGenTweaks/) - + Optimize `Quick absorb`, consumes less CPU time and take turns firing to nodes. - + `Fast Mining` ensures full output of oil extractors now. - + Fix issue that `Belt signal generator` not working after switched off then on again. - + Fix absorption issue by `Quick absorb` and `Skip bullet period` enabled at the same time. - + Crash fix for some options -* 2.3.1 - + Add UXAssist to dependencies in manifest. -* 2.3.0 - + Move some functions to an individual mod: [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) - + Depends on [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) now, so that config panel is unified with UXAssist. - + Remove `LCtrl+A` from Dev Shortcuts, to avoid misoperation. - + Infinite bots/drones/vessels in `Architect mode` now. -* 2.2.7 - + New function: `Construct only nodes but frames` - + Opening config panel does not close inventory panel now - + Remove `Input direction conflict` check while using `Remove some build conditions` - + Fix a bug that prevents `Belt signal alt format` from switching number formats for current belt signals -* 2.2.6 - + New function: `Stop ejectors when available nodes are all filled up` - + Fix a bug that absorb solar sails on unfinised nodes -* 2.2.5 - + Skip all intermediate states and absorb solar sails instantly while enable `Quick absorb`, `Skip bullet period` and `Skip absorption period` at the same time. - + Fix a problem that `Quick absorb` does not absorb all solar sails instantly when most nodes are full. - + Fix crash while using with some mods -* 2.2.4 - + New function: `Enable player actions in globe view` - + Fix UI bug -* 2.2.3 - + New function: `Remove some build conditions` - + Fix compatibility with some mods -* 2.2.2 - + New function: `Assign gamesave to currrnet account` - + New subfunction: `Belt signal alt format` - + Fix a crash on using `Initialize this Planet` - + Fix belt build in `Finish build immediately` -* 2.2.1 - + Check condition for miners even when `Build without condition` is enabled. - + Fix a patch issue that may cause `Build without condition` not working. -* 2.2.0 - + Add some power related functions - + Add a subfunction to belt signal item generation, which simulates production process of raws and intermediates on statistics - + Split some functions from Architect mode -* 2.1.0 - + Belt signal item generation - + Fix window display priority which may cause tips to be covered by main window -* 2.0.0 - + Refactorying codes - + UI implementation - + Add a lot of functions -* 1.0.0 - + Initial release +* 2.3.22 + + Fix `Pump Anywhere` +* 2.3.21 + + `Retrieve/Place items from/to remote planets on logistics control panel`: Items are put back to player's inventory when a slot is removed from the logistics station on remote planet. + + `Dev Shortcuts`: Camera Pose related shortcurts are working now. +* 2.3.20 + + New feature: `Retrieve/Place items from/to remote planets on logistics control panel` +* 2.3.19 + + New features: + + `Remove all metadata consumption records` + + `Remove metadata consumption record in current game` + + `Clear metadata flag which bans achievements` +* 2.3.18 + + New features: + + `Teleport to outer space`, this will teleport you to the outer space which is 50 LYs far from the farthest star. + + `Teleport to selected astronomical` + + Fix logic of `Unlock techs with key-modifiers`. + + `No condition build` does not hide rotation info of belts now. +* 2.3.17 + + Make compatible with game version 0.10.30.23292 +* 2.3.16 + + Add 2 options to `Belt signal item generation`: + - `Count generations as production in statistics` + - `Count removals as consumption in statistics` + + New feature: `Increase maximum power usage in Logistic Stations and Advanced Mining Machines` + - Logistic Stations: Increased max charging power to 3GW(ILS) and 600MW(PLS) (10x of original) + - Advanced Mining Machines: Increased max mining speed to 1000% +* 2.3.15 + + New features: + - `Instant teleport (like that in Sandbox mode)` + - `Mecha and Drones/Fleets invicible` + - `Buildings invicible` +* 2.3.14 + + Remove default shortcut key for `No condition build` and `No collision`, to avoid misoperation. You can still set them in system settings window manually if needed. + + Fix translation issue. +* 2.3.13 + + Fix a bug that shortcuts are not working and have display issue on settings window. +* 2.3.12 + + Add a shortcut to toggle `No collision`, you can modify the shortcut on system settings window. + + Add realtime tips when toggling `No condition build` and `No collision` with shortcuts. +* 2.3.11 + + Add a shortcut to toggle `No condition build`, you can modify the shortcut on system settings window. This depends on [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) 1.0.15 or later. +* 2.3.10 + + Fix following functions not working in new game updates: + - `Pump Anywhere` + - `Terraform without enough soil piles` +* 2.3.9 + + Support game version 0.10.28.21219 +* 2.3.8 + + Fix a crash on starting new games while `Finish build immediately` is enabled. + + Fix UI button width. +* 2.3.7 + + Support game version 0.10.28.20759 + + Fix belt signal that items' generation speed is not fit to number set sometimes. +* 2.3.6 + + Support for UXAssist's new function within `Finish build immediately`. + + Add a warning message when `Build without condition` is enabled. + + Fix an issue in `Finish build immediately` that some buildings are not finished immediately. +* 2.3.5 + + Fix another crash in `Skip bullet period`. +* 2.3.4 + + Use new tab layout of UXAssist 1.0.2 + + Minor bug fixes +* 2.3.3 + + Fix a crash in `Skip bullet period`. + + Unlock techs with Alt unlocks VeinUtil to 10000 instead of 7200 now, as bug fixed in UXAssist. +* 2.3.2 + + Birth star options moved to [UniverseGenTweaks](https://dsp.thunderstore.io/package/soarqin/UniverseGenTweaks/) + + Optimize `Quick absorb`, consumes less CPU time and take turns firing to nodes. + + `Fast Mining` ensures full output of oil extractors now. + + Fix issue that `Belt signal generator` not working after switched off then on again. + + Fix absorption issue by `Quick absorb` and `Skip bullet period` enabled at the same time. + + Crash fix for some options +* 2.3.1 + + Add UXAssist to dependencies in manifest. +* 2.3.0 + + Move some functions to an individual mod: [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) + + Depends on [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) now, so that config panel is unified with UXAssist. + + Remove `LCtrl+A` from Dev Shortcuts, to avoid misoperation. + + Infinite bots/drones/vessels in `Architect mode` now. +* 2.2.7 + + New function: `Construct only nodes but frames` + + Opening config panel does not close inventory panel now + + Remove `Input direction conflict` check while using `Remove some build conditions` + + Fix a bug that prevents `Belt signal alt format` from switching number formats for current belt signals +* 2.2.6 + + New function: `Stop ejectors when available nodes are all filled up` + + Fix a bug that absorb solar sails on unfinised nodes +* 2.2.5 + + Skip all intermediate states and absorb solar sails instantly while enable `Quick absorb`, `Skip bullet period` and `Skip absorption period` at the same time. + + Fix a problem that `Quick absorb` does not absorb all solar sails instantly when most nodes are full. + + Fix crash while using with some mods +* 2.2.4 + + New function: `Enable player actions in globe view` + + Fix UI bug +* 2.2.3 + + New function: `Remove some build conditions` + + Fix compatibility with some mods +* 2.2.2 + + New function: `Assign gamesave to currrnet account` + + New subfunction: `Belt signal alt format` + + Fix a crash on using `Initialize this Planet` + + Fix belt build in `Finish build immediately` +* 2.2.1 + + Check condition for miners even when `Build without condition` is enabled. + + Fix a patch issue that may cause `Build without condition` not working. +* 2.2.0 + + Add some power related functions + + Add a subfunction to belt signal item generation, which simulates production process of raws and intermediates on statistics + + Split some functions from Architect mode +* 2.1.0 + + Belt signal item generation + + Fix window display priority which may cause tips to be covered by main window +* 2.0.0 + + Refactorying codes + + UI implementation + + Add a lot of functions +* 1.0.0 + + Initial release ## 更新日志 + * 2.3.22 - + 修复了`平地抽水` + + 修复了`平地抽水` * 2.3.21 - + `在物流总控面板上可以从非本地行星取放物品`:当从非本地星球的物流站移除槽位时,物品会放回玩家的背包 - + `开发模式快捷键`:摄像机位(Pose)相关的快捷键现在生效了 + + `在物流总控面板上可以从非本地行星取放物品`:当从非本地星球的物流站移除槽位时,物品会放回玩家的背包 + + `开发模式快捷键`:摄像机位(Pose)相关的快捷键现在生效了 * 2.3.20 - + 新功能:`在物流总控面板上可以从非本地行星取放物品` + + 新功能:`在物流总控面板上可以从非本地行星取放物品` * 2.3.19 - + 新功能: - + `移除所有元数据消耗记录` - + `移除当前存档的元数据消耗记录` - + `解除当前存档因使用元数据导致的成就限制` + + 新功能: + + `移除所有元数据消耗记录` + + `移除当前存档的元数据消耗记录` + + `解除当前存档因使用元数据导致的成就限制` * 2.3.18 - + 新功能: - + `传送到外太空`,这会将你传送到距离最远星球50光年的外太空 - + `传送到选中天体` - + 修复了`组合键解锁科技`的逻辑 - + `无条件建造`现在不会隐藏传送带的旋转信息了 + + 新功能: + + `传送到外太空`,这会将你传送到距离最远星球50光年的外太空 + + `传送到选中天体` + + 修复了`组合键解锁科技`的逻辑 + + `无条件建造`现在不会隐藏传送带的旋转信息了 * 2.3.17 - + 适配游戏版本0.10.30.23292 + + 适配游戏版本0.10.30.23292 * 2.3.16 - + 为`传送带信号物品生成`添加了两个选项: - - `统计信息里将生成计算为产物` - - `统计信息里将移除计算为消耗` - + 新功能:`提升物流塔和大型采矿机的最大功耗` - - 物流塔:将最大充电功率提高到3GW(星际物流塔)和600MW(行星物流塔)(原来的10倍) - - 大型采矿机:将最大采矿速度提高到1000% + + 为`传送带信号物品生成`添加了两个选项: + - `统计信息里将生成计算为产物` + - `统计信息里将移除计算为消耗` + + 新功能:`提升物流塔和大型采矿机的最大功耗` + - 物流塔:将最大充电功率提高到3GW(星际物流塔)和600MW(行星物流塔)(原来的10倍) + - 大型采矿机:将最大采矿速度提高到1000% * 2.3.15 - + 新功能: - - `快速传送(和沙盒模式一样)` - - `机甲和战斗无人机无敌` - - `建筑无敌` + + 新功能: + - `快速传送(和沙盒模式一样)` + - `机甲和战斗无人机无敌` + - `建筑无敌` * 2.3.14 - + 移除了`无条件建造`和`无碰撞`的默认快捷键,以避免误操作。如有需要请手动在系统选项窗口中设置。 - + 修复了翻译问题。 + + 移除了`无条件建造`和`无碰撞`的默认快捷键,以避免误操作。如有需要请手动在系统选项窗口中设置。 + + 修复了翻译问题。 * 2.3.13 - + 修复了快捷键无效和设置窗口上的按键显示问题 + + 修复了快捷键无效和设置窗口上的按键显示问题 * 2.3.12 - + 添加了一个快捷键来切换`无碰撞`,你可以在系统设置面板中修改快捷键。 - + 在使用快捷键切换`无条件建造`和`无碰撞`时添加了实时提示信息。 + + 添加了一个快捷键来切换`无碰撞`,你可以在系统设置面板中修改快捷键。 + + 在使用快捷键切换`无条件建造`和`无碰撞`时添加了实时提示信息。 * 2.3.11 - + 添加了一个快捷键来切换`无条件建造`,你可以在系统设置面板中修改快捷键。这依赖于[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) 1.0.15或更高版本 + + 添加了一个快捷键来切换`无条件建造`,你可以在系统设置面板中修改快捷键。这依赖于[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) 1.0.15或更高版本 * 2.3.10 - + 修复了以下功能在新游戏版本中不生效的问题: - - `平地抽水` - - `沙土不够时依然可以整改地形` + + 修复了以下功能在新游戏版本中不生效的问题: + - `平地抽水` + - `沙土不够时依然可以整改地形` * 2.3.9 - + 支持游戏版本0.10.28.21219 + + 支持游戏版本0.10.28.21219 * 2.3.8 - + 修复了启用`建造秒完成`时开新游戏可能导致崩溃的问题 - + 修复了UI按钮宽度 + + 修复了启用`建造秒完成`时开新游戏可能导致崩溃的问题 + + 修复了UI按钮宽度 * 2.3.7 - + 支持游戏版本0.10.28.20759 - + 修复了传送带信号有时候物品生成速度和设置不匹配的问题 + + 支持游戏版本0.10.28.20759 + + 修复了传送带信号有时候物品生成速度和设置不匹配的问题 * 2.3.6 - + 在`建造秒完成`中支持UXAssist的新功能 - + 在启用`无条件建造`时添加警告信息 - + 修复了`建造秒完成`可能导致部分建筑无法立即完成的问题 + + 在`建造秒完成`中支持UXAssist的新功能 + + 在启用`无条件建造`时添加警告信息 + + 修复了`建造秒完成`可能导致部分建筑无法立即完成的问题 * 2.3.5 - + 修复了`跳过子弹阶段`可能导致崩溃的问题 + + 修复了`跳过子弹阶段`可能导致崩溃的问题 * 2.3.4 - + 使用UXAssist 1.0.2的新页签布局 - + 修复了一些小bug + + 使用UXAssist 1.0.2的新页签布局 + + 修复了一些小bug * 2.3.3 - + 修复了`跳过子弹阶段`可能导致崩溃的问题 - + 使用Alt解锁科技时,现在`矿物利用`的科技解锁到10000级而不是7200级,因为UXAssist已修复对应bug + + 修复了`跳过子弹阶段`可能导致崩溃的问题 + + 使用Alt解锁科技时,现在`矿物利用`的科技解锁到10000级而不是7200级,因为UXAssist已修复对应bug * 2.3.2 - + 母星系的选项移动到了[UniverseGenTweaks](https://dsp.thunderstore.io/package/soarqin/UniverseGenTweaks/) - + 优化了`快速吸收`,现在消耗更少的CPU,并且会轮流打向各节点 - + `高速采集`现在可以保证油井的最大产出 - + 修复了`传送带信号物品生成`在选项关闭后再次启用时不生效的问题 - + 修复了`快速吸收`和`跳过子弹阶段`同时启用时可能导致吸收计算错误的问题 - + 修复了一些选项可能导致崩溃的问题 + + 母星系的选项移动到了[UniverseGenTweaks](https://dsp.thunderstore.io/package/soarqin/UniverseGenTweaks/) + + 优化了`快速吸收`,现在消耗更少的CPU,并且会轮流打向各节点 + + `高速采集`现在可以保证油井的最大产出 + + 修复了`传送带信号物品生成`在选项关闭后再次启用时不生效的问题 + + 修复了`快速吸收`和`跳过子弹阶段`同时启用时可能导致吸收计算错误的问题 + + 修复了一些选项可能导致崩溃的问题 * 2.3.1 - + 在manifest中添加UXAssist到依赖 + + 在manifest中添加UXAssist到依赖 * 2.3.0 - + 将部分功能移动到单独的mod:[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) - + 现在依赖[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist),因此配置面板与UXAssist合并 - + 从开发模式快捷键中移除`LCtrl+A`,以避免误操作 - + 现在`建筑师模式`中配送机/物流机/物流船也无限了 + + 将部分功能移动到单独的mod:[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) + + 现在依赖[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist),因此配置面板与UXAssist合并 + + 从开发模式快捷键中移除`LCtrl+A`,以避免误操作 + + 现在`建筑师模式`中配送机/物流机/物流船也无限了 * 2.2.7 - + 新功能:`只建造节点不建造框架` - + 打开设置面板时不再关闭背包面板 - + 在`移除部分不影响游戏逻辑的建造条件`启用时移除`输入方向冲突`的检查条件 - + 修复导致`传送带信号替换格式`不切换传送带信号数字格式的问题 + + 新功能:`只建造节点不建造框架` + + 打开设置面板时不再关闭背包面板 + + 在`移除部分不影响游戏逻辑的建造条件`启用时移除`输入方向冲突`的检查条件 + + 修复导致`传送带信号替换格式`不切换传送带信号数字格式的问题 * 2.2.6 - + 新功能:`可用节点全部造完时停止弹射` - + 修复了在未完成的节点上吸收太阳帆的问题 + + 新功能:`可用节点全部造完时停止弹射` + + 修复了在未完成的节点上吸收太阳帆的问题 * 2.2.5 - + 在同时启用`快速吸收`、`跳过子弹阶段`和`跳过吸收阶段`时,所有弹射的太阳帆会跳过所有中间环节立即吸收 - + 修复了`快速吸收`在大部分节点已满时无法立即吸收所有太阳帆的问题 - + 修复了与一些mod的兼容性问题 + + 在同时启用`快速吸收`、`跳过子弹阶段`和`跳过吸收阶段`时,所有弹射的太阳帆会跳过所有中间环节立即吸收 + + 修复了`快速吸收`在大部分节点已满时无法立即吸收所有太阳帆的问题 + + 修复了与一些mod的兼容性问题 * 2.2.4 - + 新功能:`在行星视图中允许玩家操作` - + 修复了UI显示问题 + + 新功能:`在行星视图中允许玩家操作` + + 修复了UI显示问题 * 2.2.3 - + 新功能:`移除部分不影响游戏逻辑的建造条件` - + 修复了与一些mod的兼容性问题 + + 新功能:`移除部分不影响游戏逻辑的建造条件` + + 修复了与一些mod的兼容性问题 * 2.2.2 - + 新功能:`将游戏存档绑定给当前账号` - + 新子功能:`传送带信号替换格式` - + 修复了`初始化本行星`可能导致崩溃的问题 - + 修复了`建造秒完成`中传送带建造的问题 + + 新功能:`将游戏存档绑定给当前账号` + + 新子功能:`传送带信号替换格式` + + 修复了`初始化本行星`可能导致崩溃的问题 + + 修复了`建造秒完成`中传送带建造的问题 * 2.2.1 - + 即使在启用`无条件建造`时依然检查矿机的建造条件 - + 修复一个可能导致`无条件建造`不生效的问题 + + 即使在启用`无条件建造`时依然检查矿机的建造条件 + + 修复一个可能导致`无条件建造`不生效的问题 * 2.2.0 - + 添加了一些发电相关功能 - + 为传送带信号物品生成添加了一个子功能,在统计面板模拟了原材料和中间产物的生产过程 - + 从建筑师模式中分离了一些功能 + + 添加了一些发电相关功能 + + 为传送带信号物品生成添加了一个子功能,在统计面板模拟了原材料和中间产物的生产过程 + + 从建筑师模式中分离了一些功能 * 2.1.0 - + 传送带信号物品生成 - + 修复窗口显示优先级可能导致提示信息被主窗口遮挡的问题 + + 传送带信号物品生成 + + 修复窗口显示优先级可能导致提示信息被主窗口遮挡的问题 * 2.0.0 - + 重构代码 - + UI实现 - + 添加了很多功能 + + 重构代码 + + UI实现 + + 添加了很多功能 * 1.0.0 - + 初始版本 + + 初始版本 diff --git a/CheatEnabler/DysonSpherePatch.cs b/CheatEnabler/DysonSpherePatch.cs index 8dbc8c2..6f740e1 100644 --- a/CheatEnabler/DysonSpherePatch.cs +++ b/CheatEnabler/DysonSpherePatch.cs @@ -114,11 +114,11 @@ public static class DysonSpherePatch UpdateSailLifeTime(); UpdateSailsCacheForThisGame(); _patch ??= Harmony.CreateAndPatchAll(typeof(SkipBulletPatch)); - GameLogic.OnGameEnd += GameMain_Begin_Postfix; + GameLogic.OnGameBegin += GameMain_Begin_Postfix; } else { - GameLogic.OnGameEnd -= GameMain_Begin_Postfix; + GameLogic.OnGameBegin -= GameMain_Begin_Postfix; _patch?.UnpatchSelf(); _patch = null; } diff --git a/CheatEnabler/UIConfigWindow.cs b/CheatEnabler/UIConfigWindow.cs index ef51e48..043adc3 100644 --- a/CheatEnabler/UIConfigWindow.cs +++ b/CheatEnabler/UIConfigWindow.cs @@ -81,19 +81,20 @@ public static class UIConfigWindow wnd.AddSplitter(trans, 10f); wnd.AddTabGroup(trans, "Cheat Enabler", "tab-group-cheatenabler"); var tab1 = wnd.AddTab(_windowTrans, "General"); - MyCheckBox.CreateCheckBox(x, y, tab1, DevShortcuts.Enabled, "Enable Dev Shortcuts"); + var cb = wnd.AddCheckBox(x, y, tab1, DevShortcuts.Enabled, "Enable Dev Shortcuts"); + x += cb.Width + 5f; + y += 6f; + wnd.AddTipsButton2(x, y, tab1, "Dev Shortcuts", "Dev Shortcuts Tips", "dev-shortcuts-tips"); + x = 0; + y += 30f; + wnd.AddCheckBox(x, y, tab1, AbnormalDisabler.Enabled, "Disable Abnormal Checks"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab1, AbnormalDisabler.Enabled, "Disable Abnormal Checks"); - y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab1, TechPatch.Enabled, "Unlock Tech with Key-Modifiers"); - x = 156f; - y = 16f; - MyWindow.AddTipsButton(x, y, tab1, "Dev Shortcuts", "Dev Shortcuts Tips", "dev-shortcuts-tips"); - x += 52f; - y += 72f; - MyWindow.AddTipsButton(x, y, tab1, "Unlock Tech with Key-Modifiers", "Unlock Tech with Key-Modifiers Tips", "unlock-tech-tips"); + cb = wnd.AddCheckBox(x, y, tab1, TechPatch.Enabled, "Unlock Tech with Key-Modifiers"); + x += cb.Width + 5f; + y += 6f; + wnd.AddTipsButton2(x, y, tab1, "Unlock Tech with Key-Modifiers", "Unlock Tech with Key-Modifiers Tips", "unlock-tech-tips"); x = 0f; - y = 10f + 36f + 36f + 36f + 36f; + y += 30f + 36f; wnd.AddButton(x, y, 400f, tab1, "Remove all metadata consumption records", 16, "button-remove-all-metadata-consumption", PlayerFunctions.RemoveAllMetadataConsumptions); y += 36f; wnd.AddButton(x, y, 400f, tab1, "Remove metadata consumption record in current game", 16, "button-remove-current-metadata-consumption", PlayerFunctions.RemoveCurrentMetadataConsumptions); @@ -106,32 +107,32 @@ public static class UIConfigWindow var tab2 = wnd.AddTab(_windowTrans, "Factory"); x = 0f; y = 10f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.ImmediateEnabled, "Finish build immediately"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.ImmediateEnabled, "Finish build immediately"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.ArchitectModeEnabled, "Architect mode"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.ArchitectModeEnabled, "Architect mode"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.NoConditionEnabled, "Build without condition"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.NoConditionEnabled, "Build without condition"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.NoCollisionEnabled, "No collision"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.NoCollisionEnabled, "No collision"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BeltSignalGeneratorEnabled, "Belt signal generator"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.BeltSignalGeneratorEnabled, "Belt signal generator"); x += 26f; y += 26f; - var cb1 = MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BeltSignalCountGenEnabled, "Count generations as production in statistics", 13); + var cb1 = wnd.AddCheckBox(x, y, tab2, FactoryPatch.BeltSignalCountGenEnabled, "Count generations as production in statistics", 13); y += 26f; - var cb2 = MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BeltSignalCountRemEnabled, "Count removals as consumption in statistics", 13); + var cb2 = wnd.AddCheckBox(x, y, tab2, FactoryPatch.BeltSignalCountRemEnabled, "Count removals as consumption in statistics", 13); y += 26f; - var cb3 = MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BeltSignalCountRecipeEnabled, "Count all raws and intermediates in statistics", 13); + var cb3 = wnd.AddCheckBox(x, y, tab2, FactoryPatch.BeltSignalCountRecipeEnabled, "Count all raws and intermediates in statistics", 13); y += 26f; - var cb4 = MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BeltSignalNumberAltFormat, "Belt signal alt format", 13); - x += 180f; + var cb4 = wnd.AddCheckBox(x, y, tab2, FactoryPatch.BeltSignalNumberAltFormat, "Belt signal alt format", 13); + x += cb4.Width + 5f; y += 6f; - var tip1 = MyWindow.AddTipsButton(x, y, tab2, "Belt signal alt format", "Belt signal alt format tips", "belt-signal-alt-format-tips"); + var tip1 = wnd.AddTipsButton2(x, y, tab2, "Belt signal alt format", "Belt signal alt format tips", "belt-signal-alt-format-tips"); x = 0f; y += 30f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.GreaterPowerUsageInLogisticsEnabled, "Increase maximum power usage in Logistic Stations and Advanced Mining Machines"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.GreaterPowerUsageInLogisticsEnabled, "Increase maximum power usage in Logistic Stations and Advanced Mining Machines"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.ControlPanelRemoteLogisticsEnabled, "Retrieve/Place items from/to remote planets on logistics control panel"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.ControlPanelRemoteLogisticsEnabled, "Retrieve/Place items from/to remote planets on logistics control panel"); FactoryPatch.BeltSignalGeneratorEnabled.SettingChanged += (_, _) => { @@ -140,32 +141,32 @@ public static class UIConfigWindow OnBeltSignalChanged(); x = 350f; y = 10f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.RemovePowerSpaceLimitEnabled, "Remove power space limit"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.RemovePowerSpaceLimitEnabled, "Remove power space limit"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BoostWindPowerEnabled, "Boost wind power"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.BoostWindPowerEnabled, "Boost wind power"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BoostSolarPowerEnabled, "Boost solar power"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.BoostSolarPowerEnabled, "Boost solar power"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BoostGeothermalPowerEnabled, "Boost geothermal power"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.BoostGeothermalPowerEnabled, "Boost geothermal power"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BoostFuelPowerEnabled, "Boost fuel power"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.BoostFuelPowerEnabled, "Boost fuel power"); x += 32f; y += 26f; - MyWindow.AddText(x, y, tab2, "Boost fuel power 2", 13); + wnd.AddText2(x, y, tab2, "Boost fuel power 2", 13); // Planet Tab var tab3 = wnd.AddTab(_windowTrans, "Planet"); x = 0f; y = 10f; - MyCheckBox.CreateCheckBox(x, y, tab3, ResourcePatch.InfiniteResourceEnabled, "Infinite Natural Resources"); + wnd.AddCheckBox(x, y, tab3, ResourcePatch.InfiniteResourceEnabled, "Infinite Natural Resources"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab3, ResourcePatch.FastMiningEnabled, "Fast Mining"); + wnd.AddCheckBox(x, y, tab3, ResourcePatch.FastMiningEnabled, "Fast Mining"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab3, PlanetPatch.WaterPumpAnywhereEnabled, "Pump Anywhere"); + wnd.AddCheckBox(x, y, tab3, PlanetPatch.WaterPumpAnywhereEnabled, "Pump Anywhere"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab3, PlanetPatch.TerraformAnywayEnabled, "Terraform without enough soil piles"); + wnd.AddCheckBox(x, y, tab3, PlanetPatch.TerraformAnywayEnabled, "Terraform without enough soil piles"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab3, PlayerPatch.InstantTeleportEnabled, "Instant teleport (like that in Sandbox mode)"); + wnd.AddCheckBox(x, y, tab3, PlayerPatch.InstantTeleportEnabled, "Instant teleport (like that in Sandbox mode)"); x = 400f; y = 10f; wnd.AddButton(x, y, 200f, tab3, "矿物掩埋标题", 16, "button-bury-all", () => { PlanetFunctions.BuryAllVeins(true); }); @@ -192,24 +193,24 @@ public static class UIConfigWindow var tab4 = wnd.AddTab(_windowTrans, "Dyson Sphere"); x = 0f; y = 10f; - MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.SkipBulletEnabled, "Skip bullet period"); + wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.SkipBulletEnabled, "Skip bullet period"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.SkipAbsorbEnabled, "Skip absorption period"); + wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.SkipAbsorbEnabled, "Skip absorption period"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.QuickAbsorbEnabled, "Quick absorb"); + wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.QuickAbsorbEnabled, "Quick absorb"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.EjectAnywayEnabled, "Eject anyway"); + wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.EjectAnywayEnabled, "Eject anyway"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OverclockEjectorEnabled, "Overclock Ejectors"); + wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.OverclockEjectorEnabled, "Overclock Ejectors"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OverclockSiloEnabled, "Overclock Silos"); + wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.OverclockSiloEnabled, "Overclock Silos"); var tab5 = wnd.AddTab(_windowTrans, "Mecha/Combat"); x = 0f; y = 10f; - MyCheckBox.CreateCheckBox(x, y, tab5, CombatPatch.MechaInvincibleEnabled, "Mecha and Drones/Fleets invicible"); + wnd.AddCheckBox(x, y, tab5, CombatPatch.MechaInvincibleEnabled, "Mecha and Drones/Fleets invicible"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab5, CombatPatch.BuildingsInvincibleEnabled, "Buildings invicible"); + wnd.AddCheckBox(x, y, tab5, CombatPatch.BuildingsInvincibleEnabled, "Buildings invicible"); x = 400f; y = 10f; wnd.AddButton(x, y, 200f, tab5, "Teleport to outer space", 16, "button-teleport-to-outer-space", PlayerFunctions.TeleportToOuterSpace); diff --git a/UXAssist/CHANGELOG.md b/UXAssist/CHANGELOG.md index 5b8cfe0..3734ad9 100644 --- a/UXAssist/CHANGELOG.md +++ b/UXAssist/CHANGELOG.md @@ -1,8 +1,13 @@ ## Changlog + * 1.1.5 + + New feature: `Logistics Control Panel Improvement` + - Auto apply filter with item under mouse cursor while opening the panel + - Quick-set item filter while right-clicking item icons in storage list on the panel + `Quick build and dismantle stacking labs`: works for storages and tanks now + `Enable game window resize`: Keep window resizable on applying game options. + `Remember window position and size on last exit`: Do not resize window on applying game options if resolution related config entries are not changed. + + Auto resize panel to fit content, for better support of multilanguages and mods dependent on UX Assist config panel functions. + Fix a crash when config panel is opened before game is fully loaded * 1.1.4 + Fix `Remove some build conditions` @@ -76,7 +81,7 @@ + Auto-cruise does not bypass dark-fog hives if they are targeted. * 1.0.17 + New function: `Auto navigation on sailings`, which is inspired by [CruiseAssist](https://dsp.thunderstore.io/package/tanu/CruiseAssist/) and its extension [AutoPilot](https://dsp.thunderstore.io/package/tanu/AutoPilot/) - - It keeps Icarus on course to the target planet + - It keeps Icarus on course to the target planet - It will try to bypass any obstacles(planets, stars or dark-fog hives) on the way - Furthermore, there is also a shortcut key which can be set in the system options window, which is used to toggle `Auto-cruise` that enables flying to targeted planets fully automatically. - Auto-cruise will start when you target a planet on star map @@ -124,15 +129,15 @@ + Sort blueprint structures before saving, to reduce generated blueprint data size a little. * 1.0.4 + Add new function: `Off-grid building and stepped rotation` - + Fix an issue that window position not restored and can not be resized when function is enabled but game is started with different mod profiles. + + Fix an issue that window position not restored and can not be resized when function is enabled but game is started with different mod profiles. * 1.0.3 - + Add new function: `Quick build Orbital Collectors`. + + Add new function: `Quick build Orbital Collectors`. + Add confirmation popup for `Re-intialize planet`, `Quick dismantle all buildings`, `Re-initialize Dyson Spheres` and `Quick dismantle Dyson Shells`. + Fix error on `Remove build count and range limit` when building a large amount of belts. + Fix an issue that window position not saved correctly when quit game without using in-game menu. * 1.0.2 + Redesign config tabs, for clearer layout. - + Add 2 new options: + + Add 2 new options: - Enable game window resize. - Remember window position and size on last exit. * 1.0.1 @@ -143,12 +148,16 @@ + Initial release + Functions moved from [MechaDronesTweaks](https://dsp.thunderstore.io/package/soarqin/MechaDronesTweaks/) and [CheatEnabler](https://dsp.thunderstore.io/package/soarqin/CheatEnabler/) - ## 更新日志 + * 1.1.5 + + 新功能:`物流控制面板改进` + - 打开面板时自动将鼠标指向物品设为筛选条件 + - 在控制面板物流塔列表中右键点击物品图标快速设置为筛选条件 + `快速建造和拆除堆叠研究站`:现在也支持储物仓和储液罐 + `允许调整游戏窗口大小`:在应用游戏选项时保持窗口可调整大小 + `记住上次退出时的窗口位置和大小`:如果分辨率相关的配置项未改变,则在应用游戏选项时不调整窗口大小 + + 自动调整面板大小适应内容,以更好地支持多语言和依赖于UX助手配置面板功能的mod + 修复了在游戏完全加载前打开配置面板可能导致的崩溃问题 * 1.1.4 + 修复了`移除部分不影响游戏逻辑的建造条件` @@ -256,7 +265,7 @@ + 修复了`物流塔存储数量限制控制改进`启用时可能导致的崩溃问题 * 1.0.9 + 新功能:`更好的自动保存机制` - - 自动存档会以星区地址和日期时间组合为文件名存储在'Save\AutoSaves'文件夹中 + - 自动存档会以星区地址和日期时间组合为文件名存储在'Save\AutoSaves'文件夹中 - 注意:此功能会在保存/读取菜单按最后修改时间对存档进行排序,因此你不再需要[DSP_Save_Game_Sorter]了 * 1.0.8 + 新功能:`物流塔存储数量限制控制改进` diff --git a/UXAssist/DysonSpherePatch.cs b/UXAssist/DysonSpherePatch.cs index e78de22..0404510 100644 --- a/UXAssist/DysonSpherePatch.cs +++ b/UXAssist/DysonSpherePatch.cs @@ -10,6 +10,7 @@ public static class DysonSpherePatch { public static ConfigEntry StopEjectOnNodeCompleteEnabled; public static ConfigEntry OnlyConstructNodesEnabled; + public static ConfigEntry AutoConstructMultiplier; private static Harmony _dysonSpherePatch; public static void Init() @@ -57,6 +58,165 @@ public static class DysonSpherePatch } ds.RemoveLayer(index); } + + [HarmonyPrefix] + [HarmonyPatch(typeof(DysonSphere), nameof(DysonSphere.AutoConstruct))] + private static bool DysonSphere_AutoConstruct_Prefix(DysonSphere __instance) + { + var totalCount = AutoConstructMultiplier.Value * 6; + var totalCount2 = AutoConstructMultiplier.Value * 6; + foreach (var dysonSphereLayer in __instance.layersIdBased) + { + if (dysonSphereLayer == null) continue; + int todoCount; + int[] productRegister; + for (var j = dysonSphereLayer.nodePool.Length - 1; j >= 0; j--) + { + var dysonNode = dysonSphereLayer.nodePool[j]; + if (dysonNode == null || dysonNode.id != j) continue; + var count = dysonNode._spReq - dysonNode.spOrdered; + if (count > 0) + { + + if (count > totalCount) + { + count = totalCount; + dysonNode.spOrdered += count; + } + else + { + dysonNode.spOrdered = dysonNode._spReq; + __instance.RemoveAutoNode(dysonNode); + __instance.PickAutoNode(); + } + + todoCount = count; + if (dysonNode.sp < dysonNode.spMax) + { + if (dysonNode.sp + count > dysonNode.spMax) + { + var diff = dysonNode.spMax - dysonNode.sp; + count -= diff; + dysonNode.spOrdered -= diff; + dysonNode._spReq -= diff; + + dysonNode.sp = dysonNode.spMax; + } + else + { + dysonNode.spOrdered -= count; + dysonNode._spReq -= count; + + dysonNode.sp += count; + count = 0; + } + + __instance.UpdateProgress(dysonNode); + } + + if (count > 0) + { + var frameCount = dysonNode.frames.Count; + var frameIndex = dysonNode.frameTurn % frameCount; + for (var i = frameCount; i > 0; i--) + { + var dysonFrame = dysonNode.frames[frameIndex]; + var spMax = dysonFrame.spMax >> 1; + if (dysonFrame.nodeA == dysonNode && dysonFrame.spA < spMax) + { + if (dysonFrame.spA + count > spMax) + { + var diff = spMax - dysonFrame.spA; + count -= diff; + dysonNode.spOrdered -= diff; + dysonNode._spReq -= diff; + + dysonFrame.spA = spMax; + __instance.UpdateProgress(dysonFrame); + } + else + { + dysonNode.spOrdered -= count; + dysonNode._spReq -= count; + + dysonFrame.spA += count; + count = 0; + __instance.UpdateProgress(dysonFrame); + break; + } + } + + if (dysonFrame.nodeB == dysonNode && dysonFrame.spB < spMax) + { + if (dysonFrame.spB + count > spMax) + { + var diff = spMax - dysonFrame.spB; + count -= diff; + dysonNode.spOrdered -= diff; + dysonNode._spReq -= diff; + + dysonFrame.spB = spMax; + __instance.UpdateProgress(dysonFrame); + } + else + { + dysonNode.spOrdered -= count; + dysonNode._spReq -= count; + + dysonFrame.spB += count; + count = 0; + __instance.UpdateProgress(dysonFrame); + break; + } + } + + frameIndex = (frameIndex + 1) % frameCount; + } + } + + productRegister = __instance.productRegister; + if (productRegister != null) + { + lock (productRegister) + { + productRegister[11902] += todoCount - count; + } + } + } + + count = dysonNode._cpReq - dysonNode.cpOrdered; + if (count > totalCount2) count = totalCount2; + todoCount = count; + dysonNode.cpOrdered += count; + var shellCount = dysonNode.shells.Count; + var shellIndex = dysonNode.shellTurn % shellCount; + for (var i = shellCount; i > 0 && count > 0; i--) + { + var dysonShell = dysonNode.shells[shellIndex]; + var nodeIndex = dysonShell.nodeIndexMap[dysonNode.id]; + var diff = (dysonShell.vertsqOffset[nodeIndex + 1] - dysonShell.vertsqOffset[nodeIndex]) * dysonShell.cpPerVertex - dysonShell.nodecps[nodeIndex]; + if (diff > count) + diff = count; + count -= diff; + dysonNode.cpOrdered -= diff; + dysonNode._cpReq -= diff; + dysonShell.nodecps[nodeIndex] += diff; + dysonShell.nodecps[dysonShell.nodecps.Length - 1] += diff; + shellIndex = (shellIndex + 1) % shellCount; + } + productRegister = __instance.productRegister; + if (productRegister != null) + { + lock (productRegister) + { + productRegister[11903] += todoCount - count; + } + } + } + } + + return false; + } [HarmonyTranspiler] [HarmonyPriority(Priority.First)] @@ -174,7 +334,7 @@ public static class DysonSpherePatch private static bool AnyNodeForAbsorb(int starIndex) { var comp = _nodeForAbsorb[starIndex]; - return comp != null && comp.Count > 0; + return comp is { Count: > 0 }; } private static void GameMain_Begin_Postfix() diff --git a/UXAssist/FactoryPatch.cs b/UXAssist/FactoryPatch.cs index 4d64ccd..d2e14ba 100644 --- a/UXAssist/FactoryPatch.cs +++ b/UXAssist/FactoryPatch.cs @@ -22,13 +22,11 @@ public static class FactoryPatch public static ConfigEntry LargerAreaForUpgradeAndDismantleEnabled; public static ConfigEntry LargerAreaForTerraformEnabled; public static ConfigEntry OffGridBuildingEnabled; - public static ConfigEntry LogisticsCapacityTweaksEnabled; public static ConfigEntry TreatStackingAsSingleEnabled; public static ConfigEntry QuickBuildAndDismantleLabsEnabled; public static ConfigEntry ProtectVeinsFromExhaustionEnabled; public static ConfigEntry DoNotRenderEntitiesEnabled; public static ConfigEntry DragBuildPowerPolesEnabled; - public static ConfigEntry AllowOverflowInLogisticsEnabled; public static ConfigEntry BeltSignalsForBuyOutEnabled; private static PressKeyBind _doNotRenderEntitiesKey; @@ -54,14 +52,11 @@ public static class FactoryPatch LargerAreaForUpgradeAndDismantleEnabled.SettingChanged += (_, _) => LargerAreaForUpgradeAndDismantle.Enable(LargerAreaForUpgradeAndDismantleEnabled.Value); LargerAreaForTerraformEnabled.SettingChanged += (_, _) => LargerAreaForTerraform.Enable(LargerAreaForTerraformEnabled.Value); OffGridBuildingEnabled.SettingChanged += (_, _) => OffGridBuilding.Enable(OffGridBuildingEnabled.Value); - LogisticsCapacityTweaksEnabled.SettingChanged += (_, _) => LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value); TreatStackingAsSingleEnabled.SettingChanged += (_, _) => TreatStackingAsSingle.Enable(TreatStackingAsSingleEnabled.Value); QuickBuildAndDismantleLabsEnabled.SettingChanged += (_, _) => QuickBuildAndDismantleLab.Enable(QuickBuildAndDismantleLabsEnabled.Value); ProtectVeinsFromExhaustionEnabled.SettingChanged += (_, _) => ProtectVeinsFromExhaustion.Enable(ProtectVeinsFromExhaustionEnabled.Value); DoNotRenderEntitiesEnabled.SettingChanged += (_, _) => DoNotRenderEntities.Enable(DoNotRenderEntitiesEnabled.Value); DragBuildPowerPolesEnabled.SettingChanged += (_, _) => DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value); - AllowOverflowInLogisticsEnabled.SettingChanged += (_, _) => AllowOverflowInLogistics.Enable(AllowOverflowInLogisticsEnabled.Value); - LogisticsCapacityTweaksEnabled.SettingChanged += (_, _) => LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value); BeltSignalsForBuyOutEnabled.SettingChanged += (_, _) => BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value); UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value); RemoveSomeConditionBuild.Enable(RemoveSomeConditionEnabled.Value); @@ -70,14 +65,11 @@ public static class FactoryPatch LargerAreaForUpgradeAndDismantle.Enable(LargerAreaForUpgradeAndDismantleEnabled.Value); LargerAreaForTerraform.Enable(LargerAreaForTerraformEnabled.Value); OffGridBuilding.Enable(OffGridBuildingEnabled.Value); - LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value); TreatStackingAsSingle.Enable(TreatStackingAsSingleEnabled.Value); QuickBuildAndDismantleLab.Enable(QuickBuildAndDismantleLabsEnabled.Value); ProtectVeinsFromExhaustion.Enable(ProtectVeinsFromExhaustionEnabled.Value); DoNotRenderEntities.Enable(DoNotRenderEntitiesEnabled.Value); DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value); - AllowOverflowInLogistics.Enable(AllowOverflowInLogisticsEnabled.Value); - LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value); BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value); _factoryPatch ??= Harmony.CreateAndPatchAll(typeof(FactoryPatch)); @@ -92,14 +84,11 @@ public static class FactoryPatch LargerAreaForUpgradeAndDismantle.Enable(false); LargerAreaForTerraform.Enable(false); OffGridBuilding.Enable(false); - LogisticsCapacityTweaks.Enable(false); TreatStackingAsSingle.Enable(false); QuickBuildAndDismantleLab.Enable(false); ProtectVeinsFromExhaustion.Enable(false); DoNotRenderEntities.Enable(false); DragBuildPowerPoles.Enable(false); - AllowOverflowInLogistics.Enable(false); - LogisticsCapacityTweaks.Enable(false); BeltSignalsForBuyOut.Enable(false); BeltSignalsForBuyOut.UninitPersist(); @@ -872,209 +861,7 @@ public static class FactoryPatch } } } - - public static class LogisticsCapacityTweaks - { - private static Harmony _patch; - - public static void Enable(bool enable) - { - if (enable) - { - _patch ??= Harmony.CreateAndPatchAll(typeof(LogisticsCapacityTweaks)); - return; - } - - _patch?.UnpatchSelf(); - _patch = null; - } - - private static KeyCode _lastKey = KeyCode.None; - private static long _nextKeyTick; - private static bool _skipNextEvent; - - private static bool UpdateKeyPressed(KeyCode code) - { - if (!Input.GetKey(code)) - return false; - if (code != _lastKey) - { - _lastKey = code; - _nextKeyTick = GameMain.instance.timei + 30; - return true; - } - - var currTick = GameMain.instance.timei; - if (_nextKeyTick > currTick) return false; - _nextKeyTick = currTick + 4; - return true; - } - - public static void UpdateInput() - { - if (_lastKey != KeyCode.None && Input.GetKeyUp(_lastKey)) - { - _lastKey = KeyCode.None; - } - - if (VFInput.shift) return; - var ctrl = VFInput.control; - var alt = VFInput.alt; - if (ctrl && alt) return; - int delta; - if (UpdateKeyPressed(KeyCode.LeftArrow)) - { - if (ctrl) - delta = -100000; - else if (alt) - delta = -1000; - else - delta = -10; - } - else if (UpdateKeyPressed(KeyCode.RightArrow)) - { - if (ctrl) - delta = 100000; - else if (alt) - delta = 1000; - else - delta = 10; - } - else if (UpdateKeyPressed(KeyCode.DownArrow)) - { - if (ctrl) - delta = -1000000; - else if (alt) - delta = -10000; - else - delta = -100; - } - else if (UpdateKeyPressed(KeyCode.UpArrow)) - { - if (ctrl) - delta = 1000000; - else if (alt) - delta = 10000; - else - delta = 100; - } - else - { - return; - } - - var targets = new List(); - EventSystem.current.RaycastAll(new PointerEventData(EventSystem.current) { position = Input.mousePosition }, targets); - foreach (var target in targets) - { - var stationStorage = target.gameObject.GetComponentInParent(); - if (stationStorage is null) continue; - var station = stationStorage.station; - ref var storage = ref station.storage[stationStorage.index]; - var oldMax = storage.max; - var newMax = oldMax + delta; - if (newMax < 0) - { - newMax = 0; - } - else - { - int itemCountMax; - if (AllowOverflowInLogisticsEnabled.Value) - { - itemCountMax = 90000000; - } - else - { - var modelProto = LDB.models.Select(stationStorage.stationWindow.factory.entityPool[station.entityId].modelIndex); - itemCountMax = 0; - if (modelProto != null) - { - itemCountMax = modelProto.prefabDesc.stationMaxItemCount; - } - - itemCountMax += station.isStellar ? GameMain.history.remoteStationExtraStorage : GameMain.history.localStationExtraStorage; - } - - if (newMax > itemCountMax) - { - newMax = itemCountMax; - } - } - - storage.max = newMax; - _skipNextEvent = oldMax / 100 != newMax / 100; - break; - } - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(UIStationStorage), nameof(UIStationStorage.OnMaxSliderValueChange))] - private static bool UIStationStorage_OnMaxSliderValueChange_Prefix() - { - if (!_skipNextEvent) return true; - _skipNextEvent = false; - return false; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(PlanetTransport), nameof(PlanetTransport.OnTechFunctionUnlocked))] - private static bool PlanetTransport_OnTechFunctionUnlocked_Prefix(PlanetTransport __instance, int _funcId, double _valuelf, int _level) - { - switch (_funcId) - { - case 30: - { - var stationPool = __instance.stationPool; - var factory = __instance.factory; - var history = GameMain.history; - for (var i = __instance.stationCursor - 1; i > 0; i--) - { - if (stationPool[i] == null || stationPool[i].id != i || (stationPool[i].isStellar && !stationPool[i].isCollector && !stationPool[i].isVeinCollector)) continue; - var modelIndex = factory.entityPool[stationPool[i].entityId].modelIndex; - var maxCount = LDB.models.Select(modelIndex).prefabDesc.stationMaxItemCount; - var oldMaxCount = maxCount + history.localStationExtraStorage - _valuelf; - var intOldMaxCount = (int)Math.Round(oldMaxCount); - var ratio = (maxCount + history.localStationExtraStorage) / oldMaxCount; - var storage = stationPool[i].storage; - for (var j = storage.Length - 1; j >= 0; j--) - { - if (storage[j].max + 10 < intOldMaxCount) continue; - storage[j].max = Mathf.RoundToInt((float)(storage[j].max * ratio / 50.0)) * 50; - } - } - - break; - } - case 31: - { - var stationPool = __instance.stationPool; - var factory = __instance.factory; - var history = GameMain.history; - for (var i = __instance.stationCursor - 1; i > 0; i--) - { - if (stationPool[i] == null || stationPool[i].id != i || !stationPool[i].isStellar || stationPool[i].isCollector || stationPool[i].isVeinCollector) continue; - var modelIndex = factory.entityPool[stationPool[i].entityId].modelIndex; - var maxCount = LDB.models.Select(modelIndex).prefabDesc.stationMaxItemCount; - var oldMaxCount = maxCount + history.remoteStationExtraStorage - _valuelf; - var intOldMaxCount = (int)Math.Round(oldMaxCount); - var ratio = (maxCount + history.remoteStationExtraStorage) / oldMaxCount; - var storage = stationPool[i].storage; - for (var j = storage.Length - 1; j >= 0; j--) - { - if (storage[j].max + 10 < intOldMaxCount) continue; - storage[j].max = Mathf.RoundToInt((float)(storage[j].max * ratio / 100.0)) * 100; - } - } - - break; - } - } - - return false; - } - } - + public static class TreatStackingAsSingle { private static Harmony _patch; @@ -1807,72 +1594,6 @@ public static class FactoryPatch } } - private static class AllowOverflowInLogistics - { - private static Harmony _patch; - - public static void Enable(bool enable) - { - if (enable) - { - _patch ??= Harmony.CreateAndPatchAll(typeof(AllowOverflowInLogistics)); - return; - } - - _patch?.UnpatchSelf(); - _patch = null; - } - - // Do not check for overflow when try to send hand items into storages - [HarmonyTranspiler] - [HarmonyPatch(typeof(UIStationStorage), nameof(UIStationStorage.OnItemIconMouseDown))] - private static IEnumerable UIStationStorage_OnItemIconMouseDown_Transpiler(IEnumerable instructions, ILGenerator generator) - { - var matcher = new CodeMatcher(instructions, generator); - matcher.MatchForward(false, - new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(LDB), nameof(LDB.items))), - new CodeMatch(OpCodes.Ldarg_0) - ); - var pos = matcher.Pos; - matcher.MatchForward(false, - new CodeMatch(OpCodes.Ldloc_S), - new CodeMatch(OpCodes.Stloc_S) - ); - var inst = matcher.InstructionAt(1).Clone(); - var pos2 = matcher.Pos + 2; - matcher.Start().Advance(pos); - var labels = matcher.Labels; - matcher.RemoveInstructions(pos2 - pos).Insert( - new CodeInstruction(OpCodes.Ldloc_1).WithLabels(labels), - new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.inhandItemCount))), - inst - ); - return matcher.InstructionEnumeration(); - } - - // Remove storage limit check - [HarmonyTranspiler] - [HarmonyPatch(typeof(PlanetTransport), nameof(PlanetTransport.SetStationStorage))] - private static IEnumerable PlanetTransport_SetStationStorage_Transpiler(IEnumerable instructions, ILGenerator generator) - { - var matcher = new CodeMatcher(instructions, generator); - matcher.MatchForward(false, - new CodeMatch(ci => ci.IsLdarg()), - new CodeMatch(ci => ci.IsLdloc()), - new CodeMatch(ci => ci.IsLdloc()), - new CodeMatch(OpCodes.Add), - new CodeMatch(ci => ci.Branches(out _)), - new CodeMatch(ci => ci.IsLdloc()), - new CodeMatch(ci => ci.IsLdloc()), - new CodeMatch(OpCodes.Add), - new CodeMatch(ci => ci.IsStarg()) - ); - var labels = matcher.Labels; - matcher.RemoveInstructions(9).Labels.AddRange(labels); - return matcher.InstructionEnumeration(); - } - } - private static class BeltSignalsForBuyOut { private static Harmony _patch; diff --git a/UXAssist/LogisticsPatch.cs b/UXAssist/LogisticsPatch.cs new file mode 100644 index 0000000..4e28333 --- /dev/null +++ b/UXAssist/LogisticsPatch.cs @@ -0,0 +1,454 @@ +using System; +using System.Collections.Generic; +using System.Reflection.Emit; +using BepInEx.Configuration; +using HarmonyLib; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace UXAssist; + +public static class LogisticsPatch +{ + public static ConfigEntry LogisticsCapacityTweaksEnabled; + public static ConfigEntry AllowOverflowInLogisticsEnabled; + public static ConfigEntry LogisticsConstrolPanelImprovementEnabled; + + public static void Init() + { + LogisticsCapacityTweaksEnabled.SettingChanged += (_, _) => LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value); + AllowOverflowInLogisticsEnabled.SettingChanged += (_, _) => AllowOverflowInLogistics.Enable(AllowOverflowInLogisticsEnabled.Value); + LogisticsConstrolPanelImprovementEnabled.SettingChanged += (_, _) => LogisticsConstrolPanelImprovement.Enable(LogisticsConstrolPanelImprovementEnabled.Value); + LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value); + AllowOverflowInLogistics.Enable(AllowOverflowInLogisticsEnabled.Value); + LogisticsConstrolPanelImprovement.Enable(LogisticsConstrolPanelImprovementEnabled.Value); + } + + public static void Uninit() + { + LogisticsCapacityTweaks.Enable(false); + AllowOverflowInLogistics.Enable(false); + LogisticsConstrolPanelImprovement.Enable(false); + } + + public static class LogisticsCapacityTweaks + { + private static Harmony _patch; + + public static void Enable(bool enable) + { + if (enable) + { + _patch ??= Harmony.CreateAndPatchAll(typeof(LogisticsCapacityTweaks)); + return; + } + + _patch?.UnpatchSelf(); + _patch = null; + } + + private static KeyCode _lastKey = KeyCode.None; + private static long _nextKeyTick; + private static bool _skipNextEvent; + + private static bool UpdateKeyPressed(KeyCode code) + { + if (!Input.GetKey(code)) + return false; + if (code != _lastKey) + { + _lastKey = code; + _nextKeyTick = GameMain.instance.timei + 30; + return true; + } + + var currTick = GameMain.instance.timei; + if (_nextKeyTick > currTick) return false; + _nextKeyTick = currTick + 4; + return true; + } + + public static void UpdateInput() + { + if (_lastKey != KeyCode.None && Input.GetKeyUp(_lastKey)) + { + _lastKey = KeyCode.None; + } + + if (VFInput.shift) return; + var ctrl = VFInput.control; + var alt = VFInput.alt; + if (ctrl && alt) return; + int delta; + if (UpdateKeyPressed(KeyCode.LeftArrow)) + { + if (ctrl) + delta = -100000; + else if (alt) + delta = -1000; + else + delta = -10; + } + else if (UpdateKeyPressed(KeyCode.RightArrow)) + { + if (ctrl) + delta = 100000; + else if (alt) + delta = 1000; + else + delta = 10; + } + else if (UpdateKeyPressed(KeyCode.DownArrow)) + { + if (ctrl) + delta = -1000000; + else if (alt) + delta = -10000; + else + delta = -100; + } + else if (UpdateKeyPressed(KeyCode.UpArrow)) + { + if (ctrl) + delta = 1000000; + else if (alt) + delta = 10000; + else + delta = 100; + } + else + { + return; + } + + var targets = new List(); + EventSystem.current.RaycastAll(new PointerEventData(EventSystem.current) { position = Input.mousePosition }, targets); + foreach (var target in targets) + { + var stationStorage = target.gameObject.GetComponentInParent(); + if (stationStorage is null) continue; + var station = stationStorage.station; + ref var storage = ref station.storage[stationStorage.index]; + var oldMax = storage.max; + var newMax = oldMax + delta; + if (newMax < 0) + { + newMax = 0; + } + else + { + int itemCountMax; + if (AllowOverflowInLogisticsEnabled.Value) + { + itemCountMax = 90000000; + } + else + { + var modelProto = LDB.models.Select(stationStorage.stationWindow.factory.entityPool[station.entityId].modelIndex); + itemCountMax = 0; + if (modelProto != null) + { + itemCountMax = modelProto.prefabDesc.stationMaxItemCount; + } + + itemCountMax += station.isStellar ? GameMain.history.remoteStationExtraStorage : GameMain.history.localStationExtraStorage; + } + + if (newMax > itemCountMax) + { + newMax = itemCountMax; + } + } + + storage.max = newMax; + _skipNextEvent = oldMax / 100 != newMax / 100; + break; + } + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(UIStationStorage), nameof(UIStationStorage.OnMaxSliderValueChange))] + private static bool UIStationStorage_OnMaxSliderValueChange_Prefix() + { + if (!_skipNextEvent) return true; + _skipNextEvent = false; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(PlanetTransport), nameof(PlanetTransport.OnTechFunctionUnlocked))] + private static bool PlanetTransport_OnTechFunctionUnlocked_Prefix(PlanetTransport __instance, int _funcId, double _valuelf, int _level) + { + switch (_funcId) + { + case 30: + { + var stationPool = __instance.stationPool; + var factory = __instance.factory; + var history = GameMain.history; + for (var i = __instance.stationCursor - 1; i > 0; i--) + { + if (stationPool[i] == null || stationPool[i].id != i || (stationPool[i].isStellar && !stationPool[i].isCollector && !stationPool[i].isVeinCollector)) continue; + var modelIndex = factory.entityPool[stationPool[i].entityId].modelIndex; + var maxCount = LDB.models.Select(modelIndex).prefabDesc.stationMaxItemCount; + var oldMaxCount = maxCount + history.localStationExtraStorage - _valuelf; + var intOldMaxCount = (int)Math.Round(oldMaxCount); + var ratio = (maxCount + history.localStationExtraStorage) / oldMaxCount; + var storage = stationPool[i].storage; + for (var j = storage.Length - 1; j >= 0; j--) + { + if (storage[j].max + 10 < intOldMaxCount) continue; + storage[j].max = Mathf.RoundToInt((float)(storage[j].max * ratio / 50.0)) * 50; + } + } + + break; + } + case 31: + { + var stationPool = __instance.stationPool; + var factory = __instance.factory; + var history = GameMain.history; + for (var i = __instance.stationCursor - 1; i > 0; i--) + { + if (stationPool[i] == null || stationPool[i].id != i || !stationPool[i].isStellar || stationPool[i].isCollector || stationPool[i].isVeinCollector) continue; + var modelIndex = factory.entityPool[stationPool[i].entityId].modelIndex; + var maxCount = LDB.models.Select(modelIndex).prefabDesc.stationMaxItemCount; + var oldMaxCount = maxCount + history.remoteStationExtraStorage - _valuelf; + var intOldMaxCount = (int)Math.Round(oldMaxCount); + var ratio = (maxCount + history.remoteStationExtraStorage) / oldMaxCount; + var storage = stationPool[i].storage; + for (var j = storage.Length - 1; j >= 0; j--) + { + if (storage[j].max + 10 < intOldMaxCount) continue; + storage[j].max = Mathf.RoundToInt((float)(storage[j].max * ratio / 100.0)) * 100; + } + } + + break; + } + } + + return false; + } + } + + private static class AllowOverflowInLogistics + { + private static Harmony _patch; + + public static void Enable(bool enable) + { + if (enable) + { + _patch ??= Harmony.CreateAndPatchAll(typeof(AllowOverflowInLogistics)); + return; + } + + _patch?.UnpatchSelf(); + _patch = null; + } + + // Do not check for overflow when try to send hand items into storages + [HarmonyTranspiler] + [HarmonyPatch(typeof(UIStationStorage), nameof(UIStationStorage.OnItemIconMouseDown))] + private static IEnumerable UIStationStorage_OnItemIconMouseDown_Transpiler(IEnumerable instructions, ILGenerator generator) + { + var matcher = new CodeMatcher(instructions, generator); + matcher.MatchForward(false, + new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(LDB), nameof(LDB.items))), + new CodeMatch(OpCodes.Ldarg_0) + ); + var pos = matcher.Pos; + matcher.MatchForward(false, + new CodeMatch(OpCodes.Ldloc_S), + new CodeMatch(OpCodes.Stloc_S) + ); + var inst = matcher.InstructionAt(1).Clone(); + var pos2 = matcher.Pos + 2; + matcher.Start().Advance(pos); + var labels = matcher.Labels; + matcher.RemoveInstructions(pos2 - pos).Insert( + new CodeInstruction(OpCodes.Ldloc_1).WithLabels(labels), + new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.inhandItemCount))), + inst + ); + return matcher.InstructionEnumeration(); + } + + // Remove storage limit check + [HarmonyTranspiler] + [HarmonyPatch(typeof(PlanetTransport), nameof(PlanetTransport.SetStationStorage))] + private static IEnumerable PlanetTransport_SetStationStorage_Transpiler(IEnumerable instructions, ILGenerator generator) + { + var matcher = new CodeMatcher(instructions, generator); + matcher.MatchForward(false, + new CodeMatch(ci => ci.IsLdarg()), + new CodeMatch(ci => ci.IsLdloc()), + new CodeMatch(ci => ci.IsLdloc()), + new CodeMatch(OpCodes.Add), + new CodeMatch(ci => ci.Branches(out _)), + new CodeMatch(ci => ci.IsLdloc()), + new CodeMatch(ci => ci.IsLdloc()), + new CodeMatch(OpCodes.Add), + new CodeMatch(ci => ci.IsStarg()) + ); + var labels = matcher.Labels; + matcher.RemoveInstructions(9).Labels.AddRange(labels); + return matcher.InstructionEnumeration(); + } + } + + private static class LogisticsConstrolPanelImprovement + { + private static Harmony _patch; + + public static void Enable(bool enable) + { + if (enable) + { + _patch ??= Harmony.CreateAndPatchAll(typeof(LogisticsConstrolPanelImprovement)); + return; + } + + _patch?.UnpatchSelf(); + _patch = null; + } + + private static int ItemIdHintUnderMouse() + { + List targets = []; + var pointer = new PointerEventData(EventSystem.current) + { + position = Input.mousePosition + }; + EventSystem.current.RaycastAll(pointer, targets); + foreach (var target in targets) + { + var btn = target.gameObject.GetComponentInParent(); + if (btn?.tips is { itemId: > 0 }) + { + return btn.tips.itemId; + } + + var repWin = target.gameObject.GetComponentInParent(); + if (repWin != null) + { + var mouseRecipeIndex = repWin.mouseRecipeIndex; + var recipeProtoArray = repWin.recipeProtoArray; + if (mouseRecipeIndex < 0) + { + return 0; + } + + var recipeProto = recipeProtoArray[mouseRecipeIndex]; + return recipeProto != null ? recipeProto.Results[0] : 0; + } + + var grid = target.gameObject.GetComponentInParent(); + if (grid != null) + { + var storage = grid.storage; + if (storage == null) return 0; + var mouseOnX = grid.mouseOnX; + var mouseOnY = grid.mouseOnY; + if (mouseOnX < 0 || mouseOnY < 0) return 0; + var gridIndex = mouseOnX + mouseOnY * grid.colCount; + return storage.grids[gridIndex].itemId; + } + + var productEntry = target.gameObject.GetComponentInParent(); + if (productEntry == null) continue; + if (!productEntry.productionStatWindow.isProductionTab) return 0; + return productEntry.entryData?.itemId ?? 0; + } + + return 0; + } + + private static bool SetFilterItemId(UIControlPanelFilterPanel filterPanel, int itemId) + { + var filter = filterPanel.GetCurrentFilter(); + if (filter.itemsFilter is { Length: 1 } && filter.itemsFilter[0] == itemId) return false; + filter.itemsFilter = [itemId]; + filterPanel.SetNewFilter(filter); + return true; + } + + [HarmonyTranspiler] + [HarmonyPatch(typeof(UIGame), nameof(UIGame.On_I_Switch))] + private static IEnumerable UIGame_On_I_Switch_Transpiler(IEnumerable instructions, ILGenerator generator) + { + var matcher = new CodeMatcher(instructions, generator); + matcher.End().MatchBack(false, + new CodeMatch(OpCodes.Ldarg_0), + new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(UIGame), nameof(UIGame.ShutAllFunctionWindow))) + ); + if (matcher.IsInvalid) + { + UXAssist.Logger.LogWarning("Failed to patch UIGame.On_I_Switch()"); + return matcher.InstructionEnumeration(); + } + + var labels = matcher.Labels; + matcher.Labels = null; + matcher.Insert( + new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels), + Transpilers.EmitDelegate((UIGame uiGame) => + { + var itemId = ItemIdHintUnderMouse(); + if (itemId <= 0) return; + SetFilterItemId(uiGame.controlPanelWindow.filterPanel, itemId); + }) + ); + return matcher.InstructionEnumeration(); + } + + private static void OnStationEntryItemIconRightClick(UIControlPanelStationEntry stationEntry, int slot) + { + var storage = stationEntry.station?.storage; + if (storage == null) return; + var itemId = storage.Length > slot ? storage[slot].itemId : 0; + var controlPanelWindow = UIRoot.instance?.uiGame?.controlPanelWindow; + if (controlPanelWindow == null) return; + var filterPanel = controlPanelWindow.filterPanel; + if (filterPanel == null) return; + if (!SetFilterItemId(filterPanel, itemId)) return; + filterPanel.RefreshFilterUI(); + controlPanelWindow.DetermineFilterResults(); + } + + private static Action[] _onStationEntryItemIconRightClickActions = new Action[5]; + + [HarmonyPostfix] + [HarmonyPatch(typeof(UIControlPanelStationEntry), nameof(UIControlPanelStationEntry._OnRegEvent))] + private static void UIControlPanelStationEntry__OnRegEvent_Postfix(UIControlPanelStationEntry __instance) + { + _onStationEntryItemIconRightClickActions[0] = _ => OnStationEntryItemIconRightClick(__instance, 0); + _onStationEntryItemIconRightClickActions[1] = _ => OnStationEntryItemIconRightClick(__instance, 1); + _onStationEntryItemIconRightClickActions[2] = _ => OnStationEntryItemIconRightClick(__instance, 2); + _onStationEntryItemIconRightClickActions[3] = _ => OnStationEntryItemIconRightClick(__instance, 3); + _onStationEntryItemIconRightClickActions[4] = _ => OnStationEntryItemIconRightClick(__instance, 4); + __instance.storageItem0.itemButton.onRightClick += _onStationEntryItemIconRightClickActions[0]; + __instance.storageItem1.itemButton.onRightClick += _onStationEntryItemIconRightClickActions[1]; + __instance.storageItem2.itemButton.onRightClick += _onStationEntryItemIconRightClickActions[2]; + __instance.storageItem3.itemButton.onRightClick += _onStationEntryItemIconRightClickActions[3]; + __instance.storageItem4.itemButton.onRightClick += _onStationEntryItemIconRightClickActions[4]; + } + + [HarmonyPostfix] + [HarmonyPatch(typeof(UIControlPanelStationEntry), nameof(UIControlPanelStationEntry._OnUnregEvent))] + private static void UIControlPanelStationEntry__OnUnregEvent_Postfix(UIControlPanelStationEntry __instance) + { + __instance.storageItem0.itemButton.onRightClick -= _onStationEntryItemIconRightClickActions[0]; + __instance.storageItem1.itemButton.onRightClick -= _onStationEntryItemIconRightClickActions[1]; + __instance.storageItem2.itemButton.onRightClick -= _onStationEntryItemIconRightClickActions[2]; + __instance.storageItem3.itemButton.onRightClick -= _onStationEntryItemIconRightClickActions[3]; + __instance.storageItem4.itemButton.onRightClick -= _onStationEntryItemIconRightClickActions[4]; + for (var i = 0; i < 5; i++) + { + _onStationEntryItemIconRightClickActions[i] = null; + } + } + } +} \ No newline at end of file diff --git a/UXAssist/README.md b/UXAssist/README.md index 171feb4..9f95789 100644 --- a/UXAssist/README.md +++ b/UXAssist/README.md @@ -1,6 +1,7 @@ # UXAssist #### Some functions and patches for better user experience + #### 一些提升用户体验的功能和补丁 ## Usage @@ -16,7 +17,7 @@ + Enable `Hide UI` function(`F11` by default) while on Star Map view + Append mod profile name to game window title, if using mod managers (`Thunderstore Mod Manager` or `r2modman`). * Features: - + General + + General - Enable game window resize - Remember window position and size on last exit - Convert Peace-Mode saves to Combat-Mode on loading @@ -42,6 +43,9 @@ - Allow overflow when trying to insert in-hand items - Allow `Enhanced control for logistic storage limits` to exceed tech capacity limits - Remove logistic strorage limit check on loading game + - Logistics Control Panel Improvement + - Auto apply filter with item under mouse cursor while opening the panel + - Quick-set item filter while right-clicking item icons in storage list on the panel - Re-intialize planet (without reseting veins) - Quick dismantle all buildings (without drops) - Quick build Orbital Collectors @@ -81,18 +85,19 @@ - Open Dark Fog Communicator anywhere ## Notes + * Please upgrade `BepInEx` 5.4.21 or later if using with [BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/) to avoid possible conflicts. + You can download `BepInEx` [here](https://github.com/bepinex/bepinex/releases/latest)(choose x64 edition). + If using with r2modman, you can upgrade `BepInEx` by clicking `Settings` -> `Browse profile folder`, then extract downloaded zip to the folder and overwrite existing files. ## CREDITS + * [Dyson Sphere Program](https://store.steampowered.com/app/1366540): The great game * [Multifunction_mod](https://github.com/blacksnipebiu/Multifunction_mod): Some cheat functions * [LSTM](https://github.com/hetima/DSP_LSTM) & [PlanetFinder](https://github.com/hetima/DSP_PlanetFinder): UI implementations * [OffGridConstruction](https://github.com/Velociraptor115-DSPModding/OffGridConstruction): Off-grid building & stepped rotation implementations * [CruiseAssist](https://dsp.thunderstore.io/package/tanu/CruiseAssist/) and its extension [AutoPilot](https://dsp.thunderstore.io/package/tanu/AutoPilot/): `Auto navigation on sailings` and `Auto-cruise` implementations - ## 使用说明 * 按 `` Alt+`(反引号) `` 键呼出主面板,可以在面板上修改快捷键。 @@ -133,6 +138,9 @@ - 当尝试塞入手中物品时允许溢出 - 允许`物流塔存储数量限制控制改进`超过科技容量限制 - 在加载游戏时移除物流塔容量限制检查 + - 物流控制面板改进 + - 打开面板时自动将鼠标指向物品设为筛选条件 + - 在控制面板物流塔列表中右键点击物品图标快速设置为筛选条件 - 初始化本行星(不重置矿脉) - 快速拆除所有建筑(不掉落) - 快速建造轨道采集器 @@ -173,11 +181,13 @@ - 在任意位置打开黑雾通讯器 ## 注意事项 + * 如果和[BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/)一起使用,请升级`BepInEx`到5.4.21或更高版本,以避免可能的冲突。 + 你可以在[这里](https://github.com/bepinex/bepinex/releases/latest)(选择x64版本)下载`BepInEx`。 + 如果使用r2modman,你可以点击`Settings` -> `Browse profile folder`,然后将下载的zip解压到该文件夹并覆盖现有文件。 ## 鸣谢 + * [戴森球计划](https://store.steampowered.com/app/1366540): 伟大的游戏 * [BepInEx](https://bepinex.dev/): 基础模组框架 * [LSTM](https://github.com/hetima/DSP_LSTM) & [PlanetFinder](https://github.com/hetima/DSP_PlanetFinder): UI实现 diff --git a/UXAssist/UI/MyCheckbox.cs b/UXAssist/UI/MyCheckbox.cs index bd95c52..3066e59 100644 --- a/UXAssist/UI/MyCheckbox.cs +++ b/UXAssist/UI/MyCheckbox.cs @@ -59,7 +59,7 @@ public class MyCheckBox : MonoBehaviour cb.labelText.fontSize = fontSize; cb.SetLabelText(label); var width = cb.labelText.preferredWidth; - cb.labelText.rectTransform.sizeDelta = new Vector2(width, rect.sizeDelta.y); + cb.labelText.rectTransform.sizeDelta = new Vector2(width, cb.labelText.rectTransform.sizeDelta.y); } //value @@ -86,4 +86,7 @@ public class MyCheckBox : MonoBehaviour checkImage.enabled = _checked; OnChecked?.Invoke(); } + + public float Width => rectTrans.sizeDelta.x + labelText.rectTransform.sizeDelta.x; + public float Height => Math.Max(rectTrans.sizeDelta.y, labelText.rectTransform.sizeDelta.y); } diff --git a/UXAssist/UI/MyConfigWindow.cs b/UXAssist/UI/MyConfigWindow.cs index 951c925..b20c3bd 100644 --- a/UXAssist/UI/MyConfigWindow.cs +++ b/UXAssist/UI/MyConfigWindow.cs @@ -23,9 +23,8 @@ public class MyConfigWindow : MyWindowWithTabs public override void _OnCreate() { _windowTrans = GetComponent(); - _windowTrans.sizeDelta = new Vector2(810f, 584f); - OnUICreated?.Invoke(this, _windowTrans); + AutoFitWindowSize(); SetCurrentTab(0); OnUpdateUI?.Invoke(); } diff --git a/UXAssist/UI/MyWindow.cs b/UXAssist/UI/MyWindow.cs index bbeaa4d..58ee199 100644 --- a/UXAssist/UI/MyWindow.cs +++ b/UXAssist/UI/MyWindow.cs @@ -1,6 +1,7 @@ using System; using HarmonyLib; using System.Collections.Generic; +using BepInEx.Configuration; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; @@ -15,6 +16,13 @@ public class MyWindow: ManualBehaviour private readonly Dictionary, UnityAction>> _inputFields = new(); private readonly Dictionary _buttons = new(); protected bool EventRegistered { get; private set; } + private float _maxX; + protected float MaxY; + protected const float TitleHeight = 48f; + protected const float TabWidth = 105f; + protected const float TabHeight = 27f; + protected const float Margin = 30f; + protected const float Spacing = 10f; public virtual void TryClose() { @@ -43,6 +51,12 @@ public class MyWindow: ManualBehaviour } } + public void AutoFitWindowSize() + { + var trans = GetComponent(); + trans.sizeDelta = new Vector2(_maxX + Margin + TabWidth + Spacing + Margin, MaxY + TitleHeight + Margin); + } + private static void AddElement(float x, float y, RectTransform rect, RectTransform parent = null) { if (rect != null) @@ -60,14 +74,19 @@ public class MyWindow: ManualBehaviour txt.color = new Color(1f, 1f, 1f, 0.4f); txt.alignment = TextAnchor.MiddleLeft; txt.fontSize = fontSize; - if (txt.transform is RectTransform rect) - { - rect.sizeDelta = new Vector2(txt.preferredWidth + 40f, 30f); - } + txt.rectTransform.sizeDelta = new Vector2(txt.preferredWidth + 8f, txt.preferredHeight + 8f); AddElement(x, y, txt.rectTransform, parent); return txt; } - + + public Text AddText2(float x, float y, RectTransform parent, string label, int fontSize = 14, string objName = "label") + { + var text = AddText(x, y, parent, label, fontSize, objName); + _maxX = Math.Max(_maxX, x + text.rectTransform.sizeDelta.x); + MaxY = Math.Max(MaxY, y + text.rectTransform.sizeDelta.y); + return text; + } + public static UIButton AddTipsButton(float x, float y, RectTransform parent, string label, string tip, string content, string objName = "tips-button") { var src = UIRoot.instance.galaxySelect.sandboxToggle.gameObject.transform.parent.Find("tip-button"); @@ -82,6 +101,18 @@ public class MyWindow: ManualBehaviour return btn; } + public UIButton AddTipsButton2(float x, float y, RectTransform parent, string label, string tip, string content, string objName = "tips-button") + { + var tipsButton = AddTipsButton(x, y, parent, label, tip, content, objName); + var rect = tipsButton.transform as RectTransform; + if (rect != null) + { + _maxX = Math.Max(_maxX, x + rect.sizeDelta.x); + MaxY = Math.Max(MaxY, y + rect.sizeDelta.y); + } + return tipsButton; + } + public UIButton AddButton(float x, float y, RectTransform parent, string text = "", int fontSize = 16, string objName = "button", UnityAction onClick = null) { return AddButton(x, y, 150f, parent, text, fontSize, objName, onClick); @@ -115,6 +146,8 @@ public class MyWindow: ManualBehaviour if (onClick != null) btn.button.onClick.AddListener(onClick); } + _maxX = Math.Max(_maxX, x + rect.sizeDelta.x); + MaxY = Math.Max(MaxY, y + rect.sizeDelta.y); return btn; } @@ -135,7 +168,7 @@ public class MyWindow: ManualBehaviour { img.color = new Color(img.color.r, img.color.g, img.color.b, 0f); } - Util.NormalizeRectWithTopLeft(btn, x, y, parent); + var rect = Util.NormalizeRectWithTopLeft(btn, x, y, parent); var t = btn.gameObject.transform.Find("Text")?.GetComponent(); if (t != null) { @@ -148,10 +181,32 @@ public class MyWindow: ManualBehaviour { btn.button.onClick.AddListener(onClick); } + _maxX = Math.Max(_maxX, x + rect.sizeDelta.x); + MaxY = Math.Max(MaxY, y + rect.sizeDelta.y); return btn; } - protected InputField AddInputField(float x, float y, RectTransform parent, string text = "", int fontSize = 16, string objName = "input", UnityAction onChanged = null, UnityAction onEditEnd = null) + public MyCheckBox AddCheckBox(float x, float y, RectTransform parent, ConfigEntry config, string label = "", int fontSize = 15) + { + var cb = MyCheckBox.CreateCheckBox(x, y, parent, config, label, fontSize); + _maxX = Math.Max(_maxX, x + cb.Width); + MaxY = Math.Max(MaxY, y + cb.Height); + return cb; + } + + public MySlider AddSlider(float x, float y, RectTransform parent, float value, float minValue, float maxValue, string format = "G", float width = 0f) + { + var slider = MySlider.CreateSlider(x, y, parent, value, minValue, maxValue, format, width); + var rect = slider.rectTrans; + if (rect != null) + { + _maxX = Math.Max(_maxX, x + rect.sizeDelta.x); + MaxY = Math.Max(MaxY, y + rect.sizeDelta.y); + } + return slider; + } + + public InputField AddInputField(float x, float y, RectTransform parent, string text = "", int fontSize = 16, string objName = "input", UnityAction onChanged = null, UnityAction onEditEnd = null) { var stationWindow = UIRoot.instance.uiGame.stationWindow; //public InputField nameInput; @@ -173,6 +228,8 @@ public class MyWindow: ManualBehaviour if (onEditEnd != null) inputField.onEndEdit.AddListener(onEditEnd); } + _maxX = Math.Max(_maxX, x + rect.sizeDelta.x); + MaxY = Math.Max(MaxY, y + rect.sizeDelta.y); return inputField; } @@ -223,6 +280,7 @@ public class MyWindowWithTabs : MyWindow { private readonly List> _tabs = []; private float _tabY = 54f; + public override void TryClose() { _Close(); @@ -237,14 +295,14 @@ public class MyWindowWithTabs : MyWindow { var tab = new GameObject(); var tabRect = tab.AddComponent(); - Util.NormalizeRectWithMargin(tabRect, 48f, 145f, 0f, 0f, parent); + Util.NormalizeRectWithMargin(tabRect, TitleHeight, Margin + TabWidth + Spacing, 0f, 0f, parent); tab.name = "tab-" + index; var swarmPanel = UIRoot.instance.uiGame.dysonEditor.controlPanel.hierarchy.swarmPanel; var src = swarmPanel.orbitButtons[0]; var btn = Instantiate(src); - var btnRect = Util.NormalizeRectWithTopLeft(btn, 30, y, parent); + var btnRect = Util.NormalizeRectWithTopLeft(btn, Margin, y, parent); btn.name = "tab-btn-" + index; - btnRect.sizeDelta = new Vector2(105f, 27f); + btnRect.sizeDelta = new Vector2(TabWidth, TabHeight); btn.transform.Find("frame").gameObject.SetActive(false); if (btn.transitions.Length >= 3) { @@ -264,6 +322,7 @@ public class MyWindowWithTabs : MyWindow { btn.onClick += OnTabButtonClick; } + MaxY = Math.Max(MaxY, y + TabHeight); return tabRect; } diff --git a/UXAssist/UIConfigWindow.cs b/UXAssist/UIConfigWindow.cs index 3d18c21..9b64acc 100644 --- a/UXAssist/UIConfigWindow.cs +++ b/UXAssist/UIConfigWindow.cs @@ -46,6 +46,8 @@ public static class UIConfigWindow I18N.Add("Drag building power poles in maximum connection range", "Drag building power poles in maximum connection range", "拖动建造电线杆时自动使用最大连接距离间隔"); I18N.Add("Allow overflow for Logistic Stations and Advanced Mining Machines", "Allow overflow for Logistic Stations and Advanced Mining Machines", "允许物流站和大型采矿机物品溢出"); I18N.Add("Belt signals for buy out dark fog items automatically", "Belt signals for buy out dark fog items automatically", "用于自动购买黑雾物品的传送带信号"); + I18N.Add("Logistics Control Panel Improvement", "Logistics Control Panel Improvement", "物流控制面板改进"); + I18N.Add("Logistics Control Panel Improvement tips", "Auto apply filter with item under mouse cursor while opening the panel\nQuick-set item filter while right-clicking item icons in storage list on the panel", "打开面板时自动将鼠标指向物品设为筛选条件\n在控制面板物流塔列表中右键点击物品图标快速设置为筛选条件"); I18N.Add("Auto navigation on sailings", "Auto navigation on sailings", "宇宙航行时自动导航"); I18N.Add("Enable auto-cruise", "Enable auto-cruise", "启用自动巡航"); I18N.Add("Auto boost", "Auto boost", "自动加速"); @@ -81,57 +83,53 @@ public static class UIConfigWindow var tab1 = wnd.AddTab(trans, "General"); var x = 0f; var y = 10f; - MyCheckBox.CreateCheckBox(x, y, tab1, GamePatch.EnableWindowResizeEnabled, "Enable game window resize"); + wnd.AddCheckBox(x, y, tab1, GamePatch.EnableWindowResizeEnabled, "Enable game window resize"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab1, GamePatch.LoadLastWindowRectEnabled, "Remeber window position and size on last exit"); + wnd.AddCheckBox(x, y, tab1, GamePatch.LoadLastWindowRectEnabled, "Remeber window position and size on last exit"); y += 36f; /* - MyCheckBox.CreateCheckBox(x, y, tab1, GamePatch.AutoSaveOptEnabled, "Better auto-save mechanism"); + wnd.AddCheckBox(x, y, tab1, GamePatch.AutoSaveOptEnabled, "Better auto-save mechanism"); x = 200f; y += 6f; - MyWindow.AddTipsButton(x, y, tab1, "Better auto-save mechanism", "Better auto-save mechanism tips", "auto-save-opt-tips"); + wnd.AddTipsButton2(x, y, tab1, "Better auto-save mechanism", "Better auto-save mechanism tips", "auto-save-opt-tips"); x = 0f; y += 30f; */ - MyCheckBox.CreateCheckBox(x, y, tab1, GamePatch.ConvertSavesFromPeaceEnabled, "Convert old saves to Combat Mode on loading"); + wnd.AddCheckBox(x, y, tab1, GamePatch.ConvertSavesFromPeaceEnabled, "Convert old saves to Combat Mode on loading"); var tab2 = wnd.AddTab(trans, "Planet/Factory"); x = 0f; y = 10f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.RemoveSomeConditionEnabled, "Remove some build conditions"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.RemoveSomeConditionEnabled, "Remove some build conditions"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.RemoveBuildRangeLimitEnabled, "Remove build range limit"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.RemoveBuildRangeLimitEnabled, "Remove build range limit"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.NightLightEnabled, "Night Light"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.NightLightEnabled, "Night Light"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.LargerAreaForUpgradeAndDismantleEnabled, "Larger area for upgrade and dismantle"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.LargerAreaForUpgradeAndDismantleEnabled, "Larger area for upgrade and dismantle"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.LargerAreaForTerraformEnabled, "Larger area for terraform"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.LargerAreaForTerraformEnabled, "Larger area for terraform"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.OffGridBuildingEnabled, "Off-grid building and stepped rotation"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.OffGridBuildingEnabled, "Off-grid building and stepped rotation"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.TreatStackingAsSingleEnabled, "Treat stack items as single in monitor components"); - y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.LogisticsCapacityTweaksEnabled, "Enhance control for logistic storage limits"); - x = 270f; + var cb = wnd.AddCheckBox(x, y, tab2, FactoryPatch.TreatStackingAsSingleEnabled, "Treat stack items as single in monitor components"); + x += cb.Width + 5f; y += 6f; - MyWindow.AddTipsButton(x, y, tab2, "Enhance control for logistic storage limits", "Enhance control for logistic storage limits tips", "enhanced-logistic-limit-tips"); + wnd.AddTipsButton2(x, y, tab2, "Enhance control for logistic storage limits", "Enhance control for logistic storage limits tips", "enhanced-logistic-limit-tips"); x = 0f; y += 30f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.QuickBuildAndDismantleLabsEnabled, "Quick build and dismantle stacking labs"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.QuickBuildAndDismantleLabsEnabled, "Quick build and dismantle stacking labs"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.ProtectVeinsFromExhaustionEnabled, "Protect veins from exhaustion"); - x = 270f; + cb = wnd.AddCheckBox(x, y, tab2, FactoryPatch.ProtectVeinsFromExhaustionEnabled, "Protect veins from exhaustion"); + x += cb.Width + 5f; y += 6f; - MyWindow.AddTipsButton(x, y, tab2, "Protect veins from exhaustion", "Protect veins from exhaustion tips", "protect-veins-tips"); + wnd.AddTipsButton2(x, y, tab2, "Protect veins from exhaustion", "Protect veins from exhaustion tips", "protect-veins-tips"); x = 0f; y += 30f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.DragBuildPowerPolesEnabled, "Drag building power poles in maximum connection range"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.DragBuildPowerPolesEnabled, "Drag building power poles in maximum connection range"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.AllowOverflowInLogisticsEnabled, "Allow overflow for Logistic Stations and Advanced Mining Machines"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.DoNotRenderEntitiesEnabled, "Do not render factory entities"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.DoNotRenderEntitiesEnabled, "Do not render factory entities"); - y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BeltSignalsForBuyOutEnabled, "Belt signals for buy out dark fog items automatically"); + wnd.AddCheckBox(x, y, tab2, FactoryPatch.BeltSignalsForBuyOutEnabled, "Belt signals for buy out dark fog items automatically"); x = 400f; y = 10f; wnd.AddButton(x, y, tab2, "Initialize This Planet", 16, "button-init-planet", () => @@ -151,9 +149,9 @@ public static class UIConfigWindow wnd.AddButton(x, y, 200, tab2, "Quick build Orbital Collectors", 16, "button-init-planet", PlanetFunctions.BuildOrbitalCollectors); x += 10f; y += 30f; - MyWindow.AddText(x, y, tab2, "Maximum count to build", 15, "text-oc-build-count"); + wnd.AddText2(x, y, tab2, "Maximum count to build", 15, "text-oc-build-count"); y += 24f; - var ocBuildSlider = MySlider.CreateSlider(x, y, tab2, PlanetFunctions.OrbitalCollectorMaxBuildCount.Value, 0f, 40f, "G", 200f); + var ocBuildSlider = wnd.AddSlider(x, y, tab2, PlanetFunctions.OrbitalCollectorMaxBuildCount.Value, 0f, 40f, "G", 200f); if (PlanetFunctions.OrbitalCollectorMaxBuildCount.Value == 0) { ocBuildSlider.SetLabelText("max".Translate()); @@ -166,33 +164,44 @@ public static class UIConfigWindow ocBuildSlider.SetLabelText("max".Translate()); } }; + x = 400f; + y += 54f; + wnd.AddCheckBox(x, y, tab2, LogisticsPatch.LogisticsCapacityTweaksEnabled, "Enhance control for logistic storage limits"); + y += 36f; + wnd.AddCheckBox(x, y, tab2, LogisticsPatch.AllowOverflowInLogisticsEnabled, "Allow overflow for Logistic Stations and Advanced Mining Machines"); + y += 36f; + cb = wnd.AddCheckBox(x, y, tab2, LogisticsPatch.LogisticsConstrolPanelImprovementEnabled, "Logistics Control Panel Improvement"); + x += cb.Width + 5f; + y += 6f; + wnd.AddTipsButton2(x, y, tab2, "Logistics Control Panel Improvement", "Logistics Control Panel Improvement tips", "lcp-improvement-tips"); + // x -= 200f; var tab3 = wnd.AddTab(trans, "Player/Mecha"); x = 0f; y = 10f; - MyCheckBox.CreateCheckBox(x, y, tab3, FactoryPatch.UnlimitInteractiveEnabled, "Unlimited interactive range"); + wnd.AddCheckBox(x, y, tab3, FactoryPatch.UnlimitInteractiveEnabled, "Unlimited interactive range"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab3, PlanetPatch.PlayerActionsInGlobeViewEnabled, "Enable player actions in globe view"); + wnd.AddCheckBox(x, y, tab3, PlanetPatch.PlayerActionsInGlobeViewEnabled, "Enable player actions in globe view"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab3, PlayerPatch.HideTipsForSandsChangesEnabled, "Hide tips for soil piles changes"); + wnd.AddCheckBox(x, y, tab3, PlayerPatch.HideTipsForSandsChangesEnabled, "Hide tips for soil piles changes"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab3, PlayerPatch.EnhancedMechaForgeCountControlEnabled, "Enhanced count control for hand-make"); - x = 270f; + cb = wnd.AddCheckBox(x, y, tab3, PlayerPatch.EnhancedMechaForgeCountControlEnabled, "Enhanced count control for hand-make"); + x += cb.Width + 5f; y += 6f; - MyWindow.AddTipsButton(x, y, tab3, "Enhanced count control for hand-make", "Enhanced count control for hand-make tips", "enhanced-count-control-tips"); + wnd.AddTipsButton2(x, y, tab3, "Enhanced count control for hand-make", "Enhanced count control for hand-make tips", "enhanced-count-control-tips"); x = 0f; y += 30f; - MyCheckBox.CreateCheckBox(x, y, tab3, PlayerPatch.AutoNavigationEnabled, "Auto navigation on sailings"); + wnd.AddCheckBox(x, y, tab3, PlayerPatch.AutoNavigationEnabled, "Auto navigation on sailings"); x = 20f; y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab3, PlayerPatch.AutoCruiseEnabled, "Enable auto-cruise", 14); + wnd.AddCheckBox(x, y, tab3, PlayerPatch.AutoCruiseEnabled, "Enable auto-cruise", 14); x = 10f; y += 32f; - MyCheckBox.CreateCheckBox(x, y, tab3, PlayerPatch.AutoBoostEnabled, "Auto boost", 15); + wnd.AddCheckBox(x, y, tab3, PlayerPatch.AutoBoostEnabled, "Auto boost", 15); y += 32f; - MyWindow.AddText(x, y, tab3, "Distance to use warp", 15, "text-distance-to-warp"); + wnd.AddText2(x, y, tab3, "Distance to use warp", 15, "text-distance-to-warp"); y += 24f; - var distanceToWarp = MySlider.CreateSlider(x, y, tab3, (float)Math.Round(PlayerPatch.DistanceToWarp.Value * 2.0), 1f, 40f, "0.0", 200f); + var distanceToWarp = wnd.AddSlider(x, y, tab3, (float)Math.Round(PlayerPatch.DistanceToWarp.Value * 2.0), 1f, 40f, "0.0", 200f); if (PlanetFunctions.OrbitalCollectorMaxBuildCount.Value == 0) { distanceToWarp.SetLabelText(PlayerPatch.DistanceToWarp.Value.ToString("0.0")); @@ -206,9 +215,9 @@ public static class UIConfigWindow var tab4 = wnd.AddTab(trans, "Dyson Sphere"); x = 0f; y = 10f; - MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.StopEjectOnNodeCompleteEnabled, "Stop ejectors when available nodes are all filled up"); + wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.StopEjectOnNodeCompleteEnabled, "Stop ejectors when available nodes are all filled up"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OnlyConstructNodesEnabled, "Construct only structure points but frames"); + wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.OnlyConstructNodesEnabled, "Construct only structure points but frames"); x = 400f; y = 10f; wnd.AddButton(x, y, tab4, "Initialize Dyson Sphere", 16, "init-dyson-sphere", () => @@ -218,7 +227,7 @@ public static class UIConfigWindow }) ); y += 36f; - MyWindow.AddText(x, y, tab4, "Click to dismantle selected layer", 16, "text-dismantle-layer"); + wnd.AddText2(x, y, tab4, "Click to dismantle selected layer", 16, "text-dismantle-layer"); y += 26f; for (var i = 0; i < 10; i++) { @@ -246,9 +255,9 @@ public static class UIConfigWindow var tab5 = wnd.AddTab(_windowTrans, "Tech/Combat"); x = 10; y = 10; - MyCheckBox.CreateCheckBox(x, y, tab5, TechPatch.BatchBuyoutTechEnabled, "Buy out techs with their prerequisites"); + wnd.AddCheckBox(x, y, tab5, TechPatch.BatchBuyoutTechEnabled, "Buy out techs with their prerequisites"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab5, TechPatch.SorterCargoStackingEnabled, "Restore upgrades of \"Sorter Cargo Stacking\" on panel"); + wnd.AddCheckBox(x, y, tab5, TechPatch.SorterCargoStackingEnabled, "Restore upgrades of \"Sorter Cargo Stacking\" on panel"); y += 36f; wnd.AddButton(x, y, 300f, tab5, "Set \"Sorter Cargo Stacking\" to unresearched state", 16, "button-remove-cargo-stacking", () => { diff --git a/UXAssist/UXAssist.cs b/UXAssist/UXAssist.cs index 3a304ce..d0c99af 100644 --- a/UXAssist/UXAssist.cs +++ b/UXAssist/UXAssist.cs @@ -89,8 +89,6 @@ public class UXAssist : BaseUnityPlugin, IModCanSave "Increase maximum area size for terraform to 30x30 (from 10x10)\nNote: this may impact game performance while using large area"); FactoryPatch.OffGridBuildingEnabled = Config.Bind("Factory", "OffGridBuilding", false, "Enable off grid building and stepped rotation"); - FactoryPatch.LogisticsCapacityTweaksEnabled = Config.Bind("Factory", "LogisticsCapacityTweaks", true, - "Logistics capacity related tweaks"); FactoryPatch.TreatStackingAsSingleEnabled = Config.Bind("Factory", "TreatStackingAsSingle", false, "Treat stack items as single in monitor components"); FactoryPatch.QuickBuildAndDismantleLabsEnabled = Config.Bind("Factory", "QuickBuildAndDismantleLab", false, @@ -103,10 +101,14 @@ public class UXAssist : BaseUnityPlugin, IModCanSave "Do not render factory entities"); FactoryPatch.DragBuildPowerPolesEnabled = Config.Bind("Factory", "DragBuildPowerPoles", false, "Drag building power poles in maximum connection range"); - FactoryPatch.AllowOverflowInLogisticsEnabled = Config.Bind("Factory", "AllowOverflowInLogistics", false, - "Allow overflow in logistic stations"); FactoryPatch.BeltSignalsForBuyOutEnabled = Config.Bind("Factory", "BeltSignalsForBuyOut", false, "Belt signals for buy out dark fog items automatically"); + LogisticsPatch.LogisticsCapacityTweaksEnabled = Config.Bind("Factory", "LogisticsCapacityTweaks", true, + "Logistics capacity related tweaks"); + LogisticsPatch.AllowOverflowInLogisticsEnabled = Config.Bind("Factory", "AllowOverflowInLogistics", false, + "Allow overflow in logistic stations"); + LogisticsPatch.LogisticsConstrolPanelImprovementEnabled = Config.Bind("Factory", "LogisticsConstrolPanelImprovement", false, + "Logistics control panel improvement"); PlanetFunctions.OrbitalCollectorMaxBuildCount = Config.Bind("Factory", "OCMaxBuildCount", 0, "Maximum Orbital Collectors to build once, set to 0 to build as many as possible"); PlayerPatch.EnhancedMechaForgeCountControlEnabled = Config.Bind("Player", "EnhancedMechaForgeCountControl", false, "Enhanced count control for hand-make, increases maximum of count to 1000, and you can hold Ctrl/Shift/Alt to change the count rapidly"); @@ -127,6 +129,7 @@ public class UXAssist : BaseUnityPlugin, IModCanSave "Stop ejectors when available nodes are all filled up"); DysonSpherePatch.OnlyConstructNodesEnabled = Config.Bind("DysonSphere", "OnlyConstructNodes", false, "Construct only nodes but frames"); + DysonSpherePatch.AutoConstructMultiplier = Config.Bind("DysonSphere", "AutoConstructMultiplier", 10, "Dyson Sphere auto-construct speed multiplier"); I18N.Init(); I18N.Add("UXAssist Config", "UXAssist Config", "UX助手设置"); @@ -142,6 +145,7 @@ public class UXAssist : BaseUnityPlugin, IModCanSave UIConfigWindow.Init(); GamePatch.Init(); FactoryPatch.Init(); + LogisticsPatch.Init(); PlanetPatch.Init(); PlayerPatch.Init(); TechPatch.Init(); @@ -173,7 +177,7 @@ public class UXAssist : BaseUnityPlugin, IModCanSave if (VFInput.inputing) return; if (VFInput.onGUI) { - FactoryPatch.LogisticsCapacityTweaks.UpdateInput(); + LogisticsPatch.LogisticsCapacityTweaks.UpdateInput(); } if (_toggleKey.keyValue) { @@ -261,8 +265,8 @@ public class UXAssist : BaseUnityPlugin, IModCanSave if (panelButtonGo != null && btn != null) { panelButtonGo.name = "open-uxassist-config"; - rect.localScale = new Vector3(0.5f, 0.5f, 0.5f); - rect.anchoredPosition3D = new Vector3(128f, -105f, 0f); + rect.localScale = new Vector3(0.6f, 0.6f, 0.6f); + rect.anchoredPosition3D = new Vector3(64f, -5f, 0f); b.onClick.RemoveAllListeners(); btn.onClick += _ => { ToggleConfigWindow(); }; btn.tips.tipTitle = "UXAssist Config"; diff --git a/UXAssist/UXAssist.csproj b/UXAssist/UXAssist.csproj index 690d56f..ed6a2a2 100644 --- a/UXAssist/UXAssist.csproj +++ b/UXAssist/UXAssist.csproj @@ -4,7 +4,7 @@ net472 org.soardev.uxassist DSP MOD - UXAssist - 1.1.4 + 1.1.5 true latest UXAssist diff --git a/UXAssist/package/manifest.json b/UXAssist/package/manifest.json index 6ae5ec6..1180a40 100644 --- a/UXAssist/package/manifest.json +++ b/UXAssist/package/manifest.json @@ -1,10 +1,11 @@ { "name": "UXAssist", - "version_number": "1.1.4", + "version_number": "1.1.5", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist", "description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁", "dependencies": [ "CommonAPI-CommonAPI-1.6.5", + "CommonAPI-DSPModSave-1.1.4", "xiaoye97-BepInEx-5.4.17" ] }