From a800b148a2eab6d1529033c5f352dab494aef7a4 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Wed, 25 May 2022 19:05:34 +0200 Subject: [PATCH] Clients: allow "&[]" in tooltips, as kivy-escaped characters and fix similar translate issues in copy-paste clipboard --- CommonClient.py | 4 ++-- kvui.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CommonClient.py b/CommonClient.py index 62ed32a1..bd8e1248 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -223,12 +223,12 @@ class CommonContext(): for location_name, location_id in gamedata["location_name_to_id"].items(): locations_lookup[location_id] = location_name - def get_item_name_from_id(code: int): + def get_item_name_from_id(code: int) -> str: return item_lookup.get(code, f'Unknown item (ID:{code})') self.item_name_getter = get_item_name_from_id - def get_location_name_from_address(address: int): + def get_location_name_from_address(address: int) -> str: return locations_lookup.get(address, f'Unknown location (ID:{address})') self.location_name_getter = get_location_name_from_address diff --git a/kvui.py b/kvui.py index 8f681d69..3ea14191 100644 --- a/kvui.py +++ b/kvui.py @@ -181,7 +181,7 @@ class SelectableLabel(RecycleDataViewBehavior, HovererableLabel): rv, index, data) def create_tooltip(self, text, x, y): - text = text.replace("
", "\n") + text = text.replace("
", "\n").replace('&', '&').replace('&bl;', '[').replace('&br;', ']') if self.tooltip: # update self.tooltip.children[0].text = text @@ -240,7 +240,7 @@ class SelectableLabel(RecycleDataViewBehavior, HovererableLabel): else: # Not a fan of the following few lines, but they work. temp = MarkupLabel(text=self.text).markup - text = "".join(part for part in temp if not part.startswith(("[color", "[/color]"))) + text = "".join(part for part in temp if not part.startswith(("[color", "[/color]", "[ref=", "[/ref]"))) cmdinput = App.get_running_app().textinput if not cmdinput.text and " did you mean " in text: for question in ("Didn't find something that closely matches, did you mean ", @@ -253,7 +253,7 @@ class SelectableLabel(RecycleDataViewBehavior, HovererableLabel): elif not cmdinput.text and text.startswith("Missing: "): cmdinput.text = text.replace("Missing: ", "!hint_location ") - Clipboard.copy(text) + Clipboard.copy(text.replace('&', '&').replace('&bl;', '[').replace('&br;', ']')) return self.parent.select_with_touch(self.index, touch) def apply_selection(self, rv, index, is_selected):