0.3.5 reworked ui for multiple bot engine support

- shifted config into a toplevel
- logs before starting update
This commit is contained in:
DESKTOP-JVKHS7I\Adam 2020-05-24 03:44:09 +05:30
parent c8510d56cf
commit cd1b2dd8f6
10 changed files with 123 additions and 69 deletions

View File

@ -1,2 +1,2 @@
from fishy.__main__ import main
__version__ = "0.3.4"
__version__ = "0.3.5"

View File

@ -47,12 +47,15 @@ class SemiFisherEngine:
def gui(self):
return self.get_gui().funcs
def start_fishing(self, action_key: str, borderless: bool, collect_r: bool):
def start_fishing(self):
"""
Starts the fishing
code explained in comments in detail
"""
action_key = self.config.get("action_key", "e")
borderless = self.config.get("borderless", False)
# initialize widow
# noinspection PyUnresolvedReferences
try:
@ -63,7 +66,7 @@ class SemiFisherEngine:
return
# initializes fishing modes and their callbacks
FishingMode("hook", 0, HookEvent(action_key, collect_r))
FishingMode("hook", 0, HookEvent(action_key, False))
FishingMode("stick", 1, StickEvent())
FishingMode("look", 2, LookEvent(action_key))
FishingMode("idle", 3, IdleEvent(self.config.get("uid")))

View File

@ -7,11 +7,11 @@ class SemiFisherFuncs:
def __init__(self, engine):
self.engine = engine
def start_button_pressed(self, *params):
def start_button_pressed(self):
def func():
self.engine.start = not self.engine.start
if self.engine.start:
self.engine.fishy_thread = Thread(target=self.engine.start_fishing, args=(*params,))
self.engine.fishy_thread = Thread(target=self.engine.start_fishing)
self.engine.fishy_thread.start()
self.engine.gui_events.append(func)

48
fishy/gui/config_top.py Normal file
View File

@ -0,0 +1,48 @@
import typing
from fishy import web
from fishy.gui.notification import _give_notification_link
from tkinter import *
from tkinter.ttk import *
from fishy.helper.popup import PopUp
if typing.TYPE_CHECKING:
from fishy.gui import GUI
def start_semifisher_config(gui: 'GUI'):
def save():
gui._config.set("action_key", action_key_entry.get(), False)
gui._config.set("borderless", borderless.instate(['selected']), False)
gui._config.save_config()
top = PopUp(save, gui._root, background=gui._root["background"])
controls_frame = Frame(top)
top.title("Config")
Label(controls_frame, text="Notification:").grid(row=0, column=0)
gui._notify = IntVar(0)
gui._notify_check = Checkbutton(controls_frame, command=lambda: _give_notification_link(gui),
variable=gui._notify)
gui._notify_check.grid(row=0, column=1)
gui._notify_check['state'] = DISABLED
is_subbed = web.is_subbed(gui._config.get('uid'))
if is_subbed[1]:
gui._notify_check['state'] = NORMAL
gui._notify.set(is_subbed[0])
Label(controls_frame, text="Fullscreen: ").grid(row=1, column=0, pady=(5, 5))
borderless = Checkbutton(controls_frame, var=BooleanVar(value=gui._config.get("borderless")))
borderless.grid(row=1, column=1)
Label(controls_frame, text="Action Key:").grid(row=2, column=0)
action_key_entry = Entry(controls_frame, justify=CENTER)
action_key_entry.grid(row=2, column=1)
action_key_entry.insert(0, gui._config.get("action_key", "e"))
controls_frame.pack(padx=(5, 5), pady=(5, 5))
top.start()

View File

@ -6,12 +6,6 @@ class GUIFuncs:
def __init__(self, gui):
self.gui = gui
def set_notify(self, flag):
def func():
self.gui._notify_check['state'] = NORMAL
self.gui._notify.set(flag)
self.gui.call_in_thread(func)
def show_error(self, error):
self.gui.call_in_thread(lambda: messagebox.showerror("ERROR", error))

View File

@ -1,15 +1,16 @@
import logging
import threading
import time
from tkinter import *
from tkinter.ttk import *
from ttkthemes import ThemedTk
from fishy import helper, web
from fishy.gui import config_top
from .notification import _give_notification_link
import typing
from fishy.helper import not_implemented
if typing.TYPE_CHECKING:
from . import GUI
@ -22,6 +23,12 @@ def _apply_theme(gui: 'GUI'):
def _create(gui: 'GUI'):
engines = {
"Semi Fisher": [lambda: config_top.start_semifisher_config(gui), gui.engine.start_button_pressed],
# "Full-Auto Fisher": [not_implemented, not_implemented],
# "Lock Picker": [not_implemented, not_implemented]
}
gui._root = ThemedTk(theme="equilux", background=True)
gui._root.title("Fishybot for Elder Scrolls Online")
@ -56,12 +63,12 @@ def _create(gui: 'GUI'):
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="Log Dump", command=lambda: logging.error("Not Implemented"))
debug_menu.add_command(label="Log Dump", command=not_implemented)
debug_menu.add_command(label="Restart", command=helper.restart)
menubar.add_cascade(label="Debug", menu=debug_menu)
help_menu = Menu(menubar, tearoff=0)
help_menu.add_command(label="Troubleshoot Guide", command=lambda: logging.debug("Not Implemented"))
help_menu.add_command(label="Troubleshoot Guide", command=not_implemented)
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)
@ -71,66 +78,27 @@ def _create(gui: 'GUI'):
# region console
gui._console = Text(gui._root, state='disabled', wrap='none', background="#707070", fg="#ffffff")
gui._console.pack(fill=BOTH, expand=True, pady=(15, 15), padx=(5, 5))
gui._console.pack(fill=BOTH, expand=True, pady=(15, 15), padx=(10, 10))
gui._console.mark_set("sentinel", INSERT)
gui._console.config(state=DISABLED)
controls_frame = Frame(gui._root)
# endregion
# region controls
left_frame = Frame(controls_frame)
start_frame = Frame(gui._root)
Label(left_frame, text="Notification:").grid(row=0, column=0)
engine_var = StringVar(start_frame)
labels = list(engines.keys())
engine_select = OptionMenu(start_frame, engine_var, labels[0], *labels)
engine_select.pack(side=LEFT)
gui._notify = IntVar(0)
gui._notify_check = Checkbutton(left_frame, command=lambda: _give_notification_link(gui),
variable=gui._notify)
gui._notify_check.grid(row=0, column=1)
gui._notify_check['state'] = DISABLED
button = Button(start_frame, text="", width=0, command=lambda: engines[engine_var.get()][0]())
button.pack(side=RIGHT)
def update_notify_check():
is_subbed = web.is_subbed(gui._config.get('uid'))
if is_subbed[1]:
gui.funcs.set_notify(is_subbed[0])
gui._start_button = Button(start_frame, text="STOP" if gui._bot_running else "START", width=25,
command=lambda: engines[engine_var.get()][1]())
gui._start_button.pack(side=RIGHT)
threading.Thread(target=update_notify_check).start()
Label(left_frame, text="Fullscreen: ").grid(row=1, column=0, pady=(5, 5))
borderless = Checkbutton(left_frame, )
borderless.grid(row=1, column=1)
left_frame.grid(row=0, column=0)
right_frame = Frame(controls_frame)
Label(right_frame, text="Action Key:").grid(row=0, column=0)
action_key_entry = Entry(right_frame)
action_key_entry.grid(row=0, column=1)
action_key_entry.insert(0, gui._config.get("action_key", "e"))
Label(right_frame, text="Collect R: ").grid(row=1, column=0, pady=(5, 5))
collect_r = Checkbutton(right_frame, variable=IntVar(value=1 if gui._config.get("collect_r", False) else 0))
collect_r.grid(row=1, column=1)
right_frame.grid(row=0, column=1, padx=(50, 0))
controls_frame.pack()
gui._start_button = Button(gui._root, text="STOP" if gui._bot_running else "START", width=25)
def start_button_callback():
gui.engine.start_button_pressed(action_key_entry.get(),
borderless.instate(['selected']),
collect_r.instate(['selected']))
gui._config.set("action_key", action_key_entry.get(), False)
gui._config.set("borderless", borderless.instate(['selected']), False)
gui._config.set("collect_r", collect_r.instate(['selected']), False)
gui._config.save_config()
gui._start_button["command"] = start_button_callback
gui._start_button.pack(pady=(15, 15))
start_frame.pack(padx=(10, 10), pady=(5, 15), fill=X)
# endregion
_apply_theme(gui)

View File

@ -1,4 +1,4 @@
from .auto_update import auto_upgrade
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
create_shortcut_first, check_addon, restart, create_shortcut, not_implemented

View File

@ -2,7 +2,7 @@
auto_update.py
checks version and auto updates
"""
import logging
import re
import subprocess
import sys
@ -77,6 +77,8 @@ def auto_upgrade():
"""
index = "https://pypi.python.org/simple"
pkg = "fishy"
if _get_highest_version(index, pkg) > _get_current_version(pkg):
hightest_version = _get_highest_version(index, pkg)
if hightest_version > _get_current_version(pkg):
logging.info(f"Updating to v{'.'.join(hightest_version)}, Please Wait...")
subprocess.call(["python", '-m', 'pip', 'install', '--upgrade', 'fishy', '--user'])
execl(sys.executable, *([sys.executable] + sys.argv))

View File

@ -19,6 +19,10 @@ from fishy import web
from . import Config
def not_implemented():
logging.error("Not Implemented")
def open_web(website):
"""
Opens a website on browser,

35
fishy/helper/popup.py Normal file
View File

@ -0,0 +1,35 @@
import time
from tkinter import Toplevel
def center(win):
win.update_idletasks()
win.master.update_idletasks()
width = win.winfo_width()
height = win.winfo_height()
offset_x = win.master.winfo_x() + win.master.winfo_width() // 2 - (width // 2)
offset_y = win.master.winfo_y()+ win.master.winfo_height() // 2 - (height // 2)
win.geometry('{}x{}+{}+{}'.format(width, height, offset_x, offset_y))
class PopUp(Toplevel):
def __init__(self, quit_callback, *args, **kwargs):
super().__init__(*args, **kwargs)
self.running = True
self.quit_callback = quit_callback
def quit_top(self):
self.quit_callback()
self.destroy()
self.running = False
def start(self):
self.protocol("WM_DELETE_WINDOW", self.quit_top)
self.grab_set()
center(self)
while self.running:
self.update()
time.sleep(0.01)
self.grab_release()