mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
a964c65776
- changed engine.toggle_start to abstract method - check for state before turning off bot engine - added and corrected logging messages for contorls and calibration - callibrate._get_factor returning None fixed - optimized controls - removed config for show crop - recorder now runs asksaveasfile in gui thread and blocks itself till resoponse - corrrected logic for saving failed files - semifisher dont log started bot engine if not ran from gui - added file name label in full auto config top - call in thread now can return values - gui now saves location when closed - dynamic config location, now uses correct document folder if config file is not found in incorrect document folder
72 lines
2.0 KiB
Python
72 lines
2.0 KiB
Python
import logging
|
|
import pickle
|
|
import time
|
|
from pprint import pprint
|
|
from tkinter.filedialog import asksaveasfile
|
|
|
|
from fishy.engine.fullautofisher.engine import FullAuto, State
|
|
|
|
from fishy.helper import hotkey
|
|
from fishy.helper.hotkey import Key
|
|
|
|
|
|
class Recorder:
|
|
recording_fps = 1
|
|
mark_hole_key = Key.F8
|
|
|
|
def __init__(self, engine: FullAuto):
|
|
self.recording = False
|
|
self.engine = engine
|
|
self.timeline = []
|
|
|
|
def _mark_hole(self):
|
|
coods = self.engine.get_coods()
|
|
self.timeline.append(("check_fish", coods))
|
|
logging.info("check_fish")
|
|
|
|
def toggle_recording(self):
|
|
if FullAuto.state != State.RECORDING and FullAuto.state != State.NONE:
|
|
return
|
|
|
|
self.recording = not self.recording
|
|
if self.recording:
|
|
self._start_recording()
|
|
|
|
def _start_recording(self):
|
|
FullAuto.state = State.RECORDING
|
|
logging.info("starting, press f8 to mark hole")
|
|
hotkey.set_hotkey(Recorder.mark_hole_key, self._mark_hole)
|
|
|
|
self.timeline = []
|
|
|
|
while self.recording:
|
|
start_time = time.time()
|
|
coods = None
|
|
while not coods:
|
|
coods = self.engine.get_coods()
|
|
self.timeline.append(("move_to", (coods[0], coods[1])))
|
|
|
|
time_took = time.time() - start_time
|
|
if time_took <= Recorder.recording_fps:
|
|
time.sleep(Recorder.recording_fps - time_took)
|
|
else:
|
|
logging.warning("Took too much time to record")
|
|
|
|
hotkey.free_key(Recorder.mark_hole_key)
|
|
|
|
def func():
|
|
_file = None
|
|
files = [('Fishy File', '*.fishy')]
|
|
while not _file:
|
|
_file = asksaveasfile(mode='wb', filetypes=files, defaultextension=files)
|
|
|
|
return _file
|
|
|
|
file = self.engine.get_gui().call_in_thread(func, block=True)
|
|
data = {"full_auto_path": self.timeline}
|
|
pprint(data)
|
|
pickle.dump(data, file)
|
|
file.close()
|
|
FullAuto.state = State.NONE
|
|
|