public void loadUserShipsInPort(long UserID, bool hideMessage = false) { LOG.Debug("loadUserShipsInPort()"); PlayerShipImport Importer = WGAPI.GetPlayerShips(UserID); if (Importer.Status.ToLower().Equals("ok")) { List <PlayerShip> PersonalShips = new List <PlayerShip>(); Dictionary <string, List <PlayerShip> > ImportedShips = Importer.Ships; foreach (KeyValuePair <string, List <PlayerShip> > ShipID in ImportedShips) { foreach (PlayerShip PShip in ShipID.Value) { PersonalShips.Add(PShip); } } string FileName = Commons.GetPersonalShipsFileName(); BinarySerialize.WriteToBinaryFile <List <PlayerShip> >(FileName, PersonalShips); if (hideMessage == false) { MessageBox.Show("Your ships have been imported.", "Load Personal Data", MessageBoxButtons.OK, MessageBoxIcon.Information); } LOG.Debug("User ships downloaded ok"); } else { LOG.Warning("Download of users ships failed!"); MessageBox.Show("Some error occured during gathering of data. Try again later.", "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
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); } }
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); } }
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); } }
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()); } }
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); * }*/ }
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); } }
public static void SaveSettings(Settings MySettings) { string FileName = Commons.GetSettingsFileName(); BinarySerialize.WriteToBinaryFile <Settings>(FileName, MySettings); }