private void ProcessPresetCars(Chunk chunk) { Progress?.Report("Processing preset cars"); while (Stream.Position < chunk.EndOffset) { var fePresetCar = BinaryHelpers.ReadStruct <FEPresetCar>(Reader); _presetCarService.AddPresetCar(PresetConverter.ConvertFeToAaronPresetCar(fePresetCar)); } }
public void LoadProject(string file) { CloseProject(); var project = Serialization.Deserialize <AaronProject>(File.ReadAllText(file)); project.Path = file; if (project.Version != AaronProjectVersion) { throw new Exception("Incompatible project. Please make a backup and copy your changes to a new project."); } // set slot override data _carPartService.SetSlotOverrideData(project.SlotOverrideData); DebugTiming.BeginTiming("LoadCars"); // load cars foreach (var carFilePath in Directory.GetFiles(project.CarsDirectory, "*.json")) { _carService.AddCar(Serialization.Deserialize <AaronCarRecord>(File.ReadAllText(carFilePath))); } DebugTiming.EndTiming("LoadCars"); DebugTiming.BeginTiming("LoadCarParts"); // load car part foreach (var carPartFilePath in Directory.GetFiles(project.CarPartsDirectory, "*.json")) { var aaronCarPartCollection = Serialization.Deserialize <AaronCarPartCollection>(File.ReadAllText(carPartFilePath)); _carPartService.AddCarPartCollection( aaronCarPartCollection); } DebugTiming.EndTiming("LoadCarParts"); DebugTiming.BeginTiming("LoadPresets"); // load presets foreach (var presetCarFilePath in Directory.GetFiles(project.PresetCarsDirectory, "*.xml")) { var convertServerXmlToAaronPreset = PresetConverter.ConvertServerXMLToAaronPreset( File.ReadAllText(presetCarFilePath).DataContractDeserializeObject <OwnedCarTrans>()); convertServerXmlToAaronPreset.PresetName = Path.GetFileNameWithoutExtension(presetCarFilePath); _presetCarService.AddPresetCar(convertServerXmlToAaronPreset); } DebugTiming.EndTiming("LoadPresets"); DebugTiming.BeginTiming("LoadPresetSkins"); foreach (var presetSkinFilePath in Directory.GetFiles(project.PresetSkinsDirectory, "*.json")) { _presetSkinService.AddPresetSkin( Serialization.Deserialize <AaronPresetSkinRecord>(File.ReadAllText(presetSkinFilePath))); } DebugTiming.EndTiming("LoadPresetSkins"); DebugTiming.BeginTiming("LoadDataTables"); foreach (var dataTableFilePath in Directory.GetFiles(project.DataTablesDirectory, "*.json")) { _dataTableService.AddDataTable( Serialization.Deserialize <AaronDataTable>(File.ReadAllText(dataTableFilePath))); } DebugTiming.EndTiming("LoadDataTables"); using (var namesFileStream = File.OpenRead(Path.Combine(Path.GetDirectoryName(file), "strings.json"))) { foreach (var s in Serialization.Deserialize <List <string> >( namesFileStream)) { _carPartService.AddString(s); } } _project = project; Messenger.Default.Send(new ProjectMessage(project)); }