mirror of
https://github.com/bottlesdevs/Bottles.git
synced 2026-10-28 06:06:33 +08:00
* refactor: migrate config from dict to object * fix: type hint import * fix: BottleConfig.load() * fix: config loading in BackupManager.import_backup() * fix: Remove unused import * fix: more guard code, type hints and Config object usage * fix: a potential crash when SteamManager.get_app_config() failed * Revert "fix: Remove unused import" This reverts commit2d48a4e08a. * add: new config field * fix: Config object value read * misc: remove review TODO comments * adapt to new BottleConfig object * fix RunAsync usage * add: BottleConfig._fix() * fix: type hint and Config object usage * fix: typo in FSR setting default value * adapt to new BottleConfig object * remove unnecessary DictCompat method * add: BottleConfig._filter() * fix: TemplateManager.new() * misc: critical guard code * fix: typo in commitb7ed61e678* misc: more type hinting * Revert "remove unnecessary DictCompat method" This reverts commit265633e733. * fix crash when user choose Cancel in ProtonAlertDialog * fix force stop all programs not work * adapt NVAPIComponent.check_bottle_nvngx to Config object * Better DictCompatMixIn * InstallerManager.__set_parameters incorrect adopt * fix typo incbe1dc760b* adopt LibraryManager.download_thumbnail to Config object * serialize Config object to yaml automatically * fix translation and remove workaround in0830fddbc9* fix missing locale for Chinese * comment * fix incorrect variable init position * remove 'in' extensions and some bugfix * fix executable filemode Co-authored-by: Mirko Brombin <send@mirko.pm>
99 lines
3.6 KiB
Python
99 lines
3.6 KiB
Python
# runner.py
|
|
#
|
|
# Copyright 2022 brombinmirko <send@mirko.pm>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, in version 3 of the License.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
import os
|
|
from typing import TYPE_CHECKING
|
|
|
|
from bottles.backend.logger import Logger
|
|
from bottles.backend.managers.runtime import RuntimeManager
|
|
from bottles.backend.models.config import BottleConfig
|
|
from bottles.backend.models.result import Result
|
|
from bottles.backend.utils.manager import ManagerUtils
|
|
from bottles.backend.wine.wineboot import WineBoot
|
|
|
|
if TYPE_CHECKING:
|
|
from bottles.backend.managers.manager import Manager
|
|
|
|
logging = Logger()
|
|
|
|
|
|
class Runner:
|
|
"""
|
|
This class handle everything related to the runner (e.g. Wine, Proton).
|
|
It should not contain any manager logic (e.g. catalogs, checks, etc.) or
|
|
any bottle related stuff (e.g. config handling, etc.), also DXVK, VKD3D,
|
|
NVAPI handling should not performed from here.
|
|
"""
|
|
|
|
@staticmethod
|
|
def runner_update(config: BottleConfig, manager: 'Manager', runner: str) -> Result[dict]:
|
|
"""
|
|
This method should be executed after changing the runner
|
|
for a bottle. It does a prefix update and re-initialize the
|
|
active DLLComponents (dxvk, dxvk-nvapi, vkd3d…) to re-create
|
|
the overrides and fix broken registry keys.
|
|
"""
|
|
logging.info(f"Doing runner update for bottle: {config.Name}")
|
|
wineboot = WineBoot(config)
|
|
|
|
if not runner.startswith("sys-"):
|
|
runner_path = ManagerUtils.get_runner_path(runner)
|
|
|
|
if not os.path.exists(runner_path):
|
|
logging.error(f"Runner {runner} not found in {runner_path}")
|
|
return Result(
|
|
status=False,
|
|
data={"config": config}
|
|
)
|
|
|
|
# kill wineserver after update
|
|
wineboot.kill(force_if_stalled=True)
|
|
|
|
# update bottle config
|
|
up_config = manager.update_config(
|
|
config=config,
|
|
key="Runner",
|
|
value=runner
|
|
).data["config"]
|
|
|
|
# perform a prefix update
|
|
wineboot.update()
|
|
|
|
# re-initialize DLLComponents
|
|
if config.Parameters.dxvk:
|
|
manager.install_dll_component(config, "dxvk", overrides_only=True)
|
|
if config.Parameters.dxvk_nvapi:
|
|
manager.install_dll_component(config, "nvapi", overrides_only=True)
|
|
if config.Parameters.vkd3d:
|
|
manager.install_dll_component(config, "vkd3d", overrides_only=True)
|
|
|
|
"""
|
|
enable Steam runtime if using Proton.
|
|
|
|
NOTE: Official Proton runners need to be launched with the Steam Runtime to works
|
|
properly, since it relies on a lot of libraries that should not be present on
|
|
the host system. There are some exceptions, like the Soda and Wine-GE runners,
|
|
which are built to work without the Steam Runtime.
|
|
"""
|
|
if "proton" in runner.lower() and RuntimeManager.get_runtimes("steam"):
|
|
manager.update_config(config, "use_steam_runtime", True, "Parameters")
|
|
|
|
return Result(
|
|
status=True,
|
|
data={"config": up_config}
|
|
)
|