Exemple #1
0
        public override void DrawAutoCompleteMember(int id, string searchTerms, bool selected)
        {
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            GUILayout.Label("",
                            new GUIStyle()
            {
                fixedWidth  = 20,
                fixedHeight = 20,
                normal      = { background =
                                    MonkeyStyle.GetIconForFile("fake.unity") }
            });

            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
            GUILayout.Label(GetStringValue(id).Highlight(searchTerms, true,
                                                         StringExt.ColorTag(MonkeyStyle.Instance.SearchResultTextColor),
                                                         StringExt.ColorTagClosing,
                                                         StringExt.ColorTag(MonkeyStyle.Instance.HighlightOnSelectedTextColor),
                                                         StringExt.ColorTagClosing), MonkeyStyle.Instance.CommandNameStyle,
                            GUILayout.ExpandWidth(true));
            GUILayout.EndHorizontal();

            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
Exemple #2
0
        internal static void DisplayCommandInSearch(CommandInfo x, int index,
                                                    int selectedIndex, bool mouseActivity, bool control, string searchTerms)
        {
            int height = x.CommandHelp.IsNullOrEmpty()
                ? MonkeyStyle.Instance.CommandGroupNoHelpHeight
                : MonkeyStyle.Instance.CommandGroupHeight;

            bool selected = InitResultSelectionStyle(index, selectedIndex, mouseActivity, 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();

            if (x.IsMenuItem)
            {
                GUILayout.Label("",
                                new GUIStyle()
                {
                    fixedWidth  = 18,
                    fixedHeight = 16,
                    alignment   = TextAnchor.MiddleCenter,
                    normal      = { background =
                                        MonkeyStyle.GetIconForFile("fake.unity") }
                });
            }
            else
            {
                if (x.IsParametric && (!control || !selected || !x.CanUseQuickDefaultCall))
                {
                    GUILayout.Label("", (selected) ? MonkeyStyle.Instance.ParamIconSelectedStyle :
                                    MonkeyStyle.Instance.ParamIconStyle);
                }
                else
                {
                    GUILayout.Label("", (selected) ? MonkeyStyle.Instance.NonParamIconSelectedStyle :
                                    MonkeyStyle.Instance.NonParamIconStyle);
                }
            }


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

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

            GUILayout.FlexibleSpace();

            DisplayCommandTitle(selected, x, searchTerms);

            DisplayCommandHelp(x, selected);

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndVertical();

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

            if (DisplayCommandValidationMessage(x, selected, control) || !selected)
            {
                if (Event.current.type != EventType.MouseMove)
                {
                    GUILayout.FlexibleSpace();
                    DisplayCommandHotKey(x, selected);
                    GUILayout.FlexibleSpace();
                }
            }

            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();
            }
        }
Exemple #3
0
        public override void DrawAutoCompleteMember(int id, string searchTerms, bool selected)
        {
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();

            Texture2D icon = (Texture2D)(IsDirectory((string)GetValue(id))
                ? EditorGUIUtility.IconContent("Folder Icon").image
                : MonkeyStyle.GetIconForFile((string)GetValue(id)));

            if (showAssetPreview)
            {
                Texture2D prev = PreviewTextures.ContainsKey(id) ? PreviewTextures[id] : null;
                if (prev)
                {
                    GUILayout.Label("",
                                    new GUIStyle()
                    {
                        fixedHeight = 50,
                        fixedWidth  = 50,
                        margin      = new RectOffset(5, 5, 0, 0),
                    });
                    GUI.DrawTexture(GUILayoutUtility.GetLastRect(), prev, ScaleMode.ScaleToFit);
                }
                else
                {
                    GUILayout.Label("",
                                    new GUIStyle()
                    {
                        fixedWidth  = 20,
                        fixedHeight = 20,
                        margin      = new RectOffset(0, 2, 0, 0),
                        normal      = { background = icon }
                    });
                }
            }
            else
            {
                GUILayout.Label("",
                                new GUIStyle()
                {
                    fixedWidth  = 20,
                    fixedHeight = 20,
                    margin      = new RectOffset(0, 2, 0, 0),
                    normal      = { background = icon }
                });
            }

            GUILayout.BeginHorizontal(new GUIStyle()
            {
                margin = new RectOffset(0, 2, 0, 0)
            });
            GUILayout.Label(GetStringValue(id).Highlight(searchTerms, true,
                                                         StringExt.ColorTag(MonkeyStyle.Instance.SearchResultTextColor),
                                                         StringExt.ColorTagClosing,
                                                         StringExt.ColorTag(MonkeyStyle.Instance.HighlightOnSelectedTextColor),
                                                         StringExt.ColorTagClosing), MonkeyStyle.Instance.AssetNameStyle);
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();

            string path = (string)GetValue(id);

            path = path.Replace("Assets/", "");

            int idName = path.LastIndexOf(path.GetAssetNameFromPath(), StringComparison.Ordinal);

            if (idName > 0)
            {
                path = path.Substring(0, idName - 1);
            }

            if (path.Length > MaxPathLength)
            {
                path = path.Substring(0, Mathf.Min(MaxPathLength, path.Length)) + "...";
            }
            GUILayout.Label(path, MonkeyStyle.Instance.PathStyle /*, GUILayout.MaxWidth(150)*/);

            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }