Skip to content

Commit

Permalink
make a crude component lookup on init and change launcher identify to…
Browse files Browse the repository at this point in the history
… check that lookup first
  • Loading branch information
qwint committed Dec 15, 2024
1 parent ccea6bc commit a557938
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ def _stop(self, *largs):
def identify(path: Union[None, str]) -> Tuple[Union[None, str], Union[None, Component]]:
if path is None:
return None, None
else:
suffix = "." + path.split(".")[-1]
from worlds.LauncherComponents import component_by_suffix
if suffix in component_by_suffix:
return path, component_by_suffix[suffix]
for component in components:
if component.handles_file(path):
return path, component
Expand Down
9 changes: 9 additions & 0 deletions worlds/LauncherComponents.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from Utils import local_path, open_filename


component_by_suffix = {}


class Type(Enum):
TOOL = auto()
MISC = auto()
Expand Down Expand Up @@ -48,6 +51,12 @@ def __init__(self, display_name: str, script_name: Optional[str] = None, frozen_
Type.ADJUSTER if "Adjuster" in display_name else Type.MISC)
self.func = func
self.file_identifier = file_identifier
if isinstance(file_identifier, SuffixIdentifier):
for suffix in file_identifier.suffixes:
if suffix in component_by_suffix:
raise Exception("TODO")
else:
component_by_suffix[suffix] = self
self.game_name = game_name
self.supports_uri = supports_uri

Expand Down

0 comments on commit a557938

Please sign in to comment.