예제 #1
0
    def __install(self, game: Game = None):
        GLib.idle_add(self.__update_to_state, game.state.INSTALLING, game)
        game.install_dir = game.get_install_dir()
        try:
            if os.path.exists(game.keep_path):
                install_game(game, game.keep_path, main_window=self)
            else:
                install_game(game, game.download_path, main_window=self)
        except (FileNotFoundError, BadZipFile):
            GLib.idle_add(self.__update_to_state, game.state.DOWNLOADABLE,
                          game)
            return
        GLib.idle_add(self.__update_to_state, game.state.INSTALLED, game)
        GLib.idle_add(self.__reload_state, game)
        # make user to add the game to the side bar

        # check if DLCs should also be installed
        if game.type == "game" and Config.get("install_dlcs"):
            # first ensure we know about game dlcs
            self.library.update_dlcs_for_game(game)
            if len(game.dlcs) == 0:
                return
            # now grab DLCs that can be installed
            downloads = []
            for dlc in game.dlcs:
                try:
                    download_info = self.api.get_download_info(
                        dlc, game.platform, True, dlc.get_installers())
                except Exception:
                    # could not find a valid target, ignore it
                    continue
                # set dlc information now, otherwise this will break later
                dlc.platform = game.platform
                dlc.language = game.language
                # add download
                # Start the download for all files
                for key, file_info in enumerate(download_info['files']):
                    if key > 0:
                        download_path = "{}-{}.bin".format(
                            dlc.download_path, key)
                    else:
                        download_path = dlc.download_path
                    download = Download(url=self.api.get_real_download_link(
                        file_info["downlink"]),
                                        title=dlc.name,
                                        associated_object=dlc,
                                        save_location=download_path,
                                        number=key + 1,
                                        file_size=download_info["total_size"],
                                        out_of_amount=len(
                                            download_info['files']))
                    download.register_finish_function(self.__dlc_finish_func,
                                                      [game, dlc])
                    download.register_progress_function(
                        self.set_progress, game)
                    download.register_cancel_function(self.__cancel_download,
                                                      game)
                    downloads.append(download)
            DownloadManager.download(downloads)
예제 #2
0
 def __update(self, game: Game = None):
     GLib.idle_add(self.__update_to_state, game.state.UPDATING, game)
     game.install_dir = self.__get_install_dir(game)
     try:
         if os.path.exists(game.keep_path):
             install_game(self.game,
                          self.keep_path,
                          parent_window=self.parent)
         else:
             install_game(self.game,
                          self.update_path,
                          parent_window=self.parent)
     except (FileNotFoundError, BadZipFile):
         GLib.idle_add(self.__update_to_state, game.state.UPDATABLE, game)
         return
     # reset updates count flag
     game.updates = 0
     GLib.idle_add(self.__update_to_state, game.state.INSTALLED, game)