Skip to content

Commit bf6f7bf

Browse files
committed
Launcher Icon
1 parent a5e12c9 commit bf6f7bf

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/__init__.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
import json
55
from typing import Callable, Optional
66

7+
import requests
78
import Utils
89
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
1011

1112
from .Data import item_table, location_table, region_table, category_table, meta_table
1213
from .Game import game_name, filler_item_name, starting_items
@@ -435,21 +436,30 @@ def launch_client(*args):
435436
Main()
436437

437438
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)
440441
self.version = version
441442

442443
def add_client_to_launcher() -> None:
443444
version = 2024_09_29 # YYYYMMDD
444445
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+
445454
for c in components:
446455
if c.display_name == "Manual Client":
447456
found = True
448457
if getattr(c, "version", 0) < version: # We have a newer version of the Manual Client than the one the last apworld added
449458
c.version = version
450459
c.func = launch_client
460+
c.icon = "manual"
451461
return
452462
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"))
454464

455465
add_client_to_launcher()

0 commit comments

Comments
 (0)