public void Scan() { if (!Scanned) { _mScanner = new IniScanner { IniData = masfile.Master.ExtractString(masfile) }; _mScanner.Read(); Scanned = true; _team = _mScanner.TryGetString("Description"); _driver = _mScanner.TryGetString("Driver"); _description = _mScanner.TryGetString("Team"); _number = _mScanner.TryGetInt32("Number"); if (_team.Length > 3) { _team = _team.Substring(1, _team.Length - 2); } if (_driver.Length > 3) { _driver = _driver.Substring(1, _driver.Length - 2); } if (_description.Length > 3) { _description = _description.Substring(1, _description.Length - 2); } string c = _mScanner.TryGetString("Classes"); if (c.StartsWith("\"")) { c = c.Substring(1, c.Length - 2); } if (c.StartsWith("\"")) { c = c.Substring(1, c.Length - 2); } if (c.Contains(" ")) { _classes = new List <string>(c.Split(" ".ToCharArray())); } else { _classes = new List <string>(c.Split(",".ToCharArray())); } _files = new Dictionary <string, MAS2File>(); _files.Add("Vehicle", rFactor2.Garage.Files.SearchFile(_mScanner.TryGetString("HDVehicle"))); _infoEngineManufacturer = _mScanner.TryGetString("Engine"); _infoYearFounded = _mScanner.TryGetInt32("TeamFounded"); _infoHq = _mScanner.TryGetString("TeamHeadquarters"); _infoStarts = _mScanner.TryGetInt32("TeamStarts"); _infoPoles = _mScanner.TryGetInt32("TeamPoles"); _infoWins = _mScanner.TryGetInt32("TeamWins"); _infoChampionships = _mScanner.TryGetInt32("TeamWorldChampionships"); _mHDV = new IniScanner { IniData = _files["Vehicle"].Master.ExtractString(_files["Vehicle"]) }; _mHDV.IgnoreGroups = false; _mHDV.Read(); } }
public void Scan() { string rfmData = MASFile.Master.ExtractString(MASFile); _teams = new List <string>(); _championships = new List <IModChampionship>(); _classes = new List <string>(); _models = new List <ICar>(); IniScanner scan = new IniScanner { IniData = rfmData }; scan.HandleCustomKeys += new Signal(Scan_AddTeamAndLayout); scan.FireEventsForKeys = new List <string>(); scan.FireEventsForKeys.Add("Main.layout"); scan.FireEventsForKeys.Add("Main.team"); scan.Read(); _name = scan.TryGetString("Mod Name"); _version = scan.TryGetString("Mod Version"); _opponents = scan.TryGetInt32("Max Opponents"); _author = "Henk"; _website = ""; _pitSpeedPracticeDefault = scan.TryGetInt32("NormalPitKPH"); _pitSpeedRaceDefault = scan.TryGetInt32("RacePitKPH"); _description = ""; _directoryVehicles = ""; // Irrelevant?! _image = "Cache/Mods/rfactor2_ " + _name + ".png"; // Search&extract DDS from RFM file if (System.IO.File.Exists(_image) == false) { // Search in the MAS archive for SMICON.DDS foreach (MAS2File masf in MASFile.Master.Files) { if (masf.Filename.Contains("SMICON")) { try { MASFile.Master.ExtractFile(masf, "tmp.dds"); Bitmap dds_bitmap = DevIL.DevIL.LoadBitmap("tmp.dds"); System.IO.File.Delete("tmp.dds"); DevIL.DevIL.SaveBitmap(_image, dds_bitmap); } catch (Exception ex) { // Failed _image = ""; } break; } } } // Search for vehicles in mod directory // rFactor2 works with 'teams' instead of car class filters List <MAS2File> vehicles = rFactor2.Garage.Files.SearchFiles("*.veh"); foreach (MAS2File f in vehicles) { rFactor2Car c = (rFactor2Car)rFactor2.Garage.CarFactory(this, f.Filename); c.Scan(); if (_teams.Contains(c.Team.Trim().ToLower())) { _models.Add(c); } } }
public void Scan() { if (!Scanned) { _classes = new List <string>(); _files = new Dictionary <string, string>(); Scanned = true; try { _mScanner = new IniScanner { IniFile = _file }; _mScanner.Read(); _team = _mScanner.TryGetString("Team"); _driver = _mScanner.TryGetString("Driver"); _description = _mScanner.TryGetString("Description"); _number = _mScanner.TryGetInt32("Number"); if (_team.Length > 3) { _team = _team.Substring(1, _team.Length - 2); } if (_driver.Length > 3) { _driver = _driver.Substring(1, _driver.Length - 2); } if (_description.Length > 3) { _description = _description.Substring(1, _description.Length - 2); } string c = _mScanner.TryGetString("Classes"); if (c.StartsWith("\"") && c.Length > 3) { c = c.Substring(1, c.Length - 2); } if (c.StartsWith("\"") && c.Length > 3) { c = c.Substring(1, c.Length - 2); } if (c.Contains(" ")) { _classes = new List <string>(c.Split(" ".ToCharArray())); } else { _classes = new List <string>(c.Split(",".ToCharArray())); } // Add category to classes as well! string _category = _mScanner.TryGetString("Category"); if (_category.Length > 3) { if (_category.StartsWith("\"") && _category.Length > 3) { _category = _category.Substring(1, _category.Length - 2); } _classes.AddRange(_category.Split(',')); } _mod.AddClasses(_classes); if (_files.ContainsKey("Vehicle") == false) { _files.Add("Vehicle", rFactor.Garage.Files.SearchFile(rFactor.Garage.GamedataDirectory, _mScanner.TryGetString("HDVehicle"))); } _infoEngineManufacturer = _mScanner.TryGetString("Engine"); _infoYearFounded = _mScanner.TryGetInt32("TeamFounded"); _infoHq = _mScanner.TryGetString("TeamHeadquarters"); _infoStarts = _mScanner.TryGetInt32("TeamStarts"); _infoPoles = _mScanner.TryGetInt32("TeamPoles"); _infoWins = _mScanner.TryGetInt32("TeamWins"); _infoChampionships = _mScanner.TryGetInt32("TeamWorldChampionships"); } catch (Exception e) { } if (_files.ContainsKey("Vehicle")) { try { _mHDV = new IniScanner { IniFile = _files["Vehicle"] }; _mHDV.IgnoreGroups = false; _mHDV.Read(); int gears = _mHDV.TryGetInt32("DRIVELINE", "forwardgears"); _gearbox = new rFactorCarGearbox(gears); _wheels = new rFactorCarWheels(_mHDV); } catch (Exception e) { } } // Add additional files. //_files.Add("Tyre", rFactor.Garage.Files.SearchFile(rFactor.Garage.GamedataDirectory, _mHDV.TryGetString("GENERAL", "TireBrand") + ".tbc")); // TODO: Parse more data. } }