public static XDocument BuildXml(BattleDataOptions battleData, FighterDataOptions fighterData) { var type = fighterData.GetFighters().GetType().Name.ToLower(); type = type.Remove(type.Length - 2); XDocument doc = new XDocument(new XDeclaration("1.0", "utf-8", null), new XElement("struct", // <list hash="battle_data_tbl"> // <*DataList.Type* hash="*DataTbl.Type*"> new XElement(type, new XAttribute("hash", battleData.GetXmlName()), //<struct index="0"> // <struct index="*DataListItem.GetIndex*"> battleData.GetBattles().Select(battle => battle.GetAsXElement(battleData.GetBattleIndex(battle) ) ) ), // <list hash="fighter_data_tbl"> // <*DataList.Type* hash="*DataTbl.Type*"> new XElement(type, new XAttribute("hash", fighterData.GetXmlName()), //<struct index="0"> // <struct index="*DataListItem.GetIndex*"> fighterData.GetFighters().Select(fighter => fighter.GetAsXElement(fighterData.GetFighterIndex(fighter) ) ) ) ) ); return(doc); }
public void EmptySpiritData() { var options = dataOptions.OfType <BattleDataOptions>(); battleData = new BattleDataOptions(); fighterData = new FighterDataOptions(); }
// Replace Save calls to calls here. public static void SaveUnencrypted(BattleDataOptions battleData, FighterDataOptions fighterData, string fileLocation, string fileName) { fileLocation = FixFolderEndPath(fileLocation); // Save the version for local editing. Directory.CreateDirectory(fileLocation); SaveToFile(ConvertDataToXDocument(battleData, fighterData), fileLocation + fileName); }
public static void SaveEncrypted(BattleDataOptions battleData, FighterDataOptions fighterData, string fileLocation, string fileName, bool useFolderStructure = false) { fileLocation = FixFolderEndPath(fileLocation); // Save an encrypted version for direct placement on SD card. if (useFolderStructure) { fileLocation += GetFilePath(fileName); } Directory.CreateDirectory(fileLocation); SaveToEncryptedFile(ConvertDataToXDocument(battleData, fighterData), fileLocation + fileName); }
public static void SaveRandomized(BattleDataOptions battleData, FighterDataOptions fighterData, int seed = -1, int iteration = 0) { // Do multiple randomizers, in case an impossible battle happens. var fileName = config.file_name_encr; var randomizerString = iteration > 0 ? ".Randomizer " : "Randomizer "; var directory = config.file_directory_randomized + randomizerString + seed + " " + iteration; // Randomizer ### 1 Save(battleData, fighterData, directory, fileName, unencrypted: false, useFolderStructure: true, saveSpiritTitles: false); CopyPreloadFiles(directory); CopySpiritImages(directory); }
public static void Save(BattleDataOptions battleData, FighterDataOptions fighterData, string fileLocation, string fileName, SpiritDataOptions spiritData = null, bool unencrypted = true, bool encrypted = true, bool useFolderStructure = false, bool saveSpiritTitles = true) { fileLocation += @"\"; if (unencrypted) { var pathMod = useFolderStructure ? "" : config.unencr_sub; SaveUnencrypted(battleData, fighterData, fileLocation + pathMod, fileName); } if (encrypted) { SaveEncrypted(battleData, fighterData, fileLocation, fileName, useFolderStructure); if (spiritData?.HasData() ?? false) { var loc = MiscDbsToSave(); SaveEncrypted(spiritData, Path.GetDirectoryName(loc), Path.GetFileName(loc)); } } if (saveSpiritTitles) { SaveSpiritTitles(battleData.GetBattles(), config.file_directory_preload); } }
public void ImportBattle(BattleDataOptions battles, FighterDataOptions fighters) { battleData.ReplaceBattles(battles); fighterData.ReplaceFighters(fighters); }
public static XDocument ConvertDataToXDocument(BattleDataOptions battleData, FighterDataOptions fighterData) { return(XmlHelper.BuildXml(battleData, fighterData)); }