diff --git a/MANIFEST.in b/MANIFEST.in index 4a765de..097c810 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,7 +2,6 @@ include LICENSE include README.md include requirements.txt include fishy/icon.ico -include fishy/ProvisionsChalutier.zip include fishy/fishybot_logo.png include fishy/sound.mp3 include fishy/beep.wav diff --git a/fishy/ProvisionsChalutier.zip b/fishy/ProvisionsChalutier.zip deleted file mode 100644 index 58f9774..0000000 Binary files a/fishy/ProvisionsChalutier.zip and /dev/null differ diff --git a/fishy/__main__.py b/fishy/__main__.py index 37414ca..d5ff1e3 100644 --- a/fishy/__main__.py +++ b/fishy/__main__.py @@ -12,6 +12,7 @@ from fishy.engine.common.event_handler import EngineEventHandler from fishy.gui import GUI, splash, update_dialog from fishy.helper import hotkey from fishy.helper.config import config +from fishy.constants import chalutier, lam2 def check_window_name(title): @@ -58,7 +59,10 @@ def initialize(window_to_hide): helper.install_thread_excepthook() sys.excepthook = helper.unhandled_exception_logging - helper.check_addon("ProvisionsChalutier") + if not config.get("addoninstalled", False) and not helper.addon_exists(chalutier[0]): + helper.install_addon(*chalutier) + helper.install_addon(*lam2) + config.set("addoninstalled", True) def main(): diff --git a/fishy/constants.py b/fishy/constants.py new file mode 100644 index 0000000..e03e92b --- /dev/null +++ b/fishy/constants.py @@ -0,0 +1,3 @@ +apiversion = 1 +chalutier = ("Chalutier", "https://www.esoui.com/downloads/dl2934/1616505502-Chalutier_1.1.1.zip") +lam2 = ("LibAddonMenu-2.0", "https://www.esoui.com/downloads/dl7/LibAddonMenu-2.0r32.zip") \ No newline at end of file diff --git a/fishy/engine/semifisher/pixel_loc.py b/fishy/engine/semifisher/pixel_loc.py index 2b018e4..90854de 100644 --- a/fishy/engine/semifisher/pixel_loc.py +++ b/fishy/engine/semifisher/pixel_loc.py @@ -57,7 +57,7 @@ class PixelLoc: def config(): """ Uses the game window to get an image of the game screen - then uses `GetKeypointFromImage()` to find the ProvisionsChalutier pixel location + then uses `GetKeypointFromImage()` to find the Chalutier pixel location :return: false if pixel loc not found """ diff --git a/fishy/gui/main_gui.py b/fishy/gui/main_gui.py index e5fa2b8..6f9fdf1 100644 --- a/fishy/gui/main_gui.py +++ b/fishy/gui/main_gui.py @@ -14,6 +14,7 @@ from fishy.helper import hotkey from .discord_login import discord_login from ..helper.config import config from ..helper.hotkey import Key +from ..constants import chalutier, lam2 if typing.TYPE_CHECKING: from . import GUI @@ -58,6 +59,16 @@ def _create(gui: 'GUI'): if config.get("dont_ask_update", False): filemenu.add_command(label="Update", command=helper.update) + def installer(): + if filemenu.entrycget(4, 'label') == "Remove Chalutier": + helper.remove_addon(chalutier[0]) + filemenu.entryconfigure(4, label="Install Chalutier") + else: + helper.install_addon(*chalutier) + helper.install_addon(*lam2) + filemenu.entryconfigure(4, label="Remove Chalutier") + chaEntry = "Remove Chalutier" if helper.addon_exists(chalutier[0]) else "Install Chalutier" + filemenu.add_command(label=chaEntry, command=installer) menubar.add_cascade(label="Options", menu=filemenu) debug_menu = Menu(menubar, tearoff=0) diff --git a/fishy/helper/__init__.py b/fishy/helper/__init__.py index 272a0af..9a0750f 100644 --- a/fishy/helper/__init__.py +++ b/fishy/helper/__init__.py @@ -1,4 +1,4 @@ from .auto_update import auto_upgrade, upgrade_avail, versions from .config import Config from .helper import open_web, initialize_uid, install_thread_excepthook, unhandled_exception_logging, manifest_file, \ - create_shortcut_first, check_addon, restart, create_shortcut, not_implemented, update + create_shortcut_first, addon_exists, install_addon, remove_addon, restart, create_shortcut, not_implemented, update diff --git a/fishy/helper/helper.py b/fishy/helper/helper.py index 99cab4a..6f50f7a 100644 --- a/fishy/helper/helper.py +++ b/fishy/helper/helper.py @@ -1,10 +1,13 @@ import logging import os +import shutil import sys import threading import time import traceback import webbrowser +import requests +from io import BytesIO from threading import Thread from zipfile import ZipFile @@ -142,23 +145,34 @@ def create_shortcut(anti_ghosting: bool): logging.error("Couldn't create shortcut") +def get_addondir(): + # noinspection PyUnresolvedReferences + from win32com.shell import shell, shellcon + documents = shell.SHGetFolderPath(0, shellcon.CSIDL_PERSONAL, None, 0) + return os.path.join(documents, "Elder Scrolls Online", "live", "Addons") + + +def addon_exists(name): + return os.path.exists(os.path.join(get_addondir(), name)) + + # noinspection PyBroadException -def check_addon(name): - """ - Extracts the addon from zip and installs it into the AddOn folder of eso - """ +def install_addon(name, url): try: - # noinspection PyUnresolvedReferences - from win32com.shell import shell, shellcon - documents = shell.SHGetFolderPath(0, shellcon.CSIDL_PERSONAL, None, 0) - addon_dir = os.path.join(documents, "Elder Scrolls Online", "live", "Addons") - if not os.path.exists(os.path.join(addon_dir, name)): - logging.info(f"{name} Addon not found, installing it...") - with ZipFile(manifest_file(f"{name}.zip"), 'r') as z: - z.extractall(path=addon_dir) - logging.info("Please make sure you enable \"Allow outdated addons\" in-game") - except Exception: - logging.error("couldn't install addon, try doing it manually") + r = requests.get(url, stream=True) + z = ZipFile(BytesIO(r.content)) + z.extractall(path=get_addondir()) + logging.info("Add-On "+name+" installed successfully!\nPlease make sure to enable \"Allow outdated addons\" in ESO") + except Exception as ex: + logging.error("Could not install Add-On "+name+", try doing it manually") + + +def remove_addon(name): + try: + shutil.rmtree(os.path.join(get_addondir(), name)) + logging.info("Add-On "+name+" removed!") + except FileNotFoundError: + pass def get_documents(): diff --git a/fishy/web/constants.py b/fishy/web/constants.py deleted file mode 100644 index 636230e..0000000 --- a/fishy/web/constants.py +++ /dev/null @@ -1 +0,0 @@ -apiversion = 1 diff --git a/fishy/web/web.py b/fishy/web/web.py index 03ecb70..a6b30e6 100644 --- a/fishy/web/web.py +++ b/fishy/web/web.py @@ -6,7 +6,7 @@ from fishy import helper from . import urls from .decorators import fallback, uses_session from ..helper.config import config -from .constants import apiversion +from ..constants import apiversion _session_id = None