Skip to content

Commit

Permalink
Supported the ratio closed to 21:9
Browse files Browse the repository at this point in the history
Tested under resolution 2560x1080. [#3]
  • Loading branch information
emako committed Nov 8, 2022
1 parent eebe68d commit adb84ee
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/GenshinWoodmen/Core/LaunchCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,21 @@ public static async Task<bool> Logout()
}
await JiggingProcessor.Delay(950);
RECT rect = NativeMethods.GetWindowRECT(hwnd);
NativeMethods.SetCursorPos(rect.Left + 20, rect.Bottom - 30);
double ratio = (rect.Right - rect.Left) / (double)(rect.Bottom - rect.Top);
(int xclose, int yclose) = (new Func<int>(() =>
{
// Assert as 21:9 even if low resolution (calced discarded `SystemInformation.CaptionHeight`)
if (ratio >= 2.333d) return 85;
else return 20;
}).Invoke(), -30);
NativeMethods.SetCursorPos(rect.Left + xclose, rect.Bottom + yclose);
await JiggingProcessor.Delay(100);
UserSimulator.Input.Mouse.LeftButtonClick(); // Exit
await JiggingProcessor.Delay(800);
(double cx, double cy) = ((rect.Right - rect.Left) / 2d, (rect.Bottom - rect.Top) / 2d);
double ratio = (rect.Right - rect.Left) / (double)(rect.Bottom - rect.Top);
(double xfactor, double yfactor) = (1.1d, new Func<double>(() =>
{
// Inspected from ratio (such as 1.33, 1.5, 1.6, 1.78), calced without `SystemInformation.CaptionHeight` actually.
// TODO: Calc with `SystemInformation.CaptionHeight`.
// Inspected from ratio (such as 1.33, 1.5, 1.6, 1.78), calced discarded `SystemInformation.CaptionHeight` actually.
if (ratio >= 1.6d) return 1.4d;
else if (ratio >= 1.5d) return 1.35d;
else if (ratio >= 1.4d) return 1.33d;
Expand Down Expand Up @@ -179,9 +184,9 @@ public static async Task<IntPtr> Launch(int? delayMs = null, RelaunchMethod rela

internal class LaunchParameter
{
public bool? IsFullScreen { get; set; } = null;
public int? ScreenWidth { get; set; } = null;
public int? ScreenHeight { get; set; } = null;
public bool? IsFullScreen { get; set; } = null!;
public int? ScreenWidth { get; set; } = null!;
public int? ScreenHeight { get; set; } = null!;

public override string ToString()
{
Expand Down

0 comments on commit adb84ee

Please sign in to comment.