diff --git a/katrain/core/game.py b/katrain/core/game.py index a4dc887..3f2c788 100644 --- a/katrain/core/game.py +++ b/katrain/core/game.py @@ -75,11 +75,12 @@ class Game: self.root.place_handicap_stones(handicap) else: board_size = katrain.config("game/size") + rules = katrain.config("game/rules") self.komi = katrain.config("game/komi") self.root = GameNode( properties={ **Game.DEFAULT_PROPERTIES, - **{"SZ": board_size, "KM": self.komi, "DT": self.game_id}, + **{"SZ": board_size, "KM": self.komi, "DT": self.game_id, "RU": rules}, **(game_properties or {}), } ) diff --git a/katrain/core/sgf_parser.py b/katrain/core/sgf_parser.py index a233d9f..edd4037 100644 --- a/katrain/core/sgf_parser.py +++ b/katrain/core/sgf_parser.py @@ -82,6 +82,10 @@ class SGFNode: self.parent.children.append(self) if parent and move: self.set_property(move.player, move.sgf(self.board_size)) + self._clear_cache() + + def _clear_cache(self): + self.moves_cache = None def sgf_properties(self, **xargs) -> Dict: """For hooking into in a subclass and overriding/formatting any additional properties to be output.""" @@ -134,6 +138,7 @@ class SGFNode: """Add some values to the property list.""" # SiZe[19] ==> SZ[19] etc. for old SGF normalized_property = re.sub("[a-z]", "", property) + self._clear_cache() self.properties[normalized_property] += values def get_list_property(self, property, default=None) -> Any: @@ -144,6 +149,7 @@ class SGFNode: """Add some values to the property. If not a list, it will be made into a single-value list.""" if not isinstance(value, list): value = [value] + self._clear_cache() self.properties[property] = value def get_property(self, property, default=None) -> Any: @@ -207,11 +213,13 @@ class SGFNode: @property def moves(self) -> List[Move]: """Returns all moves in the node - typically 'move' will be better.""" - return [ - Move.from_sgf(move, player=pl, board_size=self.board_size) - for pl in Move.PLAYERS - for move in self.get_list_property(pl, []) - ] + if self.moves_cache is None: + self.moves_cache = [ + Move.from_sgf(move, player=pl, board_size=self.board_size) + for pl in Move.PLAYERS + for move in self.get_list_property(pl, []) + ] + return self.moves_cache @property def placements(self) -> List[Move]: diff --git a/katrain/gui/popups.py b/katrain/gui/popups.py index 5911773..b2436e5 100644 --- a/katrain/gui/popups.py +++ b/katrain/gui/popups.py @@ -254,7 +254,7 @@ class NewGamePopup(QuickConfigGui): def normalized_rules(self): rules = self.katrain.game.root.get_property("RU", "japanese").strip().lower() for abbr, name in self.katrain.engine.RULESETS_ABBR: - if abbr == rules or abbr == rules: + if abbr == rules or name == rules: return name def update_playerinfo(self, *args): diff --git a/katrain/gui/widgets/graph.py b/katrain/gui/widgets/graph.py index 5e923cd..1c208a0 100644 --- a/katrain/gui/widgets/graph.py +++ b/katrain/gui/widgets/graph.py @@ -76,7 +76,8 @@ class ScoreGraph(Graph): navigate_move = ListProperty([None, 0, 0, 0]) def on_touch_down(self, touch): - if self.collide_point(*touch.pos): + if self.collide_point(*touch.pos) and "scroll" not in getattr(touch, "button",''): + print(touch) ix, _ = min(enumerate(self.score_points[::2]), key=lambda ix_v: abs(ix_v[1] - touch.x)) self.navigate_move = [ self.nodes[ix], @@ -91,7 +92,7 @@ class ScoreGraph(Graph): return self.on_touch_down(touch) def on_touch_up(self, touch): - if self.collide_point(*touch.pos) and self.navigate_move[0]: + if self.collide_point(*touch.pos) and self.navigate_move[0] and "scroll" not in getattr(touch, "button",''): katrain = MDApp.get_running_app().gui if katrain and katrain.game: katrain.game.set_current_node(self.navigate_move[0]) diff --git a/katrain/gui/widgets/movetree.py b/katrain/gui/widgets/movetree.py index 2074e89..a848108 100644 --- a/katrain/gui/widgets/movetree.py +++ b/katrain/gui/widgets/movetree.py @@ -247,6 +247,12 @@ class MoveTree(ScrollView, BackgroundMixin): sy = (y - self.height / 2) / (vp.height - self.height) self.scroll_y = max(0, min(1, sy)) + # disable mousewheel + def on_scroll_start(self, touch, check_children=True): + if "button" in touch.profile and touch.button.startswith("scroll"): + return False + return super().on_scroll_start(touch, check_children) + Builder.load_string( """ @@ -256,7 +262,6 @@ Builder.load_string( : background_color: Theme.BOX_BACKGROUND_COLOR move_tree_canvas: move_tree_canvas - scroll_distance: 0 # scroll wheel is for forward/backward MoveTreeCanvas: scroll_view_widget: root id: move_tree_canvas diff --git a/katrain/i18n/locales/de/LC_MESSAGES/katrain.mo b/katrain/i18n/locales/de/LC_MESSAGES/katrain.mo index e210093..c8553d1 100644 Binary files a/katrain/i18n/locales/de/LC_MESSAGES/katrain.mo and b/katrain/i18n/locales/de/LC_MESSAGES/katrain.mo differ diff --git a/katrain/i18n/locales/de/LC_MESSAGES/katrain.po b/katrain/i18n/locales/de/LC_MESSAGES/katrain.po index 5b81bfe..fb72ede 100644 --- a/katrain/i18n/locales/de/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/de/LC_MESSAGES/katrain.po @@ -752,9 +752,7 @@ msgstr "Show stats if more than ... visits" #. TODO - analysis option msgid "cache analysis to sgf" -msgstr "" -"cache analysis to sgf\n" -"(larger files, only compatible with KaTrain)" +msgstr "Cache analysis in SGF" #. TODO msgid "menu:save-as" diff --git a/katrain/i18n/locales/fr/LC_MESSAGES/katrain.po b/katrain/i18n/locales/fr/LC_MESSAGES/katrain.po index 5c09647..1079970 100644 --- a/katrain/i18n/locales/fr/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/fr/LC_MESSAGES/katrain.po @@ -522,7 +522,6 @@ msgstr "" "possiblement pour cause de \n" "mémoire insuffisante : {error}" -#. TODO: updated msgid "teaching undo message" msgstr "" "Le coup {move} a été annulé car il perdait {points_lost:.1f} points.Vous " diff --git a/katrain/popups.kv b/katrain/popups.kv index 9cba6d5..14fdd3c 100644 --- a/katrain/popups.kv +++ b/katrain/popups.kv @@ -389,12 +389,14 @@ LabelledTextInput: text: '' id: black_player_name + write_tab: False hint_text: i18n._("black player name hint") size_hint: 0.75, None AnchorLayout: LabelledTextInput: text: '' id: white_player_name + write_tab: False hint_text: i18n._("white player name hint") size_hint: 0.75, None DescriptionLabel: @@ -404,6 +406,7 @@ text: '19' id: boardsize input_property: 'game/size' + write_tab: False size_hint: 0.5, None hint_text: i18n._("non square board hint") AnchorLayout: @@ -425,6 +428,7 @@ LabelledIntInput: text: '0' input_property: 'game/handicap' + write_tab: False id: handicap AnchorLayout: MDBoxLayout: