mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-07-29 10:30:46 -07:00
Android: replace supports_mobile with more generic available check
This commit is contained in:
+6
-7
@@ -31,12 +31,12 @@ if __name__ == "__main__":
|
||||
import settings
|
||||
import Utils
|
||||
from Utils import (env_cleared_lib_path, init_logging, is_frozen, is_linux, is_macos, is_windows, local_path,
|
||||
messagebox, open_filename, user_path, is_mobile)
|
||||
messagebox, open_filename, user_path)
|
||||
|
||||
if __name__ == "__main__":
|
||||
init_logging('Launcher')
|
||||
|
||||
from worlds.LauncherComponents import Component, components, icon_paths, SuffixIdentifier, Type
|
||||
from worlds.LauncherComponents import Component, components, icon_paths, SuffixIdentifier, Type, always_available
|
||||
|
||||
|
||||
def open_host_yaml():
|
||||
@@ -124,14 +124,14 @@ components.extend([
|
||||
Component("Generate Template Options", func=generate_yamls,
|
||||
description="Generate template YAMLs for currently installed games."),
|
||||
Component("Archipelago Website", func=lambda: webbrowser.open("https://archipelago.gg/"),
|
||||
supports_mobile=True,
|
||||
available=always_available,
|
||||
description="Open archipelago.gg in your browser."),
|
||||
Component("Discord Server", icon="discord", func=lambda: webbrowser.open("https://discord.gg/8Z65BR2"),
|
||||
supports_mobile=True,
|
||||
available=always_available,
|
||||
description="Join the Discord server to play public multiworlds, report issues, or just chat!"),
|
||||
Component("Unrated/18+ Discord Server", icon="discord",
|
||||
func=lambda: webbrowser.open("https://discord.gg/fqvNCCRsu4"),
|
||||
supports_mobile=True,
|
||||
available=always_available,
|
||||
description="Find unrated and 18+ games in the After Dark Discord server."),
|
||||
Component("Browse Files", func=browse_files,
|
||||
description="Open the Archipelago installation folder in your file browser."),
|
||||
@@ -557,8 +557,7 @@ def run():
|
||||
process.join()
|
||||
|
||||
|
||||
if is_mobile:
|
||||
components[:] = [c for c in components if c.supports_mobile]
|
||||
components[:] = [c for c in components if c.available()]
|
||||
|
||||
|
||||
logging.info(f"Loaded {len(components)} components.")
|
||||
|
||||
@@ -56,14 +56,14 @@ class Component:
|
||||
"""Game name to identify component when handling launch links from WebHost"""
|
||||
supports_uri: Optional[bool]
|
||||
"""Bool to identify if a component supports being launched by launch links from WebHost"""
|
||||
supports_mobile: bool
|
||||
"""Bool to identify if a component supports being launched on mobile devices"""
|
||||
|
||||
available: Callable[[], bool]
|
||||
"""Callable that returns a bool to identify if this component is currently available.
|
||||
Default is available anywhere except mobile platforms."""
|
||||
def __init__(self, display_name: str, script_name: Optional[str] = None, frozen_name: Optional[str] = None,
|
||||
cli: bool = False, icon: str = 'icon', component_type: Optional[Type] = None,
|
||||
func: Optional[Callable] = None, file_identifier: Optional[Callable[[str], bool]] = None,
|
||||
game_name: Optional[str] = None, supports_uri: Optional[bool] = False,
|
||||
supports_mobile: bool = False, description: str = "") -> None:
|
||||
available: Callable[[], bool] = lambda: not is_mobile, description: str = "") -> None:
|
||||
self.display_name = display_name
|
||||
self.description = description
|
||||
self.script_name = script_name
|
||||
@@ -82,7 +82,7 @@ class Component:
|
||||
self.file_identifier = file_identifier
|
||||
self.game_name = game_name
|
||||
self.supports_uri = supports_uri
|
||||
self.supports_mobile = supports_mobile
|
||||
self.available = available
|
||||
|
||||
def handles_file(self, path: str):
|
||||
return self.file_identifier(path) if self.file_identifier else False
|
||||
@@ -91,6 +91,10 @@ class Component:
|
||||
return f"{self.__class__.__name__}({self.display_name})"
|
||||
|
||||
|
||||
def always_available() -> bool:
|
||||
return True
|
||||
|
||||
|
||||
processes = weakref.WeakSet()
|
||||
|
||||
|
||||
@@ -223,19 +227,19 @@ def export_datapackage() -> None:
|
||||
|
||||
components: List[Component] = [
|
||||
# Launcher
|
||||
Component('Launcher', 'Launcher', component_type=Type.HIDDEN, supports_mobile=True),
|
||||
Component('Launcher', 'Launcher', component_type=Type.HIDDEN, available=always_available),
|
||||
# Core
|
||||
Component('Host', 'MultiServer', 'ArchipelagoServer', cli=True,
|
||||
file_identifier=SuffixIdentifier('.archipelago', '.zip'),
|
||||
description="Host a generated multiworld on your computer."),
|
||||
Component('Generate', 'Generate', cli=True,
|
||||
description="Generate a multiworld with the YAMLs in the players folder."),
|
||||
Component("Options Creator", "OptionsCreator", "ArchipelagoOptionsCreator", component_type=Type.TOOL,
|
||||
description="Visual creator for Archipelago option files."),
|
||||
Component("Options Creator", "OptionsCreator", "ArchipelagoOptionsCreator",
|
||||
component_type=Type.TOOL, description="Visual creator for Archipelago option files."),
|
||||
Component("Install APWorld", func=install_apworld, file_identifier=SuffixIdentifier(".apworld"),
|
||||
description="Install an APWorld to play games not included with Archipelago by default."),
|
||||
Component('Text Client', 'CommonClient', 'ArchipelagoTextClient', func=launch_textclient,
|
||||
supports_mobile=True,
|
||||
Component('Text Client', 'CommonClient', 'ArchipelagoTextClient',
|
||||
func=launch_textclient, available=always_available,
|
||||
description="Connect to a multiworld using the text client."),
|
||||
Component('LttP Adjuster', 'LttPAdjuster'),
|
||||
# Ocarina of Time
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from worlds.LauncherComponents import Component, Type, components, launch
|
||||
from worlds.LauncherComponents import Component, Type, components, launch, always_available
|
||||
|
||||
|
||||
# The most common type of component is a client, but there are other components, such as sprite/palette adjusters.
|
||||
@@ -29,7 +29,7 @@ components.append(
|
||||
game_name="APQuest",
|
||||
component_type=Type.CLIENT,
|
||||
supports_uri=True,
|
||||
supports_mobile=True,
|
||||
available=always_available,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user