internal static void ShowToolTip(Vector2 toolTipPos, string toolTip) { Vector2 size = ToolTipStyle.CalcSize(new GUIContent(toolTip)); Position = new Rect(toolTipPos.x + 5, toolTipPos.y + 5, size.x, size.y); RepositionToolTip(); GUI.Window(0, Position, EmptyWindow, toolTip, ToolTipStyle); GUI.BringWindowToFront(0); }
void GUIActive(int windowID) { #if false if (HighLogic.LoadedScene == GameScenes.SETTINGS) { GUI.BringWindowToFront(09271); } #endif GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Name: "); nameString = GUILayout.TextField(nameString); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Width: "); xString = GUILayout.TextField(xString); xString = Regex.Replace(xString, @"[^0-9]", ""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Height: "); yString = GUILayout.TextField(yString); yString = Regex.Replace(yString, @"[^0-9]", ""); GUILayout.EndHorizontal(); fullScreen = GUILayout.Toggle(fullScreen, "Fullscreen"); reloadScene = GUILayout.Toggle(reloadScene, "Reload scene"); if (GUILayout.Button("Set Screen Resolution")) { if (xString != null && yString != null) { x = Convert.ToInt32(xString); y = Convert.ToInt32(yString); if (x > 0 && y > 0) { GameSettings.SCREEN_RESOLUTION_HEIGHT = y; GameSettings.SCREEN_RESOLUTION_WIDTH = x; GameSettings.FULLSCREEN = fullScreen; GameSettings.SaveSettings(); Screen.SetResolution(x, y, fullScreen); Log.detail("Set screen resolution"); if (reloadScene) { if (HighLogic.LoadedScene != GameScenes.LOADING) { HighLogic.LoadScene(HighLogic.LoadedScene); } else { ScreenMessages.PostScreenMessage("You cannot reload the scene while loading the game!", 1); } } } else { ScreenMessages.PostScreenMessage("One or both of your values is too small. Please enter a valid value.", 1, ScreenMessageStyle.UPPER_CENTER); } } else { ScreenMessages.PostScreenMessage("The values you have set are invalid. Please set a valid value.", 1, ScreenMessageStyle.UPPER_CENTER); } } if (nameString == "") { GUI.enabled = false; } if (GUILayout.Button("Save")) { string newName = nameString; string newX = xString; string newY = yString; bool newFullscreen = fullScreen; ConfigNode config = new ConfigNode(newName); config.AddValue("name", newName); config.AddValue("x", newX); config.AddValue("y", newY); config.AddValue("fullscreen", newFullscreen.ToString()); this.presets.Create(config); ScreenMessages.PostScreenMessage("Preset saved. You can change the preset later by using the same name in this editor.", 5, ScreenMessageStyle.UPPER_CENTER); this.presets.ReloadFiles(); } GUI.enabled = 0 != this.presets.files.Count; if (deleteEnabled) { if (GUILayout.Button("Disable Delete")) { deleteEnabled = false; } } else { if (GUILayout.Button("Enable Delete")) { deleteEnabled = true; } } if (GUILayout.Button("Close")) { toolbarButton.Active = false; } GUILayout.EndVertical(); GUILayout.BeginVertical(); scrollViewPos = GUILayout.BeginScrollView(scrollViewPos); foreach (Data.ConfigNode configNode in this.presets.files) { ConfigNode config = configNode.Node; if (deleteEnabled) { if (GUILayout.Button("Delete " + config.GetValue("name"))) { confirmDeleteEnabled = true; this.presets.MarkForDeletion(configNode); } } else { if (GUILayout.Button(config.GetValue("name"))) { int xVal; int.TryParse(config.GetValue("x"), out xVal); int yVal; int.TryParse(config.GetValue("y"), out yVal); bool fullscreen; bool.TryParse(config.GetValue("fullscreen"), out fullscreen); GameSettings.SCREEN_RESOLUTION_HEIGHT = yVal; GameSettings.SCREEN_RESOLUTION_WIDTH = xVal; GameSettings.FULLSCREEN = fullscreen; GameSettings.SaveSettings(); Screen.SetResolution(xVal, yVal, fullscreen); Log.detail("Set screen resolution from preset"); } } } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (GUI.Button(new Rect(anyresWinRect.width - 18, 3f, 15f, 15f), new GUIContent("X"))) { toolbarButton.Active = false; } GUI.DragWindow(); }