|  | 
| 4 | 4 | import json | 
| 5 | 5 | from typing import Callable, Optional | 
| 6 | 6 | 
 | 
|  | 7 | +import requests | 
| 7 | 8 | import Utils | 
| 8 | 9 | from worlds.generic.Rules import forbid_items_for_player | 
| 9 |  | -from worlds.LauncherComponents import Component, SuffixIdentifier, components, Type, launch_subprocess | 
|  | 10 | +from worlds.LauncherComponents import Component, SuffixIdentifier, components, Type, launch_subprocess, icon_paths | 
| 10 | 11 | 
 | 
| 11 | 12 | from .Data import item_table, location_table, region_table, category_table, meta_table | 
| 12 | 13 | from .Game import game_name, filler_item_name, starting_items | 
| @@ -435,21 +436,30 @@ def launch_client(*args): | 
| 435 | 436 |         Main() | 
| 436 | 437 | 
 | 
| 437 | 438 | class VersionedComponent(Component): | 
| 438 |  | -    def __init__(self, display_name: str, script_name: Optional[str] = None, func: Optional[Callable] = None, version: int = 0, file_identifier: Optional[Callable[[str], bool]] = None): | 
| 439 |  | -        super().__init__(display_name=display_name, script_name=script_name, func=func, component_type=Type.CLIENT, file_identifier=file_identifier) | 
|  | 439 | +    def __init__(self, display_name: str, script_name: Optional[str] = None, func: Optional[Callable] = None, version: int = 0, file_identifier: Optional[Callable[[str], bool]] = None, icon: Optional[str] = None): | 
|  | 440 | +        super().__init__(display_name=display_name, script_name=script_name, func=func, component_type=Type.CLIENT, file_identifier=file_identifier, icon=icon) | 
| 440 | 441 |         self.version = version | 
| 441 | 442 | 
 | 
| 442 | 443 | def add_client_to_launcher() -> None: | 
| 443 | 444 |     version = 2024_09_29 # YYYYMMDD | 
| 444 | 445 |     found = False | 
|  | 446 | + | 
|  | 447 | +    icon_url = "https://cdn.discordapp.com/icons/1097532591650910289/31019cd41a862df824f886c6cefbeb68.png?size=96" | 
|  | 448 | +    if "manual" not in icon_paths: | 
|  | 449 | +        icon_paths["manual"] = Utils.user_path('data', 'manual.png') | 
|  | 450 | +        if not os.path.exists(icon_paths["manual"]): | 
|  | 451 | +            with open(icon_paths["manual"], 'wb') as f: | 
|  | 452 | +                f.write(requests.get(icon_url).content) | 
|  | 453 | + | 
| 445 | 454 |     for c in components: | 
| 446 | 455 |         if c.display_name == "Manual Client": | 
| 447 | 456 |             found = True | 
| 448 | 457 |             if getattr(c, "version", 0) < version:  # We have a newer version of the Manual Client than the one the last apworld added | 
| 449 | 458 |                 c.version = version | 
| 450 | 459 |                 c.func = launch_client | 
|  | 460 | +                c.icon = "manual" | 
| 451 | 461 |                 return | 
| 452 | 462 |     if not found: | 
| 453 |  | -        components.append(VersionedComponent("Manual Client", "ManualClient", func=launch_client, version=version, file_identifier=SuffixIdentifier('.apmanual'))) | 
|  | 463 | +        components.append(VersionedComponent("Manual Client", "ManualClient", func=launch_client, version=version, file_identifier=SuffixIdentifier('.apmanual'), icon="manual")) | 
| 454 | 464 | 
 | 
| 455 | 465 | add_client_to_launcher() | 
0 commit comments