mirror of
https://github.com/lutris/lutris
synced 2024-10-06 15:59:39 +00:00
Switch the install_updates and install_dlc to use the InstallUIDelegate, and always provide it.
Also, increase pylint max-parents. This thing is not measuring the depth of the hierarchy- we're being penalized for multiple inheritance here.
This commit is contained in:
parent
9fb4e3b258
commit
ad040a318e
|
@ -344,7 +344,7 @@ max-branches=12
|
|||
max-locals=15
|
||||
|
||||
# Maximum number of parents for a class (see R0901).
|
||||
max-parents=7
|
||||
max-parents=15
|
||||
|
||||
# Maximum number of public methods for a class (see R0904).
|
||||
max-public-methods=20
|
||||
|
|
|
@ -380,12 +380,8 @@ class Game(GObject.Object):
|
|||
game.connect("game-error", on_error)
|
||||
game.launch(launch_ui_delegate)
|
||||
|
||||
def install_updates(self, launch_ui_delegate=None):
|
||||
application = Gio.Application.get_default()
|
||||
if not launch_ui_delegate:
|
||||
launch_ui_delegate = application.launch_ui_delegate
|
||||
|
||||
service = launch_ui_delegate.get_service(self.service)
|
||||
def install_updates(self, install_ui_delegate):
|
||||
service = install_ui_delegate.get_service(self.service)
|
||||
db_game = games_db.get_game_by_field(self.id, "id")
|
||||
|
||||
def on_installers_ready(installers, error):
|
||||
|
@ -394,18 +390,16 @@ class Game(GObject.Object):
|
|||
|
||||
if not installers:
|
||||
raise RuntimeError(_("No updates found"))
|
||||
|
||||
application = Gio.Application.get_default()
|
||||
application.show_installer_window(installers, service, self.appid,
|
||||
installation_kind=InstallationKind.UPDATE)
|
||||
|
||||
jobs.AsyncCall(service.get_update_installers, on_installers_ready, db_game)
|
||||
return True
|
||||
|
||||
def install_dlc(self, launch_ui_delegate=None):
|
||||
application = Gio.Application.get_default()
|
||||
if not launch_ui_delegate:
|
||||
launch_ui_delegate = application.launch_ui_delegate
|
||||
|
||||
service = launch_ui_delegate.get_service(self.service)
|
||||
def install_dlc(self, install_ui_delegate):
|
||||
service = install_ui_delegate.get_service(self.service)
|
||||
db_game = games_db.get_game_by_field(self.id, "id")
|
||||
|
||||
def on_installers_ready(installers, error):
|
||||
|
@ -415,6 +409,7 @@ class Game(GObject.Object):
|
|||
if not installers:
|
||||
raise RuntimeError(_("No DLC found"))
|
||||
|
||||
application = Gio.Application.get_default()
|
||||
application.show_installer_window(installers, service, self.appid, installation_kind=InstallationKind.DLC)
|
||||
|
||||
jobs.AsyncCall(service.get_dlc_installers_runner, on_installers_ready, db_game, db_game["runner"])
|
||||
|
|
|
@ -32,7 +32,7 @@ from lutris.util.system import path_exists
|
|||
class BaseGameActions:
|
||||
def __init__(self, games, window, application=None):
|
||||
self.application = application or Gio.Application.get_default()
|
||||
self.window = window # also used as a LaunchUIDelegate
|
||||
self.window = window # also used as a LaunchUIDelegate and InstallUIDelegate
|
||||
self.games = games
|
||||
|
||||
def get_game_actions(self):
|
||||
|
@ -278,11 +278,11 @@ class GameActions(BaseGameActions):
|
|||
|
||||
def on_update_clicked(self, _widget):
|
||||
for game in self.games:
|
||||
game.install_updates(launch_ui_delegate=self.window)
|
||||
game.install_updates(install_ui_delegate=self.window)
|
||||
|
||||
def on_install_dlc_clicked(self, _widget):
|
||||
for game in self.games:
|
||||
game.install_dlc(launch_ui_delegate=self.window)
|
||||
game.install_dlc(install_ui_delegate=self.window)
|
||||
|
||||
def on_game_duplicate(self, _widget):
|
||||
for game in self.games:
|
||||
|
|
|
@ -10,7 +10,14 @@ from lutris.services import get_enabled_services
|
|||
from lutris.util.downloader import Downloader
|
||||
|
||||
|
||||
class LaunchUIDelegate:
|
||||
class Delegate:
|
||||
def get_service(self, service_id):
|
||||
"""Returns a new service object by its id. This seems dumb, but it is a work-around
|
||||
for Python's circular import limitations."""
|
||||
return get_enabled_services()[service_id]()
|
||||
|
||||
|
||||
class LaunchUIDelegate(Delegate):
|
||||
"""These objects provide UI for the game while it is being launched;
|
||||
one provided to the launch() method.
|
||||
|
||||
|
@ -42,13 +49,8 @@ class LaunchUIDelegate:
|
|||
"""
|
||||
return {} # primary game
|
||||
|
||||
def get_service(self, service_id):
|
||||
"""Returns a new service object by its id. This seems dumb, but it is a work-around
|
||||
for Python's circular import limitations."""
|
||||
return get_enabled_services()[service_id]()
|
||||
|
||||
|
||||
class InstallUIDelegate:
|
||||
class InstallUIDelegate(Delegate):
|
||||
"""These objects provide UI for a runner as it is installing itself.
|
||||
One of these must be provided to the install() method.
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ from lutris import settings
|
|||
from lutris.config import LutrisConfig
|
||||
from lutris.database.games import get_game_by_field
|
||||
from lutris.exceptions import MisconfigurationError
|
||||
from lutris.gui.dialogs.delegates import Delegate
|
||||
from lutris.installer import AUTO_EXE_PREFIX
|
||||
from lutris.installer.commands import CommandsMixin
|
||||
from lutris.installer.errors import MissingGameDependencyError, ScriptingError
|
||||
|
@ -29,7 +30,7 @@ class ScriptInterpreter(GObject.Object, CommandsMixin):
|
|||
"runners-installed": (GObject.SIGNAL_RUN_FIRST, None, ()),
|
||||
}
|
||||
|
||||
class InterpreterUIDelegate:
|
||||
class InterpreterUIDelegate(Delegate):
|
||||
"""This is a base class for objects that provide UI services
|
||||
for running scripts. The InstallerWindow inherits from this."""
|
||||
|
||||
|
|
Loading…
Reference in a new issue