Example #1
0
        private void ProcessDataTable(Chunk chunk)
        {
            Progress?.Report("Processing data table");
            Stream.Align(0x10);

            var table = new AaronDataTable();

            table.Name    = HashResolver.Resolve(Reader.ReadUInt32());
            table.Entries = new List <AaronDataTableEntry>();

            while (Stream.Position < chunk.EndOffset)
            {
                var entry = new AaronDataTableEntry();
                entry.Name     = HashResolver.Resolve(Reader.ReadUInt32());
                entry.Unknown  = Reader.ReadUInt32();
                entry.Unknown2 = Reader.ReadSingle();

                table.Entries.Add(entry);
            }

            _dataTableService.AddDataTable(table);
        }
Example #2
0
        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));
        }