Launcher: add icons where present and add headers to table

This commit is contained in:
Fabian Dill 2023-04-17 02:35:54 +02:00 committed by Fabian Dill
parent 4dc934729d
commit e1f17fadfc
3 changed files with 39 additions and 17 deletions

View File

@ -20,7 +20,7 @@ from shutil import which
from typing import Sequence, Union, Optional from typing import Sequence, Union, Optional
import Utils import Utils
from worlds.LauncherComponents import Component, components, Type, SuffixIdentifier from worlds.LauncherComponents import Component, components, Type, SuffixIdentifier, icon_paths
if __name__ == "__main__": if __name__ == "__main__":
import ModuleUpdate import ModuleUpdate
@ -84,12 +84,12 @@ def open_folder(folder_path):
components.extend([ components.extend([
# Functions # Functions
Component('Open host.yaml', func=open_host_yaml), Component("Open host.yaml", func=open_host_yaml),
Component('Open Patch', func=open_patch), Component("Open Patch", func=open_patch),
Component('Generate Template Settings', func=generate_yamls), Component("Generate Template Settings", func=generate_yamls),
Component('Discord Server', func=lambda: webbrowser.open("https://discord.gg/8Z65BR2")), Component("Discord Server", icon="discord", func=lambda: webbrowser.open("https://discord.gg/8Z65BR2")),
Component('18+ Discord Server', func=lambda: webbrowser.open("https://discord.gg/fqvNCCRsu4")), Component("18+ Discord Server", icon="discord", func=lambda: webbrowser.open("https://discord.gg/fqvNCCRsu4")),
Component('Browse Files', func=browse_files), Component("Browse Files", func=browse_files),
]) ])
@ -146,6 +146,8 @@ def launch(exe, in_terminal=False):
def run_gui(): def run_gui():
from kvui import App, ContainerLayout, GridLayout, Button, Label from kvui import App, ContainerLayout, GridLayout, Button, Label
from kivy.uix.image import Image
from kivy.uix.relativelayout import RelativeLayout
class Launcher(App): class Launcher(App):
base_title: str = "Archipelago Launcher" base_title: str = "Archipelago Launcher"
@ -167,24 +169,43 @@ def run_gui():
self.container = ContainerLayout() self.container = ContainerLayout()
self.grid = GridLayout(cols=2) self.grid = GridLayout(cols=2)
self.container.add_widget(self.grid) self.container.add_widget(self.grid)
self.grid.add_widget(Label(text="General"))
self.grid.add_widget(Label(text="Clients"))
button_layout = self.grid # make buttons fill the window button_layout = self.grid # make buttons fill the window
def build_button(component: Component):
"""
Builds a button widget for a given component.
Args:
component (Component): The component associated with the button.
Returns:
None. The button is added to the parent grid layout.
"""
button = Button(text=component.display_name)
button.component = component
button.bind(on_release=self.component_action)
if component.icon != "icon":
image = Image(source=icon_paths[component.icon], size=(38, 38), size_hint=(None, 1), pos=(5, 0))
box_layout = RelativeLayout()
box_layout.add_widget(button)
box_layout.add_widget(image)
button_layout.add_widget(box_layout)
else:
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._funcs.items(), self._adjusters.items()), self._clients.items()):
# column 1 # column 1
if tool: if tool:
button = Button(text=tool[0]) build_button(tool[1])
button.component = tool[1]
button.bind(on_release=self.component_action)
button_layout.add_widget(button)
else: else:
button_layout.add_widget(Label()) button_layout.add_widget(Label())
# column 2 # column 2
if client: if client:
button = Button(text=client[0]) build_button(client[1])
button.component = client[1]
button.bind(on_press=self.component_action)
button_layout.add_widget(button)
else: else:
button_layout.add_widget(Label()) button_layout.add_widget(Label())

BIN
data/discord-mark-blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -102,5 +102,6 @@ components: List[Component] = [
icon_paths = { icon_paths = {
'icon': local_path('data', 'icon.ico' if is_windows else 'icon.png'), 'icon': local_path('data', 'icon.ico' if is_windows else 'icon.png'),
'mcicon': local_path('data', 'mcicon.ico') 'mcicon': local_path('data', 'mcicon.ico'),
'discord': local_path('data', 'discord-mark-blue.png'),
} }