-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4018264
commit 7be934c
Showing
22 changed files
with
640 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import math | ||
from dataclasses import dataclass | ||
|
||
@dataclass | ||
class ScreenInfo: | ||
width: int | ||
height: int | ||
|
||
@property | ||
def ratio(self): | ||
gcd = math.gcd(self.width, self.height) | ||
return (self.width // gcd, self.height // gcd) | ||
|
||
def scaleWidth(self, value: int|float|tuple): | ||
return self._scale(value, self.width, 1920, 1680) | ||
|
||
def scaleHeight(self, value: int|float|tuple): | ||
return self._scale(value, self.height, 1080, 1050) | ||
|
||
def _scale(self, value, dimension, base16_9, base8_5): | ||
if isinstance(value, tuple): | ||
if len(value) == 2: | ||
v16_9, v8_5 = value | ||
elif len(value) == 3: | ||
v16_9 = value[0] + (value[2][0] if isinstance(value[2], tuple) else value[2]) | ||
v8_5 = value[1] + (value[2][1] if isinstance(value[2], tuple) else value[2]) | ||
else: | ||
v16_9 = v8_5 = value | ||
|
||
if self.ratio == (8, 5): | ||
if not isinstance(value, tuple): base8_5 = base16_9 | ||
return int(v8_5 / base8_5 * dimension) | ||
|
||
return int(v16_9 / base16_9 * dimension) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,31 @@ | ||
import logging | ||
import pygetwindow as gw | ||
|
||
from game.screenInfo import ScreenInfo | ||
from properties.config import DPI_SCALING | ||
|
||
logger = logging.getLogger('WindowManager') | ||
|
||
class WindowManager: | ||
_width = 1920 | ||
_height = 1080 | ||
|
||
@classmethod | ||
def getWindowSize(cls): | ||
"""Update and return the size of the active window, adjusted for DPI scaling.""" | ||
try: | ||
window = gw.getActiveWindow() | ||
if window is None: | ||
raise ValueError("No active window found.") | ||
cls._width = int(window.width / DPI_SCALING) | ||
cls._height = int(window.height / DPI_SCALING) | ||
return cls._width, cls._height | ||
except Exception as e: | ||
logger.error(f"Error getting window size: {e}") | ||
return cls._width, cls._height | ||
|
||
@classmethod | ||
def getWidth(cls): | ||
"""Return the width of the active window.""" | ||
return cls._width | ||
class WindowManager: | ||
_screen_info = ScreenInfo(1920, 1080) | ||
|
||
@classmethod | ||
def getHeight(cls): | ||
"""Return the height of the active window.""" | ||
return cls._height | ||
@classmethod | ||
def getWindowSize(cls): | ||
try: | ||
window = gw.getActiveWindow() | ||
if window is None: | ||
raise ValueError("No active window found.") | ||
cls._screen_info = ScreenInfo( | ||
int(window.width / DPI_SCALING), | ||
int(window.height / DPI_SCALING) | ||
) | ||
return cls._screen_info | ||
except Exception as e: | ||
logger.error(f"Error getting window size: {e}") | ||
return cls._screen_info | ||
|
||
@classmethod | ||
def updateWindowSize(cls): | ||
"""Update the stored window size.""" | ||
cls.getWindowSize() | ||
@classmethod | ||
def getScreenInfo(cls): | ||
cls.getWindowSize() | ||
return cls._screen_info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
pyuac | ||
PySide6-Fluent-Widgets | ||
rapidocr-onnxruntime | ||
mss | ||
opencv-python | ||
pygetwindow | ||
pyinstaller | ||
pyperclip | ||
pyuac==0.0.3 | ||
PySide6-Fluent-Widgets==1.6.5 | ||
rapidocr-onnxruntime==1.3.24 | ||
mss==9.0.2 | ||
opencv-python==4.10.0.84 | ||
pygetwindow==0.0.9 | ||
pyinstaller==6.10.0 | ||
pyperclip==1.9.0 | ||
babel==2.16.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.