/// <summary> /// Displays the <see cref="_expressionHistory"/> at the given width with the given style /// </summary> private void DisplayHistory() { // Draw the foldout and the clear history button. GUILayout.BeginHorizontal(); { showHistory = RexUIUtils.Toggle(showHistory, _texts["history_header"]); if (showHistory) { if (_expressionHistory.Count > 0 && GUILayout.Button(_texts["history_clear"], GUILayout.Width(50))) { _expressionHistory.Clear(); } } } GUILayout.EndHorizontal(); if (!showHistory) { return; } EditorGUILayout.BeginVertical(slimBox); { scroll = EditorGUILayout.BeginScrollView(scroll); var deleteIndex = -1; for (int i = 0; i < _expressionHistory.Count; i++) { var expr = _expressionHistory[i]; var content = _texts.GetText("history_item_" + (expr.IsExpanded ? "hide" : "show"), expr.Code); var isExpaned = GUILayout.Toggle(expr.IsExpanded, content, EditorStyles.foldout); if (isExpaned != expr.IsExpanded) { _expressionHistory.ForEach(e => e.IsExpanded = false); expr.IsExpanded = isExpaned; } if (expr.IsExpanded) { // Draw dropdown var IsDeleted = false; DisplayHistorySelectionToggle(expr.Code, out IsDeleted); if (IsDeleted) { deleteIndex = i; } } GUILayout.Box("", GUILayout.Height(1f), GUILayout.ExpandWidth(true)); } EditorGUILayout.EndScrollView(); if (deleteIndex >= 0) { _expressionHistory.RemoveAt(deleteIndex); } } EditorGUILayout.EndVertical(); }
/// <summary> /// Display the <see cref="Macros"/> window at the given width using the given style. /// </summary> private void DisplayMacros() { showMacros = RexUIUtils.Toggle(showMacros, _texts["macros_header"]); if (showMacros) { // box begins EditorGUILayout.BeginVertical(slimBox); { // scroll begins scroll4 = EditorGUILayout.BeginScrollView(scroll4); { string deleted = null; foreach (var macro in _macros) { EditorGUILayout.BeginHorizontal(); { // Draw the RUN button if (GUILayout.Button(_texts.GetText("macro_go", tooltipFormat: macro), GUILayout.Width(30))) { // parse, compile & execute Execute(macro); } // Remove the macro if the X button is pressed if (GUILayout.Button(_texts["macro_remove"], GUILayout.Width(20))) { deleted = macro; } // if the label is pressed... then run this code..? // TODO: Highlight this... if (GUILayout.Button(_texts.GetText("select_macro", macro, macro), GUI.skin.label)) { RexISM.Code = macro; RexISM.DisplayHelp = false; } } EditorGUILayout.EndHorizontal(); } if (deleted != null) { _macros = RexMacroHandler.Remove(deleted); } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); } }
/// <summary> /// Displays the <see cref="RexHelper.Variables"/> /// </summary> private void DisplayVariables() { showVariables = RexUIUtils.Toggle(showVariables, _texts["variables_header"]); if (showVariables) { // Outer box begins EditorGUILayout.BeginVertical(slimBox); { // Scroll begins scroll2 = EditorGUILayout.BeginScrollView(scroll2); { string deleted = null; foreach (var var in RexHelper.Variables) { EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); { var shouldDelete = DisplayVariable(var.Key, var.Value); if (shouldDelete) { deleted = var.Key; } } EditorGUILayout.EndHorizontal(); } if (deleted != null) { RexHelper.Variables.Remove(deleted); } } EditorGUILayout.EndScrollView(); // Scroll ends } EditorGUILayout.EndVertical(); // outer box ends } }
/// <summary> /// Displays the selection screen for Namespaces. /// </summary> private void DisplayScope() { showUsings = RexUIUtils.Toggle(showUsings, _texts["scope_header"]); if (showUsings) { EditorGUILayout.BeginVertical(slimBox); { var useWidth = 25; EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); EditorGUILayout.LabelField(_texts["scope_use"], GUILayout.Width(useWidth)); EditorGUILayout.LabelField(_texts["scope_namespace"], GUILayout.ExpandWidth(false)); EditorGUILayout.EndHorizontal(); usingScroll = EditorGUILayout.BeginScrollView(usingScroll, GUILayout.Height(1), GUILayout.MaxHeight(150)); { var depth = 0; foreach (var n in RexCompileEngine.Instance.NamespaceInfos) { if (n.Depth > depth) { continue; } if (n.Depth < depth) { depth = n.Depth; } EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); { for (int i = 0; i < n.Depth; i++) { GUILayout.Space(25f); } var prev = n.Selected; n.Selected = GUILayout.Toggle(n.Selected, "", GUILayout.Width(useWidth)); if (prev != n.Selected) { if (prev) { RexUsingsHandler.Remove(n.Name); } else { RexUsingsHandler.Save(n.Name); } } if (n.HasSubNamespaces) { EditorGUILayout.LabelField(n.Name); } else if (n.DisplaySubNamespaces = EditorGUILayout.Foldout(n.DisplaySubNamespaces, n.Name)) { depth = n.Depth + 1; } //EditorGUILayout.LabelField(n.Assembly.Location); } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); } }