mirror of
https://github.com/csd4ni3l/aim-trainer.git
synced 2026-01-01 04:03:42 +01:00
Initial version
This commit is contained in:
33
utils/utils.py
Normal file
33
utils/utils.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from panda3d.core import GraphicsPipeSelection
|
||||
|
||||
def get_closest_resolution():
|
||||
allowed_resolutions = [(1366, 768), (1440, 900), (1600,900), (1920,1080), (2560,1440), (3840,2160)]
|
||||
pipe = GraphicsPipeSelection.getGlobalPtr().makeDefaultPipe()
|
||||
|
||||
if not pipe:
|
||||
screen_width, screen_height = min(allowed_resolutions, key=lambda res: res[0] * res[1])
|
||||
else:
|
||||
screen_width = pipe.getDisplayWidth()
|
||||
screen_height = pipe.getDisplayHeight()
|
||||
|
||||
if (screen_width, screen_height) in allowed_resolutions:
|
||||
if not allowed_resolutions.index((screen_width, screen_height)) == 0:
|
||||
closest_resolution = allowed_resolutions[allowed_resolutions.index((screen_width, screen_height))-1]
|
||||
else:
|
||||
closest_resolution = (screen_width, screen_height)
|
||||
else:
|
||||
target_width, target_height = screen_width // 2, screen_height // 2
|
||||
|
||||
closest_resolution = min(
|
||||
allowed_resolutions,
|
||||
key=lambda res: abs(res[0] - target_width) + abs(res[1] - target_height)
|
||||
)
|
||||
return closest_resolution
|
||||
|
||||
class FakePyPresence():
|
||||
def __init__(self):
|
||||
...
|
||||
def update(self, *args, **kwargs):
|
||||
...
|
||||
def close(self, *args, **kwargs):
|
||||
...
|
||||
Reference in New Issue
Block a user