Пример #1
0
        /// <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();
        }
Пример #2
0
        public void UpdateEntry_WhenNoChangeMade_ShouldNotAffectIt()
        {
            // GIVEN
            var camFile =
                FileTesting.CreateFileFromResource("TDUModdingLibraryTests.Resources.cameras." +
                                                   ExtendedCamerasResourceFile, Path.Combine(_tempPath, ExtendedCamerasResourceFile));
            var cameras = new Cameras(camFile);

            Cameras.CamEntry modifiedEntry = cameras.GetEntryByCameraId("101");

            // WHEN
            cameras.UpdateEntry(modifiedEntry);

            // THEN
            Assert.AreEqual(modifiedEntry, cameras.GetEntryByCameraId("101"));
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
        public void UpdateEntry_WhenReplacedView_ShouldAffectIt()
        {
            // GIVEN
            var camFile =
                FileTesting.CreateFileFromResource("TDUModdingLibraryTests.Resources.cameras." +
                                                   ExtendedCamerasResourceFile, Path.Combine(_tempPath, ExtendedCamerasResourceFile));
            var cameras       = new Cameras(camFile);
            var baseEntry     = cameras.GetEntryByCameraId("101");
            var modifiedEntry = baseEntry;
            var modifiedView  = modifiedEntry.views[0];

            modifiedView.type = Cameras.ViewType.Follow_Large_Back;

            modifiedEntry.views = new List <Cameras.View>();
            modifiedEntry.views.AddRange(baseEntry.views);
            modifiedEntry.views[0] = modifiedView;

            // WHEN
            cameras.UpdateEntry(modifiedEntry);

            // THEN
            Assert.AreNotEqual(modifiedEntry, baseEntry);
        }
Пример #5
0
        /// <summary>
        /// Defines window contents
        /// </summary>
        private void _InitializeContents()
        {
            Cursor = Cursors.WaitCursor;

            // Views treeview
            viewsTreeView.Nodes.Clear();

            // Bugs spotted > default view disabled for now

            /*TreeNode newNode = new TreeNode(_NODE_DEFAULTS)
             *                     {
             *                         NodeFont = new Font(viewsTreeView.Font, FontStyle.Bold),
             *                         Tag = -1
             *                     };
             *
             * viewsTreeView.Nodes.Add(newNode);*/

            try
            {
                // Browsing available cameras...
                foreach (KeyValuePair <string, string> cameraRef in VehicleSlotsHelper.CamReferenceReverse)
                {
                    TreeNode newNode = new TreeNode(cameraRef.Key);

                    // Browsing current set...
                    Cameras.CamEntry currentEntry = _CamerasData.GetEntryByCameraId(cameraRef.Value);

                    if (currentEntry.isValid && currentEntry.views.Count > 0)
                    {
                        // EVO_169 View label now sorted
                        SortedDictionary <string, Cameras.View> viewsByType =
                            new SortedDictionary <string, Cameras.View>();

                        foreach (Cameras.View anotherView in currentEntry.views)
                        {
                            viewsByType.Add(anotherView.type.ToString(), anotherView);
                        }

                        foreach (KeyValuePair <string, Cameras.View> viewInfomation in viewsByType)
                        {
                            TreeNode newChildNode = new TreeNode(viewInfomation.Key)
                            {
                                NodeFont = new Font(viewsTreeView.Font, FontStyle.Bold),
                                Tag      =
                                    cameraRef.Value + Tools.SYMBOL_VALUE_SEPARATOR +
                                    (int)viewInfomation.Value.type
                            };

                            newNode.Nodes.Add(newChildNode);
                        }
                        //

                        viewsTreeView.Nodes.Add(newNode);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBoxes.ShowError(null, ex);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }