Skip to content

Commit

Permalink
自动读取快捷键
Browse files Browse the repository at this point in the history
  • Loading branch information
ok-oldking committed Oct 5, 2024
1 parent 4db63a5 commit 6438b81
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions src/task/BaseCombatTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,29 +298,25 @@ def check_combat(self):
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 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
if not self.key_config['HotKey Verify'] or force:

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()
Expand Down

0 comments on commit 6438b81

Please sign in to comment.