예제 #1
0
        protected override void OnHeaderGUI()
        {
            if (ScriptAsset == null || drawHeaderMethod == null)
            {
                return;
            }

            var headerRect = (Rect)drawHeaderMethod.Invoke(null, new object[] { this, ScriptAsset.name + (ScriptView.ScriptModified ? "*" : string.Empty) });

            using (new EditorGUI.DisabledScope(!ScriptView.ScriptModified))
            {
                var applyButtonRect = new Rect(new Vector2(headerRect.xMax - 98, headerRect.yMax - 26), new Vector2(48, 25));
                if (GUI.Button(applyButtonRect, "Apply", EditorStyles.miniButton))
                {
                    GUI.FocusControl(null);
                    ApplyAndImportChecked();
                }
                var revertButtonRect = new Rect(new Vector2(headerRect.xMax - 150, headerRect.yMax - 26), new Vector2(50, 25));
                if (GUI.Button(revertButtonRect, "Revert", EditorStyles.miniButton))
                {
                    GUI.FocusControl(null);
                    ResetValues();
                    if (ScriptAsset && VisualEditor != null)
                    {
                        VisualEditor.GenerateForScript(scriptText, ScriptAsset, true);
                    }
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Handles the TextChanged event of TitleTextBox object.
 /// </summary>
 private void titleTextBox_TextChanged(object sender, EventArgs e)
 {
     if (!_isUiUpdating)
     {
         FocusedChart.Title = titleTextBox.Text;
         VisualEditor.OnDocumentChanged();
     }
 }
예제 #3
0
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     if (!DocumentIsReady)
     {
         VisualEditor.NavigateToString(WrapHtmlContent(HtmlSource, StyleSheet));
     }
     _styleTimer.Start();
 }
예제 #4
0
        /// <summary>
        /// Handles the ValueChanged event of SeriesMarkerSizeNumericUpDown object.
        /// </summary>
        private void seriesMarkerSizeNumericUpDown_ValueChanged(object sender, EventArgs e)
        {
            if (!_seriesUiUpdating)
            {
                FocusedSeries.Marker.Size = (byte)seriesMarkerSizeNumericUpDown.Value;

                VisualEditor.OnDocumentChanged();
            }
        }
예제 #5
0
        /// <summary>
        /// Handles the ColorChanged event of MarkerColorPanelControl object.
        /// </summary>
        private void markerColorPanelControl_ColorChanged(object sender, EventArgs e)
        {
            if (!_seriesUiUpdating)
            {
                UpdateFocusedSeriesMarkerColor();

                VisualEditor.OnDocumentChanged();
            }
        }
예제 #6
0
        /// <summary>
        /// Handles the Click event of ButtonOk object.
        /// </summary>
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (VisualEditor.IsDocumentChanged)
            {
                VisualEditor.UpdateDocumentSource();
            }

            DialogResult = DialogResult.OK;
        }
예제 #7
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of SeriesMarkerStyleComboBox object.
        /// </summary>
        private void seriesMarkerStyleComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!_seriesUiUpdating)
            {
                FocusedSeries.Marker.Style = (OpenXmlDocumentChartMarkerStyle)seriesMarkerStyleComboBox.SelectedItem;

                UpdateFocusedSeriesMarkerColor();

                VisualEditor.OnDocumentChanged();
            }
        }
예제 #8
0
        private void HandleScriptModified(string assetPath)
        {
            var curPath = AssetDatabase.GetAssetPath(ScriptAsset);

            if (curPath != assetPath)
            {
                return;
            }

            ScriptAsset = AssetDatabase.LoadAssetAtPath <Script>(assetPath);
            scriptText  = File.ReadAllText(AssetDatabase.GetAssetPath(ScriptAsset));
            VisualEditor.GenerateForScript(scriptText, ScriptAsset);
        }
예제 #9
0
        /// <summary>
        /// Called when chart data is changed.
        /// </summary>
        private void OnChartDataChanged()
        {
            if (_isUiUpdating)
            {
                return;
            }

            // set chart data
            FocusedChart.ChartData.SetFromDataTable(GetFocusedDataTable());

            // notify visual editor that DOCX document with chart is changed
            VisualEditor.OnDocumentChanged();
        }
        public GraphEditorViewModel(VisualEditor graphControl)
        {
            this.graphControl = graphControl;

            DeleteSelectedNodesCommand = new RelayCommand(DeleteSelectedNodes)
            {
                CanExecute = true
            };
            AddConstantCommand = new RelayCommand(AddConstant)
            {
                CanExecute = true
            };
        }
예제 #11
0
        protected override void Apply()
        {
            base.Apply();

            if (VisualEditor is null)
            {
                return;
            }

            var scriptText = VisualEditor.GenerateText();
            var scriptPath = AssetDatabase.GetAssetPath(ScriptAsset);

            File.WriteAllText(scriptPath, scriptText, Encoding.UTF8);
            ScriptView.ScriptModified = false;
        }
예제 #12
0
        /// <summary>
        /// Handles the ColorChanged event of DataPointColorPanelControl object.
        /// </summary>
        private void dataPointColorPanelControl_ColorChanged(object sender, EventArgs e)
        {
            if (!_seriesUiUpdating)
            {
                if (FocusedDataPoint.ShapeProperties.FillColor.HasValue)
                {
                    FocusedDataPoint.ShapeProperties.FillColor = dataPointColorPanelControl.Color;
                }
                if (FocusedDataPoint.ShapeProperties.OutlineColor.HasValue)
                {
                    FocusedDataPoint.ShapeProperties.OutlineColor = dataPointColorPanelControl.Color;
                }

                VisualEditor.OnDocumentChanged();
            }
        }
        public override void LoadGraph(object selectedObject)
        {
            _loadedGraph     = (TranslatedDialogueGraph)selectedObject;
            serializedObject = new SerializedObject(_loadedGraph);

            if (!_loadedGraph.isInitialized)
            {
                SetDefaultLanguage();
                _loadedGraph.isInitialized = true;
            }
            LoadTextNodesFromOriginal();

            textNodes = new ReorderableList(serializedObject, serializedObject.FindProperty("translatedTexts"), false, false, false, false);
            textNodes.headerHeight        = 5f;
            textNodes.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                var    text  = _loadedGraph.translatedTexts[index];
                string label = text.OriginalText + (text.isOriginalTextChanged ? "*" : "");
                if (label.Length > 40)
                {
                    label = label.Remove(40) + "...";
                }


                Rect statusRect = new Rect(5, rect.y + 2.5f, 10, 10);
                GUI.Label(statusRect, "", VisualEditorGUIStyle.ColorBox(TranslationStatus(text)));
                rect.x     += 15;
                rect.width -= 15;

                GUI.Label(rect, label);
            };
            textNodes.onSelectCallback = (ReorderableList list) =>
            {
                int i = Mathf.Clamp(list.index, 0, _loadedGraph.translatedTexts.Count);
                _selectedText = _loadedGraph.translatedTexts[i];

                var editor = VisualEditor.GetWindow <VisualEditor>();
                var node   = _loadedGraph.Original.Nodes.Find(_selectedText.OriginalID);
                editor.PanToNode(node);
            };
        }
예제 #14
0
        private void ApplyAndImportChecked()
        {
            if (!ScriptView.ScriptModified || !ObjectUtils.IsValid(ScriptAsset))
            {
                return;
            }

            // Make sure the script actually changed before invoking `ApplyAndImport()`;
            // in case the generated script text will be the same as it was, Unity editor will
            // fail internally and loose reference to the edited asset target.
            var scriptPath         = AssetDatabase.GetAssetPath(ScriptAsset);
            var modifiedScriptText = VisualEditor.GenerateText();
            var savedScriptText    = File.ReadAllText(scriptPath, Encoding.UTF8);

            if (modifiedScriptText == savedScriptText)
            {
                ScriptView.ScriptModified = false;
                return;
            }
            ApplyAndImport();
        }
예제 #15
0
 private void OnPrintExecute()
 {
     SetHeaderAndFooter();
     VisualEditor.ShowPrintDialog();
     SetHeaderAndFooter(true);
 }