playsond beep twice, moved from hotkey to engine

This commit is contained in:
Semjon Kerner 2021-04-15 20:27:08 +02:00
parent 363a0dd1bd
commit 0396ea3239
4 changed files with 20 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import logging
from threading import Thread
from typing import Callable
from typing import Optional
from playsound import playsound
from fishy.engine.common.window import WindowClient
from fishy.engine.semifisher.fishing_mode import Colors, FishingMode
@ -14,6 +15,7 @@ from fishy.engine.semifisher.fishing_mode import FishingMode
from fishy.engine.semifisher.fishing_event import FishEvent
from fishy.engine.semifisher import fishing_mode, fishing_event
from fishy.engine.semifisher.pixel_loc import PixelLoc
from fishy.helper import helper
from fishy.helper.luaparser import sv_color_extract
@ -84,6 +86,9 @@ class SemiFisherEngine(IEngine):
if self.start:
self.thread = Thread(target=self.run)
self.thread.start()
playsound(helper.manifest_file("beep.wav"), False)
else:
helper.playsound_multiple(helper.manifest_file("beep.wav"))
if __name__ == '__main__':

View File

@ -2,5 +2,5 @@ from .auto_update import auto_upgrade, upgrade_avail, versions
from .config import Config
from .helper import open_web, initialize_uid, install_thread_excepthook, unhandled_exception_logging, manifest_file, \
create_shortcut_first, addon_exists, get_addonversion, install_addon, remove_addon, restart, create_shortcut, \
not_implemented, update, get_savedvarsdir
not_implemented, update, get_savedvarsdir, playsound_multiple
from .luaparser import sv_color_extract

View File

@ -7,6 +7,7 @@ import time
import traceback
import webbrowser
import requests
from playsound import playsound
from io import BytesIO
from threading import Thread
from zipfile import ZipFile
@ -23,6 +24,19 @@ import winshell
from fishy import web
def playsound_multiple(path, count=2):
if count < 1:
logging.debug("Please don't make me beep 0 times or less.")
return
def _ps_m():
for i in range(count-1):
playsound(path, True)
playsound(path, False)
Thread(target=_ps_m).start()
def not_implemented():
logging.error("Not Implemented")

View File

@ -3,9 +3,6 @@ from threading import Thread
from typing import Dict, Callable, Optional
import keyboard
from playsound import playsound
from fishy.helper import helper
class Key(Enum):
@ -27,7 +24,6 @@ def _get_callback(k):
if not _hotkeys[k]:
return
playsound(helper.manifest_file("beep.wav"), False)
Thread(target=_hotkeys[k]).start()
return callback