private void LoadMetadata()
 {
     _container.MetadataChildItemAdded += ContainerOnMetadataChildItemAdded;
     try
     {
         using (new UpdateRegion(_container))
         {
             if (_databases != null && _databases.Count != 0)
             {
                 LoadForDatabases();
             }
             else
             {
                 LoadEntireContainer();
             }
         }
     }
     catch (Exception e)
     {
         LoadingFailed?.Invoke(this, e.Message);
     }
     finally
     {
         _container.MetadataChildItemAdded -= ContainerOnMetadataChildItemAdded;
         LoadingFinished?.Invoke(this, EventArgs.Empty);
     }
 }
 public async Task LoadModules(string path, string filter)
 {
     await Task.Run(() =>
     {
         try
         {
             var curplug     = 0;
             var pluginFiles = System.IO.Directory.GetFiles(path, filter, System.IO.SearchOption.TopDirectoryOnly);
             foreach (var filename in pluginFiles)
             {
                 ReportProgress?.Invoke(this, new ReportProgressEventArgs(++curplug, pluginFiles.Length, "Loading plugins...", OperationTag.Active));
                 var types = AssemblyLoader.LoadClassesFromFile <IInstallerModule>(System.IO.Path.GetFullPath(filename)).Where(t => t != null);
                 if (types.Any())
                 {
                     PluginLoaded?.Invoke(this, new PluginLoadedEventArgs(types));
                 }
             }
         }
         catch (Exception ex)
         {
             ErrorOccured?.Invoke(this, new ErrorOccuredEventArgs(ex, "Error loading modules"));
         }
         finally
         {
             ReportProgress?.Invoke(this, new ReportProgressEventArgs(0, StatusName.Idle, OperationTag.None));
             LoadingFinished?.Invoke(this, EventArgs.Empty);
         }
     });
 }
Beispiel #3
0
        IEnumerator FakeLoadingScreen()
        {
            GameManager.gameIsPaused = true;
            yield return(new WaitForSeconds(loadingScreen.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).length));

            GameManager.gameIsPaused = false;
            loadingScreen.SetActive(false);
            LoadingFinished.Invoke();
        }
Beispiel #4
0
        private void Refresh_Click(object sender, EventArgs e)
        {
            Recent.Rows.Clear();
            var             Loading  = new Loading();
            LoadingFinished finished = (bool close) => {
                if (close)
                {
                    Loading.Close();
                }
            };

            Loading.finished = finished;
            Loading.Show();
            GetRecents();
        }
        internal IEnumerator LoadTableCoroutine(string table_name)
        {
            while (mLoadersCount >= MAX_LOADERS_COUNT)
            {
                yield return(0);
            }
            mLoadersCount++;

            string url = string.Format("{0}/{1}.json.gz", Path, table_name);

            UnityEngine.Debug.Log("[SnipeTable] Loading table " + url);

            this.LoadingFailed = false;

            int retry = 0;

            while (!this.Loaded && retry <= 2)
            {
                if (retry > 0)
                {
                    yield return(new WaitForSecondsRealtime(0.1f));

                    UnityEngine.Debug.Log($"[SnipeTable] Retry #{retry} to load table - {table_name}");
                }

                retry++;

                using (UnityWebRequest loader = new UnityWebRequest(url))
                {
                    loader.downloadHandler = new DownloadHandlerBuffer();
                    yield return(loader.SendWebRequest());

                    if (loader.isNetworkError || loader.isHttpError)
                    {
                        UnityEngine.Debug.Log("[SnipeTable] Network error: Failed to load table - " + table_name);
                    }
                    else
                    {
                        UnityEngine.Debug.Log("[SnipeTable] table file loaded - " + table_name);
                        try
                        {
                            if (loader.downloadHandler.data == null || loader.downloadHandler.data.Length < 1)
                            {
                                UnityEngine.Debug.Log("[SnipeTable] Error: loaded data is null or empty. Table: " + table_name);
                            }
                            else
                            {
                                using (GZipStream gzip = new GZipStream(new MemoryStream(loader.downloadHandler.data, false), CompressionMode.Decompress))
                                {
                                    using (StreamReader reader = new StreamReader(gzip))
                                    {
                                        string        json_string = reader.ReadToEnd();
                                        ExpandoObject data        = ExpandoObject.FromJSONString(json_string);

                                        if (data["list"] is List <object> list)
                                        {
                                            foreach (ExpandoObject item_data in list)
                                            {
                                                AddTableItem(item_data);
                                            }
                                        }

                                        UnityEngine.Debug.Log("[SnipeTable] table ready - " + table_name);
                                        this.Loaded = true;
                                    }
                                }
                            }
                        }
                        catch (Exception)
                        {
                            UnityEngine.Debug.Log("[SnipeTable] failed to parse table - " + table_name);
                        }
                    }
                }
            }

            this.LoadingFailed = !this.Loaded;
            LoadingFinished?.Invoke(this.Loaded);

            mLoadersCount--;
        }
 private void OnLoadingFinished()
 {
     _loadingFinished?.Invoke();
     LoadingFinished?.Invoke(this, EventArgs.Empty);
 }
Beispiel #7
0
 public void OnLoadingFinished()
 {
     LoadingFinished?.Invoke(this, new EventArgs());
 }
        public static bool LoadCDB(string dir, bool overwrite, bool clearData = false)
        {
            logger.Info("Start LOAD CDB {0}", dir);
            LoadPicsFile();

            if (!File.Exists(dir))
            {
                return(false);
            }

            if (clearData)
            {
                CardData.Clear();
            }

            SQLiteConnection connection = new SQLiteConnection("Data Source=" + dir);
            List <string[]>  datas      = new List <string[]>();
            List <string[]>  texts      = new List <string[]>();

            try
            {
                connection.Open();
                datas = SQLiteCommands.LoadData(connection);
                texts = SQLiteCommands.LoadText(connection);
                connection.Close();
            }
            catch (Exception ex)
            {
                logger.Error("LOADCDB :" + ex.ToString());
                connection.Close();
                return(false);
            }

            progress = 0;
            total    = datas.Count + texts.Count;
            foreach (string[] row in datas)
            {
                if (overwrite)
                {
                    CardManager.UpdateOrAddCard(new CardInfos(row));
                }
                else
                {
                    if (!CardManager.ContainsCard(int.Parse(row[0])))
                    {
                        CardManager.UpdateOrAddCard(new CardInfos(row));
                    }
                }

                if (!CheckPicsLoaded(Convert.ToInt32(row[0])))
                {
                    DownloadPics(row[0]);
                }
                else
                {
                    progress++;
                    Application.Current.Dispatcher.Invoke(() => LoadingProgress?.Invoke(progress, total));
                }
            }
            foreach (string[] row in texts)
            {
                progress++;
                Application.Current.Dispatcher.Invoke(() => LoadingProgress?.Invoke(progress, total));

                if (CardManager.ContainsCard(int.Parse(row[0])))
                {
                    CardManager.GetCard(int.Parse(row[0])).SetCardText(row);
                }
            }

            if (File.Exists(Path.Combine(FormExecution.path, "BattleCityAlpha", "strings.conf")))
            {
                LoadSetCodesFromFile(CreateFileStreamFromString(File.ReadAllText(Path.Combine(FormExecution.path, "BattleCityAlpha", "strings.conf"))));
            }
            SetCodesStringInit();

            while (progress != total)
            {
                Thread.Sleep(500);
            }
            Application.Current.Dispatcher.Invoke(() => LoadingFinished?.Invoke());

            return(true);
        }