Пример #1
0
        private void LoadAllData()
        {
            LOG.Info("Loading game data");
            bool allFilesLoaded = true;

            try { Program.AllModules = BinarySerialize.Read2 <Dictionary <string, ModuleData> >(Commons.GetModulesFileName()); } catch (Exception e) { allFilesLoaded = false; LOG.Error("Unable to load Modules", e); }
            try { Program.AllShips = BinarySerialize.Read2 <List <Ship> >(Commons.GetShipListFileName()); } catch (Exception e) { allFilesLoaded = false; LOG.Error("Unable to load Ships", e); }
            try { Program.Upgrades = BinarySerialize.ReadFromBinaryFile <List <Consumable> >(Commons.GetUpgradesFileName()); } catch (Exception e) { allFilesLoaded = false; LOG.Error("Unable to load Upgrades", e); }
            //try { Program.CommanderSkills = BinarySerialize.ReadFromBinaryFile<List<Skill>>(Commons.GetCommanderSkillFileName()); } catch(Exception) { allFilesLoaded = false; }
            try { Program.CommanderSkills = BinarySerialize.ReadFromBinaryFile <Dictionary <string, List <Skill> > >(Commons.GetCommanderSkillFileName()); } catch (Exception e) { allFilesLoaded = false; LOG.Error("Unable to load Skills", e); }
            try { Program.Flags = BinarySerialize.ReadFromBinaryFile <List <Consumable> >(Commons.GetFlagsFileName()); } catch (Exception e) { allFilesLoaded = false; LOG.Error("Unable to load Flags", e); }

            if (Program.Flags.Count == 0 || Program.CommanderSkills.Count == 0 || Program.Upgrades.Count == 0 || Program.AllShips.Count == 0 || Program.AllModules.Count == 0)
            {
                LOG.Warning("Not all files loaded; " + Program.Flags.Count + "," + Program.CommanderSkills.Count + "," + Program.Upgrades.Count + "," + Program.AllShips.Count + "," + Program.AllModules.Count);
                allFilesLoaded = false;
            }

            if (allFilesLoaded == false)
            {
                LOG.Info("One or more files missing - force update");
                StartLoadingAnimation();
                BGUpdater.RunWorkerAsync();
            }
            else
            {
                randomizerUpdater.UpdateCommanderSkills();
                Updater.AddConsumablesInfo(false);
                LOG.Info("All files loaded.");
                FinalizeLoad();
            }
        }
Пример #2
0
 protected virtual void OnLoadComplete(EventArgs e)
 {
     LOG.Debug("OnLoadComplete()");
     if (callUpdateAll)
     {
         LOG.Debug("callUpdateAll");
         callUpdateAll = false;
         StartLoadingAnimation();
         BGUpdater.RunWorkerAsync();
     }
 }
Пример #3
0
        private void menuProfile_Click(object sender, EventArgs e)
        {
            LOG.Debug("menuProfile_Click");
            ToolStripMenuItem item = (ToolStripMenuItem)sender;

            if (item.Checked)
            {
                return;
            }
            try
            {
                profileHandler.activateItem(item.Text);
                Program.AllShips.Clear();
                PersonalShips.Clear();
                ExcludedShips.Clear();

                LoadAllData();
                Thread.Sleep(500);
                LOG.Debug("Profile loaded: " + item.Text);
                MessageBox.Show("Profile has been loaded.", "Profile loaded", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                LOG.Warning("Exception received; handling... ", ex);
                profileHandler.clearCurrentProfile();
                if (Program.Settings == null)
                {
                    Program.Settings = new Settings();
                }
                Program.Settings.Server = item.Text;
                Program.AllShips.Clear();

                loadMyShipsToolStripMenuItem.Enabled = false;
                OpenSettingsForceUpdate();
                if (callUpdateAll)
                {
                    StartLoadingAnimation();
                    callUpdateAll = false;
                    BGUpdater.RunWorkerAsync();
                }
                if (Program.Settings != null)
                {
                    if (!Program.Settings.Server.Equals("") && !Program.Settings.Nickname.Equals(""))
                    {
                        loadMyShipsToolStripMenuItem.Enabled = true;
                    }
                }
            }
        }