protected virtual void DrawWindow() { if (visible) { bool paused = false; if (HighLogic.LoadedSceneIsFlight) { try { paused = PauseMenu.isOpen || FlightResultsDialog.isDisplaying; } catch (Exception) { // ignore the error and assume the pause menu is not open } } if (!paused) { GUI.skin = HighLogic.Skin; ConfigureStyles(); windowPos = WindowUtils.EnsureVisible(windowPos); windowPos = GUILayout.Window(windowId, windowPos, PreDrawWindowContents, WindowTitle, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinWidth(64), GUILayout.MinHeight(64)); } } }
protected Window(string windowTitle, float defaultWidth, float defaultHeight) { this.WindowTitle = windowTitle; this.windowId = windowTitle.GetHashCode() + new System.Random().Next(65536) + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.GetHashCode(); configNodeName = windowTitle.Replace(" ", ""); windowPos = new Rect((Screen.width - defaultWidth) / 2, (Screen.height - defaultHeight) / 2, defaultWidth, defaultHeight); mouseDown = false; visible = false; var texture = WindowUtils.LoadImage <T>(IOUtils.GetFilePathFor(typeof(T), "resize.png")); resizeContent = (texture != null) ? new GUIContent(texture, "Drag to resize the window.") : new GUIContent("R", "Drag to resize the window."); Resizable = true; HideCloseButton = false; }
public virtual ConfigNode Load(ConfigNode config) { if (config.HasNode(configNodeName)) { ConfigNode windowConfig = config.GetNode(configNodeName); windowPos.x = WindowUtils.GetValue(windowConfig, "x", windowPos.x); windowPos.y = WindowUtils.GetValue(windowConfig, "y", windowPos.y); windowPos.width = WindowUtils.GetValue(windowConfig, "width", windowPos.width); windowPos.height = WindowUtils.GetValue(windowConfig, "height", windowPos.height); bool newValue = WindowUtils.GetValue(windowConfig, "visible", visible); SetVisible(newValue); return(windowConfig); } else { return(null); } }