From 1f9dba83c11975699087c3fc7af4b47e6f8c7296 Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 19 Sep 2023 20:10:52 +0800 Subject: [PATCH] pugwash: updated default_theme thanks to @tekenfedde then broke it so he can fix it, added menu descriptions, fixed bug with image loading. --- PortMaster/pugwash | 4 +- PortMaster/pylibs/default_theme/theme.json | 258 ++++++++++++++++++++- PortMaster/pylibs/pugscene.py | 105 +++++++-- PortMaster/pylibs/pySDL2gui.py | 28 ++- 4 files changed, 357 insertions(+), 38 deletions(-) diff --git a/PortMaster/pugwash b/PortMaster/pugwash index 989ff50..87df40b 100755 --- a/PortMaster/pugwash +++ b/PortMaster/pugwash @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ## -- BEGIN PORTMASTER INFO -- -PORTMASTER_VERSION = '8.4.8' +PORTMASTER_VERSION = '8.4.9' PORTMASTER_RELEASE_CHANNEL = 'beta' ## -- END PORTMASTER INFO -- @@ -958,7 +958,7 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback): self.text_data[key] = value self.changed_keys.add(key) - # logger.debug(f"{key}: {value}") + logger.debug(f"{key}: {value}") def format_data(self, input_string, used_keys=None): return self.formatter.format_string(input_string, used_keys) diff --git a/PortMaster/pylibs/default_theme/theme.json b/PortMaster/pylibs/default_theme/theme.json index 8691869..5c36e83 100644 --- a/PortMaster/pylibs/default_theme/theme.json +++ b/PortMaster/pylibs/default_theme/theme.json @@ -150,6 +150,14 @@ "area[3:2]": [ 0.0, 0.0, 0.4, 1.0 ], "area[wide]": [ 0.0, 0.0, 0.4, 1.0 ] }, + + "left_pane_featured": { + "comment": "Left side of the screen.", + "area": [ 0.0, 0.0, 0.3, 1.0 ], + "area[3:2]": [ 0.0, 0.0, 0.35, 1.0 ], + "area[wide]": [ 0.0, 0.0, 0.35, 1.0 ] + }, + "right_pane": { "comment": "Right side of the screen.", "area": [ 0.3, 0.0, 1.0, 1.0 ], @@ -161,6 +169,12 @@ "parent": "left_pane", "area": [ 0.0, 0.0, 1.0, 1.0 ] }, + "port_info_list_area_featured": { + "comment": "List area", + "parent": "left_pane_featured", + "area": [ 0.0, 0.0, 1.0, 1.0 ] + }, + "port_info_area": { "comment": "The area used for the info text/image", "parent": "right_pane", @@ -178,12 +192,28 @@ "area[hires]": [ 0.0, 0.1, 1.0, 0.5 ], "area[4:3]": [ 0.0, 0.1, 1.0, 0.5 ] }, + + "port_info_image_area_featured": { + "comment": "Port image", + "parent": "port_info_area", + "area": [ 0.0, 0.1, 1.0, 0.4 ], + "area[30:17|427:240]": [ 0.0, 0.1, 1.0, 0.75 ], + "area[16:9]": [ 0.0, 0.1, 1.0, 0.65 ] + + }, + "port_info_text_area": { "comment": "Port Info", "parent": "port_info_area", "area": [ 0.0, 0.4, 1.0, 1.0 ], "area[1920x1152, hires]": [ 0.0, 0.5, 1.0, 1.0 ] }, + + "port_info_title_area_featured": { + "comment": "Port Info", + "area": [ 0.0, 0.0, 1.0, 0.1 ] + }, + "background": { "area": [ 0.0, 0.0, 1.0, 1.0 ], "fill": "background", @@ -207,12 +237,14 @@ "button-sound": "click" }, "option_list": { - "area": [ 0.1, 0.25, 0.9, 0.9 ], + "area": [ 0.0, 0.21, 0.9, 0.9 ], + "area[3:2]": [ 0.0, 0.21, 0.9, 0.8 ], "border": 8, "font-size": 30, + "font-size[16:9]": 22, "font-color": "list_text", "select-color": "list_selected", - "text-clip": false, + "text-clip": true, "thickness": 10, "click-sound": "click", "click-sound-volume": 64 @@ -363,18 +395,16 @@ "main_menu": { "#element:background": {}, "#element:option_list": { - "align": "center", + "align": "midleft", "list": [], "options": [], "pointer": "pointenfedde.png", - "pointer-align": [ "midleft", "midright" ], + "pointer-align": [ "midright", "midleft" ], "pointer-size": [ 51, 26 ], "pointer-attach": "text", - "pointer-offset": [ 0, 0 ], - "pointer-flip-x": false, - "pointer-flip-y": false, - "pointer-mirror": true, - "pointer-mirror-x": true + "pointer-offset": [ 0, 2 ], + "pointer-flip-x": true, + "pointer-flip-y": false }, "#element:button_bar": {}, "system_time": { @@ -398,14 +428,36 @@ "#element:background": { "music": null }, + "option_title": { + "area": [ 0.01, 0.05, 1.0, 0.10 ], + "text": "{scene.title}", + "font-size": 20, + "font-color": "general_font" + }, "#element:option_list": { "list": [], "options": [], "align": "midleft", + "area": [ 0.0, 0.10, 0.5, 0.85 ], "text-clip": true, "font-size": 25, "no-select-color": "list_unselectable", - "inactive-select-color": "list_unselectable" + "inactive-select-color": "list_unselectable", + "pointer": "pointenfedde.png", + "pointer-align": [ "midright", "midleft" ], + "pointer-size": [ 51, 26 ], + "pointer-attach": "text", + "pointer-offset": [ 0, 2 ], + "pointer-flip-x": true, + "pointer-flip-y": false + }, + "option_description": { + "text": "{scene.tooltip}", + "font-size": 25, + "font-color": "general_font", + "area": [ 0.5, 0.10, 1.0, 0.85 ], + "align": "topleft", + "text-wrap": true }, "#element:button_bar": {}, "ip": { @@ -449,6 +501,7 @@ "scroll-speed": 30, "scroll-delay-start": 500, "scroll-delay-end": 500 + }, "theme_general_info": { "parent": "port_info_text_area", @@ -500,6 +553,51 @@ }, "#element:button_bar": {} }, + "runtime_list": { + "#element:background": { + "music": null + }, + "option_title": { + "area": [ 0.01, 0.05, 1.0, 0.10 ], + "text": "{scene.title}", + "font-size": 20, + "font-color": "general_font" + }, + "#element:option_list:runtime_list": { + "list": [], + "options": [], + "align": "midleft", + "area": [ 0.0, 0.10, 0.5, 0.85 ], + "text-clip": true, + "font-size": 25, + "no-select-color": "list_unselectable", + "inactive-select-color": "list_unselectable", + "pointer": "pointenfedde.png", + "pointer-align": [ "midright", "midleft" ], + "pointer-size": [ 51, 26 ], + "pointer-attach": "text", + "pointer-offset": [ 0, 2 ], + "pointer-flip-x": true, + "pointer-flip-y": false + }, + "option_description": { + "text": "Name: {runtime_info.name}\nStatus: {runtime_info.status}\nPorts: {runtime_info.ports}\nVerified: {runtime_info.verified}\nDownload Size: {runtime_info.download_size}\nInstall Size: {runtime_info.disk_size}", + "font-size": 25, + "font-color": "general_font", + "area": [ 0.5, 0.10, 1.0, 0.85 ], + "align": "topleft", + "text-wrap": true + }, + "#element:button_bar": {}, + "ip": { + "text": "IP: {system.ip_address}", + "font-size": 11, + "font-size[427:240]": 16, + "font-color": "general_font", + "area": [ 0.02, 0.05, 0.95, 0.95 ], + "align": "bottomleft" + } + }, "on_screen_keyboard": { "#element:background": {}, "keyboard": { @@ -578,6 +676,144 @@ "#element:button_bar": {} }, + "featured_ports_list": { + "#element:background": {}, + + "option_title": { + "area": [ 0.01, 0.05, 1.0, 0.10 ], + "text": "{scene.title}", + "font-size": 20, + "font-color": "general_font" + }, + + "port_info": { + "area": [ 0.0, 0.1, 1.0, 0.3 ], + "image": "{featured_ports.image}" + }, + + "option_list": { + "list": [], + "align": "center", + "area": [ 0.0, 0.40, 1.0, 0.85 ], + "text-clip": true, + "font-size": 25, + "font-color": "list_text", + "select-color": "list_selected", + "pointer": "pointenfedde.png", + "pointer-align": [ "midright", "midleft" ], + "pointer-size": [ 51, 26 ], + "pointer-attach": "text", + "pointer-offset": [ 0, 2 ], + "pointer-flip-x": true, + "pointer-flip-y": false + }, + + "featured_port_description": { + "text": "{featured_ports.description}", + "font-size": 25, + "font-color": "general_font", + "area": [ 0.5, 0.10, 1.0, 0.85 ], + "align": "topleft", + "text-wrap": true + }, + + "#element:button_bar": {} + + }, + "featured_ports": { + "#element:background": {}, + + "ports_list": { + "parent": "port_info_list_area_featured", + "area": [ 0.0, 0.3, 0.95, 0.6 ], + "area[3:2]": [ 0.0, 0.15, 0.95, 0.5 ], + "border-x": 16, + "border-y": 25, + "align": "midleft", + "font-size": 17, + "font-size[427:240]": 22, + "font-size[16:9]": 19, + "font-size[1920x1152]": 22, + "alt-fill": "secondary-selection-fill", + "select-fill": "selection-fill", + "font-color": "list_text", + "select-color": "list_selected", + "text-clip": true, + "text-wrap": false, + "autoscroll": "slide", + "scroll-speed": 30, + "scroll-delay-start": 500, + "scroll-delay-end": 500 + }, + + "port_desc": { + "parent": "port_info_text_area", + "area": [ 5, 115, -5, -45 ], + "area[4:3]": [ 5, 168, -5, -50 ], + "area[3:2]": [ 5, 115, -5, -25 ], + "area[16:9]": [ 5, 215, -5, -100 ], + "area[1920x1152]": [ 0.05, 0.3, 0.8, 0.7 ], + "area[427:240]": [ 5, 195, -5, -50 ], + "area[30:17]": [ 5, 195, -5, -65 ], + "font-size": 17, + "font-size[1920x1152]": 13, + "font-size[16:9]": 13, + "font-color": "general_font", + "text-wrap": true, + "autoscroll": "marquee", + "scroll-speed": 60, + "scroll-delay-start": 1500, + "scroll-delay-end": 1500, + "text": "{port_info.description}" + }, + + "port_title": { + "parent": "port_info_title_area_featured", + "area": [ 0.0, 0.0, 1.0, 1.0 ], + "text": "{featured_ports.name}", + "font-size": 22, + "font-color": "list_selected", + "align": "center" + }, + + "featured_image": { + "area": [ 0.0, 0.2, 0.3, 0.35 ], + "image": "{featured_ports.image}", + "area[3:2|wide]": [ 0.0, 0.1, 0.3, 0.21 ] + }, + + "port_image": { + "parent": "port_info_image_area_featured", + "area": [ 0.0, 0.0, 1.0, 1.0 ], + "image": "{port_info.image}" + }, + + "featured_port_description": { + "text": "{featured_ports.description}", + "font-size": 16, + "font-color": "general_font", + "area": [ 0.0, 0.10, 0.3, 0.85 ], + "align": "topleft", + "text-wrap": true + }, + + "port_general_info": { + "parent": "left_pane_featured", + "area": [ 0.0, 0.6, 0.95, 0.8 ], + "border-x": 16, + "font-size": 16, + "font-size[1920x1152]": 11, + "font-size[16:9]": 11, + "font-color": "general_font", + "text-wrap": true, + "text": "Genres: {port_info.genres}\n{if:port_info.install_size}Installed Size: {port_info.install_size}{else}Download Size: {port_info.download_size}{endif}{if:port_info.runtime}\nRuntime: {port_info.runtime} ({port_info.runtime_status}){endif}" + }, + + + "#element:button_bar": {} + + }, + "message_box": { "#element:background": {}, @@ -697,4 +933,4 @@ "#element:button_bar": {} } -} \ No newline at end of file +} diff --git a/PortMaster/pylibs/pugscene.py b/PortMaster/pylibs/pugscene.py index a965a8e..52b11dc 100644 --- a/PortMaster/pylibs/pugscene.py +++ b/PortMaster/pylibs/pugscene.py @@ -155,6 +155,10 @@ def scene_activate(self): self.gui.set_data("scene.title", self.scene_title) self.gui.set_data("scene.tooltip", self.scene_tooltip) + def set_tooltip(self, text): + self.scene_tooltip = text + self.gui.set_data("scene.tooltip", text) + def load_regions(self, section, required_tags): rects = self.gui.new_rects() temp_required_tags = list(required_tags) @@ -325,20 +329,37 @@ def __init__(self, gui): self.load_regions("main_menu", ['option_list']) self.tags['option_list'].reset_options() - self.tags['option_list'].add_option(('install', []), _("All Ports")) - self.tags['option_list'].add_option(('install', ['rtr']), _("Ready to Run Ports")) - self.tags['option_list'].add_option(('uninstall', ['installed']), _("Uninstall Ports")) - + self.tags['option_list'].add_option( + ('install', []), + _("All Ports"), + description=_("List all ports available on PortMaster.")) + self.tags['option_list'].add_option( + ('install', ['rtr']), + _("Ready to Run Ports"), + description=_("List all ports that are ready to play!")) if self.gui.get_config().get('konami', False): - self.tags['option_list'].add_option(None, "") - self.tags['option_list'].add_option(('featured-ports', None), _('Featured Ports')) + self.tags['option_list'].add_option( + ('featured-ports', None), + _('Featured Ports'), + description=_("Hand curated lists of ports")) + self.tags['option_list'].add_option( + ('uninstall', ['installed']), + _("Uninstall Ports"), + description=_("Remove unwanted ports")) self.tags['option_list'].add_option(None, "") - self.tags['option_list'].add_option(('options', None), _("Options")) - self.tags['option_list'].add_option(('exit', None), _("Exit")) + self.tags['option_list'].add_option( + ('options', None), + _("Options"), + description=_("PortMaster Options")) + self.tags['option_list'].add_option( + ('exit', None), + _("Exit"), + description=_("Quit PortMaster")) self.set_buttons({'A': _('Enter'), 'B': _('Quit')}) self.detecting_konami = 0 + self.last_selected = None def do_update(self, events): super().do_update(events) @@ -361,6 +382,10 @@ def do_update(self, events): elif events.any_pressed(): self.detecting_konami = 0 + if self.last_selected != self.tags['option_list'].selected_option(): + self.set_tooltip(self.tags['option_list'].selected_description()) + self.last_selected = self.tags['option_list'].selected_option() + if events.was_pressed('A'): selected_option, selected_parameter = self.tags['option_list'].selected_option() @@ -398,47 +423,79 @@ def __init__(self, gui): self.tags['option_list'].reset_options() self.tags['option_list'].add_option(None, _("System")) - self.tags['option_list'].add_option('update-ports', _("Update Ports")) - self.tags['option_list'].add_option('update-portmaster', _("Update PortMaster")) - self.tags['option_list'].add_option('runtime-list', _("Runtime Manager")) + self.tags['option_list'].add_option( + 'update-ports', + _("Update Ports"), + description=_("Update all ports and associated information")) + self.tags['option_list'].add_option( + 'update-portmaster', + _("Update PortMaster"), + description=_("Force check for a new PortMaster version.")) + self.tags['option_list'].add_option( + 'runtime-list', + _("Runtime Manager"), + description=_("Download/Check/Delete Port runtimes.")) if len(self.gui.hm.get_gcd_modes()) > 0: gcd_mode = self.gui.hm.get_gcd_mode() self.tags['option_list'].add_option( 'toggle-gcd', - _("Controller Mode: {controller_mode}").format(controller_mode=gcd_mode)) + _("Controller Mode: {controller_mode}").format(controller_mode=gcd_mode), + description=_("Toggle between various controller layouts.")) self.tags['option_list'].add_option(None, _("Audio")) self.tags['option_list'].add_option( 'toggle-music', - _("Music: ") + (self.gui.sounds.music_is_disabled and _("Disabled") or _("Enabled"))) + _("Music: ") + (self.gui.sounds.music_is_disabled and _("Disabled") or _("Enabled")), + description=_("Enable or Disable background music in PortMaster.")) self.tags['option_list'].add_option( 'toggle-sfx', - _("Sound FX: ") + (self.gui.sounds.sound_is_disabled and _("Disabled") or _("Enabled"))) + _("Sound FX: ") + (self.gui.sounds.sound_is_disabled and _("Disabled") or _("Enabled")), + description=_("Enable or Disable soundfx in PortMaster.")) self.tags['option_list'].add_option(None, _("Interface")) - self.tags['option_list'].add_option('select-language', _("Choose Language")) - self.tags['option_list'].add_option('select-theme', _("Select Theme")) + self.tags['option_list'].add_option( + 'select-language', + _("Choose Language"), + description=_("Select the language PortMaster uses.")) + self.tags['option_list'].add_option( + 'select-theme', + _("Select Theme"), + description=_("Select a theme for PortMaster.")) schemes = self.gui.themes.get_theme_schemes_list() if len(schemes) > 0: - self.tags['option_list'].add_option('select-scheme', _("Select Color Scheme")) + self.tags['option_list'].add_option( + 'select-scheme', + _("Select Color Scheme"), + description=_("Select a colour scheme for PortMaster")) if self.gui.hm.cfg_data.get('konami', False): self.tags['option_list'].add_option(None, _("Secret Options")) - self.tags['option_list'].add_option('delete-config', _("Delete PortMaster Config")) - self.tags['option_list'].add_option('delete-runtimes', _("Delete PortMaster Runtimes")) + self.tags['option_list'].add_option( + 'delete-config', + _("Delete PortMaster Config"), + description=_("This can break stuff, don't touch unless you know what you are doing.")) + self.tags['option_list'].add_option( + 'delete-runtimes', + _("Delete PortMaster Runtimes"), + description=_("This can break stuff, don't touch unless you know what you are doing.")) # self.tags['option_list'].add_option(None, "") # self.tags['option_list'].add_option('back', _("Back")) self.tags['option_list'].list_select(0) self.set_buttons({'A': _('Enter'), 'B': _('Back')}) + self.last_selected = None def do_update(self, events): super().do_update(events) + if self.last_selected != self.tags['option_list'].selected_option(): + self.set_tooltip(self.tags['option_list'].selected_description()) + self.last_selected = self.tags['option_list'].selected_option() + if events.was_pressed('A'): selected_option = self.tags['option_list'].selected_option() @@ -1001,7 +1058,7 @@ def do_update(self, events): class FeaturedPortsListScene(BaseScene): def __init__(self, gui): super().__init__(gui) - self.scene_title = _("Featured Ports List") + self.scene_title = _("Featured Ports") self.load_regions("featured_ports_list", ['option_list', ]) @@ -1020,7 +1077,7 @@ def update_selection(self): port_list = self.featured_ports[selected] self.gui.set_data('featured_ports.name', port_list['name']) self.gui.set_data('featured_ports.description', port_list['description']) - self.gui.set_data('featured_ports.image', port_list['image']) + self.gui.set_data('featured_ports.image', str(port_list['image'])) self.last_select = selected def do_update(self, events): @@ -1187,7 +1244,7 @@ def __init__(self, gui, options): self.gui.set_data('featured_ports.name', options['name']) self.gui.set_data('featured_ports.description', options['description']) - self.gui.set_data('featured_ports.image', options['image']) + self.gui.set_data('featured_ports.image', str(options['image'])) self.gui.set_data('ports_list.total_ports', str(len(self.port_list))) self.gui.set_data('ports_list.filter_ports', str(len(self.port_list))) self.gui.set_data('ports_list.filters', "") @@ -1197,7 +1254,7 @@ def __init__(self, gui, options): self.all_ports[port_name]['attr']['title'] for port_name in self.port_list] - self.last_port = self.tags['ports_list'].selected + self.last_port = self.tags['ports_list'].selected + 1 self.set_buttons({'A': _('Show Info'), 'B': _('Back')}) @@ -1413,7 +1470,7 @@ def update_filters(self): first_add = True - for hm_genre in self.gui.hm.porters_list(): + for hm_genre in sorted(self.gui.hm.porters_list(), key=lambda name: name.lower()): if hm_genre in self.locked_genres: continue diff --git a/PortMaster/pylibs/pySDL2gui.py b/PortMaster/pylibs/pySDL2gui.py index 07eadaa..3cff52f 100644 --- a/PortMaster/pylibs/pySDL2gui.py +++ b/PortMaster/pylibs/pySDL2gui.py @@ -2371,28 +2371,37 @@ def draw(self, area=None, text=None, image=None): def reset_options(self): self.list = [] self.options = [] + self.descriptions = [] self._list_selected = [] self.gui.updated = True - def add_option(self, option, text, index=0): + def add_option(self, option, text, index=0, description=None): if self.list is None: self.list = [] self.options = [] + self.descriptions = [] self._list_selected = [] if self.options is None: self.options = [] + if self.options is None: + self.descriptions = [] + if self._list_selected is None: self._list_selected = [] while len(self.options) < len(self.list): self.options.append(None) + while len(self.descriptions) < len(self.list): + self.descriptions.append("") + while len(self._list_selected) < len(self.list): self._list_selected.append(0) self.gui.updated = True + self.descriptions.append(description) self.options.append(option) self.list.append(text) self._list_selected.append(index) @@ -2406,8 +2415,25 @@ def selected_option(self): if len(self.options) == 0: return None + if self.selected >= len(self.options): + return None + return self.options[self.selected] + def selected_description(self): + if self.descriptions is None: + return "" + if self.list is None: + return "" + + if len(self.descriptions) == 0: + return "" + + if self.selected >= len(self.descriptions): + return "" + + return self.descriptions[self.selected] + def list_selected(self): return self.selected