/// <summary> /// /// </summary> /// <param name="vehicle"></param> /// <param name="cameraIK"></param> /// <param name="physicsTable"></param> private static void _SetEasyCamIK(string vehicle, string cameraIK, DB physicsTable) { string chosenObject = cameraIK.Split(Tools.SYMBOL_VALUE_SEPARATOR)[0]; VehicleSlotsHelper.ChangeCameraByVehicleName(vehicle, chosenObject, physicsTable); VehicleSlotsHelper.ChangeIKByVehicleName(vehicle, chosenObject, physicsTable); }
/// <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> /// What the instruction should do /// </summary> protected override void _Process() { // Parameters string camId = _GetParameter(PatchInstructionParameter.ParameterName.cameraIKIdentifier); string viewSource = _GetParameter(PatchInstructionParameter.ParameterName.viewSource); Cameras.Position sourcePosition = _ValidatePosition(viewSource); string viewTarget = _GetParameter(PatchInstructionParameter.ParameterName.viewTarget); Cameras.Position targetPosition = _ValidatePosition(viewTarget); // Loading current camera string currentCamFile = LibraryConstants.GetSpecialFile(LibraryConstants.TduSpecialFile.CamerasBin); Cameras currentCameras = TduFile.GetFile(currentCamFile) as Cameras; if (currentCameras == null || !currentCameras.Exists) { throw new Exception("Unable to load current camera data: " + currentCamFile); } // Retrieving entry Cameras.CamEntry entryToEdit = currentCameras.GetEntryByCameraId(camId); VehicleSlotsHelper.CustomizeCameraPosition(currentCameras, entryToEdit, Cameras.ViewType.Cockpit, sourcePosition, targetPosition); // Saving currentCameras.Save(); }
/// <summary> /// Customizes specified camera view /// </summary> /// <param name="currentData"></param> /// <param name="defaultData"></param> /// <param name="camToChange"></param> /// <param name="viewToChange"></param> /// <param name="camIdToTake"></param> /// <param name="viewToTake"></param> private static void _Customize(Cameras currentData, Cameras defaultData, string camToChange, Cameras.ViewType viewToChange, string camIdToTake, Cameras.ViewType viewToTake) { Cameras.CamEntry entryToChange = currentData.GetEntryByCameraId(camToChange); Cameras.CamEntry entryToTake = defaultData.GetEntryByCameraId(camIdToTake); VehicleSlotsHelper.CustomizeCameraView(currentData, entryToChange, viewToChange, entryToTake, viewToTake); }
/// <summary> /// Reverts changes in camera entry. /// </summary> /// <param name="args">Arguments.</param> public void Reset(string[] args) { var camFileName = GetCamFileNameParam(args); var cameraId = GetCamIdParam(args); var camFile = _LoadCameras(camFileName); var defaultCamFile = _LoadDefaultCameras(); var entryToReset = _GetEntry(camFile, cameraId); var viewKinds = new List <NativeCameras.ViewType> (); foreach (var view in entryToReset.views) { viewKinds.Add(view.type); } var defaultEntry = _GetEntry(defaultCamFile, cameraId); foreach (var viewKind in viewKinds) { VehicleSlotsHelper.CustomizeCameraView(camFile, entryToReset, viewKind, defaultEntry, viewKind); } camFile.Save(); _moduleDispatcher.NoModuleOutput(); }
private static void _Customize(NativeCameras currentData, NativeCameras defaultData, int entryId, NativeCameras.ViewType currentView, int takenEntryId, NativeCameras.ViewType takenView) { var entryToChange = _GetEntry(currentData, entryId); var takenEntry = _GetEntry(defaultData, takenEntryId); VehicleSlotsHelper.CustomizeCameraView(currentData, entryToChange, currentView, takenEntry, takenView); }
/// <summary> /// Loads camera.bin data /// </summary> private void _LoadReferenceCameras() { Cursor = Cursors.WaitCursor; // Parsing ref XML file and writing to reference VehicleSlotsHelper.InitReference(AppConstants.FOLDER_XML); // View selector dialog _CamViewSelectorDialog = new CamSelectorDialog(VehicleSlotsHelper.DefaultCameras); Cursor = Cursors.Default; }
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> /// Sets camera or IK for specified slot according to combo list item /// </summary> /// <param name="vehicle"></param> /// <param name="cameraOrIK"></param> /// <param name="physicsTable"></param> /// <param name="isCam"></param> private static void _SetCamOrIK(string vehicle, string cameraOrIK, DB physicsTable, bool isCam) { string chosenObject = cameraOrIK.Split(Tools.SYMBOL_VALUE_SEPARATOR)[0]; if (isCam) { VehicleSlotsHelper.ChangeCameraByVehicleName(vehicle, chosenObject, physicsTable); } else { VehicleSlotsHelper.ChangeIKByVehicleName(vehicle, chosenObject, physicsTable); } }
/// <summary> /// What the instruction should do /// </summary> protected void _CommonProcess() { // Common parameters string camId = _GetParameter(PatchInstructionParameter.ParameterName.cameraIKIdentifier); string hoodView = _GetParameter(PatchInstructionParameter.ParameterName.newHoodView); string hoodBackView = _GetParameter(PatchInstructionParameter.ParameterName.newHoodBackView); string cockpitView = _GetParameter(PatchInstructionParameter.ParameterName.newCockpitView); string cockpitBackView = _GetParameter(PatchInstructionParameter.ParameterName.newCockpitBackView); // Parameter validation string hoodCamId = hoodView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[0]; Cameras.ViewType hoodViewType = _ValidateViewType(hoodView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[1]); string hoodBackCamId = hoodBackView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[0]; Cameras.ViewType hoodBackViewType = _ValidateViewType(hoodBackView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[1]); string cockpitCamId = cockpitView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[0]; Cameras.ViewType cockpitViewType = _ValidateViewType(cockpitView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[1]); string cockpitBackCamId = cockpitBackView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[0]; Cameras.ViewType cockpitBackViewType = _ValidateViewType(cockpitBackView.Split(Tools.SYMBOL_VALUE_SEPARATOR)[1]); // Loading current camera string currentCamFile = LibraryConstants.GetSpecialFile(LibraryConstants.TduSpecialFile.CamerasBin); Cameras currentCameras = TduFile.GetFile(currentCamFile) as Cameras; if (currentCameras == null || !currentCameras.Exists) { throw new Exception("Unable to load current camera data: " + currentCamFile); } // Loading default camera Cameras defaultCameras = TduFile.GetFile(camReferenceFilename) as Cameras; if (defaultCameras == null || !defaultCameras.Exists) { throw new Exception("Unable to load new camera data: " + camReferenceFilename); } // Views VehicleSlotsHelper.InitReference(Tools.WorkingPath + LibraryConstants.FOLDER_XML); _Customize(currentCameras, defaultCameras, camId, Cameras.ViewType.Hood, hoodCamId, hoodViewType); _Customize(currentCameras, defaultCameras, camId, Cameras.ViewType.Hood_Back, hoodBackCamId, hoodBackViewType); _Customize(currentCameras, defaultCameras, camId, Cameras.ViewType.Cockpit, cockpitCamId, cockpitViewType); _Customize(currentCameras, defaultCameras, camId, Cameras.ViewType.Cockpit_Back, cockpitBackCamId, cockpitBackViewType); // Saving currentCameras.Save(); }
/// <summary> /// Sets new view on a custom camera /// </summary> /// <param name="cameraId"></param> /// <param name="viewType"></param> /// <param name="newCameraId"></param> /// <param name="newViewType"></param> /// <param name="isForFront"></param> private void _CustomizeCameraView(string cameraId, Cameras.ViewType viewType, string newCameraId, Cameras.ViewType newViewType, bool isForFront) { if (!string.IsNullOrEmpty(cameraId) && !string.IsNullOrEmpty(newCameraId)) { // Getting entry Cameras.CamEntry currentEntry = _CameraData.GetEntryByCameraId(cameraId); if (currentEntry.isValid) { // Goal is to replace current view (front or back one) with specified Cameras.CamEntry baseEntry = VehicleSlotsHelper.DefaultCameras.GetEntryByCameraId(newCameraId); Cameras.ViewType currentViewType = (isForFront ? viewType : viewType + 20); if (baseEntry.isValid) { VehicleSlotsHelper.CustomizeCameraView(_CameraData, currentEntry, currentViewType, baseEntry, newViewType); } } } }
/// <summary> /// Default constructor /// </summary> public VehicleManagerForm() { InitializeComponent(); // Vehicle slots reference VehicleSlotsHelper.InitReference(AppConstants.FOLDER_XML); try { _LoadReferenceCameras(); } catch (Exception ex) { MessageBoxes.ShowError(this, new Exception(_ERROR_LOADING_CAMERAS, ex)); } _InitializeContents(); try { _LoadDatabase(); } catch (Exception ex) { MessageBoxes.ShowError(this, new Exception(_ERROR_LOADING_DATABASE, ex)); } // Getting setting for list mod bool originalMode = bool.Parse(Program.ApplicationSettings.VehicleManagerOriginalDisplayMode); _IsShowOriginalNames = !originalMode; if (originalMode) { originalNamesRadioButton.Checked = true; } else { moddedNamesRadioButton.Checked = true; } }
private void browseSlotsButton_Click(object sender, EventArgs e) { // Click on '...' button for slots try { Cursor = Cursors.WaitCursor; // Preparing slot list SortedStringCollection sortedSlotList = new SortedStringCollection(); Dictionary <string, string> index = new Dictionary <string, string>(); // Misc slot sortedSlotList.Add(Tools.NAME_MISC_SLOT); index.Add(Tools.NAME_MISC_SLOT, Tools.KEY_MISC_SLOT); // Vehicle slots VehicleSlotsHelper.InitReference(Tools.WorkingPath + LibraryConstants.FOLDER_XML); foreach (KeyValuePair <string, string> pair in VehicleSlotsHelper.SlotReference) { sortedSlotList.Add(pair.Key); index.Add(pair.Key, pair.Value); } Cursor = Cursors.Default; // Displaying browse dialog TableBrowsingDialog dialog = new TableBrowsingDialog(_MESSAGE_BROWSE_SLOTS, sortedSlotList, index); DialogResult dr = dialog.ShowDialog(); if (dr == DialogResult.OK && dialog.SelectedIndex != null) { slotRefTextBox.Text = dialog.SelectedIndex; } } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } }
private void cockSetButton_Click(object sender, EventArgs e) { // Click on Set c**k position button try { Cursor = Cursors.WaitCursor; Cameras.Position sourcePos = (Cameras.Position)Enum.Parse(typeof(Cameras.Position), cockSourceComboBox.Text); Cameras.Position targetPos = (Cameras.Position)Enum.Parse(typeof(Cameras.Position), cockTargetComboBox.Text); Cameras.CamEntry currentEntry = _CameraData.GetEntryByCameraId(customCameraIdLabel.Text); if (currentEntry.isValid) { VehicleSlotsHelper.CustomizeCameraPosition(_CameraData, currentEntry, Cameras.ViewType.Cockpit, sourcePos, targetPos); // Refresh _RefreshCameraIKContents(); // Modification flag _IsCameraModified = true; StatusBarLogManager.ShowEvent(this, _STATUS_CHANGING_VIEW_POS_OK); } } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } finally { Cursor = Cursors.Default; } }
/// <summary> /// What the instruction should do /// </summary> protected override void _Process() { // Parameters string vehicleName = _GetParameter(PatchInstructionParameter.ParameterName.slotFullName); string cameraId = _GetParameter(PatchInstructionParameter.ParameterName.cameraIKIdentifier); // Loading reference VehicleSlotsHelper.InitReference(PatchHelper.CurrentPath); // Checking validity if (!VehicleSlotsHelper.SlotReference.ContainsKey(vehicleName)) { throw new Exception("Specified vehicle name is not supported: " + vehicleName); } if (!VehicleSlotsHelper.CamReference.ContainsKey(cameraId)) { throw new Exception("Specified camera identifier is not supported: " + cameraId); } // Edit task EditHelper.Task task = new EditHelper.Task(); try { try { string bnkFileName = string.Concat(LibraryConstants.GetSpecialFolder(LibraryConstants.TduSpecialFolder.Database), DB.GetBNKFileName(DB.Culture.Global)); BNK dbBnkFile = TduFile.GetFile(bnkFileName) as BNK; if (dbBnkFile != null) { string dbFilePath = dbBnkFile.GetPackedFilesPaths(DB.GetFileName(DB.Culture.Global, DB.Topic.CarPhysicsData))[0]; task = EditHelper.Instance.AddTask(dbBnkFile, dbFilePath, true); } } catch (Exception ex) { throw new Exception("Unable to get TDU database contents in DB.BNK.", ex); } // Opens packed file DB physicsDB = TduFile.GetFile(task.extractedFile) as DB; if (physicsDB == null) { throw new Exception("Unable to get CarPhysicsData information."); } // Changes camera try { string vehicleRef = VehicleSlotsHelper.SlotReference[vehicleName]; VehicleSlotsHelper.ChangeCameraById(vehicleRef, cameraId, physicsDB); } catch (Exception ex) { throw new Exception("Unable to use new camera set: " + cameraId + " for " + vehicleName, ex); } // Saving try { physicsDB.Save(); EditHelper.Instance.ApplyChanges(task); EditHelper.Instance.RemoveTask(task); } catch (Exception ex) { throw new Exception("Unable to save and replace file in BNK.", ex); } } finally { EditHelper.Instance.RemoveTask(task); } }
/// <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; } }