internal static void DisplayLoadingNotice(EditorWindow window) { lock (CommandManager.Instance) { GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true), GUILayout.Height(20)); if (CommandManager.Instance.TotalAssemblies == 0) { GUILayout.Label( MonkeyStyle .StylizeWithLoadingLabelStyle(MonKeyLocManager.CurrentLoc.PreLoadingNotice), MonkeyStyle.Instance.SearchLabelStyle); } else { StringBuilder noticeBuilder = new StringBuilder(); noticeBuilder.Append(MonKeyLocManager.CurrentLoc.LoadingLabel); noticeBuilder.Append(MonKeyLocManager.CurrentLoc.EndLoadingLabel); noticeBuilder.Append(CommandManager.Instance.AssemblyAnalyzed); noticeBuilder.Append("/"); noticeBuilder.Append(CommandManager.Instance.TotalAssemblies); noticeBuilder.Append(" | Checking Class:"); noticeBuilder.Append(CommandManager.Instance.CurrentClassLoading); GUILayout.Label( MonkeyStyle.StylizeWithLoadingLabelStyle(noticeBuilder.ToString()), MonkeyStyle.Instance.SearchLabelStyle); } GUILayout.EndHorizontal(); window.Repaint(); } }
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(); }
public override CommandParameterAutoComplete <Color> AddValue(string alias, Color value) { base.AddValue(alias, value); if (!colorTextures.ContainsKey(alias)) { colorTextures.Add(alias, MonkeyStyle.ColorTexture(1, 1, value)); } return(this); }
public void PostInstanceCreation() { MonKeyInternalSettings.FindInstance(); MonkeyStyle.FindInstance(); MonkeyLocalizationFile.FindInstance(); Instance.OnEnable(); /*f (CommandConsoleWindow.CurrentPanel) * CommandConsoleWindow.CurrentPanel.CloseOrSetInactive();*/ }
private void ParamStartIndex() { if (DisplayedInWindow) { GUILayout.BeginHorizontal(); return; } if (!MonkeyStyle.Instance) { MonkeyStyle.FindInstance(); GUILayout.BeginHorizontal(); return; } GUILayout.BeginHorizontal(lineNumber % 2 == 0 ? MonkeyStyle.Instance.ParameterLayoutForcedHighlightStyle : MonkeyStyle.Instance.ParameterLayoutNoHighlightStyle); lineNumber++; }
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(); }
private static void InitGraphics(GettingStartedPanel panel) { MonkeyStyle.Instance.PostInstanceCreation(); panel.monKeyBanner = MonkeyStyle.Instance.GetTextureFromName("MonKeyBanner"); panel.monKeyBannerStyle = new GUIStyle() { fixedWidth = 601, fixedHeight = 260, normal = { background = panel.monKeyBanner } }; panel.welcomeTitleStyle = new GUIStyle() { fontSize = 28, stretchWidth = true, alignment = TextAnchor.MiddleCenter, padding = new RectOffset(10, 10, 10, 5), normal = { background = MonkeyStyle.Instance.WindowBackgroundTex } }; panel.rateUsSectionStyle = new GUIStyle(panel.welcomeTitleStyle) { padding = new RectOffset(15, 10, 10, 5), normal = { background = MonkeyStyle.Instance.TopPanelGradientTexture } }; panel.sectionTitleStyle = new GUIStyle() { fontSize = 20, stretchWidth = true, alignment = TextAnchor.MiddleLeft, padding = new RectOffset(5, 5, 5, 0), margin = new RectOffset(30, 0, 0, 0) }; panel.welcomeTextStyle = new GUIStyle(MonkeyStyle.Instance.CommandNameStyle) { fontSize = 12, stretchWidth = true, alignment = TextAnchor.MiddleCenter, padding = new RectOffset(5, 5, 5, 5), // normal = { background = MonkeyStyle.Instance.SelectedResultFieldTex } }; panel.sectionSubtitleStyle = new GUIStyle(panel.welcomeTextStyle) { alignment = TextAnchor.MiddleLeft, margin = new RectOffset(30, 0, 0, 0) }; panel.sectionBackgroundStyle = new GUIStyle() { normal = { background = MonkeyStyle.ColorTexture(1, 1, ColorExt.HTMLColor("3a3a3a")) } }; panel.titleColor = ColorExt.HTMLColor("cbcbcb"); panel.sectionSubtitleColor = ColorExt.HTMLColor("ae8d4d"); panel.buttonStyle = new GUIStyle() { fixedHeight = 50, fixedWidth = 250, fontSize = 12, alignment = TextAnchor.MiddleCenter, normal = { background = MonkeyStyle.ColorTexture(1, 1, ColorExt.HTMLColor("4d4d4d")) }, hover = { background = MonkeyStyle.ColorTexture(1, 1, ColorExt.HTMLColor("4d4d4d").DarkerBrighter(-.1f)) }, }; panel.newVersionButtonStyle = new GUIStyle() { fixedHeight = 30, stretchWidth = true, fontSize = 12, alignment = TextAnchor.MiddleCenter, normal = { background = MonkeyStyle.ColorTexture(1, 1, ColorExt.HTMLColor("4d4d4d")) }, hover = { background = MonkeyStyle.ColorTexture(1, 1, ColorExt.HTMLColor("4d4d4d").DarkerBrighter(-.05f)) }, }; panel.rateUsButtonBoxStyle = new GUIStyle() { margin = new RectOffset(1, 1, 1, 1), stretchWidth = true, }; panel.newVersionButtonBoxStyle = new GUIStyle() { margin = new RectOffset(1, 1, 1, 1), padding = new RectOffset(5, 5, 0, 0), stretchWidth = true, }; panel.buttonTop = new GUIStyle() { fixedHeight = 2, stretchWidth = true, normal = { background = MonkeyStyle.ColorTexture(1, 1, ColorExt.HTMLColor("616161")) }, hover = { background = MonkeyStyle.ColorTexture(1, 1, ColorExt.HTMLColor("616161").DarkerBrighter(-.1f)) } }; panel.buttonBottom = new GUIStyle() { fixedHeight = 2, stretchWidth = true, normal = { background = MonkeyStyle.ColorTexture(1, 1, ColorExt.HTMLColor("2d2d2d")) }, hover = { background = MonkeyStyle.ColorTexture(1, 1, ColorExt.HTMLColor("2d2d2d").DarkerBrighter(-.1f)) } }; panel.buttonHighlightStyle = new GUIStyle() { margin = new RectOffset(10, 10, 10, 10), normal = { background = MonkeyStyle.ColorTexture(1, 1, ColorExt.HTMLColor("8FC225")) } }; }
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(); } }
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; } }
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); }
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(); }