Launcher: deprecate FUNC Component type (#1872)
* Launcher: add hidden component type --------- Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
This commit is contained in:
parent
c4e28a8736
commit
25f285b242
12
Launcher.py
12
Launcher.py
|
@ -155,10 +155,10 @@ def run_gui():
|
||||||
container: ContainerLayout
|
container: ContainerLayout
|
||||||
grid: GridLayout
|
grid: GridLayout
|
||||||
|
|
||||||
_tools = {c.display_name: c for c in components if c.type == Type.TOOL and isfile(get_exe(c)[-1])}
|
_tools = {c.display_name: c for c in components if c.type == Type.TOOL}
|
||||||
_clients = {c.display_name: c for c in components if c.type == Type.CLIENT and isfile(get_exe(c)[-1])}
|
_clients = {c.display_name: c for c in components if c.type == Type.CLIENT}
|
||||||
_adjusters = {c.display_name: c for c in components if c.type == Type.ADJUSTER and isfile(get_exe(c)[-1])}
|
_adjusters = {c.display_name: c for c in components if c.type == Type.ADJUSTER}
|
||||||
_funcs = {c.display_name: c for c in components if c.type == Type.FUNC}
|
_miscs = {c.display_name: c for c in components if c.type == Type.MISC}
|
||||||
|
|
||||||
def __init__(self, ctx=None):
|
def __init__(self, ctx=None):
|
||||||
self.title = self.base_title
|
self.title = self.base_title
|
||||||
|
@ -199,7 +199,7 @@ def run_gui():
|
||||||
button_layout.add_widget(button)
|
button_layout.add_widget(button)
|
||||||
|
|
||||||
for (tool, client) in itertools.zip_longest(itertools.chain(
|
for (tool, client) in itertools.zip_longest(itertools.chain(
|
||||||
self._tools.items(), self._funcs.items(), self._adjusters.items()), self._clients.items()):
|
self._tools.items(), self._miscs.items(), self._adjusters.items()), self._clients.items()):
|
||||||
# column 1
|
# column 1
|
||||||
if tool:
|
if tool:
|
||||||
build_button(tool[1])
|
build_button(tool[1])
|
||||||
|
@ -215,7 +215,7 @@ def run_gui():
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def component_action(button):
|
def component_action(button):
|
||||||
if button.component.type == Type.FUNC:
|
if button.component.func:
|
||||||
button.component.func()
|
button.component.func()
|
||||||
else:
|
else:
|
||||||
launch(get_exe(button.component), button.component.cli)
|
launch(get_exe(button.component), button.component.cli)
|
||||||
|
|
7
Utils.py
7
Utils.py
|
@ -785,3 +785,10 @@ def async_start(co: Coroutine[typing.Any, typing.Any, bool], name: Optional[str]
|
||||||
task = asyncio.create_task(co, name=name)
|
task = asyncio.create_task(co, name=name)
|
||||||
_faf_tasks.add(task)
|
_faf_tasks.add(task)
|
||||||
task.add_done_callback(_faf_tasks.discard)
|
task.add_done_callback(_faf_tasks.discard)
|
||||||
|
|
||||||
|
|
||||||
|
def deprecate(message: str):
|
||||||
|
if __debug__:
|
||||||
|
raise Exception(message)
|
||||||
|
import warnings
|
||||||
|
warnings.warn(message)
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
from typing import Optional, Callable, List, Iterable
|
from typing import Optional, Callable, List, Iterable
|
||||||
|
|
||||||
from Utils import local_path, is_windows
|
from Utils import local_path
|
||||||
|
|
||||||
|
|
||||||
class Type(Enum):
|
class Type(Enum):
|
||||||
TOOL = auto()
|
TOOL = auto()
|
||||||
FUNC = auto() # not a real component
|
MISC = auto()
|
||||||
CLIENT = auto()
|
CLIENT = auto()
|
||||||
ADJUSTER = auto()
|
ADJUSTER = auto()
|
||||||
|
FUNC = auto() # do not use anymore
|
||||||
|
HIDDEN = auto()
|
||||||
|
|
||||||
|
|
||||||
class Component:
|
class Component:
|
||||||
display_name: str
|
display_name: str
|
||||||
type: Optional[Type]
|
type: Type
|
||||||
script_name: Optional[str]
|
script_name: Optional[str]
|
||||||
frozen_name: Optional[str]
|
frozen_name: Optional[str]
|
||||||
icon: str # just the name, no suffix
|
icon: str # just the name, no suffix
|
||||||
|
@ -22,18 +24,21 @@ class Component:
|
||||||
file_identifier: Optional[Callable[[str], bool]]
|
file_identifier: Optional[Callable[[str], bool]]
|
||||||
|
|
||||||
def __init__(self, display_name: str, script_name: Optional[str] = None, frozen_name: Optional[str] = None,
|
def __init__(self, display_name: str, script_name: Optional[str] = None, frozen_name: Optional[str] = None,
|
||||||
cli: bool = False, icon: str = 'icon', component_type: Type = None, func: Optional[Callable] = None,
|
cli: bool = False, icon: str = 'icon', component_type: Optional[Type] = None,
|
||||||
file_identifier: Optional[Callable[[str], bool]] = None):
|
func: Optional[Callable] = None, file_identifier: Optional[Callable[[str], bool]] = None):
|
||||||
self.display_name = display_name
|
self.display_name = display_name
|
||||||
self.script_name = script_name
|
self.script_name = script_name
|
||||||
self.frozen_name = frozen_name or f'Archipelago{script_name}' if script_name else None
|
self.frozen_name = frozen_name or f'Archipelago{script_name}' if script_name else None
|
||||||
self.icon = icon
|
self.icon = icon
|
||||||
self.cli = cli
|
self.cli = cli
|
||||||
self.type = component_type or \
|
if component_type == Type.FUNC:
|
||||||
None if not display_name else \
|
from Utils import deprecate
|
||||||
Type.FUNC if func else \
|
deprecate(f"Launcher Component {self.display_name} is using Type.FUNC Type, which is pending removal.")
|
||||||
Type.CLIENT if 'Client' in display_name else \
|
component_type = Type.MISC
|
||||||
Type.ADJUSTER if 'Adjuster' in display_name else Type.TOOL
|
|
||||||
|
self.type = component_type or (
|
||||||
|
Type.CLIENT if "Client" in display_name else
|
||||||
|
Type.ADJUSTER if "Adjuster" in display_name else Type.MISC)
|
||||||
self.func = func
|
self.func = func
|
||||||
self.file_identifier = file_identifier
|
self.file_identifier = file_identifier
|
||||||
|
|
||||||
|
@ -60,7 +65,7 @@ class SuffixIdentifier:
|
||||||
|
|
||||||
components: List[Component] = [
|
components: List[Component] = [
|
||||||
# Launcher
|
# Launcher
|
||||||
Component('', 'Launcher'),
|
Component('Launcher', 'Launcher', component_type=Type.HIDDEN),
|
||||||
# Core
|
# Core
|
||||||
Component('Host', 'MultiServer', 'ArchipelagoServer', cli=True,
|
Component('Host', 'MultiServer', 'ArchipelagoServer', cli=True,
|
||||||
file_identifier=SuffixIdentifier('.archipelago', '.zip')),
|
file_identifier=SuffixIdentifier('.archipelago', '.zip')),
|
||||||
|
|
Loading…
Reference in New Issue