/// <summary> /// /// </summary> /// <param name="vehicle"></param> /// <param name="physicsTable"></param> private static void _ResetCamIK(string vehicle, DB physicsTable) { VehicleSlotsHelper.VehicleInfo vi = VehicleSlotsHelper.VehicleInformation[vehicle]; VehicleSlotsHelper.ChangeCameraById(vehicle, vi.defaultCamera, physicsTable); VehicleSlotsHelper.ChangeIKById(vehicle, vi.defaultIK, physicsTable); }
/// <summary> /// Defines tab contents /// </summary> private void _InitializeCameraIKContents() { // Available ids easyVehicleComboBox.Items.Clear(); availableCamIKComboBox.Items.Clear(); foreach (KeyValuePair <string, string> pair in VehicleSlotsHelper.CamReference) { string itemText = string.Format(_FORMAT_CAMIK_SET_NAME, pair.Value, pair.Key); // Easy list only shows moddable vehicles string vehicleRef = VehicleSlotsHelper.SlotReference[pair.Value]; VehicleSlotsHelper.VehicleInfo info = VehicleSlotsHelper.VehicleInformation[vehicleRef]; if (info.isModdable) { easyVehicleComboBox.Items.Add(itemText); } // Classic list availableCamIKComboBox.Items.Add(itemText); } // Cockpit positions cockSourceComboBox.Items.Add(_CAMERA_COCKPIT_POSITION_LEFT); cockSourceComboBox.Items.Add(_CAMERA_COCKPIT_POSITION_MIDDLE); cockSourceComboBox.Items.Add(_CAMERA_COCKPIT_POSITION_RIGHT); cockTargetComboBox.Items.Add(_CAMERA_COCKPIT_POSITION_LEFT); cockTargetComboBox.Items.Add(_CAMERA_COCKPIT_POSITION_MIDDLE); cockTargetComboBox.Items.Add(_CAMERA_COCKPIT_POSITION_RIGHT); }
private void useCustomCamCheckBox_CheckedChanged(object sender, EventArgs e) { // Click on 'Use own camera set' checkbox if (useOwnCamCheckBox.Checked) { // Vehicle now uses its own camera try { Cursor = Cursors.WaitCursor; // Action VehicleSlotsHelper.VehicleInfo vi = VehicleSlotsHelper.VehicleInformation[_CurrentVehicle]; VehicleSlotsHelper.ChangeCameraById(_CurrentVehicle, vi.newCamera, _PhysicsTable); // Refresh _RefreshCameraIKContents(); // Modification flag _IsDatabaseModified = true; StatusBarLogManager.ShowEvent(this, _STATUS_SETTING_CUSTOM_CAM_OK); Cursor = Cursors.Default; } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } } else { // Restoring default camera Cursor = Cursors.WaitCursor; // Action VehicleSlotsHelper.VehicleInfo vi = VehicleSlotsHelper.VehicleInformation[_CurrentVehicle]; short defaultCamera = short.Parse(vi.defaultCamera); VehicleSlotsHelper.ChangeCameraById(_CurrentVehicle, defaultCamera.ToString(), _PhysicsTable); // Refresh _RefreshCameraIKContents(); // Modification flag _IsDatabaseModified = true; StatusBarLogManager.ShowEvent(this, _STATUS_UNSETTING_CUSTOM_CAM_OK); Cursor = Cursors.Default; } }
/// <summary> /// Refreshes tab contents /// </summary> private void _RefreshCameraIKContents() { // Current camera DB.Cell cameraRefCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(DatabaseConstants.CAMERA_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; string cameraRef = cameraRefCell.value; try { string customCamId = VehicleSlotsHelper.VehicleInformation[_CurrentVehicle].newCamera; if (cameraRef.Equals(customCamId)) { cameraLabel.Text = _LABEL_CUSTOM; useOwnCamCheckBox.Checked = true; } else { cameraLabel.Text = VehicleSlotsHelper.CamReference[cameraRef]; useOwnCamCheckBox.Checked = false; } } catch (Exception) { cameraLabel.Text = _LABEL_UNKNOWN; useOwnCamCheckBox.Checked = false; } // Current IK DB.Cell ikRefCell = DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(DatabaseConstants.SAME_IK_PHYSICS_DB_COLUMN, _PhysicsTable, _CurrentVehicle)[0]; string ikRef = ikRefCell.value; try { ikLabel.Text = VehicleSlotsHelper.IKReference[ikRef]; } catch (Exception) { ikLabel.Text = _LABEL_UNKNOWN; } // New set id (own) VehicleSlotsHelper.VehicleInfo currentInfo = VehicleSlotsHelper.VehicleInformation[_CurrentVehicle]; // No new camera for this slot; checkbox disabled useOwnCamCheckBox.Enabled = (currentInfo.newCamera != null); ListView2.StoreSelectedIndex(camSetDetailsListView); camSetDetailsListView.Items.Clear(); if (cameraRef == currentInfo.defaultCamera || cameraRef == currentInfo.newCamera) { advancedCameraControlsPanel.Enabled = true; customCameraIdLabel.Text = cameraRef; useOwnCamCheckBox.Checked = (cameraRef == currentInfo.newCamera); // Set customization: only hood and cockpit views are handled Cameras.CamEntry customCam = _CameraData.GetEntryByCameraId(cameraRef); if (customCam.isValid) { useOwnCamCheckBox.Enabled = true; // Hood ListViewItem customItem = new ListViewItem(Cameras.ViewType.Hood.ToString()) { UseItemStyleForSubItems = false, Font = new Font(camSetDetailsListView.Font, FontStyle.Bold), Tag = Cameras.ViewType.Hood }; Cameras.View currentView = Cameras.GetViewByType(customCam, Cameras.ViewType.Hood); string customViewLabel = _GetCustomViewLabel(currentView); customItem.SubItems.Add(customViewLabel); currentView = Cameras.GetViewByType(customCam, Cameras.ViewType.Hood_Back); customViewLabel = _GetCustomViewLabel(currentView); customItem.SubItems.Add(customViewLabel); camSetDetailsListView.Items.Add(customItem); // Cockpit customItem = new ListViewItem(Cameras.ViewType.Cockpit.ToString()) { UseItemStyleForSubItems = false, Font = new Font(camSetDetailsListView.Font, FontStyle.Bold), Tag = Cameras.ViewType.Cockpit }; currentView = Cameras.GetViewByType(customCam, Cameras.ViewType.Cockpit); customViewLabel = _GetCustomViewLabel(currentView); customItem.SubItems.Add(customViewLabel); currentView = Cameras.GetViewByType(customCam, Cameras.ViewType.Cockpit_Back); customViewLabel = _GetCustomViewLabel(currentView); customItem.SubItems.Add(customViewLabel); camSetDetailsListView.Items.Add(customItem); // Cockpit positions Cameras.View cockpitView = Cameras.GetViewByType(customCam, Cameras.ViewType.Cockpit); cockSourceComboBox.Text = cockpitView.source.ToString(); cockTargetComboBox.Text = cockpitView.target.ToString(); } else { Log.Warning(_ERROR_NEW_CAM_NOT_FOUND); // No new camera for this slot; checkbox disabled useOwnCamCheckBox.Enabled = false; } } else { // Other camera can't be modified customCameraIdLabel.Text = _LABEL_NO_CAM; advancedCameraControlsPanel.Enabled = false; } ListView2.RestoreSelectedIndex(camSetDetailsListView); }
/// <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> /// Manages component install/uninstall /// </summary> /// <param name="isInstall">true if install / false if uninstall</param> private void _Process(bool isInstall) { // Current culture //string selectedCulture = gameCultureComboBox.Text.Substring(0, 2); //DB.Culture currentCulture = (DB.Culture) Enum.Parse(typeof (DB.Culture), selectedCulture); // EVO_147 const DB.Culture currentCulture = DB.Culture.US; // Selects right patch according to install/uninstall case PCH currentPatch = (isInstall ? _CurrentInstallPatch : _CurrentUninstallPatch); // TDU folder (override) Tools.TduPath = tduPathTextbox.Text; // Authorization checks // If specified ref matches a car pack vehicle, TDU version must be '1.66+megapack' if (Tools.InstalledTduVersion != Tools.TduVersion.V1_66_Megapack) { // Loading reference try { VehicleSlotsHelper.InitReference(Application.StartupPath + LibraryConstants.FOLDER_XML); // Getting vehicle information... if (!Tools.KEY_MISC_SLOT.Equals(_CurrentInstallPatch.SlotRef) && VehicleSlotsHelper.VehicleInformation.ContainsKey(currentPatch.SlotRef)) { VehicleSlotsHelper.VehicleInfo info = VehicleSlotsHelper.VehicleInformation[currentPatch.SlotRef]; if (info.isAddon) { MessageBoxes.ShowWarning(this, _ERROR_MOD_NOT_ALLOWED); return; } } } catch (Exception ex) { MessageBoxes.ShowError(this, ex); return; } } // If another mod is installed on current slot... // Exception for Patch 1.67d if (isInstall && InstallHelper.IsAnotherModInstalled(currentPatch.SlotRef, currentPatch.Name) && !AppConstants.SLOT_COMMUNITY_PATCH.Equals(currentPatch.SlotRef)) { MessageBoxes.ShowWarning(this, string.Format(_ERROR_ANOTHER_MOD_INSTALLED, InstallHelper.GetInstalledModName(currentPatch.SlotRef))); return; } // EVO_134 Group handling, if necessary List <string> chosenInstallGroups = new List <string> { PCH.REQUIRED_GROUP_NAME }; if (isInstall && currentPatch.Groups.Count > 1) { GroupsDialog dlg = new GroupsDialog(_CurrentInstallPatch); DialogResult dr = dlg.ShowDialog(this); if (dr == DialogResult.OK) { chosenInstallGroups = dlg.ChosenGroups; } else { return; } } // Patch logger init string logFile = Application.StartupPath + LibraryConstants.FILE_LOG_PATCH; Log patchLog = new Log(logFile); patchLog.Appenders.Add(new ConsoleAppender()); // EVO_100: progress bar init progressPanel.Visible = true; infoLabel.Visible = false; mainProgressBar.Minimum = 0; mainProgressBar.Maximum = currentPatch.PatchInstructions.Count; mainProgressBar.Step = 1; mainProgressBar.Value = 0; PatchHelper.ProgressBar = mainProgressBar; // Using new helper try { InstallHelper.RunAll(currentPatch, patchLog, currentCulture, isInstall, chosenInstallGroups); Application.DoEvents(); // Showing gui messages foreach (string message in PatchHelper.Messages) { MessageBoxes.ShowWarning(this, message); } // OK MessageBoxes.ShowInfo(this, isInstall ? _MESSAGE_PATCH_SUCCESS : _MESSAGE_PATCH_UNINSTALL_SUCCESS); // Refreshing window contents //_LoadData(_CurrentInstallPatch.FileName, (_CurrentUninstallPatch == null) ? null : _CurrentUninstallPatch.FileName); // Contextual information has to be updated _UpdateContextualControls(); } catch (Exception ex) { // Showing messages first foreach (string message in PatchHelper.Messages) { MessageBoxes.ShowWarning(this, message); } if (PatchHelper.Messages.Count == 0) { MessageBoxes.ShowError(this, ex); } } finally { // Hiding progress bar progressPanel.Visible = false; } }