private void DrawKerbiniAtol(float line) { GUIStyle guardStyle = KerbiniAtol ? HighLogic.Skin.box : HighLogic.Skin.button; var saveRect = new Rect(LeftIndent * 1.5f, ContentTop + line * entryHeight, contentWidth * 0.9f, entryHeight); if (!KerbiniAtol) { if (GUI.Button(saveRect, "Kerbini Atol", guardStyle)) { if (!launchSiteChanged) { launchSiteChanged = true; KerbiniAtol = true; EditorLogic.fetch.launchVessel(); } } } else { if (GUI.Button(saveRect, "Kerbini Atol", guardStyle)) { ResetLaunchCoords(); } } }
private void DrawMissileRange200Island(float line) { GUIStyle guardStyle = MissileRange200Island ? HighLogic.Skin.box : HighLogic.Skin.button; var saveRect = new Rect(LeftIndent * 1.5f, ContentTop + line * entryHeight, contentWidth * 0.9f, entryHeight); if (!MissileRange200Island) { if (GUI.Button(saveRect, "Missile Range 200", guardStyle)) { if (!launchSiteChanged) { launchSiteChanged = true; MissileRange200Island = true; EditorLogic.fetch.launchVessel(); } } } else { if (GUI.Button(saveRect, "Missile Range 200", guardStyle)) { ResetLaunchCoords(); } } }
private void DrawkscIslandNewHarbor(float line) { GUIStyle guardStyle = kscHarborEast ? HighLogic.Skin.box : HighLogic.Skin.button; var saveRect = new Rect(LeftIndent * 1.5f, ContentTop + line * entryHeight, contentWidth * 0.9f, entryHeight); if (!kscIslandNewHarbor) { if (GUI.Button(saveRect, "KSC Island Harbor", guardStyle)) { if (!launchSiteChanged) { launchSiteChanged = true; kscIslandNewHarbor = true; EditorLogic.fetch.launchVessel(); } } } else { if (GUI.Button(saveRect, "KSC Island Harbor", guardStyle)) { ResetLaunchCoords(); } } }
private void DrawLaunchToGPS(float line) { GUIStyle guardStyle = islandRunway ? HighLogic.Skin.box : HighLogic.Skin.button; var saveRect = new Rect(LeftIndent * 1.5f, ContentTop + line * entryHeight, contentWidth * 0.9f, entryHeight); if (!gps) { if (GUI.Button(saveRect, "Launch to GPS", guardStyle)) { if (!launchSiteChanged) { launchSiteChanged = true; gps = true; EditorLogic.fetch.launchVessel(); } } } else { if (GUI.Button(saveRect, "Launch to GPS", guardStyle)) { ResetLaunchCoords(); } } }
private void DrawTrunkPeninsula(float line) { GUIStyle guardStyle = TrunkPeninsula ? HighLogic.Skin.box : HighLogic.Skin.button; var saveRect = new Rect(LeftIndent * 1.5f, ContentTop + line * entryHeight, contentWidth * 0.9f, entryHeight); if (!TrunkPeninsula) { if (GUI.Button(saveRect, "Trunk Peninsula", guardStyle)) { if (!launchSiteChanged) { launchSiteChanged = true; TrunkPeninsula = true; EditorLogic.fetch.launchVessel(); } } } else { if (GUI.Button(saveRect, "Trunk Peninsula", guardStyle)) { ResetLaunchCoords(); } } }
private void DrawDropVessel(float line) { var saveRect = new Rect(LeftIndent * 1.5f, ContentTop + line * entryHeight, contentWidth * 0.9f, entryHeight); if (GUI.Button(saveRect, "Drop Vessel")) { DropVessel(); DisableGuiF(); } }
private void DrawGetGPS(float line) { var saveRect = new Rect(LeftIndent * 1.5f, ContentTop + line * entryHeight, contentWidth * 0.9f, entryHeight); if (GUI.Button(saveRect, "LOG GPS COORDS")) { GetGPS(); } }
private static void OnWindow(int winID) { if (GUI.Button(new Rect(5, 15, 65, 20), "Previous")) { NavUtilLib.GlobalVariables.FlightData.rwyIdx--; NavUtilLib.GlobalVariables.FlightData.rwyIdx = NavUtilLib.Utils.indexChecker(NavUtilLib.GlobalVariables.FlightData.rwyIdx, NavUtilLib.GlobalVariables.FlightData.currentBodyRunways.Count() - 1, 0); } if (GUI.Button(new Rect(75, 15, 95, 20), "Runway list")) { RunwayListGUI.show(winPos); } if (GUI.Button(new Rect(175, 15, 65, 20), "Next")) { NavUtilLib.GlobalVariables.FlightData.rwyIdx++; NavUtilLib.GlobalVariables.FlightData.rwyIdx = NavUtilLib.Utils.indexChecker(NavUtilLib.GlobalVariables.FlightData.rwyIdx, NavUtilLib.GlobalVariables.FlightData.currentBodyRunways.Count() - 1, 0); } if (GUI.Button(new Rect(5, 40, 115, 20), "Previous G/S")) { NavUtilLib.GlobalVariables.FlightData.gsIdx--; NavUtilLib.GlobalVariables.FlightData.gsIdx = NavUtilLib.Utils.indexChecker(NavUtilLib.GlobalVariables.FlightData.gsIdx, NavUtilLib.GlobalVariables.FlightData.gsList.Count() - 1, 0); } if (GUI.Button(new Rect(130, 40, 115, 20), "Next G/S")) { NavUtilLib.GlobalVariables.FlightData.gsIdx++; NavUtilLib.GlobalVariables.FlightData.gsIdx = NavUtilLib.Utils.indexChecker(NavUtilLib.GlobalVariables.FlightData.gsIdx, NavUtilLib.GlobalVariables.FlightData.gsList.Count() - 1, 0); } GUI.Label(new Rect(5, 75, 115, 25), "HSI GUI scale"); if (GUI.Button(new Rect(130, 75, 100, 25), "Default Scale")) { NavUtilLib.GlobalVariables.Settings.hsiGUIscale = 0.5f; } if (GUI.Button(new Rect(5, 150, 115, 20), "Custom Rwys")) { NavUtilGUI.RunwaysEditor.startGUI(); } //GUI.Label(new Rect(125, 150, 90, 20), "Popup in IVA?"); GlobalVariables.Settings.hideNavBallWaypoint = GUI.Toggle(new Rect(30, 120, 240, 20), GlobalVariables.Settings.hideNavBallWaypoint, "Hide NavBall waypoint icon"); GlobalVariables.Settings.enableWindowsInIVA = GUI.Toggle(new Rect(125, 150, 120, 20), GlobalVariables.Settings.enableWindowsInIVA, "Popup in IVA"); NavUtilLib.GlobalVariables.Settings.hsiGUIscale = GUI.HorizontalSlider(new Rect(5, 105, 240, 30), NavUtilLib.GlobalVariables.Settings.hsiGUIscale, 0.1f, 1.0f); GUI.DragWindow(); }
public static void OnWindow(int winId) { rwyListVector = GUI.BeginScrollView(new Rect(10, 20, 170, 300), rwyListVector, new Rect(0, 0, 150, GlobalVariables.FlightData.currentBodyRunways.Count * 25)); for (int i = 0; i < GlobalVariables.FlightData.currentBodyRunways.Count; i++) { if (GUI.Button(new Rect(2, (i * 25), 140, 20), GlobalVariables.FlightData.currentBodyRunways[i].ident) && !GlobalVariables.FlightData.isINSMode()) { GlobalVariables.FlightData.rwyIdx = i; GlobalVariables.FlightData.updateNavigationData(); isActive = false; } } GUI.EndScrollView(); if (GUI.Button(new Rect(60, 320, 60, 30), "Close")) { isActive = false; } GUI.DragWindow(); }
public static bool TitleBarButton(Rect window) { if (!GUIControls.layoutStarted) { throw new GUIControlsException("GUI layout must be started before adding title bar buttons, call BeginLayout first."); } const float TitleBarIconSpacing = 20; const float TitleBarIconPadding = 2; const float TitleBarIconY = 3; const float TitleBarIconWidth = 12; const float TitleBarIconHeight = 12; bool result = false; GUIControls.titleBarButtonCount++; float x = window.width - ((TitleBarIconSpacing * GUIControls.titleBarButtonCount) + TitleBarIconPadding); result = GUI.Button(new Rect(x, TitleBarIconY, TitleBarIconWidth, TitleBarIconHeight), default(string)); return(result); }
private void DisplayOptionWindow(int windowID) { Rect rect = new Rect(_windowOptionsPosition.width - 20, 4, 16, 16); if (GUI.Button(rect, "")) { _optionsVisible = false; } GUILayout.BeginVertical(); // Unrestricted Xfers bool oldAllow = _allowUnrestrictedTransfers; _allowUnrestrictedTransfers = GUILayout.Toggle(_allowUnrestrictedTransfers, _clsLocUnrestricted); // "Allow Crew Unrestricted Transfers" if (oldAllow != _allowUnrestrictedTransfers) { _backupAllowUnrestrictedTransfers = _allowUnrestrictedTransfers; } // Optional Passable Parts bool newEnablePassable = GUILayout.Toggle(EnablePassable, _clsLocOptPassable); // "Enable Optional Passable Parts\r\n(Requires game restart)" if (newEnablePassable != EnablePassable) { EnablePassable = newEnablePassable; onSettingsChanged(); } GUI.enabled = true; EnableBlizzyToolbar = false; EnableBlizzyToolbar = GUILayout.Toggle(EnableBlizzyToolbar, _clsLocBlizzy); // "Use Blizzy's Toolbar instead of Stock" GUI.enabled = true; GUILayout.EndVertical(); GUI.DragWindow(); RepositionWindow(ref _windowOptionsPosition); }
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(); }
internal void drawWindow(int id) { if (PartCommander.Instance.settings.altSkin) { GUI.skin = PartCommander.Instance.modStyleUnity.skin; } else { GUI.skin = PartCommander.Instance.modStyle.skin; } GUILayout.BeginVertical(); GUILayout.Label("Settings", modStyle.guiStyles["titleLabel"]); GUILayout.EndVertical(); if (Event.current.type == EventType.Repaint) { dragRect = GUILayoutUtility.GetLastRect(); } GUILayout.BeginVertical(); scrollPos = GUILayout.BeginScrollView(scrollPos); GUILayout.BeginHorizontal(); bool newHideUnAct = GUILayout.Toggle(settings.hideUnAct, "Hide unactionable parts", modStyle.guiStyles["toggleText"]); if (newHideUnAct != settings.hideUnAct) { PartCommander.Instance.updateParts = true; settings.hideUnAct = newHideUnAct; settings.Save(); } GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.BeginHorizontal(); GUILayout.Label("Font Size:", modStyle.guiStyles["settingsLabel"]); bool fontChanged = false; GUILayout.FlexibleSpace(); if (settings.fontSize <= 12) { GUI.enabled = false; } if (GUILayout.Button("<", modStyle.guiStyles["settingsButton"])) { settings.fontSize--; fontChanged = true; } GUI.enabled = true; string s = GUILayout.TextField(settings.fontSize.ToString(), modStyle.guiStyles["settingsLabel"]); if (settings.fontSize >= 20) { GUI.enabled = false; } if (GUILayout.Button(">", modStyle.guiStyles["settingsButton"])) { settings.fontSize++; fontChanged = true; } GUI.enabled = true; if (fontChanged) { settings.Save(); PartCommander.Instance.modStyle.UpdateFontSize(settings.fontSize); PartCommander.Instance.modStyleUnity.UpdateFontSize(settings.fontSize); } GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.BeginHorizontal(); bool newAltSkin = GUILayout.Toggle(settings.altSkin, "Use alternate skin", modStyle.guiStyles["toggleText"]); if (newAltSkin != settings.altSkin) { settings.altSkin = newAltSkin; settings.Save(); if (PartCommander.Instance.settings.altSkin) { modStyle = PartCommander.Instance.modStyleUnity; PartCommander.Instance.modStyle = PartCommander.Instance.modStyleUnity; } else { modStyle = PartCommander.Instance.modStyleKSP; PartCommander.Instance.modStyle = PartCommander.Instance.modStyle; } } GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.BeginHorizontal(); bool newEnableHotKey = GUILayout.Toggle(settings.enableHotKey, "Enable hot key", modStyle.guiStyles["toggleText"]); if (newEnableHotKey != settings.enableHotKey) { settings.enableHotKey = newEnableHotKey; settings.Save(); } GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.BeginHorizontal(); if (settingHotKey) { GUILayout.Label("Type a new hot key...", modStyle.guiStyles["settingsLabel"]); if (Event.current.isKey) { settings.hotKey = Event.current.keyCode; settings.Save(); settingHotKey = false; } } else { if (settings.enableHotKey) { GUILayout.BeginHorizontal(); GUILayout.Label("Mod + "); if (GUILayout.Button(new GUIContent(settings.hotKey.ToString(), "Click to set new hot key"), modStyle.guiStyles["settingsButton"])) { settingHotKey = true; } GUILayout.EndHorizontal(); } } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); GUILayout.Space(25f); GUILayout.EndVertical(); if (GUI.Button(new Rect(windowRect.width - 18, 3f, 15f, 15f), new GUIContent("", "Close"), modStyle.guiStyles["closeButton"])) { showWindow = false; } // Create resize button in bottom right corner if (GUI.RepeatButton(new Rect(windowRect.width - 23, windowRect.height - 23, 20, 20), "", modStyle.guiStyles["resizeButton"])) { resizingWindow = true; } GUI.DragWindow(); }
private void OnWindow(int WindowID) { Log.dbg("NavUtils: NavUtilLibApp.OnWindow()"); Log.dbg("HSI: OnWindow()"); Rect rwyBtn = new Rect(20 * var.Settings.hsiGUIscale, 13 * var.Settings.hsiGUIscale, 200 * var.Settings.hsiGUIscale, 20 * var.Settings.hsiGUIscale); Rect gsBtn = new Rect(20 * var.Settings.hsiGUIscale, 38 * var.Settings.hsiGUIscale, 200 * var.Settings.hsiGUIscale, 20 * var.Settings.hsiGUIscale); Rect closeBtn = new Rect(330 * var.Settings.hsiGUIscale, 580 * var.Settings.hsiGUIscale, 300 * var.Settings.hsiGUIscale, 50 * var.Settings.hsiGUIscale); if (GUI.Button(closeBtn, new GUIContent("CloseBtn", "closeOn"))) { //displayHSI(); Log.dbg("CloseHSI"); appButton.SetFalse(true); //goto CloseWindow; } if (GUI.tooltip == "closeOn") { closeHover = true; } else { closeHover = false; } if (GUI.Button(rwyBtn, new GUIContent("Next Runway", "rwyOn")) && !var.FlightData.isINSMode()) //doesn't let runway to be switched in INS mode { if (Event.current.alt) { RunwayListGUI.show(windowPosition); } else { if (Event.current.button == 0) { var.FlightData.rwyIdx++; } else { var.FlightData.rwyIdx--; } var.FlightData.rwyIdx = NavUtilLib.Utils.indexChecker(var.FlightData.rwyIdx, var.FlightData.currentBodyRunways.Count - 1, 0); } } if (GUI.tooltip == "rwyOn") { rwyHover = true; } else { rwyHover = false; } if (GUI.Button(gsBtn, new GUIContent("Next G/S", "gsOn"))) { if (Event.current.button == 0) { var.FlightData.gsIdx++; } else { var.FlightData.gsIdx--; } var.FlightData.gsIdx = NavUtilLib.Utils.indexChecker(var.FlightData.gsIdx, var.FlightData.gsList.Count - 1, 0); } if (GUI.tooltip == "gsOn") { gsHover = true; } else { gsHover = false; } rt.Create(); DrawGauge(rt); GUI.DrawTexture(new Rect(0, 0, windowPosition.width, windowPosition.height), rt, ScaleMode.ScaleToFit); //GUI.DrawTexture(new Rect(0, 0, windowPosition.width, windowPosition.height), var.Materials.Instance.overlay.mainTexture); GUI.DragWindow(); }
private void ToolbarWindow(int windowID) { float line = 0; line += 1.25f; if (FlightGlobals.ActiveVessel && (FlightGlobals.ActiveVessel.LandedOrSplashed || VesselMove.Instance.IsMovingVessel)) { if (!VesselMove.Instance.IsMovingVessel) { if (GUI.Button(LineRect(ref line, 1.5f), "Move Vessel", HighLogic.Skin.button)) { VesselMove.Instance.StartMove(FlightGlobals.ActiveVessel, true); } line += 0.2f; Rect spawnVesselRect = LineRect(ref line); svRectScreenSpace = new Rect(spawnVesselRect); svRectScreenSpace.x += toolbarRect.x; svRectScreenSpace.y += toolbarRect.y; if (GUI.Button(spawnVesselRect, "Spawn Vessel", HighLogic.Skin.button)) { VesselSpawn.instance.StartVesselSpawn(); } line += .75f; Rect crewRect1 = LineRect(ref line); Rect crewRect2 = new Rect(crewRect1.x + crewRect1.width / 2 + 5f, crewRect1.y, crewRect1.width / 2, crewRect1.height); crewRect1.width = crewRect1.width / 2; svCrewScreenSpace = new Rect(crewRect1); svCrewScreenSpace.x += toolbarRect.x; svCrewScreenSpace.y += toolbarRect.y; addCrewMembers = GUI.Toggle(crewRect1, addCrewMembers, "Spawn Crew"); if (!addCrewMembers) { GUI.enabled = false; } selectCrewMembers = GUI.Toggle(crewRect2, selectCrewMembers, "Choose Crew"); GUI.enabled = true; showMoveHelp = false; } else { if (GUI.Button(LineRect(ref line, 2), "Place Vessel", HighLogic.Skin.button)) { VesselMove.Instance.EndMove(); } line += 0.3f; if (GUI.Button(LineRect(ref line, 2), "Drop Vessel", HighLogic.Skin.button)) { VesselMove.Instance.DropMove(); } line += 0.3f; if (GUI.Button(LineRect(ref line), "Help", HighLogic.Skin.button)) { showMoveHelp = !showMoveHelp; } } } else { GUIStyle centerLabelStyle = new GUIStyle(HighLogic.Skin.label); centerLabelStyle.alignment = TextAnchor.UpperCenter; GUI.Label(LineRect(ref line), "You need to be landed to use this!", centerLabelStyle); } toolbarRect.height = (line * toolbarLineHeight) + (toolbarMargin * 2); GUI.DragWindow(new Rect(0, 0, Screen.width, 30)); VMUtils.RepositionWindow(ref toolbarRect); }
void ToolbarWindow(int windowID) { float line = 0; line += 1.25f; if (!FlightGlobals.ActiveVessel) { return; } if (AirPark.Instance) { if (!AirParkInstance.Parked) { if (GUI.Button(LineRect(ref line, 1.5f), "Park Vessel", HighLogic.Skin.button)) { if (FlightGlobals.ActiveVessel && !FlightGlobals.ActiveVessel.Landed) { AirPark.Instance.TogglePark(); } } } else { if (GUI.Button(LineRect(ref line, 2), "Un-Park", HighLogic.Skin.button)) { AirPark.Instance.TogglePark(); } } line += 0.2f; { Rect spawnVesselRect = LineRect(ref line); svRectScreenSpace = new Rect(spawnVesselRect); svRectScreenSpace.x += toolbarRect.x; svRectScreenSpace.y += toolbarRect.y; if (!AirPark.autoPark) { if (GUI.Button(spawnVesselRect, "Auto-Park OFF", HighLogic.Skin.button)) { AirPark.Instance.ToggleAutoPark(); } } else { if (GUI.Button(spawnVesselRect, "Auto-Park ON", HighLogic.Skin.button)) { AirPark.Instance.ToggleAutoPark(); } } } { line += 0.2f; Rect spawnVesselRect = LineRect(ref line); svRectScreenSpace = new Rect(spawnVesselRect); svRectScreenSpace.x += toolbarRect.x; svRectScreenSpace.y += toolbarRect.y; if (!AirPark.isSuborbitalParkAllowed) { if (GUI.Button(spawnVesselRect, "Sub Orbital Park OFF", HighLogic.Skin.button)) { AirPark.Instance.ToggleSubOrbitalPark(); } } else { if (GUI.Button(spawnVesselRect, "Sub Orbital Park ON", HighLogic.Skin.button)) { AirPark.Instance.ToggleSubOrbitalPark(); } } } } else { GUIStyle centerLabelStyle = new GUIStyle(HighLogic.Skin.label) { alignment = TextAnchor.UpperCenter }; GUI.Label(LineRect(ref line), "No AirPark Module Found", centerLabelStyle); } toolbarRect.height = (line * toolbarLineHeight) + (toolbarMargin * 2); }
private static void OnWindow(int winID) { rwyListLength = Rwy.customRunways.Count * 40; rwyListVector = GUI.BeginScrollView(new Rect(10, 20, 150, 270), rwyListVector, new Rect(0, 0, 135, rwyListLength + 35)); if (GUI.Button(new Rect(2, 0, 130, 30), "Create Runway")) { tempRwy = new NavUtilLib.Runway(); isNewRwy = true; } for (int i = 0; i < Rwy.customRunways.Count; i++) { if (i == Rwy.cRwyIdx && !isNewRwy) { if (GUI.Button(new Rect(2, (i * 40) + 40, 130, 30), "* " + Rwy.customRunways[i].ident)) { Rwy.cRwyIdx = i; tempRwy = Rwy.customRunways[i]; isNewRwy = false; } } else { if (GUI.Button(new Rect(2, (i * 40) + 40, 130, 30), Rwy.customRunways[i].ident)) { Rwy.cRwyIdx = i; tempRwy = Rwy.customRunways[i]; isNewRwy = false; } } } GUI.EndScrollView(); //begin runway info area GUI.Label(new Rect(170, 20, 200, 20), "Runway Ident"); GUI.Label(new Rect(170, 70, 150, 20), "Runway Heading"); GUI.Label(new Rect(170, 120, 150, 20), "Runway Elevation (m)"); GUI.Label(new Rect(170, 185, 240, 20), "Marker distance from current point (m)"); GUI.Label(new Rect(190, 200, 60, 20), " Inner"); GUI.Label(new Rect(260, 200, 60, 20), " Middle"); GUI.Label(new Rect(330, 200, 60, 20), " Outer"); //isNewRwy //only difference is textbox vs label if (isNewRwy) { GUI.Label(new Rect(340, 70, 85, 20), "Auto Hdg?"); useAutoHdg = GUI.Toggle(new Rect(350, 90, 20, 20), useAutoHdg, ""); GUI.Label(new Rect(340, 120, 85, 20), "Auto Elevation?"); useAutoElevation = GUI.Toggle(new Rect(350, 140, 20, 20), useAutoElevation, ""); tempRwy.ident = GUI.TextField(new Rect(170, 40, 200, 20), tempRwy.ident); GUI.Label(new Rect(340, 70, 85, 20), "Auto Hdg?"); useAutoHdg = GUI.Toggle(new Rect(350, 90, 20, 20), useAutoHdg, ""); if (useAutoHdg) { tempRwy.hdg = (float)Math.Round(FlightGlobals.ship_heading, 2); GUI.Label(new Rect(170, 90, 150, 20), tempRwy.hdg.ToString() + "°"); } else { tempRwy.hdg = Convert.ToSingle(GUI.TextField(new Rect(170, 90, 150, 20), Convert.ToString(tempRwy.hdg))); } GUI.Label(new Rect(340, 120, 85, 20), "Auto Alt?"); useAutoElevation = GUI.Toggle(new Rect(350, 140, 20, 20), useAutoElevation, ""); if (useAutoElevation) { tempRwy.altMSL = (float)Math.Round(FlightGlobals.ActiveVessel.altitude, 1); GUI.Label(new Rect(170, 140, 150, 20), Convert.ToString(tempRwy.altMSL) + "m"); } else { tempRwy.altMSL = Convert.ToSingle(GUI.TextField(new Rect(170, 140, 150, 20), Convert.ToString(tempRwy.altMSL))); } GUI.Label(new Rect(170, 165, 120, 20), "Use Marker Becons?"); makeMarkers = GUI.Toggle(new Rect(350, 168, 20, 20), makeMarkers, ""); if (makeMarkers) { tempRwy.innerMarkerDist = Convert.ToSingle(GUI.TextField(new Rect(190, 220, 60, 20), Convert.ToString(tempRwy.innerMarkerDist))); tempRwy.middleMarkerDist = Convert.ToSingle(GUI.TextField(new Rect(260, 220, 60, 20), Convert.ToString(tempRwy.middleMarkerDist))); tempRwy.outerMarkerDist = Convert.ToSingle(GUI.TextField(new Rect(330, 220, 60, 20), Convert.ToString(tempRwy.outerMarkerDist))); if (tempRwy.innerMarkerDist < -500) { tempRwy.innerMarkerDist = -500; } if (tempRwy.middleMarkerDist < -500) { tempRwy.middleMarkerDist = -500; } if (tempRwy.outerMarkerDist < -500) { tempRwy.outerMarkerDist = -500; } } } else { GUI.Label(new Rect(170, 40, 200, 20), tempRwy.ident); GUI.Label(new Rect(170, 90, 150, 20), tempRwy.hdg.ToString() + "°"); GUI.Label(new Rect(170, 140, 150, 20), Convert.ToString(tempRwy.altMSL) + "m"); if (tempRwy.innerMarkerDist > -500) { GUI.Label(new Rect(190, 220, 60, 20), tempRwy.innerMarkerDist.ToString() + "m"); } else { GUI.Label(new Rect(190, 220, 60, 20), " N/A"); } if (tempRwy.middleMarkerDist > -500) { GUI.Label(new Rect(260, 220, 60, 20), tempRwy.middleMarkerDist.ToString() + "m"); } else { GUI.Label(new Rect(260, 220, 60, 20), " N/A"); } if (tempRwy.outerMarkerDist > -500) { GUI.Label(new Rect(330, 220, 60, 20), tempRwy.outerMarkerDist.ToString() + "m"); } else { GUI.Label(new Rect(330, 220, 60, 20), " N/A"); } } if (isNewRwy) { if (GUI.Button(new Rect(170, 250, 200, 20), "Create Runway")) { //create the runway and add to database tempRwy.body = FlightGlobals.currentMainBody.bodyName; tempRwy.gsLatitude = (float)FlightGlobals.ship_latitude; tempRwy.gsLongitude = (float)FlightGlobals.ship_longitude; Vector2d loc = NavUtilLib.Utils.CalcCoordinatesFromInitialPointBearingDistance(new Vector2d(tempRwy.gsLatitude, tempRwy.gsLongitude), tempRwy.hdg, 1000, FlightGlobals.currentMainBody.Radius); tempRwy.locLatitude = (float)loc.x; tempRwy.locLongitude = (float)loc.y; if (!makeMarkers) { tempRwy.innerMarkerDist = -1000; tempRwy.middleMarkerDist = -1000; tempRwy.outerMarkerDist = -1000; } Rwy.customRunways.Add(tempRwy); Rwy.currentBodyRunways.Add(tempRwy); Rwy.cRwyIdx = Rwy.customRunways.FindIndex(r => r.ident == tempRwy.ident); WriteCustomRwys(); isNewRwy = false; } } else { //show delete button if (GUI.Button(new Rect(170, 250, 200, 20), "Delete This Runway")) { Rwy.allRunways.Remove(Rwy.customRunways[Rwy.cRwyIdx]); if (Rwy.currentBodyRunways.Contains(Rwy.customRunways[Rwy.cRwyIdx])) { Rwy.currentBodyRunways.Remove(Rwy.customRunways[Rwy.cRwyIdx]); } Rwy.customRunways.Remove(Rwy.customRunways[Rwy.cRwyIdx]); WriteCustomRwys(); Rwy.cRwyIdx = 0; isNewRwy = true; tempRwy = new NavUtilLib.Runway(); } } GUI.DragWindow(); }
/// <summary> /// Darws the Info window where the new saved partfile can be configured /// </summary> /// <param name="windowID"></param> private void HandleInfoWindow(int windowID) { float margin = 5f; float height = 20; float posH = height; float columnWidth = (Constants.guiInfoWindowW - (margin * 5)) / 4; float columnHeight = (Constants.guiInfoWindowH - ((height + margin) * 2)); float scrollwidth = columnWidth - 20.0f; GUIStyle style = new GUIStyle(); for (int i = 0; i < 4; i++) { _guiInfoWindowColoumns[i] = new Rect((margin * (i + 1)) + (columnWidth * i), height, columnWidth, columnHeight); posH = height; switch (i) { case 0: { GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Name:"); posH += height + margin; //_welder.Name = _textFieldTitle.DrawAdvancedGUITextField(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), _welder.Name, 100, (int)this.state); _welder.Name = GUI.TextField(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), _welder.Name, 100); posH += height + margin; GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Title:"); posH += height + margin; //_welder.Title = _textFieldTitle.DrawAdvancedGUITextField(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), _welder.Title, 100, (int)this.state); _welder.Title = GUI.TextField(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), _welder.Title, 100); posH += height + margin; GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Description:"); posH += height + margin; //_welder.Description = _textAreaDescription.DrawAdvancedGUITextArea(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, 7 * height + 6 * margin), _welder.Description, 600, (int)this.state); _welder.Description = GUI.TextArea(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, 8 * height + 7 * margin), _welder.Description, 600); posH += 8 * height + 8 * margin; GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Symmetry:"); posH += height + margin; _welder.stringStackSymmetry = GUI.TextField(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), _welder.stringStackSymmetry, 100); } break; case 1: { GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Category:"); posH += height + margin; Rect _cetegoryBox = new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height); posH += height + margin; GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "RequiredTech:"); posH += height + margin; Rect _techBox = new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height); posH += height + margin; Rect _vesselTypeBox = new Rect(); if (_welder.vesselTypeList.Count > 0) { GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "VesselType:"); posH += height + margin; _vesselTypeBox = new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height); posH += height + margin; } GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("Nb Parts: {0}", _welder.NbParts)); posH += height + margin; GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("Cost: {0:F2}", _welder.Cost)); posH += height + margin; GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("Mass: {0:F3} / {1:F3}", _welder.Mass, _welder.WetMass)); posH += height + margin; GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("Temp: {0:F1}", _welder.MaxTemp)); posH += height + margin; GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("B Force: {0:F3}", _welder.BreakingForce)); posH += height + margin; GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("B Torque: {0:F3}", _welder.BreakingTorque)); posH += height + margin; GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("Drag: {0:F3} / {1:F3}", _welder.MinDrag, _welder.MaxDrag)); if (_techDropdown.IsOpen || _catDropdown.IsOpen) { GUI.Box(_vesselTypeBox, _welder.vesselType); } else { if (_welder.vesselTypeList.Count > 0) { _welder.vesselType = _welder.vesselTypeList[_vesselTypeDropdown.Show(_vesselTypeBox)]; } } if (_catDropdown.IsOpen) { GUI.Box(_techBox, _welder.techRequire); } else { _welder.techRequire = _welder.techList[_techDropdown.Show(_techBox)]; } _catDropdown.SelectedItemIndex = (int)_welder.Category; _welder.Category = (PartCategories)_catDropdown.Show(_cetegoryBox); } break; case 2: { GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Modules:"); posH += height + margin; string[] modulenames = _welder.Modules; _scrollMod = GUI.BeginScrollView(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, (height * 14 + margin * 13)), _scrollMod, new Rect(0, 0, scrollwidth, modulenames.Length > 14 ? 345 + (modulenames.Length - 14) * (height + margin) : 345), false, true); style.wordWrap = false; style.normal.textColor = Color.white; posH = 0; foreach (string modulename in modulenames) { GUI.Label(new Rect(2, posH, scrollwidth, height), modulename, style); posH += height + margin; } GUI.EndScrollView(); } break; case 3: { GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Resources:"); posH += height + margin; string[] resourcesdata = _welder.Resources; _scrollRes = GUI.BeginScrollView(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, (height * 14 + margin * 13)), _scrollRes, new Rect(0, 0, scrollwidth, resourcesdata.Length > 14 ? 345 + (resourcesdata.Length - 14) * (height + margin) : 345), false, true); style.wordWrap = false; style.normal.textColor = Color.white; posH = 0; foreach (string resname in resourcesdata) { GUI.Label(new Rect(2, posH, scrollwidth, height), resname, style); posH += height + margin; } GUI.EndScrollView(); } break; default: { GUI.Label(new Rect(0, posH, columnWidth, height), "Broken GUI Column:"); } break; } } if (!WelderNameNotUsed()) { style.normal.textColor = Color.red; GUI.Label(new Rect(margin, columnHeight + margin, columnWidth * 1.5f, height), Constants.guiNameUsed, style); } if (!isSymmetryNumber()) { style.normal.textColor = Color.red; GUI.Label(new Rect(margin, height + columnHeight + margin, columnWidth * 1.5f, height), Constants.guiSymmetryNotNumbered, style); } if (!string.IsNullOrEmpty(_welder.Name)) { if (GUI.Button(new Rect(_guiInfoWindowColoumns[1].x + columnWidth * 0.5f, height + columnHeight + margin, columnWidth * 0.5f, height), Constants.guiSave)) { //check if the file exist string welding_pathname = this.welding_pathname; // Cache the built pathname if (!File <UbioZurWeldingLtd> .Local.Exists(welding_pathname)) { //create the file (why? LisiasT) L.StreamWriter partfile = File <UbioZurWeldingLtd> .Local.CreateText(welding_pathname); partfile.Close(); WriteCfg(welding_pathname); this.state = DisplayState.savedWindow; } else { this.state = DisplayState.overwriteDial; } } } else { GUI.Box(new Rect(_guiInfoWindowColoumns[1].x + columnWidth * 0.5f, height + columnHeight + margin, columnWidth * 0.5f, height), Constants.guiSave); } if (GUI.Button(new Rect(_guiInfoWindowColoumns[2].x, height + columnHeight + margin, columnWidth * 0.5f, height), Constants.guiCancel)) { this.state = DisplayState.none; ClearEditor(); } GUI.DragWindow(); }
private void DisplayCLSWindow() { // set scrollviewer sizes... if (Event.current.type == EventType.Repaint) { _scrollY = _scrollCrew.height > _scrollParts.height ? _scrollCrew.height : _scrollParts.height; _scrollXCrew = _scrollCrew.width > 140 ? _scrollCrew.width : 140; _scrollXParts = _scrollParts.width > 240 ? _scrollParts.width : 240; // reset counters. _scrollCrew.height = _scrollParts.height = _scrollCrew.width = _scrollParts.width = 0; } try { Rect rect = new Rect(_windowPosition.width - 20, 4, 16, 16); if (GUI.Button(rect, "")) { OnCLSButtonToggle(); } rect = new Rect(_windowPosition.width - 90, 4, 65, 16); if (GUI.Button(rect, new GUIContent(_clsLocOptions, _clsLocOptionTt))) // "Options","Click to view/edit options" { _optionsVisible = !_optionsVisible; } GUILayout.BeginVertical(); GUI.enabled = true; // Build strings describing the contents of each of the spaces. if (null != _vessel) { string[] spaceNames = new string[_vessel.Spaces.Count]; int counter = 0; int newSelectedSpace = -1; string partsList = ""; List <ICLSSpace> .Enumerator spaces = _vessel.Spaces.GetEnumerator(); while (spaces.MoveNext()) { if (spaces.Current == null) { continue; } if (spaces.Current.Name == "") { spaceNames[counter] = $"{_clsLocSpace} {counter + 1}"; } else { spaceNames[counter] = spaces.Current.Name; } counter++; } spaces.Dispose(); if (_vessel.Spaces.Count > 0) { newSelectedSpace = DisplaySpaceButtons(WindowSelectedSpace, spaceNames); } // Only fiddle with the highlighting if the selected space has actually changed UpdateDisplayHighlghting(newSelectedSpace); // Update the space that has been selected. WindowSelectedSpace = newSelectedSpace; // If one of the spaces has been selected then display lists of the crew and parts that make it up if (WindowSelectedSpace != -1) { Rect _rect; // Loop through all the parts in the newly selected space and create a list of all the spaces in it. partsList = $"{_clsLocParts}:"; List <ICLSPart> .Enumerator parts = _vessel.Spaces[WindowSelectedSpace].Parts.GetEnumerator(); while (parts.MoveNext()) { if (parts.Current == null) { continue; } partsList += $"\n- {(parts.Current.Part).partInfo.title}"; } parts.Dispose(); string crewList = $"{_clsLocInfo}:"; if (_vessel.Spaces[WindowSelectedSpace].Crew.Count == 0) { crewList += $"\n- {_clsLocNone}"; } else { List <ICLSKerbal> .Enumerator crewmembers = _vessel.Spaces[WindowSelectedSpace].Crew.GetEnumerator(); while (crewmembers.MoveNext()) { if (crewmembers.Current == null) { continue; } crewList += $"\n- {(crewmembers.Current.Kerbal).name}"; } crewmembers.Dispose(); } // Display the text box that allows the space name to be changed GUILayout.BeginHorizontal(); GUILayout.Label($"{_clsLocName}:"); // "Name:" _spaceNameEditField = GUILayout.TextField(_spaceNameEditField, GUILayout.Width(200)); if (GUILayout.Button(_clsLocUpdate)) // "Update" { _vessel.Spaces[WindowSelectedSpace].Name = _spaceNameEditField; } GUILayout.EndHorizontal(); // Lets use 2 scrollers for Crew and parts to save space... GUILayout.BeginHorizontal(); // Crew Scroller _scrollViewerCrew = GUILayout.BeginScrollView(_scrollViewerCrew, GUILayout.Width(_scrollXCrew), GUILayout.Height(20 > _scrollY ? 20 : _scrollY + 20)); GUILayout.BeginVertical(); // Display the crew capacity of the space. GUILayout.Label($"{_clsLocCapacity}: {_vessel.Spaces[WindowSelectedSpace].MaxCrew}"); _rect = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.Repaint) { _scrollCrew.height = _rect.height; _scrollCrew.width = _rect.width; } // Crew Capacity GUILayout.Label(crewList); _rect = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.Repaint) { _scrollCrew.height += _rect.height; _scrollCrew.width = _scrollCrew.width > _rect.width ? _scrollCrew.width : _rect.width; } GUILayout.EndVertical(); GUILayout.EndScrollView(); // Part Scroller _scrollViewerParts = GUILayout.BeginScrollView(_scrollViewerParts, GUILayout.Width(_scrollXParts), GUILayout.Height(20 > _scrollY ? 20 : _scrollY + 20)); GUILayout.BeginVertical(); // Display the Part count of the space. GUILayout.Label($"{_clsLocPartCount}: {_vessel.Spaces[WindowSelectedSpace].Parts.Count}"); // Selected Space Parts Count _rect = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.Repaint) { _scrollParts.height = _rect.height; _scrollParts.width = _rect.width; } // Display the list of component parts. GUILayout.Label(partsList); _rect = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.Repaint) { _scrollParts.height += _rect.height; _scrollParts.width = _scrollParts.width > _rect.width ? _scrollParts.width : _rect.width; } GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndHorizontal(); } } else { GUILayout.Label("", GUILayout.Height(20)); // Add some vertical space. GUILayout.Label(_clsLocNoVessel, CLSStyles.LabelStyleBold, GUILayout.Width(380)); // "No current vessel" } GUILayout.EndVertical(); GUI.DragWindow(); RepositionWindow(ref _windowPosition); } catch (Exception ex) { Log.error(ex, this); } }