Beispiel #1
0
        public void StartDownload(GUIMod module)
        {
            if (module == null || !module.IsCKAN)
            {
                return;
            }

            Main.Instance.ShowWaitDialog(false);
            if (cacheWorker.IsBusy)
            {
                Task.Factory.StartNew(() =>
                {
                    // Just pass to the existing worker
                    downloader.DownloadModules(new List <CkanModule> {
                        module.ToCkanModule()
                    });
                    module.UpdateIsCached();
                });
            }
            else
            {
                // Start up a new worker
                downloader = new NetAsyncModulesDownloader(Main.Instance.currentUser, Main.Instance.Manager.Cache);
                cacheWorker.RunWorkerAsync(module);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Makes sure all the specified mods are downloaded.
        /// </summary>
        private void DownloadModules(IEnumerable <CkanModule> mods, NetAsyncModulesDownloader downloader)
        {
            List <CkanModule> downloads = mods.Where(module => !ksp.Cache.IsCachedZip(module.download)).ToList();

            if (downloads.Count > 0)
            {
                downloader.DownloadModules(ksp.Cache, downloads);
            }
        }
Beispiel #3
0
        private void CacheMod(object sender, DoWorkEventArgs e)
        {
            Main.Instance.ResetProgress();
            Main.Instance.ClearLog();

            NetAsyncModulesDownloader downloader = new NetAsyncModulesDownloader(Main.Instance.currentUser);

            downloader.DownloadModules(Main.Instance.Manager.Cache, new List <CkanModule> {
                (CkanModule)e.Argument
            });
            e.Result = e.Argument;
        }
Beispiel #4
0
        public void StartDownload(GUIMod module)
        {
            if (module == null || !module.IsCKAN)
            {
                return;
            }

            if (cacheWorker == null)
            {
                cacheWorker = new BackgroundWorker()
                {
                    WorkerReportsProgress      = true,
                    WorkerSupportsCancellation = true,
                };
                cacheWorker.DoWork             += CacheMod;
                cacheWorker.RunWorkerCompleted += PostModCaching;
            }

            Main.Instance.ShowWaitDialog(false);
            if (cacheWorker.IsBusy)
            {
                Task.Factory.StartNew(() =>
                {
                    // Just pass to the existing worker
                    downloader.DownloadModules(new List <CkanModule> {
                        module.ToCkanModule()
                    });
                    module.UpdateIsCached();
                });
            }
            else
            {
                // Start up a new worker
                downloader = new NetAsyncModulesDownloader(Main.Instance.currentUser, Main.Instance.Manager.Cache);
                cacheWorker.RunWorkerAsync(module);
            }
        }
Beispiel #5
0
        private void CacheMod(object sender, DoWorkEventArgs e)
        {
            CfanModule module = (CfanModule)e.Argument;

            if (module.isMetapackage)
            {
                AddLogMessage($"Cannot download metapackage. {module.title}");
                return;
            }
            if (module.download == null)
            {
                AddLogMessage($"No available download link for {module.title}.");
                return;
            }
            ResetProgress();
            ClearLog();

            NetAsyncModulesDownloader dowloader = new NetAsyncModulesDownloader(m_User, CurrentInstance.tryGetFactorioAuthData());

            dowloader.DownloadModules(CurrentInstance.Cache, new List <CfanModule> {
                module
            });
            e.Result = e.Argument;
        }