mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
created interface and proxy for os services
This commit is contained in:
parent
455976a018
commit
6000e9022e
@ -16,6 +16,7 @@ from fishy.helper.active_poll import active
|
||||
from fishy.helper.config import config
|
||||
from fishy.helper.hotkey.hotkey_process import hotkey
|
||||
from fishy.helper.migration import Migration
|
||||
from fishy.osservices.os_services import os_services
|
||||
|
||||
|
||||
def check_window_name(title):
|
||||
@ -56,6 +57,7 @@ def initialize(window_to_hide):
|
||||
def main():
|
||||
print("launching please wait...")
|
||||
|
||||
os_services.init()
|
||||
config.init()
|
||||
if not check_eula():
|
||||
return
|
||||
|
0
fishy/osservices/__init__.py
Normal file
0
fishy/osservices/__init__.py
Normal file
29
fishy/osservices/linux.py
Normal file
29
fishy/osservices/linux.py
Normal file
@ -0,0 +1,29 @@
|
||||
from typing import Tuple
|
||||
|
||||
from fishy.osservices.os_services import IOSServices
|
||||
|
||||
|
||||
class Linux(IOSServices):
|
||||
def hide_terminal(self):
|
||||
pass
|
||||
|
||||
def create_shortcut(self):
|
||||
pass
|
||||
|
||||
def get_documents_path(self) -> str:
|
||||
pass
|
||||
|
||||
def is_admin(self) -> bool:
|
||||
pass
|
||||
|
||||
def get_eso_config_path(self) -> str:
|
||||
pass
|
||||
|
||||
def is_eso_active(self) -> bool:
|
||||
pass
|
||||
|
||||
def get_monitor_rect(self):
|
||||
pass
|
||||
|
||||
def get_game_window_rect(self) -> Tuple[int, int, int, int]:
|
||||
pass
|
76
fishy/osservices/os_services.py
Normal file
76
fishy/osservices/os_services.py
Normal file
@ -0,0 +1,76 @@
|
||||
import logging
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Tuple, Optional
|
||||
import platform
|
||||
|
||||
|
||||
class IOSServices(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def hide_terminal(self):
|
||||
"""
|
||||
:return: hides the terminal used to launch fishy
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def create_shortcut(self):
|
||||
"""
|
||||
creates a new shortcut on desktop
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_documents_path(self) -> str:
|
||||
"""
|
||||
:return: documents path to save config file
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def is_admin(self) -> bool:
|
||||
"""
|
||||
:return: true if has elevated rights
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_eso_config_path(self) -> str:
|
||||
"""
|
||||
:return: path location of the ElderScrollsOnline Folder (in documents) which has "live" folder in it
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def is_eso_active(self) -> bool:
|
||||
"""
|
||||
:return: true if eso is the active window
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_monitor_rect(self):
|
||||
"""
|
||||
:return: [top, left, height, width] of monitor which has game running in it
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_game_window_rect(self) -> Tuple[int, int, int, int]:
|
||||
"""
|
||||
:return: location of the game window without any frame
|
||||
"""
|
||||
|
||||
|
||||
class MyMetaclass(type):
|
||||
def __getattr__(cls, name):
|
||||
return getattr(os_services._instance, name)
|
||||
|
||||
|
||||
class os_services(metaclass=MyMetaclass):
|
||||
_instance: Optional[IOSServices] = None
|
||||
|
||||
@staticmethod
|
||||
def init():
|
||||
os_name = platform.system()
|
||||
if os_name == "Windows":
|
||||
from fishy.osservices.windows import Windows
|
||||
os_services._instance = Windows()
|
||||
elif os_name == "Linux":
|
||||
from fishy.osservices.linux import Linux
|
||||
os_services._instance = Linux()
|
||||
else:
|
||||
logging.error("Platform not supported")
|
29
fishy/osservices/windows.py
Normal file
29
fishy/osservices/windows.py
Normal file
@ -0,0 +1,29 @@
|
||||
from typing import Tuple
|
||||
|
||||
from fishy.osservices.os_services import IOSServices
|
||||
|
||||
|
||||
class Windows(IOSServices):
|
||||
def hide_terminal(self):
|
||||
pass
|
||||
|
||||
def create_shortcut(self):
|
||||
pass
|
||||
|
||||
def get_documents_path(self) -> str:
|
||||
pass
|
||||
|
||||
def is_admin(self) -> bool:
|
||||
pass
|
||||
|
||||
def get_eso_config_path(self) -> str:
|
||||
pass
|
||||
|
||||
def is_eso_active(self) -> bool:
|
||||
pass
|
||||
|
||||
def get_monitor_rect(self):
|
||||
pass
|
||||
|
||||
def get_game_window_rect(self) -> Tuple[int, int, int, int]:
|
||||
pass
|
Loading…
Reference in New Issue
Block a user