From fe0aca2069c15bbbd98db4c019c4348d205dc6f8 Mon Sep 17 00:00:00 2001 From: Sander Land Date: Sat, 17 Oct 2020 11:13:51 +0200 Subject: [PATCH] shortcuts --- katrain/__main__.py | 27 ++++++++++++++++----------- katrain/core/ai.py | 4 +--- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/katrain/__main__.py b/katrain/__main__.py index 7a5564e..7e2a29c 100644 --- a/katrain/__main__.py +++ b/katrain/__main__.py @@ -467,7 +467,8 @@ class KaTrainGui(Screen, KaTrainBase): return else: return - + ctrl_pressed = "ctrl" in modifiers + alt_pressed = "alt" in modifiers shortcuts = self.shortcuts if keycode[1] == "tab": self.play_mode.switch_ui_mode() @@ -475,26 +476,30 @@ class KaTrainGui(Screen, KaTrainBase): self.nav_drawer.set_state("toggle") elif keycode[1] == "spacebar": self.toggle_continuous_analysis() - elif keycode[1] == "b" and "ctrl" not in modifiers: + elif keycode[1] == "b" and ctrl_pressed: self.controls.timer.paused = not self.controls.timer.paused - elif keycode[1] in ["`", "~", "m"] and "ctrl" not in modifiers: + elif keycode[1] in ["`", "~", "m"] and ctrl_pressed: self.zen = (self.zen + 1) % 3 elif keycode[1] in ["left", "z"]: - self("undo", 1 + ("alt" in modifiers) * 9 + ("ctrl" in modifiers) * 999) + self("undo", 1 + alt_pressed * 4 + (ctrl_pressed and not alt_pressed) * 999) elif keycode[1] in ["right", "x"]: - self("redo", 1 + ("alt" in modifiers) * 9 + ("ctrl" in modifiers) * 999) - elif keycode[1] == "n" and "ctrl" in modifiers: + self("redo", 1 + alt_pressed * 4 + (ctrl_pressed and not alt_pressed) * 999) + elif keycode[1] == "home": + self("undo", 999) + elif keycode[1] == "end": + self("redo", 999) + elif keycode[1] == "n" and ctrl_pressed: self("new-game-popup") - elif keycode[1] == "l" and "ctrl" in modifiers: + elif keycode[1] == "l" and ctrl_pressed: self("analyze-sgf-popup") - elif keycode[1] == "s" and "ctrl" in modifiers: + elif keycode[1] == "s" and ctrl_pressed: self("output-sgf") - elif keycode[1] == "c" and "ctrl" in modifiers: + elif keycode[1] == "c" and ctrl_pressed: Clipboard.copy(self.game.root.sgf()) self.controls.set_status(i18n._("Copied SGF to clipboard."), STATUS_INFO) - elif keycode[1] == "v" and "ctrl" in modifiers: + elif keycode[1] == "v" and ctrl_pressed: self.load_sgf_from_clipboard() - elif keycode[1] in shortcuts.keys() and "ctrl" not in modifiers: + elif keycode[1] in shortcuts.keys() and not ctrl_pressed: shortcut = shortcuts[keycode[1]] if isinstance(shortcut, Widget): shortcut.trigger_action(duration=0) diff --git a/katrain/core/ai.py b/katrain/core/ai.py index 38f6dbe..92fe0e2 100644 --- a/katrain/core/ai.py +++ b/katrain/core/ai.py @@ -430,9 +430,7 @@ def generate_ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move, ai_thoughts += f"{ai_mode} strategy. Top 5 Candidates {', '.join(cands)} " aimove = moves_with_settledness[0][0] else: - raise( - Exception("No moves found - are you using an older KataGo with no per-move ownership info?") - ) + raise (Exception("No moves found - are you using an older KataGo with no per-move ownership info?")) else: if ai_mode not in [AI_DEFAULT, AI_HANDICAP]: game.katrain.log(f"Unknown AI mode {ai_mode} or policy missing, using default.", OUTPUT_INFO)