mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-08 21:33:28 +08:00
UXAssist 1.2.6
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
## Changlog
|
||||
|
||||
* 1.2.6
|
||||
+ `Remember window position and size on last exit`
|
||||
- Fix a bug that window position is restored even the option is disabled.
|
||||
- Fix a bug that the last window position is wrongly remembere when game is closed at minimized state.
|
||||
* 1.2.5
|
||||
+ New feature: `Set process priority`
|
||||
+ New feature: `Set enabled CPU threads`
|
||||
@@ -202,6 +206,10 @@
|
||||
|
||||
## 更新日志
|
||||
|
||||
* 1.2.6
|
||||
+ `记住上次退出时的窗口位置和大小`
|
||||
- 修复了即使选项被禁用也恢复窗口位置的问题
|
||||
- 修复了窗口最小化时关闭游戏导致窗口位置被错误记录的问题
|
||||
* 1.2.5
|
||||
+ 新功能:`设置进程优先级`
|
||||
+ 新功能:`设置使用的CPU线程`
|
||||
|
||||
@@ -39,6 +39,7 @@ public static class WindowFunctions
|
||||
I18N.Add("\nEnabled CPUs: ", "\nEnabled CPUs: ", "\n使用的CPU: ");
|
||||
I18N.Add("Unknown", "Unknown", "未知");
|
||||
ProcessorDetails = WinApi.GetLogicalProcessorDetails();
|
||||
SetWindowTitle();
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
@@ -50,6 +51,7 @@ public static class WindowFunctions
|
||||
{
|
||||
_oldWndProc = WinApi.SetWindowLongPtr(gameWnd, WinApi.GWLP_WNDPROC, Marshal.GetFunctionPointerForDelegate(wndProc));
|
||||
}
|
||||
if (GamePatch.LoadLastWindowRectEnabled.Value)
|
||||
GamePatch.LoadLastWindowRect.MoveWindowPosition(true);
|
||||
|
||||
ProcessPriority.SettingChanged += (_, _) => WinApi.SetPriorityClass(WinApi.GetCurrentProcess(), ProrityFlags[ProcessPriority.Value]);
|
||||
@@ -103,12 +105,12 @@ public static class WindowFunctions
|
||||
switch ((long)wParam & 0xFFF0L)
|
||||
{
|
||||
case WinApi.SC_MOVE:
|
||||
if (!_gameLoaded) return (IntPtr)1L;
|
||||
if (GamePatch.LoadLastWindowRectEnabled.Value && !_gameLoaded) return (IntPtr)1L;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WinApi.WM_MOVING:
|
||||
if (_gameLoaded) break;
|
||||
if (!GamePatch.LoadLastWindowRectEnabled.Value || _gameLoaded) break;
|
||||
var rect = GamePatch.LastWindowRect.Value;
|
||||
if (rect is { z: 0f, w: 0f }) break;
|
||||
var x = Mathf.RoundToInt(rect.x);
|
||||
@@ -119,7 +121,7 @@ public static class WindowFunctions
|
||||
Marshal.StructureToPtr(rect2, lParam, false);
|
||||
break;
|
||||
case WinApi.WM_SIZING:
|
||||
if (_gameLoaded) break;
|
||||
if (!GamePatch.LoadLastWindowRectEnabled.Value || _gameLoaded) break;
|
||||
rect = GamePatch.LastWindowRect.Value;
|
||||
if (rect is { z: 0f, w: 0f }) break;
|
||||
x = Mathf.RoundToInt(rect.x);
|
||||
|
||||
@@ -11,11 +11,13 @@ using UXAssist.Functions;
|
||||
|
||||
namespace UXAssist.Patches;
|
||||
|
||||
public class GamePatch: PatchImpl<GamePatch>
|
||||
public class GamePatch : PatchImpl<GamePatch>
|
||||
{
|
||||
public static ConfigEntry<bool> EnableWindowResizeEnabled;
|
||||
public static ConfigEntry<bool> LoadLastWindowRectEnabled;
|
||||
|
||||
public static ConfigEntry<int> MouseCursorScaleUpMultiplier;
|
||||
|
||||
// public static ConfigEntry<bool> AutoSaveOptEnabled;
|
||||
public static ConfigEntry<bool> ConvertSavesFromPeaceEnabled;
|
||||
public static ConfigEntry<Vector4> LastWindowRect;
|
||||
@@ -26,6 +28,7 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
private static PressKeyBind _speedDownKey;
|
||||
private static PressKeyBind _speedUpKey;
|
||||
private static bool _enableGameUpsFactor = true;
|
||||
|
||||
public static bool EnableGameUpsFactor
|
||||
{
|
||||
get => _enableGameUpsFactor;
|
||||
@@ -40,6 +43,7 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
GameUpsFactor.Value = 1.0;
|
||||
return;
|
||||
}
|
||||
|
||||
GameUpsFactor.Value = Maths.Clamp(FPSController.instance.fixUPS / GameMain.tickPerSec, 0.1, 10.0);
|
||||
}
|
||||
else
|
||||
@@ -71,8 +75,6 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
I18N.Add("KEYUPSSpeedUp", "Increase logical frame rate", "提升逻辑帧率");
|
||||
I18N.Add("Logical frame rate: {0}x", "Logical frame rate: {0}x", "逻辑帧速率: {0}x");
|
||||
|
||||
WindowFunctions.SetWindowTitle();
|
||||
|
||||
EnableWindowResizeEnabled.SettingChanged += (_, _) => EnableWindowResize.Enable(EnableWindowResizeEnabled.Value);
|
||||
LoadLastWindowRectEnabled.SettingChanged += (_, _) => LoadLastWindowRect.Enable(LoadLastWindowRectEnabled.Value);
|
||||
MouseCursorScaleUpMultiplier.SettingChanged += (_, _) =>
|
||||
@@ -92,6 +94,7 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
FPSController.SetFixUPS(0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
FPSController.SetFixUPS(GameMain.tickPerSec * GameUpsFactor.Value);
|
||||
};
|
||||
}
|
||||
@@ -126,6 +129,7 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
GameUpsFactor.Value = Maths.Clamp(Math.Round((GameUpsFactor.Value - 0.5) * 2.0) / 2.0, 0.1, 10.0);
|
||||
UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead(string.Format("Logical frame rate: {0}x".Translate(), GameUpsFactor.Value));
|
||||
}
|
||||
|
||||
if (_speedUpKey.keyValue)
|
||||
{
|
||||
GameUpsFactor.Value = Maths.Clamp(Math.Round((GameUpsFactor.Value + 0.5) * 2.0) / 2.0, 0.1, 10.0);
|
||||
@@ -142,6 +146,7 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
{
|
||||
UIRoot.instance.loadGameWindow._Close();
|
||||
}
|
||||
|
||||
if (UIRoot.instance.saveGameWindow.gameObject.activeSelf)
|
||||
{
|
||||
UIRoot.instance.saveGameWindow._Close();
|
||||
@@ -166,12 +171,11 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
var wnd = WindowFunctions.FindGameWindow();
|
||||
if (wnd == IntPtr.Zero) return;
|
||||
WinApi.GetWindowRect(wnd, out var rect);
|
||||
LastWindowRect.Value = new Vector4(rect.Left, rect.Top, Screen.width, Screen.height);
|
||||
LastWindowRect.Value = new Vector4(rect.Left < 20 - Screen.width ? 0 : rect.Left, rect.Top < 20 - Screen.height ? 0 : rect.Top, Screen.width, Screen.height);
|
||||
}
|
||||
|
||||
private class EnableWindowResize: PatchImpl<EnableWindowResize>
|
||||
private class EnableWindowResize : PatchImpl<EnableWindowResize>
|
||||
{
|
||||
|
||||
private static bool _enabled;
|
||||
|
||||
protected override void OnEnable()
|
||||
@@ -214,7 +218,7 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
}
|
||||
}
|
||||
|
||||
public class LoadLastWindowRect: PatchImpl<LoadLastWindowRect>
|
||||
public class LoadLastWindowRect : PatchImpl<LoadLastWindowRect>
|
||||
{
|
||||
private static bool _loaded;
|
||||
|
||||
@@ -234,11 +238,13 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
w = 1280;
|
||||
needFix = true;
|
||||
}
|
||||
|
||||
if (h < 100)
|
||||
{
|
||||
h = 720;
|
||||
needFix = true;
|
||||
}
|
||||
|
||||
var sw = Screen.currentResolution.width;
|
||||
var sh = Screen.currentResolution.height;
|
||||
if (x + w > sw)
|
||||
@@ -246,26 +252,31 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
x = sw - w;
|
||||
needFix = true;
|
||||
}
|
||||
|
||||
if (y + h > sh)
|
||||
{
|
||||
y = sh - h;
|
||||
needFix = true;
|
||||
}
|
||||
|
||||
if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
needFix = true;
|
||||
}
|
||||
|
||||
if (y < 0)
|
||||
{
|
||||
y = 0;
|
||||
needFix = true;
|
||||
}
|
||||
|
||||
if (needFix)
|
||||
{
|
||||
LastWindowRect.Value = new Vector4(x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
MoveWindowPosition();
|
||||
}
|
||||
|
||||
@@ -289,6 +300,7 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
var h = Mathf.RoundToInt(rect.w);
|
||||
Screen.SetResolution(w, h, false);
|
||||
}
|
||||
|
||||
WinApi.SetWindowPos(wnd, IntPtr.Zero, x, y, 0, 0, 0x0235);
|
||||
}
|
||||
|
||||
@@ -332,6 +344,7 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
}
|
||||
|
||||
private static GameOption _gameOption;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UIOptionWindow), nameof(UIOptionWindow._OnOpen))]
|
||||
private static void UIOptionWindow__OnOpen_Postfix()
|
||||
@@ -496,7 +509,7 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
}
|
||||
*/
|
||||
|
||||
private class ConvertSavesFromPeace: PatchImpl<ConvertSavesFromPeace>
|
||||
private class ConvertSavesFromPeace : PatchImpl<ConvertSavesFromPeace>
|
||||
{
|
||||
private static bool _needConvert;
|
||||
|
||||
@@ -535,7 +548,7 @@ public class GamePatch: PatchImpl<GamePatch>
|
||||
}
|
||||
|
||||
[PatchSetCallbackFlag(PatchCallbackFlag.CallOnDisableAfterUnpatch)]
|
||||
private class MouseCursorScaleUp: PatchImpl<MouseCursorScaleUp>
|
||||
private class MouseCursorScaleUp : PatchImpl<MouseCursorScaleUp>
|
||||
{
|
||||
public static bool NeedReloadCursors;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
|
||||
<Description>DSP MOD - UXAssist</Description>
|
||||
<Version>1.2.5</Version>
|
||||
<Version>1.2.6</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageId>UXAssist</PackageId>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "UXAssist",
|
||||
"version_number": "1.2.5",
|
||||
"version_number": "1.2.6",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist",
|
||||
"description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁",
|
||||
"dependencies": [
|
||||
|
||||
Reference in New Issue
Block a user