void OnExitPlaymode()
        {
            Button        recordButton       = rootVisualElement.Q <Button>("RecordButton");
            Button        reportButton       = rootVisualElement.Q <Button>("ReportButton");
            Button        saveSegmentButton  = rootVisualElement.Q <Button>("SaveButton");
            Button        endButton          = rootVisualElement.Q <Button>("EndButton");
            List <Button> recordingStateBtns = new List <Button>()
            {
                saveSegmentButton,
                endButton
            };

            BulkButtonDisplayUpdate(recordingStateBtns, DisplayStyle.None);
            recordButton.style.display = DisplayStyle.Flex;
            if (ReportingManager.DoesReportExist(ReportingManager.ReportType.Html))
            {
                reportButton.style.display      = DisplayStyle.Flex;
                reportButton.clickable.clicked += () => { HandleOpenHtmlReportClick(); };
                reportButton.SetEnabled(true);
            }

            if (playModeStartedFromHere)
            {
                if (RecordedPlaybackPersistentData.GetRecordingMode() == RecordingMode.Record ||
                    RecordedPlaybackPersistentData.GetRecordingMode() == RecordingMode.Extend)
                {
                    RecordedPlaybackEditorUtils.SaveCurrentRecordingDataAsProjectAsset();
                }

                RecordedPlaybackPersistentData.SetRecordingMode(RecordingMode.None);
            }

            playModeStartedFromHere = false;
            SetupViews();
        }
Beispiel #2
0
        void RenderElements()
        {
            VisualElement buttonsRow = new VisualElement()
            {
                style =
                {
                    flexDirection = FlexDirection.Row,
                    flexShrink    =                0f,
                    alignContent  = Align.Center
                }
            };

            buttonsRow.AddToClassList("buttons-row");

            if (!renderStopButton && !RecordingInputModule.isWorkInProgress)
            {
                Button saveButton = new Button()
                {
                    text = "Record", style = { flexGrow = 1, height = 30 }
                };
                saveButton.clickable.clicked += () => { StartRecording(); };
                saveButton.AddToClassList("button");
                buttonsRow.Add(saveButton);

                Button crawlButton = new Button()
                {
                    text = "Crawl", style = { flexGrow = 1, height = 30 }
                };
                crawlButton.clickable.clicked += () => { StartCrawl(); };
                crawlButton.AddToClassList("button");
                buttonsRow.Add(crawlButton);
            }
            else
            {
                stateLabel      = new Label();
                stateLabel.text = "●";
                stateLabel.AddToClassList("state-label");
                stateLabel.AddToClassList("red");
                buttonsRow.Add(stateLabel);
                Button stopButton = new Button()
                {
                    text = "Stop", style = { flexGrow = 1, height = 30 }
                };
                stopButton.clickable.clicked += () => { StopRecording(); };
                stopButton.AddToClassList("button");
                buttonsRow.Add(stopButton);
            }

            if (ReportingManager.DoesReportExist(ReportingManager.ReportType.Html))
            {
                Button reportButton = new Button()
                {
                    text = "☰ Show Report", style = { flexGrow = 1, height = 30 }
                };
                reportButton.clickable.clicked += () => { ShowHtmlReport(); };
                reportButton.AddToClassList("button");
                buttonsRow.Add(reportButton);
            }

            root.Add(buttonsRow);

            Label label = new Label();

            label.text = "- Recording asset path -";
            label.AddToClassList("center");
            root.Add(label);

            Label val = new Label()
            {
                style =
                {
                    marginBottom = 10
                }
            };

            val.text = AutomatedQARuntimeSettings.RecordingFolderNameWithAssetPath;
            val.AddToClassList("center");
            root.Add(val);

            VisualElement refreshRow = new VisualElement()
            {
                style =
                {
                    flexDirection = FlexDirection.Row,
                    flexShrink    =                0f,
                    alignContent  = Align.Center
                }
            };

            Label filterLabel = new Label();

            filterLabel.text = "Filter: ";
            filterLabel.AddToClassList("filter-label");
            refreshRow.Add(filterLabel);

            searchFilterText = string.Empty;
            TextField newName = new TextField();

            newName.AddToClassList("filter-field");
            newName.RegisterValueChangedCallback(x =>
            {
                searchFilterText = x.newValue;
                root.Remove(recordingContainer);
                RenderRecordings();
            });
            refreshRow.Add(newName);

            Button refreshListButton = new Button()
            {
                text = "↻", tooltip = "Refresh recordings list"
            };

            refreshListButton.clickable.clicked += () =>
            {
                newName.value  = string.Empty;
                recordingPaths = GetAllRecordingAssetPaths();
                recordingPaths.Sort();
                SetUpView();
            };
            refreshListButton.AddToClassList("refresh-button");
            refreshRow.Add(refreshListButton);
            root.Add(refreshRow);
        }
        /* START Recording Management Buttons */
        private void SetupControls()
        {
            // Asset path reference in uxml
            Label assetPath = rootVisualElement.Q <Label>("AssetPath");

            assetPath.text = $"{AutomatedQARuntimeSettings.RecordingFolderNameWithAssetPath}";
            assetPath.SetEnabled(false);

            // Button element references from ButtonHolder in uxml
            Button recordButton      = rootVisualElement.Q <Button>("RecordButton");
            Button reportButton      = rootVisualElement.Q <Button>("ReportButton");
            Button saveSegmentButton = rootVisualElement.Q <Button>("SaveButton");
            Button endButton         = rootVisualElement.Q <Button>("EndButton");

            // Button element references from CompositeRecordingsPanel in uxml
            Button combineButton      = rootVisualElement.Q <Button>("OpenCompositeButton");
            Button closeCombineButton = rootVisualElement.Q <Button>("CloseCompositeButton");
            Button saveCombineButton  = rootVisualElement.Q <Button>("SaveCombineButton");
            Button playContinueButton = rootVisualElement.Q <Button>("PlayAndContinueButton");

            var    recordingListContainer = rootVisualElement.Q("CompositeRecordingList");
            Button addButton    = rootVisualElement.Q <Button>("AddCompositeButton");
            Button deleteButton = rootVisualElement.Q <Button>("DeleteCompositeButton");

            List <Button> recordingStateBtns = new List <Button>()
            {
                saveSegmentButton,
                endButton
            };

            // On window open, hide recording mode buttons
            if (EditorApplication.isPlaying && playModeStartedFromHere)
            {
                saveSegmentButton.clickable.clicked += () => { HandleSaveSegmentClick(); };
                endButton.clickable.clicked         += () => { HandleEndClick(recordButton, reportButton, recordingStateBtns); };
                BulkButtonDisplayUpdate(recordingStateBtns, DisplayStyle.Flex);
                reportButton.style.display = recordButton.style.display = DisplayStyle.None;
            }
            else
            {
                recordButton.clickable.clicked += () => { HandleRecordClick(); };
                if (!ReportingManager.DoesReportExist(ReportingManager.ReportType.Html))
                {
                    reportButton.SetEnabled(false);
                }
                else
                {
                    reportButton.clickable.clicked += () => { HandleOpenHtmlReportClick(); };
                }
                BulkButtonDisplayUpdate(recordingStateBtns, DisplayStyle.None);

                closeCombineButton.clickable.clicked += () =>
                {
                    rootVisualElement.Q <IntegerField>("NumberCompositeRecordings").value = 0;
                    recordingsToCombine.Clear();
                    ClearHelpBox();
                    rootVisualElement.Q(COMPOSITE_PANEL).style.display = DisplayStyle.None;
                    rootVisualElement.Q(RECORDING_PANEL).style.display = DisplayStyle.Flex;
                    combineButton.text          = COMPOSITE_RECORDING_BUTTON_TEXT;
                    combineButton.style.display = DisplayStyle.Flex;
                    isCombinePanelOpen          = true;
                };

                combineButton.clickable.clicked += () => HandleCombineClickToggle();

                saveCombineButton.clickable.clicked += () => HandleSaveComposite();

                playContinueButton.clickable.clicked += () => HandlePlayContinue();

                addButton.clickable.clicked += () => HandleAddCompositeRow(recordingListContainer);

                deleteButton.clickable.clicked += () => HandleDeleteCompositeRow(recordingListContainer);
            }
        }