diff --git a/Classes/Services/DetectionService.cs b/Classes/Services/DetectionService.cs index 13e1180..287afd7 100644 --- a/Classes/Services/DetectionService.cs +++ b/Classes/Services/DetectionService.cs @@ -212,7 +212,7 @@ public static bool AutoDetectGame(int processId, string executablePath, nint win var aspectRatio = GetAspectRatio(windowSize.GetWidth(), windowSize.GetHeight()); bool isValidAspectRatio = IsValidAspectRatio(windowSize.GetWidth(), windowSize.GetHeight()); bool isWhitelistedClass = classWhitelist.Where(c => className.ToLower().Contains(c)).Any() || classWhitelist.Where(c => className.ToLower().Replace(" ", "").Contains(c)).Any(); - detailedWindowStr += $"[{windowSize.GetWidth()}x{windowSize.GetHeight()}, {aspectRatio}]"; + detailedWindowStr += $"[{windowSize}, {aspectRatio}]"; // if there is no matched game, lets try to make assumptions from the process given the following information: // 1. window size & aspect ratio diff --git a/Classes/Services/WindowService.cs b/Classes/Services/WindowService.cs index c538a45..1fc4a37 100644 --- a/Classes/Services/WindowService.cs +++ b/Classes/Services/WindowService.cs @@ -210,7 +210,7 @@ public static IntPtr GetWindowHandleByProcessId(int processId, bool lazy = false } [StructLayout(LayoutKind.Sequential)] - public struct Rect(int left, int top, int right, int bottom) { + public struct Rect(int left = 0, int top = 0, int right = 0, int bottom = 0) { public int Left = left, Top = top, Right = right, Bottom = bottom; public int GetWidth() { @@ -221,8 +221,18 @@ public int GetHeight() { return Bottom - Top; } - public string GetSizeStr() { - return GetWidth() + "x" + GetHeight(); + public override string ToString() { + return $"{GetWidth()}x{GetHeight()}"; + } + + public static bool operator ==(Rect left, Rect right) => left.Equals(right); + public static bool operator !=(Rect left, Rect right) => !left.Equals(right); + + public override bool Equals(object obj) { + if (obj is Rect rect) { + return GetWidth() == rect.GetWidth() && GetHeight() == rect.GetHeight(); + } + return false; } }