mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
Merge pull request #185 from Femi-lawal/main
chore: make PyAutoGUI default
This commit is contained in:
commit
8a9d621086
@ -94,11 +94,23 @@ class D3DShot(IScreenShot):
|
||||
def grab(self) -> ndarray:
|
||||
return self.d3.screenshot()
|
||||
|
||||
|
||||
LIBS = [MSS, PyAutoGUI, D3DShot]
|
||||
|
||||
LIBS = [PyAutoGUI, MSS, D3DShot]
|
||||
|
||||
def create() -> IScreenShot:
|
||||
lib = LIBS[config.get("sslib", 0)]
|
||||
logging.debug(f"Using {lib.__name__} screenshot lib")
|
||||
return lib()
|
||||
# Initialize a variable to hold the preferred library index
|
||||
preferred_lib_index = config.get("sslib", 0)
|
||||
# Create a list of library indices to try, starting with the preferred one
|
||||
lib_indices = [preferred_lib_index] + [i for i in range(len(LIBS)) if i != preferred_lib_index]
|
||||
|
||||
for index in lib_indices:
|
||||
lib = LIBS[index]
|
||||
try:
|
||||
lib_instance = lib()
|
||||
if lib_instance.setup():
|
||||
logging.debug(f"Using {lib.__name__} as the screenshot library.")
|
||||
return lib_instance
|
||||
except Exception as e:
|
||||
logging.warning(f"Setup failed for {lib.__name__} with error: {str(e)}. Trying next library...")
|
||||
|
||||
logging.error("No suitable screenshot library found. Please check your configuration.")
|
||||
return None
|
||||
|
@ -36,6 +36,12 @@ def init():
|
||||
Finds the game window, and calculates the offset to remove the title bar
|
||||
"""
|
||||
WindowServer.sslib = screenshot.create()
|
||||
# Check if the screenshot library was successfully created
|
||||
if WindowServer.sslib is None:
|
||||
logging.error("Failed to create screenshot library instance")
|
||||
WindowServer.status = Status.CRASHED
|
||||
return
|
||||
|
||||
WindowServer.status = Status.RUNNING
|
||||
WindowServer.crop = os_services.get_game_window_rect()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user