示例#1
0
 void InspectDialogNode(Dialog d)
 {
     _activeOptionNode = null;
     _activeSubDialog = d;
 }
示例#2
0
 void InspectOptionNode(DialogOption o)
 {
     _activeSubDialog = null;
     _activeOptionNode = o;
 }
示例#3
0
 void DrawInlineDialogRequirements(Rect r, DialogOption d)
 {
     GUILayout.BeginArea(r);
     GUILayout.BeginHorizontal();
     var prev = GUI.color;
     var gs = new GUIStyle(GUI.skin.button)
     {
         fontSize = 8,
         alignment = TextAnchor.MiddleCenter,
         contentOffset = new Vector2(-1, 0),
         clipping = TextClipping.Overflow,
         border = new RectOffset(1, 1, 1, 1)
     };
     for (var i = d.NextDialog.Requirements.Count; i-- > 0;)
     {
         var req = d.NextDialog.Requirements[i];
         if (req != null)
         {
             GUI.color = req.GetColor();
             GUILayout.Box(new GUIContent(req.GetShortIdentifier(), req.GetToolTip()), gs, GUILayout.Width(19), GUILayout.Height(15));
         }
     }
     GUI.color = prev;
     GUILayout.EndHorizontal();
     GUILayout.EndArea();
 }
示例#4
0
 void DisplayOptionNodeInspector(Rect r, DialogOption dOption)
 {
     var prev = GUI.color;
     GUI.color = _inspectorColor;
     GUILayout.BeginArea(r, EditorStyles.textArea);
     GUI.color = prev;
     GUILayout.Space(5);
     GUILayout.Label("Text", _headerStyle);
     GUILayout.Space(5);
     GUILayout.BeginHorizontal();
     var tText = GetFormattedTitleString(dOption.Text.Description, dOption.Text.GetString);
     GUILayout.Label(tText, _lblStyle, GUILayout.MaxWidth(154));
     if (GUILayout.Button("Edit", _buttonStyle, GUILayout.Width(40)))
     {
         _activeStringEditor = new LocalizedStringEditor(dOption.Text, "Option text");
     }
     GUILayout.EndHorizontal();
     GUILayout.Space(5);
     GUILayout.Label(new GUIContent("Tag", "User data"), _headerStyle);
     GUILayout.Space(5);
     dOption.Tag = GUILayout.TextField(dOption.Tag);
     GUILayout.Space(10);
     GUILayout.Label("Connection", _headerStyle);
     GUILayout.Space(5);
     if (GUILayout.Button("New Sub-Dialog", _buttonStyle))
     {
         var d = CreateInstance<Dialog>();
         d.ID = GetUniqueId();
         AddToAsset(d);
         dOption.NextDialog = d;
         dOption.IsRedirection = false;
         CloseSubInspector();
     }
     GUILayout.Label(new GUIContent("Or link to existing: ", "Use with care, can result in infinite loops!"));
     _scrollbar = GUILayout.BeginScrollView(_scrollbar);
     var ddialogs = new List<Dialog>();
     ddialogs = GetAllDialogsInChain(ddialogs, _activeDialog);
     for (var i = 0; i < ddialogs.Count; i++)
     {
         if (ddialogs[i].Options.Contains(dOption))
         {
             continue;
         }
         var dTitle = GetFormattedTitleString(ddialogs[i].Title.Description, ddialogs[i].Title.GetString);
         if (GUILayout.Button(dTitle, _buttonStyle))
         {
             dOption.NextDialog = ddialogs[i];
             dOption.IsRedirection = true;
             CloseSubInspector();
             break;
         }
     }
     GUILayout.EndScrollView();
     dOption.IgnoreRequirements = GUILayout.Toggle(dOption.IgnoreRequirements, "Ignore Requirements");
     GUILayout.Label("Actions", _headerStyle);
     GUILayout.BeginHorizontal();
     var prevEnabled = GUI.enabled;
     if (dOption.Actions.Count >= 6)
     {
         GUI.enabled = false;
     }
     var index = EditorGUILayout.Popup(0, _usableActionNames.ToArray());
     if (index > 0)
     {
         var tr = CreateInstance(_usableActionTypes[index]) as DialogOptionAction;
         AddToAsset(tr);
         dOption.Actions.Add(tr);
     }
     GUI.enabled = prevEnabled;
     if (GUILayout.Button("Remove all", _buttonStyle))
     {
         for (var i = dOption.Actions.Count; i-- > 0;)
         {
             DestroyImmediate(dOption.Actions[i], true);
             dOption.Actions.RemoveAt(i);
         }
     }
     GUILayout.EndHorizontal();
     _scrollbar2 = GUILayout.BeginScrollView(_scrollbar2);
     for (var i = dOption.Actions.Count; i-- > 0;)
     {
         if (dOption.Actions[i] == null)
         {
             dOption.Actions.RemoveAt(i);
             continue;
         }
         if (!InlineDisplayOptionActionEditor(dOption.Actions[i]))
         {
             DestroyImmediate(dOption.Actions[i], true);
             dOption.Actions.RemoveAt(i);
         }
     }
     GUILayout.EndScrollView();
     if (GUILayout.Button("Close", _buttonStyle))
     {
         CloseSubInspector();
     }
     GUILayout.EndArea();
 }
示例#5
0
 int DisplayDialogOption(Rect r, DialogOption option)
 {
     var prev = GUI.color;
     GUI.color = _nodeColor;
     var gs = new GUIStyle(GUI.skin.button)
     {
         alignment = TextAnchor.MiddleLeft,
         fontSize = 8,
         border = new RectOffset(2, 2, 2, 2)
     };
     var rect = new Rect(r.x - r.width + IndentWidth + 1, r.y + r.height*0.6f, r.width, r.height*0.4f);
     if (rect.y + rect.height > _countedHeight)
     {
         _countedHeight = rect.y + rect.height;
     }
     if (rect.x + rect.width > _countedWidth)
     {
         _countedWidth = rect.x + rect.width;
     }
     var ret = 0;
     var tTitle = GetFormattedTitleString(option.Text.Description, option.Text.GetString, 55);
     if (GUI.Button(rect, tTitle, gs))
     {
         InspectOptionNode(option);
     }
     gs.alignment = TextAnchor.MiddleCenter;
     if (GUI.Button(new Rect(rect.x - 18, rect.y - 5, 17, 17), "˄", gs))
     {
         ret = -1;
     }
     if (GUI.Button(new Rect(rect.x - 34, rect.y - 5, 17, 17), "˅", gs))
     {
         ret = 1;
     }
     if (GUI.Button(new Rect(rect.x - 50, rect.y - 5, 17, 17), "x", gs))
     {
         ret = -10;
     }
     DrawInlineDialogOptionActions(new Rect(rect.x + IndentWidth, rect.y + rect.height, rect.width, rect.height + 10), option);
     if (option.NextDialog != null)
     {
         var prevEnabled = GUI.enabled;
         GUI.enabled = !option.IgnoreRequirements & prevEnabled;
         DrawInlineDialogRequirements(new Rect(rect.x + IndentWidth, rect.y - (rect.height + 2), rect.width, rect.height + 10), option);
         GUI.enabled = prevEnabled;
         if (GUI.Button(new Rect(rect.x + rect.width - 17, r.y + 5, 17, 13), "x", gs))
         {
             if (!option.IsRedirection)
             {
                 DeleteCleanupDialog(option.NextDialog);
             }
             option.NextDialog = null;
             option.IsRedirection = false;
         }
     }
     GUI.color = prev;
     return ret;
 }
示例#6
0
 void DisplayDialogLoop(Rect r, DialogOption dOption)
 {
     var prev = GUI.color;
     GUI.color = Color.yellow;
     var ndTitle = GetFormattedTitleString(dOption.NextDialog.Title.Description, dOption.NextDialog.Title.GetString);
     ndTitle = string.Format("({0}) {1}", dOption.NextDialog.ID, ndTitle);
     if (GUI.Button(new Rect(r.x, r.y + 5, r.width, r.height - 5), "Loop: " + ndTitle))
     {
         InspectOptionNode(dOption);
     }
     GUI.color = prev;
     if (r.x + r.width > _countedWidth)
     {
         _countedWidth = r.x + r.width;
     }
     if (r.y + r.height > _countedHeight)
     {
         _countedHeight = r.y + r.height;
     }
 }
示例#7
0
 void CloseSubInspector()
 {
     _activeSubDialog = null;
     _activeOptionNode = null;
     _activeStringEditor = null;
 }