示例#1
0
        public bool Add(TranslatedDialogueGraph graph)
        {
            translations.RemoveAll(x => x == null);

            if (translations.Contains(graph))
            {
                return(false);
            }

            foreach (var t in translations)
            {
                if (t != null && t.Language == graph.Language)
                {
                    return(false);
                }
            }

            translations.Add(graph);
            return(true);
        }
        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);
            };
        }