private static void DisplayHelp(ref Rect intelliRect, List <CodeCompletion> help, bool IsSelectable, ref Vector2 scroll) { const float lineHeight = 18.5f; intelliRect.height = Mathf.Min(lineHeight * help.Count, 150); scroll = GUI.BeginScrollView(intelliRect, scroll, new Rect(0, 0, 250, lineHeight * help.Count)); GUI.Box(new Rect(0, -15, intelliRect.width, help.Count * lineHeight + 15), "", GUI.skin.window); GUI.skin.label.richText = true; for (int i = 0; i < help.Count; i++) { var codeCompletion = help[i]; if (codeCompletion.SyntaxHighlightedDetails == null) { codeCompletion.SyntaxHighlightedDetails = RexUIUtils.SyntaxHighlingting(codeCompletion.Details, codeCompletion.Search); } var rect = new Rect(1, i * lineHeight, intelliRect.width, lineHeight); if (IsSelectable && i == RexISM.SelectedHelp) { GUI.Label(rect, string.Format("<b>{0}</b>", codeCompletion.SyntaxHighlightedDetails), GUI.skin.label); GUI.ScrollTo(rect); } else { GUI.Label(rect, codeCompletion.SyntaxHighlightedDetails, GUI.skin.label); } } GUI.skin.label.richText = false; GUI.EndScrollView(); }
/// <summary> /// Loads in the Details and converts them to Action and GUI contents. /// </summary> /// <param name="value">Ouput Value of the Expression</param> /// <param name="message">Message from the Expression execute</param> /// <param name="memberDetails"></param> private void LoadInDetails(object value, IEnumerable <MemberDetails> memberDetails) { DisplayMessage = DisplayFieldFor(value, Text); FilteredDetails = Details = (from detail in memberDetails let tooltip = RexUIUtils.SyntaxHighlingting(detail.TakeWhile(i => i.Type != SyntaxType.EqualsOp)) let content = new GUIContent(detail.Name.String, tooltip) let displayAction = DisplayFieldFor(detail.Value, detail.Constant.String) select new { displayAction, content }).ToDictionary(i => i.displayAction, i => i.content); }
/// <summary> /// Displays a single variable, returns true if the varible was deleted else false. /// </summary> /// <param name="VarName">Name of the var. (key of the <see cref="RexHelper.Variables"/>)</param> /// <param name="var">The varible to display. (Value of the <see cref="RexHelper.Variables"/>)</param> private bool DisplayVariable(string VarName, RexHelper.Variable var) { string highlightedString; var type = RexUtils.GetCSharpRepresentation(var.VarType); // Format the code for syntax highlighting using richtext. highlightedString = RexUIUtils.SyntaxHighlingting(type.Concat(new[] { Syntax.Space, Syntax.Name(VarName), Syntax.Space, Syntax.EqualsOp, Syntax.Space }).Concat(RexReflectionUtils.GetSyntaxForValue(var.VarValue))); var shouldDelete = GUILayout.Button(_texts.GetText("remove_variable", tooltipFormat: VarName), GUILayout.Width(20)); // Draw the button as a label. if (GUILayout.Button(_texts.GetText("inspect_variable", highlightedString, VarName), varLabelStyle, GUILayout.ExpandWidth(true))) { var ouput = new OutputEntry(); ouput.LoadObject(var.VarValue); RexHelper.AddOutput(ouput); } return(shouldDelete); }