Exemplo n.º 1
0
    def time_to_reach_bottom_callibrate(self):
        self._callibrate_state = 0

        def _f8_pressed():
            self._callibrate_state += 1

        logging.info("look straight up and press f8")
        hotkey.set_hotkey(Key.F8, _f8_pressed)

        wait_until(lambda: self._callibrate_state == 1)

        logging.info("as soon as you look on the floor, press f8 again")

        y_cal_start_time = time.time()
        while self._callibrate_state == 1:
            mse.move(0, FullAuto.rotate_by)
            time.sleep(0.05)
        hotkey.free_key(Key.F8)

        time_to_reach_bottom = time.time() - y_cal_start_time
        _update_factor("time_to_reach_bottom", time_to_reach_bottom)
        logging.info("done")
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
 def unassign_keys(self):
     keys = []
     for c in self.controls:
         for k in c[1].keys():
             if k not in keys:
                 hotkey.free_key(k)