/// <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> /// 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(); }
private void saveButton_Click(object sender, EventArgs e) { // Click on 'Save' button if (_IsModified) { try { Cursor = Cursors.WaitCursor; if (_IsDatabaseModified) { // 1. Saving database files _PhysicsTable.Save(); _CarShopsTable.Save(); _CarPacksTable.Save(); _CarColorsTable.Save(); _InteriorTable.Save(); // 2. Applying edit tasks EditHelper.Instance.ApplyChanges(_CurrentPhysicsTask); EditHelper.Instance.ApplyChanges(_CurrentCarShopsTask); EditHelper.Instance.ApplyChanges(_CurrentCarPacksTask); EditHelper.Instance.ApplyChanges(_CurrentCarColorsTask); EditHelper.Instance.ApplyChanges(_CurrentInteriorTask); _IsDatabaseModified = false; } if (_IsCameraModified) { // 3. Cameras _CameraData.Save(); _IsCameraModified = false; } StatusBarLogManager.ShowEvent(this, _STATUS_SAVING_SUCCESS); Cursor = Cursors.Default; } catch (Exception ex) { MessageBoxes.ShowError(this, new Exception(_ERROR_SAVING, ex)); } } }