protected void ClearEditors() { foreach (CommandEditor commandEditor in cachedCommandEditors) { DestroyImmediate(commandEditor); } cachedCommandEditors.Clear(); activeCommandEditor = null; }
public void DrawCommandUI(Flowchart flowchart, Command inspectCommand) { ResizeScrollView(flowchart); GUILayout.Space(7); activeBlockEditor.DrawButtonToolbar(); commandScrollPos = GUILayout.BeginScrollView(commandScrollPos); if (inspectCommand != null) { if (activeCommandEditor == null || inspectCommand != activeCommandEditor.target) { // See if we have a cached version of the command editor already, var editors = (from e in cachedCommandEditors where (e != null && e.target == inspectCommand) select e); if (editors.Count() > 0) { // Use cached editor activeCommandEditor = editors.First(); } else { // No cached editor, so create a new one. activeCommandEditor = Editor.CreateEditor(inspectCommand) as CommandEditor; cachedCommandEditors.Add(activeCommandEditor); } } if (activeCommandEditor != null) { activeCommandEditor.DrawCommandInspectorGUI(); } } GUILayout.EndScrollView(); GUILayout.EndArea(); // Draw the resize bar after everything else has finished drawing // This is mainly to avoid incorrect indenting. Rect resizeRect = new Rect(0, topPanelHeight + flowchart.blockViewHeight + 1, Screen.width, 4f); GUI.color = new Color(0.64f, 0.64f, 0.64f); GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture); resizeRect.height = 1; GUI.color = new Color32(132, 132, 132, 255); GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture); resizeRect.y += 3; GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture); GUI.color = Color.white; Repaint(); }
public override void DoWindowContents(Rect inRect) { if (searchQuery != lastSearch) { UpdateList(); } Rect rect = new Rect(0f, 0f, inRect.width, 60f); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect, "All Commands"); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Rect search = new Rect(0, rect.height, inRect.width / 2, 26f); searchQuery = Widgets.TextEntryLabeled(search, "Search:", searchQuery); Rect resetButton = new Rect(search.x, search.y + 28f, search.width, 26f); if (Widgets.ButtonText(resetButton, "Reset all Commands")) { CommandEditor.LoadBackups(); } resetButton.x += resetButton.width + 10f; if (Widgets.ButtonText(resetButton, "Create Command")) { Window_NewCustomCommand window = new Window_NewCustomCommand(); Find.WindowStack.TryRemove(window.GetType()); Find.WindowStack.Add(window); Close(); } inRect.yMin += 120f; Widgets.DrawMenuSection(inRect); //TabDrawer.DrawTabs(inRect, this.tabs, 2); inRect = inRect.ContractedBy(17f); GUI.BeginGroup(inRect); Rect rect2 = inRect.AtZero(); this.DoBottomButtons(rect2); Rect outRect = rect2; outRect.yMax -= 65f; if (allCommands.Count > 0) { float height = (float)allCommands.Count * 24f; float num = 0f; Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, height); Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect, true); float num2 = this.scrollPosition.y - 24f; float num3 = this.scrollPosition.y + outRect.height; for (int i = 0; i < allCommands.Count; i++) { if (num > num2 && num < num3) { Rect rect3 = new Rect(0f, num, viewRect.width, 24f); this.DoRow(rect3, allCommands[i], i); } num += 24f; } Widgets.EndScrollView(); } else { Widgets.NoneLabel(0f, outRect.width, null); } GUI.EndGroup(); }