/// <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); }
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> /// 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); } }