Clients: allow "&[]" in tooltips, as kivy-escaped characters and fix similar translate issues in copy-paste clipboard
This commit is contained in:
		
							parent
							
								
									1710e15e49
								
							
						
					
					
						commit
						a800b148a2
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										6
									
								
								kvui.py
								
								
								
								
							
							
						
						
									
										6
									
								
								kvui.py
								
								
								
								
							| 
						 | 
				
			
			@ -181,7 +181,7 @@ class SelectableLabel(RecycleDataViewBehavior, HovererableLabel):
 | 
			
		|||
            rv, index, data)
 | 
			
		||||
 | 
			
		||||
    def create_tooltip(self, text, x, y):
 | 
			
		||||
        text = text.replace("<br>", "\n")
 | 
			
		||||
        text = text.replace("<br>", "\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):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue