diff --git a/bottles/backend/globals.py b/bottles/backend/globals.py index 152afd4194..d925125f58 100644 --- a/bottles/backend/globals.py +++ b/bottles/backend/globals.py @@ -20,7 +20,7 @@ from functools import lru_cache from pathlib import Path from typing import Dict - +from bottles.backend.utils import yaml, json @lru_cache class Paths: @@ -79,6 +79,9 @@ class TrdyPaths: mangohud_available = shutil.which("mangohud") or False obs_vkc_available = shutil.which("obs-vkcapture") or False vmtouch_available = shutil.which("vmtouch") or False +base_version = "" +if os.path.isfile("/app/manifest.json"): + base_version = json.load(open("/app/manifest.json")).get("base-version","").removeprefix("stable-") # encoding detection correction, following windows defaults locale_encodings: Dict[str, str] = { diff --git a/bottles/backend/managers/dependency.py b/bottles/backend/managers/dependency.py index fb1f0981f3..218b0da817 100644 --- a/bottles/backend/managers/dependency.py +++ b/bottles/backend/managers/dependency.py @@ -128,6 +128,10 @@ def install(self, config: BottleConfig, dependency: list) -> Result: Here we execute all steps in the manifest. Steps are the actions performed to install the dependency. """ + arch = step.get("for", "win64_win32") + if config.Arch not in arch: + continue + res = self.__perform_steps(config, step) if not res.ok: TaskManager.remove(task_id) diff --git a/bottles/frontend/views/bottle_dependencies.py b/bottles/frontend/views/bottle_dependencies.py index 8cdb5158b2..160fd9d05a 100644 --- a/bottles/frontend/views/bottle_dependencies.py +++ b/bottles/frontend/views/bottle_dependencies.py @@ -28,9 +28,9 @@ from bottles.frontend.widgets.dependency import DependencyEntry -@Gtk.Template(resource_path='/com/usebottles/bottles/details-dependencies.ui') +@Gtk.Template(resource_path="/com/usebottles/bottles/details-dependencies.ui") class DependenciesView(Adw.Bin): - __gtype_name__ = 'DetailsDependencies' + __gtype_name__ = "DetailsDependencies" __registry = [] # region Widgets @@ -63,7 +63,7 @@ def __init__(self, details, config: BottleConfig, **kwargs): self.btn_report.connect("clicked", open_doc_url, "contribute/missing-dependencies") self.btn_help.connect("clicked", open_doc_url, "bottles/dependencies") - if self.manager.utils_conn.status == False: + if not self.manager.utils_conn.status: self.stack.set_visible_child_name("page_offline") self.spinner_loading.start() @@ -89,7 +89,7 @@ def empty_list(self): r.get_parent().remove(r) self.__registry = [] - def update(self, widget=False, config: Optional[BottleConfig] = None): + def update(self, _widget=False, config: Optional[BottleConfig] = None): """ This function update the dependencies list with the supported by the manager. @@ -99,7 +99,7 @@ def update(self, widget=False, config: Optional[BottleConfig] = None): self.config = config # Not sure if it's the best place to make this check - if self.manager.utils_conn.status == False: + if not self.manager.utils_conn.status: return self.stack.set_visible_child_name("page_loading") @@ -115,7 +115,7 @@ def new_dependency(dependency, plain=False): self.list_dependencies.append(entry) @GtkUtils.run_in_main_loop - def callback(result, error=False): + def callback(_result, _error=False): self.stack.set_visible_child_name("page_deps") def process_dependencies(): @@ -128,11 +128,7 @@ def process_dependencies(): if len(dependencies.keys()) > 0: for dep in dependencies.items(): if dep[0] in self.config.Installed_Dependencies: - continue # Do not list already installed dependencies' - - if dep[1].get("Arch", "win64") != self.config.Arch: - # NOTE: avoid listing dependencies not supported by the bottle arch - continue + continue # Do not list already installed dependencies GLib.idle_add(new_dependency, dep) diff --git a/bottles/frontend/views/bottle_preferences.py b/bottles/frontend/views/bottle_preferences.py index 7f5e9cb96f..7d1454cdcf 100644 --- a/bottles/frontend/views/bottle_preferences.py +++ b/bottles/frontend/views/bottle_preferences.py @@ -23,7 +23,7 @@ from gi.repository import Gtk, Adw from bottles.backend.globals import gamemode_available, vkbasalt_available, mangohud_available, obs_vkc_available, \ - vmtouch_available, gamescope_available + vmtouch_available, gamescope_available, base_version from bottles.backend.logger import Logger from bottles.backend.managers.library import LibraryManager from bottles.backend.managers.runtime import RuntimeManager @@ -194,11 +194,15 @@ def __init__(self, details, config, **kwargs): self.switch_vmtouch.set_sensitive(vmtouch_available) _not_available = _("This feature is unavailable on your system.") _flatpak_not_available = _("{} To add this feature, please run flatpak install").format(_not_available) + _gamescope_pkg_name = "org.freedesktop.Platform.VulkanLayer.gamescope" + _vkbasalt_pkg_name = "org.freedesktop.Platform.VulkanLayer.vkBasalt" + _mangohud_pkg_name = "org.freedesktop.Platform.VulkanLayer.MangoHud" + _obsvkc_pkg_name = "com.obsproject.Studio.Plugin.OBSVkCapture" _flatpak_pkg_name = { - "gamescope": "org.freedesktop.Platform.VulkanLayer.gamescope", - "vkbasalt": "org.freedesktop.Platform.VulkanLayer.vkBasalt//22.08", - "mangohud": "org.freedesktop.Platform.VulkanLayer.MangoHud//22.08", - "obsvkc": "com.obsproject.Studio.Plugin.OBSVkCapture" + "gamescope": f"{_gamescope_pkg_name}//{base_version}" if base_version else _gamescope_pkg_name, + "vkbasalt": f"{_vkbasalt_pkg_name}//{base_version}" if base_version else _vkbasalt_pkg_name, + "mangohud": f"{_mangohud_pkg_name}//{base_version}" if base_version else _mangohud_pkg_name, + "obsvkc": _obsvkc_pkg_name } if not gamemode_available: diff --git a/bottles/frontend/widgets/dependency.py b/bottles/frontend/widgets/dependency.py index d50932be48..8613b13ca3 100644 --- a/bottles/frontend/widgets/dependency.py +++ b/bottles/frontend/widgets/dependency.py @@ -28,9 +28,9 @@ from bottles.frontend.windows.generic import SourceDialog -@Gtk.Template(resource_path='/com/usebottles/bottles/dependency-entry.ui') +@Gtk.Template(resource_path="/com/usebottles/bottles/dependency-entry.ui") class DependencyEntry(Adw.ActionRow): - __gtype_name__ = 'DependencyEntry' + __gtype_name__ = "DependencyEntry" # region Widgets label_category = Gtk.Template.Child() @@ -56,10 +56,10 @@ def __init__(self, window, config: BottleConfig, dependency, plain=False, **kwar self.queue = window.page_details.queue if plain: - ''' + """ If the dependency is plain, treat it as a placeholder, it can be used to display "fake" elements on the list - ''' + """ self.set_title(dependency) self.set_subtitle("") self.btn_install.set_visible(False) @@ -67,6 +67,13 @@ def __init__(self, window, config: BottleConfig, dependency, plain=False, **kwar self.btn_reinstall.set_visible(True) return + if self.config.Arch not in dependency[1].get("Arch", "win64_win32"): + self.btn_install.set_visible(False) + self.btn_remove.set_visible(False) + self.btn_reinstall.set_visible(False) + self.btn_err.set_visible(True) + self.btn_err.set_tooltip_text(_("This dependency is not compatible with this bottle architecture.")) + # populate widgets self.set_title(dependency[0]) self.set_subtitle(dependency[1].get("Description")) @@ -80,24 +87,24 @@ def __init__(self, window, config: BottleConfig, dependency, plain=False, **kwar self.btn_license.connect("clicked", self.open_license) if dependency[0] in self.config.Installed_Dependencies: - ''' + """ If the dependency is installed, hide the btn_install button and show the btn_remove button - ''' + """ self.btn_install.set_visible(False) self.btn_remove.set_visible(True) self.btn_reinstall.set_visible(True) if dependency[0] in self.config.Uninstallers.keys(): - ''' + """ If the dependency has no uninstaller, disable the btn_remove button - ''' + """ uninstaller = self.config.Uninstallers[dependency[0]] if uninstaller in [False, "NO_UNINSTALLER"]: self.btn_remove.set_sensitive(False) - def open_manifest(self, widget): + def open_manifest(self, _widget): """ This function pop up a dialog with the manifest of the dependency @@ -111,7 +118,7 @@ def open_manifest(self, widget): ) ).present() - def open_license(self, widget): + def open_license(self, _widget): """ This function pop up a dialog with the license of the dependency @@ -121,7 +128,7 @@ def open_license(self, widget): ) webbrowser.open(manifest["License_url"]) - def install_dependency(self, widget): + def install_dependency(self, _widget): """ This function install the dependency in the bottle, it will also prevent user from installing other dependencies @@ -142,12 +149,12 @@ def install_dependency(self, widget): dependency=self.dependency, ) - def remove_dependency(self, widget): + def remove_dependency(self, _widget): """ This function remove the dependency from the bottle configuration """ - widget.set_sensitive(False) + _widget.set_sensitive(False) RunAsync( task_func=self.manager.remove_dependency, callback=self.set_install_status, @@ -172,7 +179,8 @@ def set_install_status(self, result: Result, error=None): self.window.show_toast(_("\"{0}\" uninstalled").format(self.dependency[0])) else: self.window.show_toast(_("\"{0}\" installed").format(self.dependency[0])) - return self.set_installed(uninstaller, removed) + self.set_installed(uninstaller, removed) + return self.set_err() def set_err(self):