public void LoadAllCars() { if (!File.Exists(FILEPATH_CARLIST_INI)) { MessageBox.Show("carlist.ini cannot be found. RBRCIT will close now."); Application.Exit(); System.Environment.Exit(1); } carlist_ini = new INIFile(FILEPATH_CARLIST_INI); if (File.Exists("RBRCIT\\carListUser.ini")) { carlistuser_ini = new INIFile("RBRCIT\\carListUser.ini"); } AllCars.Clear(); ModelsFound = 0; PhysicsFound = 0; foreach (string section in carlist_ini.GetSections()) { if (!section.StartsWith("Car_")) { continue; } Car c = new Car(); c.nr = section.Substring(4); c.name = carlist_ini.GetParameterValue("name", section); c.manufacturer = c.name.Substring(0, c.name.IndexOf(' ')); c.name = c.name.Substring(c.name.IndexOf(' ') + 1); //remove the manufacturer in the beginning c.physics = carlist_ini.GetParameterValue("physics", section); c.cat = carlist_ini.GetParameterValue("cat", section); c.iniFile = carlist_ini.GetParameterValue("iniFile", section); c.folder = carlist_ini.GetParameterValue("folder", section); c.trans = carlist_ini.GetParameterValue("trans", section); c.link_physics = carlist_ini.GetParameterValue("link_physics", section); c.link_model = carlist_ini.GetParameterValue("link_model", section); c.link_banks = carlist_ini.GetParameterValue("link_banks", section); c.year = carlist_ini.GetParameterValue("year", section); string power = carlist_ini.GetParameterValue("power", section); if (power != null) { int.TryParse(power.Substring(0, power.IndexOf("@")), out c.power); } string weight = carlist_ini.GetParameterValue("weight", section); if (weight != null) { int.TryParse(weight, out c.weight); } c.model_exists = Directory.Exists("Cars\\" + c.folder); if (c.model_exists) { ModelsFound++; } c.physics_exists = Directory.Exists("RBRCIT\\physics\\" + c.physics); if (c.physics_exists) { PhysicsFound++; } c.banks = carlist_ini.GetParameterValue("banks", section); if (c.banks != null && c.banks.Contains(",")) { c.banks = c.banks.Substring(0, c.banks.IndexOf(',')); } c.banks_exist = (c.banks != null) && Directory.Exists("AudioFMOD\\") && Directory.GetFiles("AudioFMOD\\", c.banks + "*").Length > 0; //are there user settings? if yes set them. Default Engine sound = subaru! c.userSettings.engineSound = "subaru"; if (carlistuser_ini != null) { string sound = carlistuser_ini.GetParameterValue("engineSound", "Car_" + c.nr); if (sound != null) { c.userSettings.engineSound = sound; } string FMODSoundBank = carlistuser_ini.GetParameterValue("FMODSoundBank", "Car_" + c.nr); if (FMODSoundBank != null) { c.userSettings.FMODSoundBank = FMODSoundBank; } c.userSettings.hideSteeringWheel = carlistuser_ini.GetParameterValueBool("hideSteeringWheel", "Car_" + c.nr); c.userSettings.hideWipers = carlistuser_ini.GetParameterValueBool("hideWipers", "Car_" + c.nr); c.userSettings.hideWindShield = carlistuser_ini.GetParameterValueBool("hideWindShield", "Car_" + c.nr); } AllCars.Add(c); } mainForm.UpdateAllCars(); }
public void LoadAllCars() { carlist_ini = new INIFile("RBRCIT\\carlist\\carList.ini"); if (File.Exists("RBRCIT\\carListUser.ini")) { carlistuser_ini = new INIFile("RBRCIT\\carListUser.ini"); } AllCars.Clear(); ModelsFound = 0; PhysicsFound = 0; foreach (string section in carlist_ini.GetSections()) { if (!section.StartsWith("Car_")) { continue; } Car c = new Car(); c.nr = section.Substring(4); c.name = carlist_ini.GetParameterValue("name", section); c.manufacturer = c.name.Substring(0, c.name.IndexOf(' ')); c.name = c.name.Substring(c.name.IndexOf(' ') + 1); //remove the manufacturer in the beginning c.physics = carlist_ini.GetParameterValue("physics", section); c.cat = carlist_ini.GetParameterValue("cat", section); c.iniFile = carlist_ini.GetParameterValue("iniFile", section); c.folder = carlist_ini.GetParameterValue("folder", section); c.trans = carlist_ini.GetParameterValue("trans", section); c.link_physics = carlist_ini.GetParameterValue("link_physics", section); c.link_model = carlist_ini.GetParameterValue("link_model", section); c.year = carlist_ini.GetParameterValue("year", section); string power = carlist_ini.GetParameterValue("power", section); if (power != null) { int.TryParse(power.Substring(0, power.IndexOf("@")), out c.power); } string weight = carlist_ini.GetParameterValue("weight", section); if (weight != null) { int.TryParse(weight, out c.weight); } c.model_exists = Directory.Exists("Cars\\" + c.folder); if (c.model_exists) { ModelsFound++; } c.physics_exists = Directory.Exists("RBRCIT\\physics\\" + c.physics); if (c.physics_exists) { PhysicsFound++; } //are there user settings? if yes set them. Default Engine sound = subaru! c.userSettings.engineSound = "subaru"; if (carlistuser_ini != null) { string sound = carlistuser_ini.GetParameterValue("engineSound", "Car_" + c.nr); if (sound != null) { c.userSettings.engineSound = sound; } c.userSettings.hideSteeringWheel = carlistuser_ini.GetParameterValueBool("hideSteeringWheel", "Car_" + c.nr); c.userSettings.hideWipers = carlistuser_ini.GetParameterValueBool("hideWipers", "Car_" + c.nr); c.userSettings.hideWindShield = carlistuser_ini.GetParameterValueBool("hideWindShield", "Car_" + c.nr); } AllCars.Add(c); } mainForm.UpdateAllCars(); }