public void DrawDirectAdd(ref Vector3 cur, float lineHeight) { string[] lines = childText.Split('\n'); Rect modifyRect; float width = CalcWidth(lines, true); if (IsConvertibleFromText(childType)) { Rect directAddRect = new Rect(cur.x, cur.y, lineHeight, lineHeight); bool add = Widgets.ButtonText(directAddRect, "+"); if (add) { TryAddNewDirect(childText); } cur.x += lineHeight + 4f; modifyRect = new Rect(cur.x, cur.y, width, lineHeight * lines.Count()); if (Mouse.IsOver(modifyRect) && Event.current.type == EventType.MouseDown && Event.current.button == 0) { DefExplorerWindow.TryChangeActiveDesc(this); } string newerChildText; newerChildText = Widgets.TextArea(modifyRect, childText, readOnly: false); if (newerChildText != childText) { childText = newerChildText; } cur.x += 20f; // buffer for bigass textbox or button } else { modifyRect = new Rect(cur.x, cur.y, width, lineHeight * lines.Count()); Widgets.Dropdown <Type, string>(modifyRect, childType, GetAddDropdownPayload, GetDropdownMenu, buttonLabel: "Add"); } cur.x += width; }
static void ResolveReferences() { foreach (DetailCategory helpCategory in DefExplorerWindow.detailCategories.Values) { helpCategory.Recache(); } DefExplorerWindow.Recache(); }
/* * private MainButton_HelpMenuDef TabDef * { * get * { * return def as MainButton_HelpMenuDef; * } * } */ public DefExplorerWindow() { //layer = WindowLayer.GameUI; soundAppear = null; soundClose = null; doCloseButton = false; doCloseX = true; closeOnCancel = true; forcePause = true; instance = this; }
public void DrawDirectEditable(ref Vector3 cur, float lineHeight, ref float width, ref float height, ref string valText, string originalText, Type objectType) { // Editable ------------------------------------------------------------- string[] lines = newValText.Split('\n'); bool changed = false; Rect modifyRect; if (IsConvertibleFromText(objectType)) { modifyRect = new Rect(cur.x, cur.y, width, lineHeight * lines.Count()); if (Mouse.IsOver(modifyRect) && Event.current.type == EventType.MouseDown && Event.current.button == 0) { DefExplorerWindow.TryChangeActiveDesc(this); } string newerValText; newerValText = Widgets.TextArea(modifyRect, valText, readOnly: false); if (newerValText != valText) { valText = newerValText; height = CalcHeight(lines, lineHeight); width = CalcWidth(lines, true); } changed = valText != originalText; if (changed) { Rect setButtonrect = new Rect(cur.x, cur.y + height, 30f, lineHeight); bool set = Widgets.ButtonText(setButtonrect, "Set"); if (set) { TrySetValue(valText); } } } else { modifyRect = new Rect(cur.x, cur.y, width, lineHeight * lines.Count()); if (Mouse.IsOver(modifyRect) && Event.current.type == EventType.MouseDown && Event.current.button == 1 && typeof(Def).IsAssignableFrom(field.FieldType) && currentVal != null) { var options = new List <FloatMenuOption>(); options.Add(new FloatMenuOption("Jump to " + GetValueString(currentVal), () => RightClickHandler(currentVal), MenuOptionPriority.High, null)); Verse.Find.WindowStack.Add(new FloatMenu(options)); Event.current.Use(); } Widgets.Dropdown <Type, string>(modifyRect, objectType, GetDropdownPayload, GetDropdownMenu, buttonLabel: originalText); } cur.x += width; cur.y += (changed ? lineHeight + 8f : 0f); cur.y += _height - DefExplorerWindow.LineHeightOffset; }