Пример #1
0
        public void GameInstalled(DownloadEngine.DownloadStatus status, long id, DownloadManager.DownloadTypes type)
        {
            Debug.LogWarning("Game installation status: " + status);

            if (status != DownloadEngine.DownloadStatus.success)
            {
                return;
            }

            Game game = FindGame(id);

            if (game == null)
            {
                Debug.LogError("Something went desperately wrong, downloaded game not found");
                return;
            }

            UnpackGame(game);

            File.WriteAllText(appPath + game.path + "version.txt", game.version.ToString());

            game.installed = true;

            //RefreshGamesDisplay();
            if (!GameListTextTemplate.Dispatcher.CheckAccess())
            {
                GameListTextTemplate.Dispatcher.Invoke(new Action(RefreshGamesDisplay));
                return;
            }
        }
Пример #2
0
        public bool DownloadIcon(Int64 gameID, string outputFile, Action <DownloadStatus, long, DownloadManager.DownloadTypes> _downloadCompleteFunction = null, bool highResImage = false)
        {
            if (working)
            {
                Debug.LogWarning("Download engine is downloading, cannot start new download");
                return(false);
            }

            type = DownloadManager.DownloadTypes.icon;

            downloadCompleteFunction = _downloadCompleteFunction;

            working = true;

            workingThread = new Thread(() => _DownloadIcon(gameID, outputFile, highResImage));
            workingThread.Start();

            return(true);
        }
Пример #3
0
        /*private void _DownloadGames(Int64[] gamesIDs, string[] outputFiles)
         * {
         *  for (int i = 0; i < outputFiles.Length; i++)
         *  {
         *      _DownloadGame(gamesIDs[i], outputFiles[i]);
         *  }
         *
         *
         * }
         *
         * public bool DownloadGames(Int64[] gamesIDs, string[] outputFiles)
         * {
         *  if (working)
         *  {
         *      Debug.LogWarning("Download engine is downloading, cannot start new download");
         *      return false;
         *  }
         *
         *  if (gamesIDs.Length != outputFiles.Length)
         *  {
         *      Debug.LogError("DownloadFilesNames and outputFilesPaths are not the same size, returning");
         *      return false;
         *  }
         *
         *  working = true;
         *  workingThread = new Thread(() => _DownloadGames(gamesIDs, outputFiles));
         *  workingThread.Start();
         *
         *
         *  return true;
         * }*/

        /// <summary>
        /// Downloads file from server
        /// </summary>
        /// <param name="id">Game ID to download</param>
        /// <param name="outputFilePath">Downloaded file path</param>
        /// <returns></returns>
        public bool DownloadGame(Int64 id, string outputFile, Action <DownloadStatus, long, DownloadManager.DownloadTypes> _downloadCompleteFunction = null)
        {
            if (working)
            {
                Debug.LogWarning("Download engine is downloading, cannot start new download");
                return(false);
            }

            type = DownloadManager.DownloadTypes.game;

            downloadCompleteFunction = _downloadCompleteFunction;

            working = true;

            workingThread = new Thread(() => _DownloadGame(id, outputFile));
            workingThread.Start();

            return(true);
        }
Пример #4
0
 private void IconDownloaded(DownloadEngine.DownloadStatus status, Int64 gameID, DownloadManager.DownloadTypes type)
 {
     if (status == DownloadEngine.DownloadStatus.success)
     {
         SetIcon(AppDomain.CurrentDomain.BaseDirectory + Library.iconsPath + gameID.ToString() + "_1.png");
     }
 }
Пример #5
0
        public void IconDownloaded(DownloadEngine.DownloadStatus status, Int64 gameID, DownloadManager.DownloadTypes type)
        {
            if (status == DownloadEngine.DownloadStatus.success)
            {
                if (actualGameSelected.id == gameID)
                {
                    LoadIcon(gameID);
                }
                return;
            }

            if (status == DownloadEngine.DownloadStatus.appWithoutIcon)
            {
                if (!GameIcon.Dispatcher.CheckAccess())
                {
                    GameIcon.Dispatcher.Invoke(new Action(() => IconDownloaded(status, gameID, type)));
                    return;
                }

                GameIcon.Source = originalIcon;
            }
        }