Exemple #1
0
        internal static void DisplayParameterPanel(CommandConsoleWindow window)
        {
            const string controlName = "searchParameter";

            GUILayout.BeginVertical(MonkeyStyle.Instance.VariablePanelStyle,
                                    GUILayout.ExpandWidth(true));
            GUILayout.Label("", MonkeyStyle.Instance.ParametricTabOutline1HorizontalStyle);
            GUILayout.Label("", MonkeyStyle.Instance.ParametricTabOutline2HorizontalStyle);

            GUILayout.BeginHorizontal(new GUIStyle {
                margin = new RectOffset(10, 10, 20, 10)
            });

            DisplayHelpPanel(window);

            DisplayAutoCompleteSection(window, controlName);

            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            GUILayout.EndVertical();

            window.Repaint();

            if (window.TabFrames > 0 && window.TabFrames < 5)
            {
                CommandConsoleWindow.ForceEditSearchAtEnd(window.SearchTerms);
                GUI.FocusControl(controlName);
            }
        }
Exemple #2
0
        public static void DisplayCommandSearchHelp(CommandConsoleWindow window)
        {
            EditorGUILayout.BeginHorizontal(MonkeyStyle.Instance.HelpStyle);
            GUILayout.FlexibleSpace();
            if (!window.Focused)
            {
                GUILayout.BeginHorizontal(MonkeyStyle.Instance.NonParamIconTipStyle);
                GUILayout.Label("");
                GUILayout.EndHorizontal();

                GUILayout.Label(MonKeyLocManager.CurrentLoc.NotFocusedHelpLabel,
                                MonkeyStyle.Instance.HelpTextStyle);
            }
            else
            {
                if (window.SelectedIndex >= 0 &&
                    window.CommandResult.ElementAt(window.SelectedIndex).IsParametric)
                {
                    DisplayParametricCommandTip(window);
                }
                else
                {
                    GUILayout.BeginHorizontal(MonkeyStyle.Instance.NonParamIconTipStyle);
                    GUILayout.Label("");
                    GUILayout.EndHorizontal();

                    GUILayout.Label(MonkeyStyle.StylizedGeneralHelp,
                                    MonkeyStyle.Instance.HelpTextStyle);
                }
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
Exemple #3
0
        private static void DisplayCommandSearchField(CommandConsoleWindow window)
        {
            EditorGUILayout.BeginVertical(MonkeyStyle.Instance.SearchLabelGroupStyle);

            EditorGUILayout.BeginHorizontal(MonkeyStyle.Instance.NameLogoStyleGroup);
            GUILayout.FlexibleSpace();
            GUILayout.Label("", MonkeyStyle.Instance.NameLogoStyle);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginVertical(MonkeyStyle.Instance.SearchLabelStyle);

            GUILayout.BeginHorizontal(MonkeyStyle.Instance.SearchLabelStyle);
            GUILayout.BeginHorizontal(MonkeyStyle.Instance.SearchIconBackgroundStyle);
            EditorGUILayout.LabelField("", MonkeyStyle.Instance.SearchIconStyle);
            GUILayout.EndHorizontal();

            DisplayTextInputField(window);

            if (window.SearchTerms.IsNullOrEmpty())
            {
                GUILayout.Label(MonKeyLocManager.CurrentLoc.CommandSearchLabel,
                                MonkeyStyle.Instance.SearchLabelHelpStyle);
            }

            GUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
        }
Exemple #4
0
        private static void DisplayCommands(CommandConsoleWindow window, bool ignoreMaxCommands = false)
        {
            int index = 0;

            if (window.MouseActivity)
            {
                window.MouseOverField = false;
            }

            if (window.CommandResult == null)
            {
                return;
            }

            foreach (var x in window.CommandResult)
            {
                if (index >= CommandManager.MaxCommandShown && !ignoreMaxCommands)
                {
                    break;
                }

                CommandDisplay.DisplayCommandInSearch(x, index, window.SelectedIndex,
                                                      window.MouseActivity, window.ForceValidationKeyPressed, window.SearchTerms);

                if (window.MouseActivity &&
                    GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
                {
                    window.SelectedIndex  = index;
                    window.MouseOverField = true;
                    window.Repaint();
                }

                index++;
            }
        }
Exemple #5
0
        private static void DisplayCategory(string catID, string catName, CommandConsoleWindow window,
                                            bool back = false, string backName = "")
        {
            int height = MonkeyStyle.Instance.CommandGroupNoHelpHeight;

            bool selected = InitResultSelectionStyle(catID == window.HoveredCategory ||
                                                     (back && backName == window.HoveredCategory),
                                                     height);

            EditorGUILayout.BeginVertical(MonkeyStyle.Instance.CommandResultInsideLayoutStyle,
                                          GUILayout.ExpandHeight(true));

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(MonkeyStyle.Instance.CommandResultGroupStyle);

            EditorGUILayout.BeginVertical(MonkeyStyle.Instance.ParamIconGroupStyle,
                                          GUILayout.Height(height), GUILayout.ExpandHeight(true));
            GUILayout.FlexibleSpace();
            GUILayout.Label("", MonkeyStyle.Instance.CategoryIconStyle);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));

            GUILayout.FlexibleSpace();

            GUILayout.Label(catName.Bold().Colored(Color.white),
                            MonkeyStyle.Instance.CommandNameStyle);

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(MonkeyStyle.Instance.CommandHotKeyStyle,
                                          GUILayout.ExpandHeight(true));

            EditorGUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSearchResultLine1Style);
            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSearchResultLine2Style);
            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSearchResultLine3Style);

            EditorGUILayout.EndVertical();

            if (selected)
            {
                CommandConsoleWindow.RowHeight = GUILayoutUtility.GetLastRect();
            }

            if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
            {
                window.BackCategory    = back;
                window.HoveredCategory = !back ? catID : backName;
            }
        }
Exemple #6
0
 private static void DisplayCommandSearchPanel(CommandConsoleWindow window)
 {
     EditorGUILayout.BeginHorizontal(MonkeyStyle.Instance.TopSearchPanelStyle);
     EditorGUILayout.BeginHorizontal(MonkeyStyle.Instance.MonkeyLogoGroupStyle);
     EditorGUILayout.LabelField("", window.MonkeyFocusLogoStyle);
     EditorGUILayout.EndHorizontal();
     DisplayCommandSearchField(window);
     EditorGUILayout.EndHorizontal();
 }
Exemple #7
0
 private static void DisplayBottomHelp(CommandConsoleWindow window)
 {
     GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideLineStyle);
     GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideSecondLineStyle);
     EditorGUILayout.BeginHorizontal(MonkeyStyle.Instance.HelpStyle);
     GUILayout.FlexibleSpace();
     CommandSearchPanelDisplay.DisplayParametricCommandTip(window);
     GUILayout.FlexibleSpace();
     EditorGUILayout.EndHorizontal();
 }
Exemple #8
0
 private static void DisplayCommandResultPanel(CommandConsoleWindow window)
 {
     if (window.DisplayNoResult)
     {
         DisplayNoCommandsFound();
     }
     else
     {
         DisplayAllFoundCommands(window);
     }
 }
Exemple #9
0
        internal static void DisplayParametricCommandTip(CommandConsoleWindow window)
        {
            GUILayout.BeginHorizontal(MonkeyStyle.Instance.ParamIconTipStyle);
            GUILayout.Label("");
            GUILayout.EndHorizontal();

            GUILayout.Label(
                window.Focused
                    ? MonKeyLocManager.CurrentLoc.ParametricHelp
                    : MonKeyLocManager.CurrentLoc.NotFocusedHelpLabel,
                MonkeyStyle.Instance.HelpTextStyle);
        }
Exemple #10
0
        private static void DisplayTextInputField(CommandConsoleWindow window)
        {
            GUI.skin.settings.cursorFlashSpeed = 1;

            const string controlName = "searchCommand";

            GUI.SetNextControlName(controlName);
            bool wasEmpty = window.SearchTerms.IsNullOrEmpty();

            window.SearchTerms = EditorGUIExt.TextField((window.SearchTerms ?? "").Replace("`", ""),
                                                        controlName,
                                                        (window.SearchTerms.IsNullOrEmpty())
                    ? MonkeyStyle.Instance.SearchLabelStyleEmpty
                    : MonkeyStyle.Instance.SearchLabelStyle);

            if (wasEmpty && !window.SearchTerms.IsNullOrEmpty())
            {
                window.CommandResult = new List <CommandInfo>();
            }

            if (window.PreventSearchMovement)
            {
                CommandConsoleWindow.ForceEditSearchAtEnd(window.SearchTerms);
            }

            if (window.Focused)
            {
                if (!window.SearchTerms.IsNullOrEmpty() && !window.CommandResult.Any())
                {
                    window.MonkeyFocusLogoStyle = MonkeyStyle.Instance.MonkeyLogoStyle;
                }
                else
                {
                    window.MonkeyFocusLogoStyle = window.SearchTerms.IsNullOrEmpty()
                        ? MonkeyStyle.Instance.MonkeyLogoStyleSmiling
                        : MonkeyStyle.Instance.MonkeyLogoStyleHappy;
                }

                window.Repaint();
            }

            if (!window.IsDocked || window.JustOpenedActiveMode || window.Focused)
            {
                GUI.FocusControl(controlName);
            }
        }
Exemple #11
0
        internal static void DisplayParametricPanel(CommandConsoleWindow window)
        {
            try
            {
                if (Event.current.type == EventType.MouseDown)
                {
                    window.Repaint();
                    window.Focus();
                    window.TabFrames = 10;
                }

                CommandConsoleWindow.RowHeight = new Rect(0, 0, 0, 0.55f);

                DisplayCommandInfo(window.CurrentExecution);

                Rect selectedRect = new Rect();
                if (window.CurrentExecution.Info.CommandParameterInfo.Count > 1)
                {
                    selectedRect = DisplayParameterTabs(window);
                }

                window.CheckSearch();

                if (window.CurrentExecution.CurrentParameterInfo != null)
                {
                    DisplayParameterPanel(window);
                }

                if (window.CurrentExecution.Info.CommandParameterInfo.Count > 1)
                {
                    DisplayTabLink(selectedRect);
                }

                DisplayBottomHelp(window);
            }
            catch (Exception e)
            {
                if (CommandConsoleWindow.LogExceptions)
                {
                    Debug.Log(e);
                }
                GUIUtility.ExitGUI();
            }
        }
Exemple #12
0
        internal static void DisplayCommandPanel(CommandConsoleWindow window)
        {
            try
            {
                if (Event.current.type == EventType.MouseDown)
                {
                    window.Repaint();
                    window.Focus();
                    return;
                }

                DisplayCommandSearchPanel(window);

                if (CommandManager.Instance.IsLoading)
                {
                    LoadingNoticeDisplay.DisplayLoadingNotice(window);
                }
            }
            catch (Exception e)
            {
                if (CommandConsoleWindow.LogExceptions)
                {
                    Debug.LogWarning(e);
                }
                GUIUtility.ExitGUI();
            }

            window.CheckSearch();

            try
            {
                DisplayCommandResultPanel(window);
                DisplayCommandSearchHelp(window);
            }
            catch (Exception e)
            {
                if (CommandConsoleWindow.LogExceptions)
                {
                    Debug.LogWarning(e);
                }
                GUIUtility.ExitGUI();
            }
        }
Exemple #13
0
        private static void DisplayInstructionOrDefault(CommandConsoleWindow window,
                                                        ParametricCommandExecution exec)
        {
            bool customInstruction = exec.CurrentAutoComplete != null &&
                                     !exec.CurrentAutoComplete.SearchInstruction.IsNullOrEmpty() &&
                                     exec.CurrentParameterInfo.PreventDefaultValueUsage;
            string textEntered = null;

            if (exec.CurrentAutoCompleteID == -1)
            {
                if (!customInstruction && exec.CurrentTextEntered.IsNullOrEmpty())
                {
                    if (exec.CurrentParameterInfo.PreventDefaultValueUsage ||
                        exec.CurrentParameterInfo.DefaultValueName.IsNullOrEmpty())
                    {
                        textEntered = MonKeyLocManager.CurrentLoc.NoValue;
                    }
                    else
                    {
                        textEntered  = exec.CurrentParameterInfo.DefaultValueName;
                        textEntered += " ( ";
                        textEntered += MonKeyLocManager.CurrentLoc.Default;
                        textEntered += " )";
                    }
                }

                textEntered = customInstruction ? exec.CurrentAutoComplete.SearchInstruction : textEntered;
            }
            else if (exec.CurrentAutoComplete != null && exec.CurrentAutoCompleteID < exec.CurrentAutoComplete.Count)
            {
                textEntered = exec.CurrentAutoComplete.GetStringValue(exec.CurrentAutoCompleteID);
            }

            bool noValue = customInstruction &&
                           textEntered == exec.CurrentAutoComplete.SearchInstruction;

            if (!textEntered.IsNullOrEmpty())
            {
                GUILayout.Label(textEntered + " | ",
                                noValue ? MonkeyStyle.Instance.SearchLabelHelpStyle : MonkeyStyle.Instance.SearchLabelStyle,
                                GUILayout.ExpandWidth(false));
            }
        }
Exemple #14
0
        private static void DisplayHelpPanel(CommandConsoleWindow window)
        {
            ParametricCommandExecution exec = window.CurrentExecution;

            GUILayout.BeginVertical(GUILayout.MinWidth(70),
                                    GUILayout.MaxWidth(200), GUILayout.ExpandHeight(true));

            GUILayout.BeginVertical(MonkeyStyle.Instance.VariableHelpGroupStyle);

            GUILayout.Label(exec.CurrentParameterInfo.
                            Name.NicifyVariableName().Bold()
                            , MonkeyStyle.Instance.VariableTypeTextStyle);

            GUILayout.Label("", MonkeyStyle.Instance.ParametricTabUnderline1Style);
            GUILayout.Label("", MonkeyStyle.Instance.ParametricTabUnderline2Style);

            CommandParameterInfo info = exec.CurrentParameterInfo;
            string parameterTypeName  = info.HasTypeNameOverride ?
                                        info.ParameterTypeNameOverride :
                                        MonkeyStyle.PrettifyTypeName(exec.CurrentParameterInfo.ParameterType);

            GUILayout.Label(MonKeyLocManager.CurrentLoc.Type + parameterTypeName
                            , MonkeyStyle.Instance.VariableTypeTextStyle);

            GUILayout.Label("", MonkeyStyle.Instance.ParametricTabUnderline1Style);
            GUILayout.Label("", MonkeyStyle.Instance.ParametricTabUnderline2Style);

            if (!info.Help.IsNullOrEmpty())
            {
                GUILayout.Label(info.Help, MonkeyStyle.Instance.VariableHelpTextStyle);
            }

            GUILayout.EndVertical();

            DisplayArrayIds(window, exec);

            GUILayout.FlexibleSpace();

            GUILayout.EndVertical();
        }
Exemple #15
0
        internal static Rect DisplayParameterTabs(CommandConsoleWindow window)
        {
            MonkeyStyle monkeyStyle = MonkeyStyle.Instance;

            GUILayout.BeginVertical(monkeyStyle.ParametricWindowBackgroundStyle);

            int i = 0;

            GUILayout.BeginHorizontal();
            int current = window.CurrentExecution.CurrentParameterID;

            Rect selectedRect = new Rect(0, 0, 0, 0);

            foreach (var info in window.CurrentExecution.Info.CommandParameterInfo)
            {
                GUIStyle panelStyle = current == i
                    ? monkeyStyle.VariableSelectedGroupStyle
                    : monkeyStyle.VariableNonSelectedGroupStyle;

                GUILayout.BeginHorizontal(monkeyStyle.VariableGroupStyle);

                GUILayout.Label("", monkeyStyle.ParametricTabShadow2Style);
                GUILayout.Label("", monkeyStyle.ParametricTabShadow1Style);

                GUILayout.BeginVertical(panelStyle, GUILayout.ExpandHeight(true));

                if (current == i)
                {
                    GUILayout.Label("", monkeyStyle.ParametricTabOutline1HorizontalStyle);
                    GUILayout.Label("", monkeyStyle.ParametricTabOutline2HorizontalStyle);
                }
                else
                {
                    GUILayout.Label("", monkeyStyle.ParametricTabOutlineUnfocusedHorizontalStyle);
                }

                GUIStyle variableStyle;
                if (window.CurrentExecution.IsParameterError(i))
                {
                    variableStyle = monkeyStyle.VariableNameErrorTextStyle;
                }
                else
                {
                    variableStyle = current == i
                        ? monkeyStyle.VariableNameSelectedTextStyle
                        : monkeyStyle.VariableNameNonSelectedTextStyle;
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label(ObjectNames.NicifyVariableName(info.Name).Bold()
                                , variableStyle);

                if (window.CurrentExecution.IsParameterError(i))
                {
                    GUILayout.Label("", monkeyStyle.ParameterWarningIconStyle);
                }

                GUILayout.EndHorizontal();

                GUILayout.EndVertical();

                if (current == i)
                {
                    GUILayout.Label("", monkeyStyle.ParametricTabOutline2VerticalStyle);
                    GUILayout.Label("", monkeyStyle.ParametricTabOutline1VerticalStyle);
                }
                else
                {
                    GUILayout.Label("", monkeyStyle.ParametricTabOutlineUnfocusedVerticalStyle);
                }

                GUILayout.EndHorizontal();

                if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) &&
                    Event.current.type == EventType.MouseDown)
                {
                    window.CurrentExecution.JumpToID(i);
                    window.Repaint();
                }

                if (current == i)
                {
                    selectedRect = GUILayoutUtility.GetLastRect();
                }

                i++;
            }

            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            return(selectedRect);
        }
Exemple #16
0
        private static void DisplayAutoCompleteOptions(CommandConsoleWindow window)
        {
            if (!window.CurrentExecution.IsAutoCompleteSuggestions)
            {
                return;
            }

            if (window.MouseActivity)
            {
                window.MouseOverField = false;
            }

            GUI.skin = MonkeyStyle.Instance.MonkeyScrollBarStyle;

            window.ScrollIndex = EditorGUILayout.BeginScrollView(window.ScrollIndex, new GUIStyle()
            {
                normal = { background = MonkeyStyle.Instance.ResultFieldTex }
            });

            for (int i = 0; i < window.CurrentExecution.CurrentAutoComplete.Count; i++)
            {
                bool selected = InitResultSelectionStyle(i, window.SelectedIndex,
                                                         window.MouseActivity);

                GUILayout.Label("", MonkeyStyle.Instance.AutoCompleteLine1Style);

                if (!selected)
                {
                    GUILayout.Label("", MonkeyStyle.Instance.AutoCompleteLine2Style);
                }
                else
                {
                    GUILayout.Label("", MonkeyStyle.Instance.AutoCompleteLine1Style);
                }

                GUILayout.BeginVertical(new GUIStyle {
                    margin = new RectOffset(2, 2, 5, 5)
                });

                GUILayout.BeginHorizontal();

                GUILayout.BeginVertical();
                DisplayAutoCompleteField(window.CurrentExecution.CurrentAutoComplete,
                                         window.CurrentExecution.GetFormattedCurrentlyChosen(), selected, i);
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();

                GUILayout.EndVertical();

                GUILayout.EndVertical();

                if ((window.MouseActivity || Event.current.type == EventType.MouseDown) &&
                    GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
                {
                    if (Event.current.type == EventType.MouseDown)
                    {
                        window.SelectedIndex = i;
                        window.CurrentExecution.
                        NotifyInputFromAutoComplete(window.SelectedIndex);
                        window.CurrentExecution.NotifyNextVariable(window);
                    }
                    window.MouseOverField = true;
                    window.SelectedIndex  = i;
                    window.Repaint();
                }

                if (selected)
                {
                    window.Repaint();
                }
            }
            EditorGUILayout.EndScrollView();

            GUI.skin = MonkeyStyle.Instance.DefaultStyle;
        }
Exemple #17
0
        private static void DisplayArrayIds(CommandConsoleWindow window, ParametricCommandExecution exec)
        {
            GUILayout.Label("", MonkeyStyle.Instance.ParametricTabUnderline1Style);
            GUILayout.Label("", MonkeyStyle.Instance.ParametricTabUnderline2Style);

            string textEntered = "";

            if (exec.IsArray)
            {
                textEntered = MonKeyLocManager.CurrentLoc.CurrentArrayValues;
            }
            else
            {
                if (exec.IsParameterError(exec.CurrentParameterID))
                {
                    textEntered = (MonKeyLocManager.CurrentLoc.Error)
                                  .Colored(MonkeyStyle.Instance.VariableValueErrorTextColor);
                }
            }

            GUILayout.Label(textEntered, MonkeyStyle.Instance.VariableValueSelectedTextStyle);

            GUILayout.BeginHorizontal();

            if (exec.IsArray)
            {
                GUILayout.BeginHorizontal(new GUIStyle()
                {
                    margin = new RectOffset(2, 2, 2, 2),
                    normal = { background = MonkeyStyle.Instance.HelpVariableTex }
                });

                int startValue = exec.CurrentArrayIDEdited == -1 ? -1 : 0;

                int columnCount = 0;
                for (int i = startValue;
                     i < Mathf.Max(exec.CurrentArrayTextEntered.Count,
                                   exec.CurrentArrayIDEdited + 1);
                     i++)
                {
                    GUIStyle style;
                    if (i == exec.CurrentArrayIDEdited && i != -1)
                    {
                        style = MonkeyStyle.Instance.ArrayVariableSelectedGroupStyle;
                    }
                    else
                    {
                        if (i >= exec.CurrentArrayTextEntered.Count || i == -1)
                        {
                            style = MonkeyStyle.Instance.ArrayVariableNewGroupStyle;
                        }
                        else
                        {
                            style = MonkeyStyle.Instance.ArrayVariableNonSelectedGroupStyle;
                        }
                    }

                    GUILayout.BeginHorizontal(style);

                    GUILayout.Label((i >= exec.CurrentArrayTextEntered.Count || i == -1 ? " (New)" : i.ToString())
                                    , MonkeyStyle.Instance.VariableTypeTextStyle);

                    if (i >= 0 && exec.CurrentArrayTextEntered.Count > i &&
                        !exec.CurrentArrayTextEntered[i].IsNullOrEmpty() &&
                        exec.CurrentArrayValuesParsed[i] == null)
                    {
                        GUILayout.Label("", MonkeyStyle.Instance.ArrayWarningIconStyle);
                    }

                    GUILayout.EndHorizontal();

                    if (Event.current.type == EventType.MouseDown &&
                        GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
                    {
                        exec.JumpToArrayID(window, i);
                    }

                    if (i - columnCount * ArrayIdBreakout >= ArrayIdBreakout)
                    {
                        GUILayout.EndHorizontal();
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal();
                        GUILayout.BeginHorizontal(new GUIStyle()
                        {
                            margin = new RectOffset(2, 2, 2, 2),
                            normal = { background = MonkeyStyle.Instance.HelpVariableTex }
                        });
                        columnCount++;
                    }
                }

                if (exec.CurrentArrayTextEntered.Count == 0 && exec.CurrentArrayIDEdited != -1)
                {
                    GUILayout.Label("None", MonkeyStyle.Instance.VariableTypeTextStyle);
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndHorizontal();
        }
Exemple #18
0
        private static void ComputeDragAndDrop(CommandConsoleWindow window)
        {
            Type currentParameterType = window.CurrentExecution.CurrentParameterInfo.ParameterType;

            if (window.CurrentExecution.CurrentParameterInfo.IsArray)
            {
                currentParameterType = currentParameterType.GetElementType();
            }

            if (!currentParameterType.IsSubclassOf(typeof(UnityEngine.Object)) &&
                currentParameterType != typeof(string))
            {
                return;
            }

            Event evt      = Event.current;
            Rect  dropArea = GUILayoutUtility.GetLastRect();

            bool isDrag = EventType.DragUpdated == evt.type || evt.type == EventType.DragPerform;

            if (isDrag && !startedDrag)
            {
                startedDrag = true;
            }

            bool   stringParam = currentParameterType == typeof(string);
            string message     = stringParam ? "Drop Your Asset Here!"
                : "Drop Your Scene Object Here!";

            GUI.Box(dropArea, startedDrag ? message : "", new GUIStyle()
            {
                alignment = TextAnchor.MiddleCenter,
                normal    =
                {
                    background = MonkeyStyle.ColorTexture(1, 1, startedDrag?
                                                          Color.white.Alphaed(1f) : Color.white.Alphaed(0))
                }
            });

            if (isDrag)
            {
                if (!dropArea.Contains(evt.mousePosition))
                {
                    return;
                }

                bool validDragAndDrop = false;

                if (stringParam)
                {
                    validDragAndDrop = !DragAndDrop.objectReferences.Where(_ => _ is GameObject)
                                       .Any(_ => ((GameObject)_).scene.IsValid());
                }
                else
                {
                    validDragAndDrop =
                        DragAndDrop.objectReferences
                        .All(_ => _ is GameObject && ((GameObject)_).scene.IsValid());
                }

                DragAndDrop.visualMode = validDragAndDrop ? DragAndDropVisualMode.Copy
                    : DragAndDropVisualMode.Rejected;

                if (evt.type == EventType.DragPerform && validDragAndDrop)
                {
                    if (window.CurrentExecution.CurrentParameterInfo.IsArray)
                    {
                        window.CurrentExecution.NotifyFewInputs(DragAndDrop.objectReferences.Convert(_ => _.name).ToArray(), window);
                    }
                    else
                    {
                        window.SearchTerms = DragAndDrop.objectReferences[0].name;
                        window.CurrentExecution.NotifyNewInput(DragAndDrop.objectReferences[0].name, window);
                    }
                    DragAndDrop.AcceptDrag();
                }
            }
            else if (evt.type == EventType.DragExited)
            {
                startedDrag = false;
            }
        }
Exemple #19
0
        private static void DisplayAutoCompleteSection(CommandConsoleWindow window,
                                                       string controlName)
        {
            ParametricCommandExecution exec = window.CurrentExecution;

            GUILayout.BeginVertical(MonkeyStyle.Instance.SearchLabelGroupStyle);


            if (exec.IsArray && exec.CurrentTextEntered.IsNullOrEmpty() &&
                exec.CurrentAutoCompleteID == -1)
            {
                if (exec.HasNextVariable)
                {
                    GUILayout.Label("Press TAB or ENTER to go to the next variable",
                                    MonkeyStyle.Instance.VariableTypeTextStyle, GUILayout.ExpandWidth(true));
                }
                else
                {
                    GUILayout.Label("Press TAB or ENTER to go to execute the command",
                                    MonkeyStyle.Instance.VariableTypeTextStyle, GUILayout.ExpandWidth(true));
                }
            }

            GUILayout.BeginHorizontal(MonkeyStyle.Instance.SearchLabelStyle);
            GUILayout.BeginHorizontal(MonkeyStyle.Instance.AutoCompleteSearchLabelGroupStyle);

            DisplayInstructionOrDefault(window, exec);

            GUI.SetNextControlName(controlName);
            window.SearchTerms = EditorGUIExt.TextField(window.SearchTerms, controlName,
                                                        MonkeyStyle.Instance.SearchLabelStyle);

            if (!window.IsDocked || window.JustOpenedActiveMode ||
                window.PreventSearchMovement || window.Focused)
            {
                if (window.PreventSearchMovement)
                {
                    CommandConsoleWindow.ForceEditSearchAtEnd(window.SearchTerms);
                }
                window.Focus();

                GUI.FocusControl(controlName);
            }

            //    GUILayout.FlexibleSpace();

            GUILayout.EndHorizontal();

            GUILayout.EndHorizontal();

            ComputeDragAndDrop(window);

            GUILayout.BeginVertical(GUILayout.ExpandWidth(true));

            DisplayAutoCompleteOptions(window);

            GUILayout.EndVertical();

            GUILayout.FlexibleSpace();

            GUILayout.EndVertical();
        }
Exemple #20
0
        private static void DisplayAllFoundCommands(CommandConsoleWindow window)
        {
            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true));
            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideSecondLineStyle);
            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideLineStyle);

            GUILayout.BeginHorizontal();

            GUILayout.Label("", MonkeyStyle.Instance.VerticalSideLineStyle);
            GUILayout.Label("", MonkeyStyle.Instance.VerticalSideLineSecondStyle);
            GUILayout.Label("", MonkeyStyle.Instance.VerticalSideLineStyle);

            GUI.skin = MonkeyStyle.Instance.MonkeyScrollBarStyle;

            window.ScrollIndex = EditorGUILayout.BeginScrollView(window.ScrollIndex, new GUIStyle()
            {
                normal = { background = MonkeyStyle.Instance.ResultFieldTex }
            });

            if (CommandConsoleWindow.DrawDebugAssemblies)
            {
                PrintAllAssemblies();
            }

            if (window.SearchTerms.IsNullOrEmpty())
            {
                if (window.CurrentCategory.IsNullOrEmpty())
                {
                    foreach (string key in CommandManager.Instance.BaseCategories)
                    {
                        if (CommandManager.Instance.CategoriesByName[key].IsMainCategory)
                        {
                            DisplayCategory(key, CommandManager.Instance.CategoriesByName[key].CategoryName, window);
                        }
                    }
                }
                else
                {
                    //acts as a back button
                    DisplayCategory("", "Back", window, true,
                                    CommandManager.Instance.CategoriesByName[window.CurrentCategory].ParentCategoryName);

                    foreach (string key in CommandManager.Instance.CategoriesByName[window.CurrentCategory]
                             .SubCategories)
                    {
                        DisplayCategory(key, CommandManager.Instance.CategoriesByName[key].CategoryName, window);
                    }

                    DisplayCommands(window, true);
                }
            }
            else
            {
                DisplayCommands(window);
            }

            EditorGUILayout.EndScrollView();

            GUILayout.Label("", MonkeyStyle.Instance.VerticalSideLineStyle);
            GUILayout.Label("", MonkeyStyle.Instance.VerticalSideLineSecondStyle);
            GUILayout.Label("", MonkeyStyle.Instance.VerticalSideLineStyle);

            GUI.skin = MonkeyStyle.Instance.DefaultStyle;

            GUILayout.EndHorizontal();

            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideLineStyle);
            GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideSecondLineStyle);

            EditorGUILayout.EndVertical();
        }