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); }; }
protected override void InitStyle() { base.InitStyle(); titleStyle.fontSize = 16; titleStyle.alignment = TextAnchor.UpperCenter; nameStyle = new GUIStyle(titleStyle); nameStyle.fontSize = 12; nameStyle.wordWrap = true; nameStyle.alignment = TextAnchor.LowerCenter; nameStyle.fontStyle = FontStyle.Normal; var pin = Node.PinCollection.Get("Value"); Color c = BuiltInColors.GetDark(pin.VariableType); var background = VisualEditorGUIStyle.GetTexture(c, new Color(0, 0, 0, 0), true, true, true, true); fieldStyle.normal.background = background.Texture; fieldStyle.active.background = background.Texture; fieldStyle.focused.background = background.Texture; fieldStyle.hover.background = background.Texture; }
void TranslatorUI(Rect rect) { _detailsScrollPos = GUI.BeginScrollView(rect, _detailsScrollPos, new Rect(0, 0, rect.width - 20, rect.height), false, false); rect.x = 0; rect.y = 0; rect.width -= 20; if (_selectedText == null) { Rect r = new Rect(rect.x + rect.width / 2 - 150, rect.y + rect.height / 2 - 20, 300, HELPBOX_HEIGHT); EditorGUI.HelpBox(r, "Please select a node from the left menu!", MessageType.Warning); } else { var original = _loadedGraph.Original.Nodes.Find(_selectedText.OriginalID) as TextNode; if (original == null) { Rect r = new Rect(rect.x + rect.width / 2 - 150, rect.y + rect.height / 2 - 20, 300, HELPBOX_HEIGHT); EditorGUI.HelpBox(r, "This text was removed from the dialogue graph!", MessageType.Error); if (GUI.Button(new Rect(r.x, r.y + r.height + 5, r.width, LINE_HEIGHT), "Delete this Translation")) { _loadedGraph.translatedTexts.Remove(_selectedText); } return; } rect.height = _detailContentHeight; GUI.Box(rect, "", VisualEditorGUIStyle.Box()); rect.x += 5; rect.width -= 10; rect.height = LINE_HEIGHT; GUI.Label(rect, "Text" + (_selectedText.isOriginalTextChanged ? "*" : ""), RunemarkGUI.Styles.H2(TextAnchor.MiddleCenter)); rect.y += 30; // Actor if (original.ActorName != "") { _selectedText.Actor = EditorGUI.TextField(rect, original.ActorName, _selectedText.Actor); rect.y += rect.height + 5; } GUIContent text = new GUIContent(original.Text); rect.height = GUI.skin.label.CalcHeight(text, rect.width); GUI.Label(rect, original.Text); rect.y += rect.height + 5; GUIStyle textArea = GUI.skin.textArea; textArea.wordWrap = true; rect.height += 50; _selectedText.TranslatedText = EditorGUI.TextArea(rect, _selectedText.TranslatedText, textArea); rect.y += rect.height + 5; rect.height = 20; GUI.Label(rect, "Answers", RunemarkGUI.Styles.H2(TextAnchor.MiddleCenter)); rect.y += rect.height + 5; foreach (var answer in _selectedText.Answers) { Variable originalAnswer = original.Variables.GetByName(answer.OriginalID); if (originalAnswer == null) { rect.height = HELPBOX_HEIGHT; EditorGUI.HelpBox(rect, "This answer was removed from the text node!", MessageType.Error); rect.y += rect.height + 5; rect.height = LINE_HEIGHT; if (GUI.Button(rect, "Delete this Translation")) { _selectedText.Answers.Remove(answer); return; } rect.y += rect.height + 5; } else { GUIStyle label = RunemarkGUI.Styles.Paragraph(12, TextAnchor.UpperLeft, FontStyle.Normal, true); GUIContent aContent = new GUIContent(originalAnswer.ConvertedValue <string>() + (answer.isOriginalTextChanged ? "*" : "")); rect.height = label.CalcHeight(aContent, rect.width / 2); GUI.Label(new Rect(rect.x, rect.y, rect.width / 2, rect.height), aContent, label); answer.TranslatedText = EditorGUI.TextField(new Rect(rect.x + rect.width / 2, rect.y, rect.width / 2, rect.height), answer.TranslatedText); rect.y += rect.height + 5; } } } _detailContentHeight = rect.y; GUI.EndScrollView(); }