1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-08 20:53:28 +08:00

UXAssist v1.0.6

This commit is contained in:
2023-12-16 17:50:09 +08:00
parent 947d3e4d20
commit d0352b7f7c
7 changed files with 59 additions and 7 deletions

View File

@@ -46,12 +46,10 @@ class PatchUILoadGame
{
var rtrans = (RectTransform)__instance.loadSandboxGroup.transform;
var anchoredPosition3D = rtrans.anchoredPosition3D;
var pos = anchoredPosition3D;
anchoredPosition3D = new Vector3(pos.x - 230, pos.y, pos.z);
_decompressButton.gameObject.name = "button-decompress";
rtrans = (RectTransform)_decompressButton.transform;
pos = anchoredPosition3D;
anchoredPosition3D = new Vector3(pos.x - 180, pos.y, pos.z);
var pos = anchoredPosition3D;
anchoredPosition3D = new Vector3(pos.x - 230, pos.y, pos.z);
rtrans.anchoredPosition3D = anchoredPosition3D;
_decompressButton.button.image.color = new Color32(0, 0xf4, 0x92, 0x77);
var textTrans = _decompressButton.transform.Find("button-text");

View File

@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection.Emit;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
@@ -13,6 +15,7 @@ public static class GamePatch
public static ConfigEntry<bool> EnableWindowResizeEnabled;
public static ConfigEntry<bool> LoadLastWindowRectEnabled;
public static ConfigEntry<bool> ConvertSavesFromPeaceEnabled;
public static ConfigEntry<Vector4> LastWindowRect;
private static Harmony _gamePatch;
@@ -20,8 +23,10 @@ public static class GamePatch
{
EnableWindowResizeEnabled.SettingChanged += (_, _) => EnableWindowResize.Enable(EnableWindowResizeEnabled.Value);
LoadLastWindowRectEnabled.SettingChanged += (_, _) => LoadLastWindowRect.Enable(LoadLastWindowRectEnabled.Value);
ConvertSavesFromPeaceEnabled.SettingChanged += (_, _) => ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
EnableWindowResize.Enable(EnableWindowResizeEnabled.Value);
LoadLastWindowRect.Enable(LoadLastWindowRectEnabled.Value);
ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
_gamePatch ??= Harmony.CreateAndPatchAll(typeof(GamePatch));
}
@@ -29,6 +34,7 @@ public static class GamePatch
{
LoadLastWindowRect.Enable(false);
EnableWindowResize.Enable(false);
ConvertSavesFromPeace.Enable(false);
_gamePatch?.UnpatchSelf();
_gamePatch = null;
}
@@ -171,4 +177,39 @@ public static class GamePatch
WinApi.GetWindowLong(wnd, (int)WindowLongFlags.GWL_STYLE) | (int)WindowStyles.WS_THICKFRAME | (int)WindowStyles.WS_MAXIMIZEBOX);
}
}
private static class ConvertSavesFromPeace
{
private static Harmony _patch;
public static void Enable(bool on)
{
if (on)
{
_patch ??= Harmony.CreateAndPatchAll(typeof(ConvertSavesFromPeace));
return;
}
_patch?.UnpatchSelf();
_patch = null;
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(GameDesc), nameof(GameDesc.Import))]
private static IEnumerable<CodeInstruction> GameDesc_Import_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(CombatSettings), nameof(CombatSettings.SetDefault)))
).Advance(-1).RemoveInstructions(2).Insert(
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(UIRoot), nameof(UIRoot.instance))),
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(UIRoot), nameof(UIRoot.galaxySelect))),
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(UIGalaxySelect), nameof(UIGalaxySelect.uiCombat))),
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(UICombatSettingsDF), nameof(UICombatSettingsDF.combatSettings))),
new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(GameDesc), nameof(GameDesc.combatSettings))),
new CodeInstruction(OpCodes.Ldarg_0),
new CodeInstruction(OpCodes.Ldc_I4_0),
new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(GameDesc), nameof(GameDesc.isPeaceMode)))
);
return matcher.InstructionEnumeration();
}
}
}

View File

@@ -4,6 +4,8 @@
#### 一些提升用户体验的功能和补丁
## Changlog
* 1.0.6
+ Convert old saves to Combat Mode on loading
* 1.0.5
+ Support game version 0.10.28.20759
+ Sort blueprint structures before saving, to reduce generated blueprint data size a little.
@@ -35,10 +37,12 @@
* Patches:
+ Strict hotkey dectection for build menu, thus building hotkeys(0~9, F1~F10, X, U) are not triggered while holding Ctrl/Alt/Shift.
+ Fix a bug that warning popup on `Veins Utilization` upgraded to level 8000+
+ Sort blueprint structures before saving, to reduce generated blueprint data size a little
* Features:
+ General
- Enable game window resize
- Remember window position and size on last exit
- Convert old saves to Combat Mode on loading
+ Planet/Factory
- Unlimited interactive range
- Sunlight at night
@@ -69,6 +73,8 @@
* [OffGridConstruction](https://github.com/Velociraptor115-DSPModding/OffGridConstruction): Off-grid building & stepped rotation implementations
## 更新日志
* 1.0.6
+ 在加载旧存档时将其转换为战斗模式
* 1.0.5
+ 支持游戏版本0.10.28.20759
+ 保存蓝图前对建筑进行排序,以减少生成的蓝图数据大小
@@ -100,10 +106,12 @@
* 补丁:
+ 更严格的建造菜单热键检测因此在按住Ctrl/Alt/Shift时不再会触发建造热键(0~9, F1~F10, X, U)
+ 修复了`矿物利用`升级到8000级以上时弹出警告的bug
+ 保存蓝图前对建筑进行排序,以减少生成的蓝图数据大小
* 功能:
+ 通用
-可调整游戏窗口大小(可最大化和拖动边框)
- 可调整游戏窗口大小(可最大化和拖动边框)
- 记住上次退出时的窗口位置和大小
- 在加载旧存档时将其转换为战斗模式
+ 行星/工厂
- 无限交互距离
- 夜间日光灯

View File

@@ -18,6 +18,7 @@ public static class UIConfigWindow
I18N.Add("Dyson Sphere", "Dyson Sphere", "戴森球");
I18N.Add("Enable game window resize", "Enable game window resize (maximum box and thick frame)", "可调整游戏窗口大小(可最大化和拖动边框)");
I18N.Add("Remeber window position and size on last exit", "Remeber window position and size on last exit", "记住上次退出时的窗口位置和大小");
I18N.Add("Convert old saves to Combat Mode on loading", "Convert old saves to Combat Mode on loading (Use settings in new game panel)", "读取旧档时转为战斗模式(使用新游戏面板的战斗难度设置)");
I18N.Add("Unlimited interactive range", "Unlimited interactive range", "无限交互距离");
I18N.Add("Night Light", "Sunlight at night", "夜间日光灯");
I18N.Add("Remove some build conditions", "Remove some build conditions", "移除部分不影响游戏逻辑的建造条件");
@@ -57,6 +58,8 @@ public static class UIConfigWindow
MyCheckBox.CreateCheckBox(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");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab1, GamePatch.ConvertSavesFromPeaceEnabled, "Convert old saves to Combat Mode on loading");
x += 10f;
y = 278f;
MyKeyBinder.CreateKeyBinder(x, y, tab1, UXAssist.Hotkey, "Hotkey");

View File

@@ -32,6 +32,8 @@ public class UXAssist : BaseUnityPlugin
"Load last window position and size when game starts");
GamePatch.LastWindowRect = Config.Bind("Game", "LastWindowRect", new Vector4(0f, 0f, 0f, 0f),
"Last window position and size");
GamePatch.ConvertSavesFromPeaceEnabled = Config.Bind("Game", "ConvertSavesFromPeace", false,
"Convert saves from Peace mode to Combat mode on save loading");
FactoryPatch.UnlimitInteractiveEnabled = Config.Bind("Factory", "UnlimitInteractive", false,
"Unlimit interactive range");
FactoryPatch.RemoveSomeConditionEnabled = Config.Bind("Factory", "RemoveSomeBuildConditionCheck", false,

View File

@@ -4,7 +4,7 @@
<TargetFramework>net472</TargetFramework>
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
<Description>DSP MOD - UXAssist</Description>
<Version>1.0.5</Version>
<Version>1.0.6</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<PackageId>UXAssist</PackageId>

View File

@@ -1,6 +1,6 @@
{
"name": "UXAssist",
"version_number": "1.0.5",
"version_number": "1.0.6",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist",
"description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁",
"dependencies": [