private static void DisplayCommandDetails(ParametricCommandExecution execution) { GUILayout.BeginVertical(MonkeyStyle.Instance.ParametricMethodMethodGroup, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); CommandDisplay.DisplayCommandTitle(false, execution.Info, null); CommandDisplay.DisplayCommandHelp(execution.Info, false, true); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); }
private void ActivateParametricMode(ParametricCommandExecution exec) { CurrentExecution = exec; IsParametricMethodCompletion = true; JustOpenedActiveMode = true; ResetSearchTerms(); ScrollIndex = Vector2.zero; DisplayNoResult = CurrentExecution.CurrentAutoComplete == null; mousePressed = false; exec.NotifyNextVariable(this); Repaint(); }
internal static void DisplayCommandInfo(ParametricCommandExecution execution) { GUILayout.BeginHorizontal(MonkeyStyle.Instance.TopSearchParametricPanelStyle); GUILayout.BeginVertical(MonkeyStyle.Instance.MonkeyLogoParametricGroupStyle); GUILayout.Label("", MonkeyStyle.Instance.MonkeyLogoStyleHappy); GUILayout.EndVertical(); GUILayout.BeginVertical(); DisplayLogoTop(); DisplayCommandDetails(execution); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideSecondLineStyle); GUILayout.Label("", MonkeyStyle.Instance.HorizontalSideLineStyle); }
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)); } }
private void HandleSimpleCommand() { if (CommandResult == null) { return; } if (CommandResult.Count() > SelectedIndex && SelectedIndex >= 0) { if (CommandResult.ElementAt(SelectedIndex) == null) { return; } if (CommandResult.ElementAt(SelectedIndex).IsParametric) { ParametricCommandExecution exec = new ParametricCommandExecution(CommandResult.ElementAt(SelectedIndex), this); if (ForceValidationKeyPressed && CommandResult.ElementAt(SelectedIndex).CanUseQuickDefaultCall) { exec.ExecuteCommand(this); CloseOrSetInactive(); } else if (CommandResult.ElementAt(SelectedIndex).IsValid) { ActivateParametricMode(exec); } } else { if (ExecuteCommand(new[] { CommandResult.ElementAt(SelectedIndex) })) { if (!Event.current.control) { CloseOrSetInactive(); } } } } }
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(); }
public static void ExecuteCommand(string commandName, bool emitWarning = true) { CommandInfo comInfo = CommandManager.Instance.GetCommandInfo(commandName); if (emitWarning && comInfo == null) { Debug.LogWarningFormat("Monkey Warning: {0} " + "is not a valid command name: the command " + "couldn't be executed", commandName); return; } if (!comInfo.IsParametric) { comInfo.ExecuteCommand(); return; } if (!CurrentPanel) { ShowNewPanel(); } else { if (!CurrentPanel.isActiveMode) { ActivatePanel(); } else { CurrentPanel.Focus(); } } ParametricCommandExecution exec = new ParametricCommandExecution(comInfo, CurrentPanel); CurrentPanel.ActivateParametricMode(exec); }
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(); }
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(); }
private void HandleInput() { CurrentPanel.PreventSearchMovement = false; // HandleMouse(); if (MonkeyEditorUtils.IsKeyDown(KeyCode.Escape)) { if (IsParametricMethodCompletion) { IsParametricMethodCompletion = false; CurrentExecution = null; ResetSearchTerms(); JustOpenedActiveMode = true; DisplayNoResult = false; ScrollIndex = Vector2.zero; CheckSearch(); Repaint(); } else { CloseOrSetInactive(); } } else if (MonkeyEditorUtils.IsKeyDown(KeyCode.DownArrow)) { PreventSearchMovement = true; SelectedIndex++; if (!IsParametricMethodCompletion) { SelectedIndex = Mathf.Min(SelectedIndex, CommandResult?.Count() - 1 ?? 0); } else { SelectedIndex = Mathf.Min(SelectedIndex, CurrentExecution.CurrentAutoComplete?.Count - 1 ?? 0); CurrentExecution.NotifyInputFromAutoComplete(SelectedIndex); } if (SelectedIndex > ScrollIndexThreshold) { ScrollIndex.y += RowHeight.height * 60; } } else if (MonkeyEditorUtils.IsKeyDown(KeyCode.UpArrow)) { PreventSearchMovement = true; SelectedIndex--; if (IsParametricMethodCompletion) { SelectedIndex = Mathf.Max(-1, SelectedIndex); CurrentExecution.NotifyInputFromAutoComplete(SelectedIndex); } else { SelectedIndex = Mathf.Max(0, SelectedIndex); } ScrollIndex.y -= RowHeight.height * 60; } else if (MonkeyEditorUtils.IsKeyDown(KeyCode.Backspace) && SearchTerms.IsNullOrEmpty()) { } validationKeyPressed = MonkeyEditorUtils.IsKeyDown(KeyCode.Return) || MonkeyEditorUtils.IsKeyDown(KeyCode.Tab) || MonkeyEditorUtils.IsKeyDown(KeyCode.KeypadEnter); bool previousForce = ForceValidationKeyPressed; ForceValidationKeyPressed = Event.current.command || Event.current.control; if (previousForce != ForceValidationKeyPressed) { Repaint(); } isShiftPressed = Event.current.shift; }