mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
made full auto runable via gui
This commit is contained in:
parent
2893b2270c
commit
fafb6ea952
@ -34,6 +34,10 @@ class WindowClient:
|
||||
if len(WindowClient.clients) == 0:
|
||||
window_server.stop()
|
||||
|
||||
@staticmethod
|
||||
def running():
|
||||
return WindowServer.status == Status.RUNNING
|
||||
|
||||
def get_capture(self):
|
||||
"""
|
||||
copies the recorded screen and then pre processes its
|
||||
@ -43,13 +47,13 @@ class WindowClient:
|
||||
return None
|
||||
|
||||
if not window_server.screen_ready():
|
||||
logging.info("waiting fors screen...")
|
||||
logging.info("waiting for screen...")
|
||||
helper.wait_until(window_server.screen_ready)
|
||||
logging.info("screen ready, continuing...")
|
||||
|
||||
temp_img = WindowServer.Screen
|
||||
|
||||
if temp_img is None:
|
||||
if temp_img is None or temp_img.size == 0:
|
||||
return None
|
||||
|
||||
if self.color is not None:
|
||||
@ -72,12 +76,17 @@ class WindowClient:
|
||||
if WindowServer.status == Status.CRASHED:
|
||||
return None
|
||||
|
||||
if func is None:
|
||||
return self.get_capture()
|
||||
else:
|
||||
return func(self.get_capture())
|
||||
img = self.get_capture()
|
||||
|
||||
def show(self, resize=None, func=None, ready_img=None):
|
||||
if img is None:
|
||||
return None
|
||||
|
||||
if func is None:
|
||||
return img
|
||||
else:
|
||||
return func(img)
|
||||
|
||||
def show(self, resize=None, func=None):
|
||||
"""
|
||||
Displays the processed image for debugging purposes
|
||||
:param ready_img: send ready image, just show the `ready_img` directly
|
||||
@ -91,13 +100,13 @@ class WindowClient:
|
||||
logging.warning("You need to assign a name first")
|
||||
return
|
||||
|
||||
if ready_img is None:
|
||||
img = self.processed_image(func)
|
||||
img = self.processed_image(func)
|
||||
|
||||
if resize is not None:
|
||||
img = imutils.resize(img, width=resize)
|
||||
else:
|
||||
img = ready_img
|
||||
if img is None:
|
||||
return
|
||||
|
||||
if resize is not None:
|
||||
img = imutils.resize(img, width=resize)
|
||||
cv2.imshow(self.show_name, img)
|
||||
|
||||
self.showing = True
|
||||
|
@ -16,8 +16,8 @@ from fishy.helper.config import config
|
||||
|
||||
|
||||
class Status(Enum):
|
||||
CRASHED = -1,
|
||||
STOPPED = 0,
|
||||
CRASHED = -1
|
||||
STOPPED = 0
|
||||
RUNNING = 1
|
||||
|
||||
|
||||
|
@ -73,12 +73,6 @@ def get_values_from_image(img, tesseract_dir):
|
||||
return None
|
||||
|
||||
|
||||
def unassign_keys():
|
||||
keys = [Key.UP, Key.RIGHT, Key.LEFT, Key.RIGHT]
|
||||
for k in keys:
|
||||
hotkey.free_key(k)
|
||||
|
||||
|
||||
class FullAuto(IEngine):
|
||||
rotate_by = 30
|
||||
|
||||
@ -95,6 +89,9 @@ class FullAuto(IEngine):
|
||||
self._hole_found_flag = False
|
||||
self._curr_rotate_y = 0
|
||||
|
||||
self.fisher = SemiFisherEngine(None)
|
||||
self.controls = Controls(self.get_controls())
|
||||
|
||||
def update_crop(self):
|
||||
self.crop = get_crop_coods(self.window)
|
||||
config.set("full_auto_crop", self.crop)
|
||||
@ -102,7 +99,9 @@ class FullAuto(IEngine):
|
||||
|
||||
def run(self):
|
||||
logging.info("Loading please wait...")
|
||||
self.initalize_keys()
|
||||
fishing_event.unsubscribe()
|
||||
self.fisher.toggle_start()
|
||||
self.controls.change_state()
|
||||
|
||||
self.window = WindowClient(color=cv2.COLOR_RGB2GRAY, show_name="Full auto debug")
|
||||
if self.crop is None:
|
||||
@ -118,12 +117,12 @@ class FullAuto(IEngine):
|
||||
|
||||
self.gui.bot_started(True)
|
||||
|
||||
while self.start:
|
||||
while self.start and WindowClient.running():
|
||||
self.window.show(func=image_pre_process)
|
||||
cv2.waitKey(25)
|
||||
|
||||
self.gui.bot_started(False)
|
||||
unassign_keys()
|
||||
self.controls.unassign_keys()
|
||||
logging.info("Quit")
|
||||
|
||||
def get_coods(self):
|
||||
@ -216,13 +215,13 @@ class FullAuto(IEngine):
|
||||
time.sleep(0.05)
|
||||
self._curr_rotate_y -= 0.05
|
||||
|
||||
def initalize_keys(self):
|
||||
def get_controls(self):
|
||||
from fishy.engine.fullautofisher.calibrate import Calibrate
|
||||
from fishy.engine.fullautofisher.recorder import Recorder
|
||||
from fishy.engine.fullautofisher.player import Player
|
||||
|
||||
def change_state():
|
||||
c.change_state()
|
||||
self.controls.change_state()
|
||||
|
||||
def print_coods():
|
||||
logging.info(self.get_coods())
|
||||
@ -258,9 +257,8 @@ class FullAuto(IEngine):
|
||||
Key.DOWN: change_state
|
||||
}
|
||||
]
|
||||
c = Controls(controls, 0)
|
||||
c.change_state()
|
||||
|
||||
return controls
|
||||
|
||||
class Controls:
|
||||
def __init__(self, controls, first=0):
|
||||
@ -278,15 +276,17 @@ class Controls:
|
||||
help_str += f"\n{key.value}: {func.__name__}"
|
||||
logging.info(help_str)
|
||||
|
||||
def unassign_keys(self):
|
||||
keys = []
|
||||
for c in self.controls:
|
||||
for k in c.keys():
|
||||
if k not in keys:
|
||||
hotkey.free_key(k)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.getLogger("").setLevel(logging.DEBUG)
|
||||
hotkey.initalize()
|
||||
# noinspection PyTypeChecker
|
||||
bot = FullAuto(None)
|
||||
fisher = SemiFisherEngine(None)
|
||||
hotkey.initalize()
|
||||
|
||||
fishing_event.unsubscribe()
|
||||
|
||||
fisher.toggle_start()
|
||||
bot.toggle_start()
|
||||
|
@ -62,7 +62,6 @@ class Player:
|
||||
|
||||
if action[0] == "move_to":
|
||||
self.engine.move_to(action[1])
|
||||
logging.info("moved")
|
||||
elif action[0] == "check_fish":
|
||||
self.engine.move_to(action[1])
|
||||
self.engine.rotate_to(action[1][2])
|
||||
|
Loading…
Reference in New Issue
Block a user