Пример #1
0
        public static Settings GetSettings()
        {
            string FileName = Commons.GetSettingsFileName();

            if (File.Exists(FileName))
            {
                Settings settings = BinarySerialize.ReadFromBinaryFile <Settings>(FileName);
                return(settings);
            }
            return(null);
        }
Пример #2
0
 public void Flush(bool complete = false)
 {
     _ = WriteToDisk(!this.autoDeleteOnFirstFlush);
     this.autoDeleteOnFirstFlush = false;
     flushedEntries.AddRange(logEntries);
     logEntries.Clear();
     if (complete)
     {
         string fileName = Commons.GetLogFileName();
         BinarySerialize.WriteToBinaryFile <List <LogEntry> >(fileName, flushedEntries);
     }
 }
Пример #3
0
 private void UpdateModules()
 {
     LOG.Debug("UpdateModules()");
     try
     {
         Program.AllModules = WGAPI.GetAllModules();
         foreach (KeyValuePair <string, ModuleData> Mod in Program.AllModules)
         {
             ModuleTranslator.Transfer(Mod.Value);
         }
         BinarySerialize.WriteToBinaryFile(Commons.GetModulesFileName(), Program.AllModules);
     }
     catch (Exception e) { LOG.Error("Error during Module import: ", e); }
 }
Пример #4
0
        private void UpdateFlags()
        {
            LOG.Debug("UpdateFlags()");
            ConsumablesImporter Importer = WGAPI.GetFlags();

            if (Importer.Status.ToLower().Equals("ok"))
            {
                Program.Flags = new List <Consumable>();
                foreach (KeyValuePair <string, Consumable> Flag in Importer.Data)
                {
                    Program.Flags.Add(Flag.Value);
                }
                BinarySerialize.WriteToBinaryFile(Commons.GetFlagsFileName(), Program.Flags);
            }
        }
Пример #5
0
        private void UpdateUpgrades()
        {
            LOG.Debug("UpdateUpgrades()");
            ConsumablesImporter Importer = WGAPI.GetUpgrades();

            if (Importer.Status.ToLower().Equals("ok"))
            {
                Program.Upgrades = new List <Consumable>();
                foreach (KeyValuePair <string, Consumable> Data in Importer.Data)
                {
                    Program.Upgrades.Add(Data.Value);
                }
                BinarySerialize.WriteToBinaryFile(Commons.GetUpgradesFileName(), Program.Upgrades);
            }
            else
            {
                LOG.Warning("Unable to import Upgrades: " + Importer.Status.ToString());
            }
        }
Пример #6
0
        public void UpdateCommanderSkills(bool ForceUpdate = false)
        {
            LOG.Debug("UpdateCommanderSkills()");
            SkillImporter Importer = WGAPI.GetCommanderSkills();

            if (Importer.Status.ToLower().Equals("ok"))
            {
                string csv = Properties.Settings.Default.CommanderSkillsVersion;

                if (ForceUpdate || (!csv.Equals("") && !csv.Equals(Importer.Version)))
                {
                    Program.CommanderSkills = new Dictionary <string, List <Skill> >();
                    Program.CommanderSkills = Importer.Data;
                    BinarySerialize.WriteToBinaryFile(Commons.GetCommanderSkillFileName(), Program.CommanderSkills);
                    Properties.Settings.Default.CommanderSkillsVersion = Importer.Version;
                    Properties.Settings.Default.Save();
                    LOG.Info("Imported commander skills: " + Program.CommanderSkills["dd"].Count + ", " + Program.CommanderSkills["ca"].Count + ", " + Program.CommanderSkills["bb"].Count + ", " + Program.CommanderSkills["cv"].Count);
                }
                else
                {
                    LOG.Info("Commander skills are up to date. No import/refresh needed.");
                }
            }
            else
            {
                LOG.Warning("Unable to import commander skills: " + Importer.Status.ToString());
            }

/*            SkillImporter Importer = WGAPI.GetCommanderSkills();
 *          if (Importer.Status.ToLower().Equals("ok"))
 *          {
 *              Program.CommanderSkills = new List<Skill>();
 *              foreach (KeyValuePair<string, Skill> SkillData in Importer.Data)
 *              {
 *                  Program.CommanderSkills.Add(SkillData.Value);
 *              }
 *              BinarySerialize.WriteToBinaryFile(Commons.GetCommanderSkillFileName(), Program.CommanderSkills);
 *          }*/
        }
Пример #7
0
        public static void AddConsumablesInfo(bool ForceUpdate = false)
        {
            if (Program.Settings == null)
            {
                return;
            }
            ConsumablesInfoImporter import = WGAPI.GetConsumablesInfo();

            if (!import.Status.Equals("ok"))
            {
                return;
            }

            if (ForceUpdate || (Program.Settings.ConsumablesInfoVersion != null && !Program.Settings.ConsumablesInfoVersion.Equals(import.Version)))
            {
                foreach (Ship ship in Program.AllShips)
                {
                    ship.Consumables = new List <ConsumableInfo>();
                    ship.Airstrike   = new ModuleAirstrike();
                }
                Program.Settings.ConsumablesInfoVersion = import.Version;

                foreach (KeyValuePair <string, List <ConsumablesInfoTypeImporter> > list in import.Consumables)
                {
                    Enum.TryParse(list.Key, out ConsumableType CType);

                    foreach (ConsumablesInfoTypeImporter con in list.Value)
                    {
                        List <Ship> ShipList = new List <Ship>();

                        if (con.GroupSelection != null && !con.GroupSelection.Equals(""))
                        {
                            ShipList = ShipFinder.FindShips(con.ID, con.GroupSelection, con.Exceptions);
                        }
                        else
                        {
                            ShipList = ShipFinder.FindShips(con.ID, con.Group, con.Exceptions);
                        }
                        foreach (Ship ship in ShipList)
                        {
                            ship.Consumables.Add(new ConsumableInfo()
                            {
                                Duration = con.Duration, Range = con.Range, Type = CType, Cooldown = con.Cooldown, Charges = con.Charges, ExtraInfo = con.ExtraInfo
                            });
                        }
                    }
                }

                foreach (KeyValuePair <string, ModuleAirstrike> airstrike in import.Airstrike)
                {
                    long shipId = Convert.ToInt64(airstrike.Key);
                    Ship ship   = Program.AllShips.Find(e => e.ID == shipId);
                    if (ship != null)
                    {
                        ship.Airstrike = airstrike.Value;
                    }
                }
                UpdateUpgradesInfo();
                BinarySerialize.WriteToBinaryFile <List <Ship> >(Commons.GetShipListFileName(), Program.AllShips);
            }
        }
Пример #8
0
        public static void SaveSettings(Settings MySettings)
        {
            string FileName = Commons.GetSettingsFileName();

            BinarySerialize.WriteToBinaryFile <Settings>(FileName, MySettings);
        }