Esempio n. 1
0
 def on_install_clicked(self, _widget=None, game_ref=None):
     """Install a game"""
     if not game_ref:
         game_id = self._get_current_game_id()
         game = pga.get_game_by_field(game_id, 'id')
         game_ref = game.get('slug')
         logger.debug("Installing game %s (%s)" % (game_ref, game_id))
     if not game_ref:
         return
     InstallerDialog(game_ref, self)
Esempio n. 2
0
 def on_game_clicked(self, *args):
     """Launch a game, or install it if it is not"""
     game_slug = self._get_current_game_slug()
     if not game_slug:
         return
     self.running_game = Game(game_slug)
     if self.running_game.is_installed:
         self.stop_button.set_sensitive(True)
         self.running_game.play()
     else:
         InstallerDialog(game_slug, self)
Esempio n. 3
0
 def on_game_run(self, *args, game_id=None):
     """Launch a game, or install it if it is not"""
     if not game_id:
         game_id = self._get_current_game_id()
     if not game_id:
         return
     self.running_game = Game(game_id)
     if self.running_game.is_installed:
         self.running_game.play()
     else:
         game_slug = self.running_game.slug
         self.running_game = None
         InstallerDialog(game_slug=game_slug, parent=self)
Esempio n. 4
0
 def on_install_clicked(self,
                        *args,
                        game_slug=None,
                        installer_file=None,
                        revision=None):
     """Install a game"""
     if not game_slug:
         game_id = self._get_current_game_id()
         game = pga.get_game_by_field(game_id, 'id')
         game_slug = game.get('slug')
         logger.debug("Installing game %s (%s)" % (game_slug, game_id))
     if not game_slug:
         return
     InstallerDialog(game_slug=game_slug,
                     installer_file=installer_file,
                     revision=revision,
                     parent=self)
Esempio n. 5
0
    def on_install_clicked(self, *args, game_slug=None, installer_file=None, revision=None):
        """Install a game"""

        installer_desc = game_slug if game_slug else installer_file
        if revision:
            installer_desc += " (%s)" % revision
        logger.info("Installing %s" % installer_desc)

        if not game_slug and not installer_file:
            # Install the currently selected game in the UI
            game_id = self._get_current_game_id()
            game = pga.get_game_by_field(game_id, 'id')
            game_slug = game.get('slug')
        if not game_slug and not installer_file:
            return
        InstallerDialog(game_slug=game_slug,
                        installer_file=installer_file,
                        revision=revision,
                        parent=self)
Esempio n. 6
0
    def do_command_line(self, command_line):
        options = command_line.get_options_dict()

        if options.contains('debug'):
            logger.setLevel(logging.DEBUG)

        if options.contains('list-games'):
            game_list = pga.get_games()
            if options.contains('installed'):
                game_list = [game for game in game_list if game['installed']]
            if options.contains('json'):
                self.print_game_json(command_line, game_list)
            else:
                self.print_game_list(command_line, game_list)
            return 0
        elif options.contains('list-steam-games'):
            self.print_steam_list(command_line)
            return 0
        elif options.contains('list-steam-folders'):
            self.print_steam_folders(command_line)
            return 0
        elif options.contains('exec'):
            command = options.lookup_value('exec').get_string()
            self.execute_command(command)
            return 0

        check_config(force_wipe=False)
        migrate()

        game_slug = ''
        uri = options.lookup_value(GLib.OPTION_REMAINING)
        if uri:
            uri = uri.get_strv()
        if uri and len(uri):
            uri = uri[0]  # TODO: Support multiple
            if not uri.startswith('lutris:'):
                self._print(command_line, '%s is not a valid URI' % uri)
                return 1
            game_slug = uri[7:]

        if game_slug or options.contains('install'):
            if options.contains('install'):
                installer_file = options.lookup_value('install').get_string()
                installer = installer_file
            else:
                installer_file = None
                installer = game_slug
            if not game_slug and not os.path.isfile(installer_file):
                self._print(command_line, "No such file: %s" % installer_file)
                return 1

            db_game = None
            if game_slug:
                db_game = (pga.get_game_by_field(game_slug, 'id')
                           or pga.get_game_by_field(game_slug, 'slug') or
                           pga.get_game_by_field(game_slug, 'installer_slug'))

            if db_game and db_game['installed'] and not options.contains(
                    'reinstall'):
                self._print(command_line, "Launching %s" % db_game['name'])
                if self.window:
                    self.run_game(db_game['id'])
                else:
                    lutris_game = Game(db_game['id'])
                    # FIXME: This is awful
                    lutris_game.exit_main_loop = True
                    lutris_game.play()
                    try:
                        GLib.MainLoop().run()
                    except KeyboardInterrupt:
                        lutris_game.stop()
                return 0
            else:
                self._print(command_line, "Installing %s" % installer)
                if self.window:
                    self.install_game(installer)
                else:
                    runtime_updater = RuntimeUpdater()
                    runtime_updater.update()
                    # FIXME: This should be a Gtk.Dialog child of LutrisWindow
                    dialog = InstallerDialog(installer)
                    self.add_window(dialog)
                return 0

        self.activate()
        return 0
Esempio n. 7
0
 def on_install_clicked(self, *args):
     """Install a game"""
     game_slug = self._get_current_game_slug()
     if not game_slug:
         return
     InstallerDialog(game_slug, self)