/// <summary> /// Updates vehicle list according to slots reference /// </summary> private void _RefreshVehicleList() { Cursor = Cursors.WaitCursor; vehicleListView.Items.Clear(); vehicleListView.Groups.Clear(); // Taking list mode into account (original/modded names) Dictionary <string, string> originalNamesByModdedNames = null; SortedStringCollection vehicleNames = new SortedStringCollection(); if (_IsShowOriginalNames) { foreach (string vehicleName in VehicleSlotsHelper.SlotReference.Keys) { vehicleNames.Add(vehicleName); } } else { // Loading database for read-only DB.Culture currentCulture = Program.ApplicationSettings.GetCurrentCulture(); // Physics TduFile[] loadedFiles = DatabaseHelper.LoadTopicForReadOnly(DB.Topic.CarPhysicsData, currentCulture); DB physics = loadedFiles[0] as DB; DBResource rPhysics = loadedFiles[1] as DBResource; // Brands loadedFiles = DatabaseHelper.LoadTopicForReadOnly(DB.Topic.Brands, currentCulture); DB brands = loadedFiles[0] as DB; DBResource rBrands = loadedFiles[1] as DBResource; originalNamesByModdedNames = new Dictionary <string, string>(); foreach (KeyValuePair <string, string> anotherPair in VehicleSlotsHelper.SlotReference) { // Brand name string brandName = NamesHelper.GetVehicleBrandName(anotherPair.Value, physics, brands, rBrands); // Vehicle name string vehicleName = NamesHelper.GetVehicleFullName(anotherPair.Value, false, physics, rPhysics, brands, rBrands); string moddedName = (brandName.ToUpper() + " " + vehicleName).Trim(); // To maintain 2 identical names while (originalNamesByModdedNames.ContainsKey(moddedName)) { moddedName += _SYMBOL_PRIME; } originalNamesByModdedNames.Add(moddedName, anotherPair.Key); vehicleNames.Add(moddedName); } } // Reference browsing foreach (string vehicleName in vehicleNames) { ListViewItem li = new ListViewItem(vehicleName); // Group by brand (first word in fact) string currentBrand = vehicleName.Split(' ')[0]; ListViewGroup currentGroup = new ListViewGroup(currentBrand, currentBrand); if (!vehicleListView.Groups.Contains(currentGroup)) { vehicleListView.Groups.Add(currentGroup); } li.Group = vehicleListView.Groups[currentBrand]; // Computing vehicle name string slotName = null; if (_IsShowOriginalNames) { slotName = vehicleName; } else if (originalNamesByModdedNames != null && originalNamesByModdedNames.ContainsKey(vehicleName)) { slotName = originalNamesByModdedNames[vehicleName]; } if (slotName != null && VehicleSlotsHelper.SlotReference.ContainsKey(slotName)) { string vehicleRef = VehicleSlotsHelper.SlotReference[slotName]; // Tag li.Tag = vehicleRef; VehicleSlotsHelper.VehicleInfo currentInfo = VehicleSlotsHelper.VehicleInformation[vehicleRef]; // Non-moddable vehicles are faded // Image depending on car or bike type if (currentInfo.isBike) { if (currentInfo.isModdable) { li.ImageIndex = (int)_ImageIndex.Bike; } else { li.ImageIndex = (int)_ImageIndex.NonModdableBike; } } else { if (currentInfo.isModdable) { li.ImageIndex = (int)_ImageIndex.Car; } else { li.ImageIndex = (int)_ImageIndex.NonModdableCar; } } vehicleListView.Items.Add(li); } } Cursor = Cursors.Default; }
/// <summary> /// Defines tab contents /// </summary> private void _InitializeDatasheetContents() { // Brand name string brandName = NamesHelper.GetVehicleBrandName(_CurrentVehicle, _PhysicsTable, _BrandsTable, _BrandsResource); // Real name : if it's mentioned, other names are not used ! DB.Cell realNameCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.REAL_NAME_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; if (DatabaseConstants.NOT_AVAILABLE_NAME_PHYSICS_DB_RESID.Equals(realNameCell.value)) { // Model + Version name _IsVehicleWithRealName = false; } else { // Real name _IsVehicleWithRealName = true; } // Brand logo DB.Cell brandRefCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.CAR_BRAND_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; string brandLogoName = _GetBrandLogoName(brandRefCell.value); if (File.Exists(brandLogoName)) { brandPictureBox.Image = Image.FromFile(brandLogoName); } else { brandPictureBox.Image = brandPictureBox.InitialImage; } // Vehicle name string vehicleName = NamesHelper.GetVehicleFullName(_CurrentVehicle, false, _PhysicsTable, _PhysicsResource, _BrandsTable, _BrandsResource); modelNameLabel.Text = string.Format(_FORMAT_MODEL_NAME, brandName.ToUpper(), vehicleName); // Engine type DB.Cell currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.ENGINE_TYPE_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; engineTypeLabel.Text = DatabaseHelper.GetResourceValueFromCell(currentCell, _PhysicsResource); // Displacement currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.DISPLACEMENT_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; engineDisplacementLabel.Text = currentCell.value; // Max power and rpm currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.POWER_BHP_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; engineMaxPowerLabel.Text = currentCell.value; currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.POWER_RPM_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; engineRpmPowerLabel.Text = currentCell.value; // Max torque and rpm currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.TORQUE_NM_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; engineMaxTorqueLabel.Text = currentCell.value; currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.TORQUE_RPM_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; engineRpmTorqueLabel.Text = currentCell.value; // Weight currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.WEIGHT_KG_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; weightLabel.Text = currentCell.value; // Tires currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.TYRES_TYPE_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; tiresTypeLabel.Text = DatabaseHelper.GetResourceValueFromCell(currentCell, _PhysicsResource); // Brakes currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.BRAKES_CHAR_FRONT_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; string brakesChar = DatabaseHelper.GetResourceValueFromCell(currentCell, _PhysicsResource); currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.BRAKES_DIM_FRONT_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; frontBrakesLabel.Text = string.Format(_FORMAT_BRAKES_LABEL, brakesChar, currentCell.value); currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.BRAKES_CHAR_REAR_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; brakesChar = DatabaseHelper.GetResourceValueFromCell(currentCell, _PhysicsResource); currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.BRAKES_DIM_REAR_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; rearBrakesLabel.Text = string.Format(_FORMAT_BRAKES_LABEL, brakesChar, currentCell.value); // Performance : max speed currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.TOP_SPEED_KMH_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; ushort slotTopSpeed = VehicleSlotsHelper.VehicleInformation[_CurrentVehicle].topSpeed; ushort currentTopSpeed = ushort.Parse(currentCell.value); // BUG_93: max speed modifications outside TDUMT _IsSpeedLimiterEnabled = (slotTopSpeed != 0); if (currentTopSpeed > slotTopSpeed) { MessageBoxes.ShowWarning(this, _WARN_MODDED_MAX_SPEED); _IsSpeedLimiterEnabled = false; } topSpeedTrackBar.Enabled = _IsSpeedLimiterEnabled; if (slotTopSpeed == 0) { topSpeedTrackBar.Maximum = currentTopSpeed; } else { topSpeedTrackBar.Maximum = slotTopSpeed; } if (_IsSpeedLimiterEnabled) { topSpeedTrackBar.Value = currentTopSpeed; } else { topSpeedTrackBar.Value = topSpeedTrackBar.Maximum; } _UpdateSpeedLimiter(); // Acceleration : 0 to 100 kph currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.ACCELERATION_0_100_KMH_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; datasheetAccelerationKmhTextBox.Text = currentCell.value; // Acceleration : 0 to 100 mph currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.ACCELERATION_0_100_MPH_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; datasheetAccelerationMphTextBox.Text = currentCell.value; // Acceleration : 0-400m currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.QUARTER_MILE_SEC_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; datasheetAcceleration400MTextBox.Text = currentCell.value; // Acceleration : 0-1000m currentCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(SharedConstants.T0_TO_1000M_SEC_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; datasheetAcceleration1000MTextBox.Text = currentCell.value; }