mirror of
https://github.com/lutris/lutris
synced 2024-10-06 15:59:39 +00:00
Pass in the launch UI delegate explicitly for launch()
This would be better with asyncio; we could keep the InstallWindow or whatnot visible until the game starts. As it is, we'll just use the LutrisWindow for this.
This commit is contained in:
parent
afacf82d07
commit
172e524ba7
|
@ -741,11 +741,8 @@ class Game(GObject.Object):
|
|||
return True
|
||||
|
||||
@watch_game_errors(game_stop_result=False)
|
||||
def launch(self, launch_ui_delegate=None):
|
||||
def launch(self, launch_ui_delegate):
|
||||
"""Request launching a game. The game may not be installed yet."""
|
||||
if not launch_ui_delegate:
|
||||
launch_ui_delegate = Gio.Application.get_default().launch_ui_delegate
|
||||
|
||||
if not self.check_launchable():
|
||||
logger.error("Game is not launchable")
|
||||
return False
|
||||
|
|
|
@ -2,7 +2,7 @@ from collections import OrderedDict
|
|||
from copy import deepcopy
|
||||
from gettext import gettext as _
|
||||
|
||||
from gi.repository import GLib, Gtk
|
||||
from gi.repository import Gio, GLib, Gtk
|
||||
|
||||
from lutris.config import write_game_config
|
||||
from lutris.database.games import add_game
|
||||
|
@ -216,7 +216,10 @@ class ImportGameDialog(ModelessDialog):
|
|||
launch_button.connect("clicked", self.on_launch_clicked, game)
|
||||
|
||||
def on_launch_clicked(self, _button, game):
|
||||
game.launch()
|
||||
# We can't use this window as the delegate because we
|
||||
# are destroying it.
|
||||
application = Gio.Application.get_default()
|
||||
game.launch(application.launch_ui_delegate)
|
||||
self.destroy()
|
||||
|
||||
def display_existing_game_info(self, filename, game):
|
||||
|
|
|
@ -906,12 +906,15 @@ class InstallerWindow(ModelessDialog,
|
|||
def on_launch_clicked(self, button):
|
||||
"""Launch a game after it's been installed."""
|
||||
button.set_sensitive(False)
|
||||
self.on_cancel_clicked(button)
|
||||
game = Game(self.interpreter.installer.game_id)
|
||||
if game.is_db_stored:
|
||||
game.launch()
|
||||
# Since we're closing this window, we can't use
|
||||
# it as the delegate.
|
||||
application = Gio.Application.get_default()
|
||||
game.launch(application.launch_ui_delegate)
|
||||
else:
|
||||
logger.error("Game has no ID, launch button should not be drawn")
|
||||
self.on_cancel_clicked(button)
|
||||
|
||||
def on_window_focus(self, _widget, *_args):
|
||||
"""Remove urgency hint (flashing indicator) when window receives focus"""
|
||||
|
|
|
@ -152,7 +152,7 @@ class ServiceSidebarRow(SidebarRow):
|
|||
|
||||
def on_service_run(self, button):
|
||||
"""Run a launcher associated with a service"""
|
||||
self.service.run()
|
||||
self.service.run(self.get_toplevel())
|
||||
|
||||
def on_refresh_clicked(self, button):
|
||||
"""Reload the service games"""
|
||||
|
|
|
@ -102,20 +102,20 @@ class BaseService(GObject.Object):
|
|||
return self._matcher
|
||||
return self.id
|
||||
|
||||
def run(self):
|
||||
def run(self, launch_ui_delegate):
|
||||
"""Launch the game client"""
|
||||
launcher = self.get_launcher()
|
||||
if launcher:
|
||||
launcher.launch()
|
||||
launcher.launch(launch_ui_delegate)
|
||||
|
||||
def is_launchable(self):
|
||||
if self.client_installer:
|
||||
return get_game_by_field(self.client_installer, "slug")
|
||||
return bool(get_game_by_field(self.client_installer, "slug"))
|
||||
return False
|
||||
|
||||
def get_launcher(self):
|
||||
if not self.client_installer:
|
||||
return
|
||||
return None
|
||||
db_launcher = get_game_by_field(self.client_installer, "slug")
|
||||
if db_launcher:
|
||||
return Game(db_launcher["id"])
|
||||
|
|
|
@ -170,14 +170,6 @@ class EAAppService(OnlineService):
|
|||
def api_url(self):
|
||||
return "https://api%s.origin.com" % random.randint(1, 4)
|
||||
|
||||
def run(self):
|
||||
db_game = get_game_by_field(self.client_installer, "slug")
|
||||
game = Game(db_game["id"])
|
||||
game.launch()
|
||||
|
||||
def is_launchable(self):
|
||||
return get_game_by_field(self.client_installer, "slug")
|
||||
|
||||
def is_connected(self):
|
||||
return bool(self.access_token)
|
||||
|
||||
|
|
|
@ -191,14 +191,6 @@ class EpicGamesStoreService(OnlineService):
|
|||
'daafbccc737745039dffe53d94fc76cf'
|
||||
)
|
||||
|
||||
def run(self):
|
||||
egs = get_game_by_field(self.client_installer, "slug")
|
||||
egs_game = Game(egs["id"])
|
||||
egs_game.launch()
|
||||
|
||||
def is_launchable(self):
|
||||
return get_game_by_field(self.client_installer, "slug")
|
||||
|
||||
def is_connected(self):
|
||||
return self.is_authenticated()
|
||||
|
||||
|
|
|
@ -161,14 +161,6 @@ class OriginService(OnlineService):
|
|||
def api_url(self):
|
||||
return "https://api%s.origin.com" % random.randint(1, 4)
|
||||
|
||||
def run(self):
|
||||
db_game = get_game_by_field(self.client_installer, "slug")
|
||||
game = Game(db_game["id"])
|
||||
game.launch()
|
||||
|
||||
def is_launchable(self):
|
||||
return get_game_by_field(self.client_installer, "slug")
|
||||
|
||||
def is_connected(self):
|
||||
return bool(self.access_token)
|
||||
|
||||
|
|
Loading…
Reference in a new issue