2020-05-14 02:03:13 +00:00
|
|
|
import logging
|
|
|
|
import time
|
2021-05-09 06:32:36 +00:00
|
|
|
import tkinter as tk
|
|
|
|
import tkinter.ttk as ttk
|
2021-05-09 07:05:51 +00:00
|
|
|
import typing
|
2020-06-25 01:22:39 +00:00
|
|
|
|
2020-05-14 02:03:13 +00:00
|
|
|
from ttkthemes import ThemedTk
|
|
|
|
|
2020-06-25 01:22:39 +00:00
|
|
|
from fishy import helper
|
2020-06-27 15:23:32 +00:00
|
|
|
from fishy.helper import hotkey
|
2021-05-09 07:05:51 +00:00
|
|
|
from fishy.web import web
|
|
|
|
|
|
|
|
from ..constants import chalutier, lam2
|
2020-10-17 19:06:07 +00:00
|
|
|
from ..helper.config import config
|
2020-10-15 01:26:31 +00:00
|
|
|
from ..helper.hotkey import Key
|
2021-05-09 07:05:51 +00:00
|
|
|
from .discord_login import discord_login
|
2020-05-23 22:14:09 +00:00
|
|
|
|
2020-05-14 02:03:13 +00:00
|
|
|
if typing.TYPE_CHECKING:
|
|
|
|
from . import GUI
|
|
|
|
|
|
|
|
|
|
|
|
def _apply_theme(gui: 'GUI'):
|
2020-10-17 19:06:07 +00:00
|
|
|
dark = config.get("dark_mode", True)
|
2020-05-14 02:03:13 +00:00
|
|
|
gui._root["theme"] = "equilux" if dark else "breeze"
|
|
|
|
gui._console["background"] = "#707070" if dark else "#ffffff"
|
|
|
|
gui._console["fg"] = "#ffffff" if dark else "#000000"
|
|
|
|
|
|
|
|
|
2020-10-18 00:50:25 +00:00
|
|
|
# noinspection PyProtectedMember
|
2020-05-14 02:03:13 +00:00
|
|
|
def _create(gui: 'GUI'):
|
2020-06-25 16:39:05 +00:00
|
|
|
engines = gui.engines
|
2020-06-01 12:58:18 +00:00
|
|
|
|
2020-05-14 02:03:13 +00:00
|
|
|
gui._root = ThemedTk(theme="equilux", background=True)
|
|
|
|
gui._root.title("Fishybot for Elder Scrolls Online")
|
|
|
|
gui._root.iconbitmap(helper.manifest_file('icon.ico'))
|
|
|
|
|
|
|
|
# region menu
|
2021-05-09 06:32:36 +00:00
|
|
|
menubar = tk.Menu(gui._root)
|
2020-05-14 02:03:13 +00:00
|
|
|
|
2021-05-09 06:32:36 +00:00
|
|
|
filemenu = tk.Menu(menubar, tearoff=0)
|
2020-10-29 21:24:52 +00:00
|
|
|
|
2021-03-07 08:40:45 +00:00
|
|
|
login = web.is_logged_in()
|
2021-05-09 06:32:36 +00:00
|
|
|
gui.login = tk.IntVar()
|
2020-10-29 22:04:43 +00:00
|
|
|
gui.login.set(1 if login > 0 else 0)
|
2021-05-09 06:32:36 +00:00
|
|
|
state = tk.DISABLED if login == -1 else tk.ACTIVE
|
2020-10-29 22:04:43 +00:00
|
|
|
filemenu.add_checkbutton(label="Login", command=lambda: discord_login(gui), variable=gui.login, state=state)
|
2020-10-13 13:49:39 +00:00
|
|
|
filemenu.add_command(label="Create Shortcut", command=lambda: helper.create_shortcut(False))
|
2020-10-29 21:24:52 +00:00
|
|
|
# filemenu.add_command(label="Create Anti-Ghost Shortcut", command=lambda: helper.create_shortcut(True))
|
2020-05-14 02:03:13 +00:00
|
|
|
|
|
|
|
def _toggle_mode():
|
2020-10-17 19:06:07 +00:00
|
|
|
config.set("dark_mode", not config.get("dark_mode", True))
|
2020-05-14 02:03:13 +00:00
|
|
|
gui._start_restart = True
|
|
|
|
|
2021-05-09 06:32:36 +00:00
|
|
|
dark_mode_var = tk.IntVar()
|
2020-10-17 19:06:07 +00:00
|
|
|
dark_mode_var.set(int(config.get('dark_mode', True)))
|
2020-05-14 02:03:13 +00:00
|
|
|
filemenu.add_checkbutton(label="Dark Mode", command=_toggle_mode,
|
|
|
|
variable=dark_mode_var)
|
2021-02-14 18:10:11 +00:00
|
|
|
if config.get("dont_ask_update", False):
|
|
|
|
filemenu.add_command(label="Update", command=helper.update)
|
2020-05-14 02:03:13 +00:00
|
|
|
|
2021-03-24 16:58:35 +00:00
|
|
|
def installer():
|
|
|
|
if filemenu.entrycget(4, 'label') == "Remove Chalutier":
|
2021-03-26 09:35:00 +00:00
|
|
|
if helper.remove_addon(chalutier[0]) == 0:
|
|
|
|
filemenu.entryconfigure(4, label="Install Chalutier")
|
2021-03-24 16:58:35 +00:00
|
|
|
else:
|
2021-03-26 09:35:00 +00:00
|
|
|
r = helper.install_addon(*chalutier)
|
|
|
|
r += helper.install_addon(*lam2)
|
|
|
|
if r == 0:
|
|
|
|
filemenu.entryconfigure(4, label="Remove Chalutier")
|
2021-03-24 16:58:35 +00:00
|
|
|
chaEntry = "Remove Chalutier" if helper.addon_exists(chalutier[0]) else "Install Chalutier"
|
|
|
|
filemenu.add_command(label=chaEntry, command=installer)
|
2020-10-29 21:24:52 +00:00
|
|
|
menubar.add_cascade(label="Options", menu=filemenu)
|
2020-05-14 02:03:13 +00:00
|
|
|
|
2021-05-09 06:32:36 +00:00
|
|
|
debug_menu = tk.Menu(menubar, tearoff=0)
|
2020-05-14 02:03:13 +00:00
|
|
|
debug_menu.add_command(label="Check PixelVal",
|
2020-05-19 03:11:58 +00:00
|
|
|
command=lambda: gui.engine.check_pixel_val())
|
2020-05-14 02:03:13 +00:00
|
|
|
|
2021-05-09 06:32:36 +00:00
|
|
|
debug_var = tk.IntVar()
|
2020-10-17 19:06:07 +00:00
|
|
|
debug_var.set(int(config.get('debug', False)))
|
2020-05-14 02:03:13 +00:00
|
|
|
|
|
|
|
def keep_console():
|
2020-10-17 19:06:07 +00:00
|
|
|
config.set("debug", bool(debug_var.get()))
|
2020-05-14 02:03:13 +00:00
|
|
|
logging.debug("Restart to update the changes")
|
|
|
|
|
|
|
|
debug_menu.add_checkbutton(label="Keep Console", command=keep_console, variable=debug_var)
|
|
|
|
debug_menu.add_command(label="Restart", command=helper.restart)
|
|
|
|
menubar.add_cascade(label="Debug", menu=debug_menu)
|
|
|
|
|
2021-05-09 06:32:36 +00:00
|
|
|
help_menu = tk.Menu(menubar, tearoff=0)
|
2020-05-14 02:03:13 +00:00
|
|
|
help_menu.add_command(label="Need Help?", command=lambda: helper.open_web("http://discord.definex.in"))
|
|
|
|
help_menu.add_command(label="Donate", command=lambda: helper.open_web("https://paypal.me/AdamSaudagar"))
|
|
|
|
menubar.add_cascade(label="Help", menu=help_menu)
|
|
|
|
|
|
|
|
gui._root.config(menu=menubar)
|
|
|
|
# endregion
|
|
|
|
|
|
|
|
# region console
|
2021-05-09 06:32:36 +00:00
|
|
|
gui._console = tk.Text(gui._root, state='disabled', wrap='none', background="#707070", fg="#ffffff")
|
|
|
|
gui._console.pack(fill=tk.BOTH, expand=True, pady=(15, 15), padx=(10, 10))
|
|
|
|
gui._console.mark_set("sentinel", tk.INSERT)
|
|
|
|
gui._console.config(state=tk.DISABLED)
|
2020-05-14 02:03:13 +00:00
|
|
|
# endregion
|
|
|
|
|
|
|
|
# region controls
|
2021-05-09 06:32:36 +00:00
|
|
|
start_frame = ttk.Frame(gui._root)
|
2020-05-14 02:03:13 +00:00
|
|
|
|
2021-05-09 06:32:36 +00:00
|
|
|
gui._engine_var = tk.StringVar(start_frame)
|
2020-05-23 22:14:09 +00:00
|
|
|
labels = list(engines.keys())
|
2020-10-17 19:06:07 +00:00
|
|
|
last_started = config.get("last_started", labels[0])
|
2021-05-09 06:32:36 +00:00
|
|
|
gui._engine_select = ttk.OptionMenu(start_frame, gui._engine_var, last_started, *labels)
|
|
|
|
gui._engine_select.pack(side=tk.LEFT)
|
2020-05-14 02:03:13 +00:00
|
|
|
|
2021-05-09 06:32:36 +00:00
|
|
|
gui._config_button = ttk.Button(start_frame, text="⚙", width=0, command=lambda: engines[gui._engine_var.get()][0]())
|
|
|
|
gui._config_button.pack(side=tk.RIGHT)
|
2020-05-14 02:03:13 +00:00
|
|
|
|
2021-05-09 06:32:36 +00:00
|
|
|
gui._start_button = ttk.Button(start_frame, text=gui._get_start_stop_text(), width=25,
|
2021-05-09 09:09:26 +00:00
|
|
|
command=gui.funcs.start_engine)
|
2021-05-09 06:32:36 +00:00
|
|
|
gui._start_button.pack(side=tk.RIGHT)
|
2020-05-14 02:03:13 +00:00
|
|
|
|
2021-05-09 06:32:36 +00:00
|
|
|
start_frame.pack(padx=(10, 10), pady=(5, 15), fill=tk.X)
|
2020-05-14 02:03:13 +00:00
|
|
|
# endregion
|
|
|
|
|
|
|
|
_apply_theme(gui)
|
|
|
|
gui._root.update()
|
|
|
|
gui._root.minsize(gui._root.winfo_width() + 10, gui._root.winfo_height() + 10)
|
2020-11-30 21:04:33 +00:00
|
|
|
if config.get("win_loc") is not None:
|
|
|
|
gui._root.geometry(config.get("win_loc"))
|
2020-05-14 02:03:13 +00:00
|
|
|
|
2020-10-15 01:26:31 +00:00
|
|
|
hotkey.set_hotkey(Key.F9, gui.funcs.start_engine)
|
2020-06-25 18:43:53 +00:00
|
|
|
|
2020-10-18 00:50:25 +00:00
|
|
|
# noinspection PyProtectedMember
|
2020-05-14 02:03:13 +00:00
|
|
|
def set_destroy():
|
2020-10-18 00:50:25 +00:00
|
|
|
if gui._bot_running:
|
2021-05-09 06:32:36 +00:00
|
|
|
if not tk.messagebox.askyesno(title="Quit?", message="Bot engine running. Quit Anyway?"):
|
2020-12-08 10:56:48 +00:00
|
|
|
return
|
2020-11-30 21:04:33 +00:00
|
|
|
|
|
|
|
config.set("win_loc", gui._root.geometry())
|
|
|
|
gui._destroyed = True
|
2020-05-14 02:03:13 +00:00
|
|
|
|
|
|
|
gui._root.protocol("WM_DELETE_WINDOW", set_destroy)
|
|
|
|
gui._destroyed = False
|
|
|
|
|
|
|
|
while True:
|
|
|
|
gui._root.update()
|
2020-05-19 03:11:58 +00:00
|
|
|
gui._clear_function_queue()
|
2020-05-14 02:03:13 +00:00
|
|
|
if gui._start_restart:
|
|
|
|
gui._root.destroy()
|
|
|
|
gui._root.quit()
|
|
|
|
gui._start_restart = False
|
|
|
|
gui.create()
|
|
|
|
if gui._destroyed:
|
2020-05-19 03:11:58 +00:00
|
|
|
gui.engine.quit()
|
2020-05-14 02:03:13 +00:00
|
|
|
break
|
|
|
|
time.sleep(0.01)
|