예제 #1
0
        private void DoConditionsEditor(Rect rect, ConditionsController conditions)
        {
            var hasConditions = conditions.getBlocksCount() > 0;

            if (GUI.Button(rect, hasConditions ? conditionsTex : noConditionsTex, noBackgroundSkin.button))
            {
                ConditionEditorWindow.ShowAtPosition(conditions, new Rect(rect.x + rect.width, rect.y, 0, 0));
            }
        }
예제 #2
0
        public DialogNodeEditor()
        {
            conditionsTex   = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24");
            noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24");

            effectTex   = Resources.Load <Texture2D>("EAdventureData/img/icons/effects/32x32/has-macro");
            noEffectTex = Resources.Load <Texture2D>("EAdventureData/img/icons/effects/32x32/macro");

            noBackgroundSkin = Resources.Load <GUISkin>("EAdventureData/skin/EditorNoBackgroundSkin");
            noBackgroundSkin.button.margin  = new RectOffset(1, 1, 1, 1);
            noBackgroundSkin.button.padding = new RectOffset(0, 0, 0, 0);

            closeStyle = new GUIStyle(GUI.skin.button)
            {
                padding = new RectOffset(0, 0, 0, 0),
                margin  = new RectOffset(0, 5, 2, 0)
            };
            closeStyle.normal.textColor  = Color.red;
            closeStyle.focused.textColor = Color.red;
            closeStyle.active.textColor  = Color.red;
            closeStyle.hover.textColor   = Color.red;

            buttonstyle = new GUIStyle()
            {
                padding = new RectOffset(5, 5, 5, 5)
            };

            linesList = new DataControlList
            {
                Columns = new List <ColumnList.Column>
                {
                    new ColumnList.Column
                    {
                        Text        = "Speaker",
                        SizeOptions = new GUILayoutOption[] { GUILayout.MaxWidth(60) }
                    },
                    new ColumnList.Column
                    {
                        Text        = "Emote",
                        SizeOptions = new GUILayoutOption[] { GUILayout.MaxWidth(30) }
                    },
                    new ColumnList.Column
                    {
                        Text        = "Line",
                        SizeOptions = new GUILayoutOption[] { GUILayout.MinWidth(250), GUILayout.ExpandWidth(true) }
                    },
                    new ColumnList.Column
                    {
                        Text        = "Cond.",
                        SizeOptions = new GUILayoutOption[] { GUILayout.MaxWidth(30) }
                    }
                },
                drawCell = (rect, index, column, isActive, isFocused) =>
                {
                    var        line       = this.linesList.list[index] as ConversationLineDataControl;
                    BubbleType bubbleType = GetBubbleType(line);
                    var        text       = line.getText();

                    // Mark the line as selected as soon as any click is performed in the line
                    if (Event.current.isMouse && Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
                    {
                        linesList.index = index;
                    }

                    // Extract the bubble type
                    if (bubbleType.Identifier != "-")
                    {
                        text = text.Remove(0, bubbleType.Identifier.Length + 2);
                    }

                    switch (column)
                    {
                    case 0:     // Speaker

                        var npc = new List <string> {
                            TC.get("ConversationLine.PlayerName")
                        };
                        npc.AddRange(Controller.Instance.IdentifierSummary.getIds <NPC>());

                        var speaker = line.getName().Equals("Player") ? 0 : npc.IndexOf(line.getName());
                        EditorGUI.BeginChangeCheck();
                        var newSpeaker = EditorGUI.Popup(rect, speaker, npc.ToArray());
                        if (EditorGUI.EndChangeCheck())
                        {
                            var newSpeakerName = newSpeaker == 0 ? "Player" : npc[newSpeaker];
                            line.setName(newSpeakerName);
                        }
                        break;

                    case 1:     // Bubble type
                        // Control
                        if (GUI.Button(rect, bubbleType.Identifier))
                        {
                            bubbleType = BubbleTypes.FirstOrDefault(b => bubbleType.Next == b.Identifier);
                            // Reinsert the bubble type
                            if (bubbleType.Identifier != "-")
                            {
                                text = "#" + bubbleType.Identifier + " " + text;
                            }
                            line.setText(text);
                        }

                        break;

                    case 2:     // Text
                        EditorGUI.BeginChangeCheck();
                        var newText = EditorGUI.TextField(rect, text);
                        if (EditorGUI.EndChangeCheck())
                        {
                            // Reinsert the bubble type
                            if (bubbleType.Identifier != "-")
                            {
                                newText = "#" + bubbleType.Identifier + " " + newText;
                            }
                            line.setText(newText);
                        }
                        break;

                    case 3:     // Conditions
                        var hasConditions = line.getConditions().getBlocksCount() > 0;
                        if (GUI.Button(rect, hasConditions ? conditionsTex : noConditionsTex, noBackgroundSkin.button))
                        {
                            ConditionEditorWindow.ShowAtPosition(line.getConditions(), new Rect(rect.x + rect.width, rect.y, 0, 0));
                        }
                        break;
                    }
                }
            };
        }