0
0
mirror of https://github.com/ok-oldking/ok-wuthering-waves.git synced 2025-06-03 09:25:19 +00:00

自动读取快捷键

This commit is contained in:
firedcto@gmail.com 2024-10-05 10:11:15 +08:00
parent 4db63a5bab
commit 6438b81651

View File

@ -298,29 +298,25 @@ class BaseCombatTask(BaseWWTask, FindFeature, OCR, CombatCheck):
self.raise_not_in_combat('combat check not in combat')
def load_hotkey(self, force=False):
if not self.key_config['HotKey Verify'] and not force:
return
resonance_key = self.ocr(0.82, 0.92, 0.85, 0.96, match=re.compile(r'^[a-zA-Z]$'), threshold=0.8,
name='resonance_key', use_grayscale=True)
echo_key = self.ocr(0.88, 0.92, 0.90, 0.96, match=re.compile(r'^[a-zA-Z]$'), threshold=0.8,
name='echo_key')
liberation_key = self.ocr(0.93, 0.92, 0.96, 0.96, match=re.compile(r'^[a-zA-Z]$'), threshold=0.8,
name='liberation_key')
keys_str = str(resonance_key) + str(echo_key) + str(liberation_key)
if not self.key_config['HotKey Verify'] or force:
# if not resonance_key or not echo_key or not liberation_key:
# raise Exception(ok.gui.app.tr(
# "Can't load game hotkey, please equip echos for all characters and use A-Z as hotkeys for skills, detected key:{}").format(
# keys_str))
if echo_key:
self.key_config['Echo Key'] = echo_key[0].name.lower()
if liberation_key:
self.key_config['Liberation Key'] = liberation_key[0].name.lower()
if resonance_key:
self.key_config['Resonance Key'] = resonance_key[0].name.lower()
self.key_config['HotKey Verify'] = False
logger.info(f'set hotkey {self.key_config}')
self.info['Skill HotKeys'] = keys_str
resonance_key = self.ocr(0.82, 0.92, 0.85, 0.96, match=re.compile(r'^[a-zA-Z]$'), threshold=0.8,
name='resonance_key', use_grayscale=True)
echo_key = self.ocr(0.88, 0.92, 0.90, 0.96, match=re.compile(r'^[a-zA-Z]$'), threshold=0.8,
name='echo_key')
liberation_key = self.ocr(0.93, 0.92, 0.96, 0.96, match=re.compile(r'^[a-zA-Z]$'), threshold=0.8,
name='liberation_key')
keys_str = str(resonance_key) + str(echo_key) + str(liberation_key)
if echo_key:
self.key_config['Echo Key'] = echo_key[0].name.lower()
if liberation_key:
self.key_config['Liberation Key'] = liberation_key[0].name.lower()
if resonance_key:
self.key_config['Resonance Key'] = resonance_key[0].name.lower()
self.key_config['HotKey Verify'] = True
self.log_info(f'set hotkey success {self.key_config.values()}', notify=True, tray=True)
self.info['Skill HotKeys'] = keys_str
def load_chars(self):
self.load_hotkey()