protected virtual void writeScreenMessage(string Message, float duration = 3f, string messagePosition = "UPPER_RIGHT") { //Default position and switch to user defined position ScreenMessageStyle position = ScreenMessageStyle.UPPER_RIGHT; switch (messagePosition) { case "UPPER_CENTER": position = ScreenMessageStyle.UPPER_CENTER; break; case "UPPER_RIGHT": position = ScreenMessageStyle.UPPER_RIGHT; break; case "UPPER_LEFT": position = ScreenMessageStyle.UPPER_LEFT; break; case "LOWER_CENTER": position = ScreenMessageStyle.LOWER_CENTER; break; } writeScreenMessage(Message, duration, position); }
private static void PostScreenMessage(string message, float duration = 5.0f, ScreenMessageStyle style = ScreenMessageStyle.UPPER_CENTER, UnityEngine.Color?color = null) { if (color == null) { ScreenMessages.PostScreenMessage(message, duration, style); } else { ScreenMessages.PostScreenMessage(message, duration, style, color.Value); } }
/// <summary> /// Post a temporary message to the screen. Examples of screen messages are the "Warp = {number}x" message /// and the "Quicksaving..." message. /// </summary> /// <param name="message">The message to post</param> /// <param name="duration">How long the message should remain on the screen, in seconds.</param> /// <param name="style">Which style of screen message to post--for instance, should it by like the warp message, the quicksaving message, etc.</param> /// <returns>A reference to the posted message</returns> public extern static ScreenMessage PostScreenMessage(string message, float duration, ScreenMessageStyle style);
/// <summary>Shows a formatted message with the specified location and timeout.</summary> /// <param name="style"><see cref="ScreenMessageStyle"/> specifier.</param> /// <param name="duration">Delay before hiding the message in seconds.</param> /// <param name="color">Color to apply on the string.</param> /// <param name="fmt"><c>string.Format()</c> formatting string.</param> /// <param name="args">Arguments for the formattign string.</param> /// <seealso href="https://kerbalspaceprogram.com/api/class_screen_messages.html"> /// KSP: ScreenMessages</seealso> /// <seealso href="https://kerbalspaceprogram.com/api/_screen_messages_8cs.html#ac19a4c3800d327889475848ccbbf9317"> /// KSP: ScreenMessageStyle</seealso> public static void ShowScreenMessage( ScreenMessageStyle style, float duration, Color color, String fmt, params object[] args) { ScreenMessages.PostScreenMessage( SetColorToRichText(String.Format(fmt, args), color), duration, style); }
void drawEditorWindow(int id) { BoxNoBorder = new GUIStyle(GUI.skin.box); BoxNoBorder.normal.background = null; BoxNoBorder.normal.textColor = Color.white; DeadButton = new GUIStyle(GUI.skin.button); DeadButton.normal.background = null; DeadButton.hover.background = null; DeadButton.active.background = null; DeadButton.focused.background = null; DeadButton.normal.textColor = Color.yellow; DeadButton.hover.textColor = Color.white; DeadButton.active.textColor = Color.yellow; DeadButton.focused.textColor = Color.yellow; DeadButton.fontSize = 14; DeadButton.fontStyle = FontStyle.Normal; DeadButton2 = new GUIStyle(GUI.skin.button); DeadButton2.normal.background = null; DeadButton2.hover.background = null; DeadButton2.active.background = null; DeadButton2.focused.background = null; DeadButton2.normal.textColor = Color.white; DeadButton2.hover.textColor = Color.green; DeadButton2.active.textColor = Color.white; DeadButton2.focused.textColor = Color.white; DeadButton2.fontSize = 14; DeadButton2.fontStyle = FontStyle.Bold; DeadButton3 = new GUIStyle(GUI.skin.button); DeadButton3.normal.background = null; DeadButton3.hover.background = null; DeadButton3.active.background = null; DeadButton3.focused.background = null; DeadButton3.normal.textColor = Color.white; DeadButton3.hover.textColor = Color.white; DeadButton3.active.textColor = Color.white; DeadButton3.focused.textColor = Color.white; DeadButton3.fontSize = 13; DeadButton3.fontStyle = FontStyle.Bold; DeadButtonRed = new GUIStyle(GUI.skin.button); DeadButtonRed.normal.background = null; DeadButtonRed.hover.background = null; DeadButtonRed.active.background = null; DeadButtonRed.focused.background = null; DeadButtonRed.normal.textColor = Color.red; DeadButtonRed.hover.textColor = Color.yellow; DeadButtonRed.active.textColor = Color.red; DeadButtonRed.focused.textColor = Color.red; DeadButtonRed.fontSize = 12; DeadButtonRed.fontStyle = FontStyle.Bold; string smessage = ""; ScreenMessageStyle smsStyle = (ScreenMessageStyle)2; GUILayout.BeginHorizontal(); { GUI.enabled = false; GUILayout.Button("-KK-", DeadButton, GUILayout.Height(21)); GUILayout.FlexibleSpace(); GUILayout.Button("Statics Editor", DeadButton, GUILayout.Height(21)); GUILayout.FlexibleSpace(); GUI.enabled = true; if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(21))) { KerbalKonstructs.instance.ToggleEditor(); } } GUILayout.EndHorizontal(); GUILayout.Space(1); GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); GUILayout.BeginHorizontal(); { if (foldedIn) { tFolded = tFoldOut; } if (!foldedIn) { tFolded = tFoldIn; } if (GUILayout.Button(tFolded, GUILayout.Height(23), GUILayout.Width(23))) { if (foldedIn) { foldedIn = false; } else { foldedIn = true; } } GUI.enabled = !creatingInstance; sButtonText = ""; fButtonWidth = 0f; if (foldedIn) { fButtonWidth = 50f; } else { fButtonWidth = 110f; } if (foldedIn) { sButtonText = "New"; } else { sButtonText = "Spawn New"; } if (GUILayout.Button("" + sButtonText, GUILayout.Height(23), GUILayout.Width(fButtonWidth))) { creatingInstance = true; showLocal = false; } GUILayout.Space(5); GUI.enabled = creatingInstance || showLocal; if (foldedIn) { sButtonText = "All"; } else { sButtonText = "All Instances"; } if (GUILayout.Button("" + sButtonText, GUILayout.Width(fButtonWidth), GUILayout.Height(23))) { creatingInstance = false; showLocal = false; KerbalKonstructs.instance.DeletePreviewObject(); KerbalKonstructs.instance.disableAllInstanceEditing = bDisableEditingSetting; } GUI.enabled = true; GUILayout.Space(2); GUI.enabled = creatingInstance || !showLocal; if (foldedIn) { sButtonText = "Local"; } else { sButtonText = "Local Instances"; } if (GUILayout.Button("" + sButtonText, GUILayout.Width(fButtonWidth), GUILayout.Height(23))) { creatingInstance = false; showLocal = true; KerbalKonstructs.instance.DeletePreviewObject(); } GUI.enabled = true; GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Save", "Save all new and edited instances."), GUILayout.Width(fButtonWidth - 10), GUILayout.Height(23))) { KerbalKonstructs.instance.saveObjects(); smessage = "Saved all changes to all objects."; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } } GUILayout.EndHorizontal(); if (!foldedIn) { if (creatingInstance) { GUILayout.BeginHorizontal(); GUILayout.Space(15); if (GUILayout.Button("Category", DeadButton, GUILayout.Width(110), GUILayout.Height(23))) { if (bSortCategory) { bSortCategory = false; } else { bSortCategory = true; } } GUILayout.Space(5); if (GUILayout.Button("Title", DeadButton, GUILayout.Height(23))) { if (bSortTitle) { bSortTitle = false; } else { bSortTitle = true; } } GUILayout.FlexibleSpace(); GUILayout.Button("Mesh", DeadButton, GUILayout.Width(140), GUILayout.Height(23)); GUILayout.Space(15); GUILayout.EndHorizontal(); } } bool showStatic = false; scrollPos = GUILayout.BeginScrollView(scrollPos); if (creatingInstance) { lStaticModels = KerbalKonstructs.instance.getStaticDB().getModels(); if (bSortCategory) { lStaticModels.Sort(delegate(StaticModel a, StaticModel b) { return(((string)a.getSetting("category")).CompareTo((string)b.getSetting("category"))); }); } if (bSortTitle) { lStaticModels.Sort(delegate(StaticModel a, StaticModel b) { return(((string)a.getSetting("title")).CompareTo((string)b.getSetting("title"))); }); } foreach (StaticModel model in lStaticModels) { if (titlefilterset == "" && categoryfilterset == "") { showStatic = true; } if (titlefilterset != "") { sTitleHolder = (string)model.getSetting("title"); if (sTitleHolder.Contains(titlefilterset)) { showStatic = true; } else { showStatic = false; } } if (categoryfilterset != "") { sCategoryHolder = (string)model.getSetting("category"); if (sCategoryHolder.Contains(categoryfilterset)) { showStatic = true; } else { showStatic = false; } } if (categoryfilterset != "" && titlefilterset != "") { sTitleHolder = (string)model.getSetting("title"); sCategoryHolder = (string)model.getSetting("category"); if (sCategoryHolder.Contains(categoryfilterset) && sTitleHolder.Contains(titlefilterset)) { showStatic = true; } else { showStatic = false; } } if (showStatic) { GUILayout.BeginHorizontal(); if (!foldedIn) { if (GUILayout.Button(new GUIContent("" + model.getSetting("category"), "Filter"), DeadButton, GUILayout.Width(110), GUILayout.Height(23))) { categoryfilter = (string)model.getSetting("category"); categoryfilterset = categoryfilter; titlefilterset = titlefilter; } //GUILayout.FlexibleSpace(); GUILayout.Space(5); } if (GUILayout.Button(new GUIContent("" + "" + model.getSetting("title"), "Spawn an instance of this static."), DeadButton2, GUILayout.Height(23))) { KerbalKonstructs.instance.DeletePreviewObject(); KerbalKonstructs.instance.bDisablePositionEditing = false; spawnInstance(model); smessage = "Spawned " + model.getSetting("title"); ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } if (!foldedIn) { GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent(" " + model.getSetting("mesh") + " ", "Edit Model Config"), DeadButton, GUILayout.Width(140), GUILayout.Height(23))) { KerbalKonstructs.instance.selectedModel = model; KerbalKonstructs.instance.showModelInfo = true; } } GUILayout.EndHorizontal(); GUILayout.Space(2); } } } if (!creatingInstance) { foreach (StaticObject obj in KerbalKonstructs.instance.getStaticDB().getAllStatics()) { bool isLocal = true; if (showLocal) { if (obj.pqsCity.sphere == FlightGlobals.currentMainBody.pqsController) { var dist = Vector3.Distance(FlightGlobals.ActiveVessel.GetTransform().position, obj.gameObject.transform.position); isLocal = dist < localRange; } else { isLocal = false; } } string sGroupHolder = ""; if (!showLocal) { if (groupfilterset != "") { sGroupHolder = (string)obj.getSetting("Group"); if (!sGroupHolder.Contains(groupfilterset)) { isLocal = false; } } } string sLaunchType = ""; if (isLocal) { GUILayout.BeginHorizontal(); if (!foldedIn) { GUILayout.Button("" + obj.getSetting("Group"), DeadButton3, GUILayout.Width(120), GUILayout.Height(23)); sLaunchType = (string)obj.getSetting("Category"); if (sLaunchType == "Runway" || sLaunchType == "Helipad") { GUILayout.Button(tSPH, DeadButton3, GUILayout.Width(23), GUILayout.Height(23)); } else { if (sLaunchType == "RocketPad") { GUILayout.Button(tVAB, DeadButton3, GUILayout.Width(23), GUILayout.Height(23)); } else { if (sLaunchType == "Other" && obj.settings.ContainsKey("LaunchSiteName")) { GUILayout.Button(tANY, DeadButton3, GUILayout.Width(23), GUILayout.Height(23)); } else { GUILayout.Button("", DeadButton3, GUILayout.Width(23), GUILayout.Height(23)); } } } } //GUI.enabled = (obj != selectedObject); if (GUILayout.Button(new GUIContent("" + obj.model.getSetting("title"), "Edit this instance."), GUILayout.Height(23))) { KerbalKonstructs.instance.bDisablePositionEditing = false; enableColliders = true; if (selectedObject != null) { selectedObjectPrevious = selectedObject; Color highlightColor = new Color(0, 0, 0, 0); obj.HighlightObject(highlightColor); } if (snapTargetInstance == obj) { snapTargetInstance = null; KerbalKonstructs.instance.snapTargetInstance = null; } if (!KerbalKonstructs.instance.disableAllInstanceEditing) { KerbalKonstructs.instance.selectObject(obj, false, true, false); } else { if (!showLocal) { KerbalKonstructs.instance.bDisablePositionEditing = true; KerbalKonstructs.instance.selectObject(obj, false, false, false); } else { KerbalKonstructs.instance.selectObject(obj, false, true, false); } } //obj.selectObject(false); Color highlightColor2 = XKCDColors.Green_Yellow; obj.HighlightObject(highlightColor2); } //GUI.enabled = true; if (showLocal) { GUI.enabled = (snapTargetInstance != obj && obj != selectedObject); if (GUILayout.Button(new GUIContent(tFocus, "Set as snap target."), GUILayout.Height(23), GUILayout.Width(23))) { if (snapTargetInstance != null) { snapTargetInstancePrevious = snapTargetInstance; Color highlightColor3 = new Color(0, 0, 0, 0); snapTargetInstance.HighlightObject(highlightColor3); } snapTargetInstance = obj; KerbalKonstructs.instance.setSnapTarget(obj); Color highlightColor4 = XKCDColors.RedPink; obj.HighlightObject(highlightColor4); } GUI.enabled = true; } GUILayout.EndHorizontal(); GUILayout.Space(2); } } } GUILayout.EndScrollView(); GUI.enabled = true; if (!foldedIn) { if (creatingInstance) { GUILayout.BeginHorizontal(); GUILayout.Label("Filter by "); GUILayout.Label(" Category:"); categoryfilter = GUILayout.TextField(categoryfilter, 30, GUILayout.Width(90)); if (GUILayout.Button(new GUIContent(tSearch, "Apply Filter."), GUILayout.Width(23), GUILayout.Height(23))) { categoryfilterset = categoryfilter; titlefilterset = titlefilter; } if (GUILayout.Button(new GUIContent(tCancelSearch, "Remove Filter."), GUILayout.Width(23), GUILayout.Height(23))) { categoryfilter = ""; categoryfilterset = ""; } GUILayout.Label(" Title:"); titlefilter = GUILayout.TextField(titlefilter, 30, GUILayout.Width(90)); if (GUILayout.Button(new GUIContent(tSearch, "Apply Filter."), GUILayout.Width(23), GUILayout.Height(23))) { categoryfilterset = categoryfilter; titlefilterset = titlefilter; } if (GUILayout.Button(new GUIContent(tCancelSearch, "Remove Filter."), GUILayout.Width(23), GUILayout.Height(23))) { titlefilter = ""; titlefilterset = ""; } GUILayout.EndHorizontal(); } } if (!foldedIn) { if (!showLocal && !creatingInstance) { GUILayout.BeginHorizontal(); { GUILayout.Label("Filter by Group:", GUILayout.Width(140)); //GUILayout.FlexibleSpace(); groupfilter = GUILayout.TextField(groupfilter, 40, GUILayout.Width(140)); if (GUILayout.Button(new GUIContent(tSearch, "Apply Filter."), GUILayout.Width(23), GUILayout.Height(23))) { groupfilterset = groupfilter; } if (GUILayout.Button(new GUIContent(tCancelSearch, "Remove Filter."), GUILayout.Width(23), GUILayout.Height(23))) { groupfilter = ""; groupfilterset = ""; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Pack Name: ", GUILayout.Width(140)); //GUILayout.FlexibleSpace(); sPackName = GUILayout.TextField(sPackName, 30, GUILayout.Width(140)); //GUILayout.FlexibleSpace(); GUI.enabled = (sPackName != "" && groupfilter != ""); if (GUILayout.Button("Export Group")) { //Validate the groupfilter to see if it is a Group name bool bValidGroupName = false; foreach (StaticObject obj in KerbalKonstructs.instance.getStaticDB().getAllStatics()) { if ((string)obj.getSetting("Group") == groupfilter) { bValidGroupName = true; break; } } if (bValidGroupName) { KerbalKonstructs.instance.exportCustomInstances(sPackName, "", groupfilter); smessage = "Exported custom instances to GameData/KerbalKonstructs/ExportedInstances/" + sPackName + "/" + groupfilter; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } else { smessage = "Group filter is not a valid Group name. Please filter with a complete and valid Group name before exporting a group."; ScreenMessages.PostScreenMessage(smessage, 20, smsStyle); } } GUI.enabled = true; GUI.enabled = (sPackName != ""); if (GUILayout.Button("Export All")) { KerbalKonstructs.instance.exportCustomInstances(sPackName, "All"); smessage = "Exported all custom instances to GameData/KerbalKonstructs/ExportedInstances/" + sPackName + "/"; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } GUI.enabled = true; } GUILayout.EndHorizontal(); if (!KerbalKonstructs.instance.disableAllInstanceEditing) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Disable Camera Focus/Position Editing", GUILayout.Height(23))) { KerbalKonstructs.instance.disableAllInstanceEditing = true; bDisableEditingSetting = true; } GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23)); GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); if (GUILayout.Button("Disable Camera Focus/Position Editing", GUILayout.Height(23))) { KerbalKonstructs.instance.disableAllInstanceEditing = false; bDisableEditingSetting = false; } GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23)); GUILayout.EndHorizontal(); } } } if (showLocal) { GUILayout.BeginHorizontal(); if (!foldedIn) { GUILayout.Label("Local:"); } GUI.enabled = false; GUILayout.Label(localRange.ToString("0") + " m", GUILayout.Width(50)); GUI.enabled = showLocal; if (GUILayout.Button("-", GUILayout.Width(25))) { if (localRange < 5000) { } else { localRange = localRange / 2; } } if (GUILayout.Button("+", GUILayout.Width(25))) { if (localRange > 79999) { } else { localRange = localRange * 2; } } GUI.enabled = true; GUILayout.FlexibleSpace(); if (!foldedIn) { GUILayout.Label("Group:"); } else { GUILayout.Label("Group"); } // GUILayout.Space(5); GUI.enabled = showLocal; if (!foldedIn) { customgroup = GUILayout.TextField(customgroup, 25, GUILayout.Width(125)); } else { customgroup = GUILayout.TextField(customgroup, 25, GUILayout.Width(45)); } GUI.enabled = true; GUI.enabled = showLocal; if (!foldedIn) { sButtonText = "Set as Group"; } else { sButtonText = "Set"; } if (!foldedIn) { fButtonWidth = 100; } else { fButtonWidth = 35; } if (GUILayout.Button("" + sButtonText, GUILayout.Width(fButtonWidth))) { setLocalsGroup(customgroup, localRange); smessage = "Set group as " + customgroup; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } GUI.enabled = true; GUILayout.EndHorizontal(); } GUILayout.Space(1); GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); if (GUI.tooltip != "") { var labelSize = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(GUI.tooltip)); GUI.Box(new Rect(Event.current.mousePosition.x - (25 + (labelSize.x / 2)), Event.current.mousePosition.y - 40, labelSize.x + 10, labelSize.y + 5), GUI.tooltip); } GUI.DragWindow(new Rect(0, 0, 10000, 10000)); }
public ScreenMsgEntry(string text, float durationInSeconds, ScreenMessageStyle location) { Text = text; Duration = durationInSeconds; Location = location; }
public void drawSelectorWindow(int id) { ButtonKK = new GUIStyle(GUI.skin.button); ButtonKK.padding.left = 0; ButtonKK.padding.right = 0; DeadButton = new GUIStyle(GUI.skin.button); DeadButton.normal.background = null; DeadButton.hover.background = null; DeadButton.active.background = null; DeadButton.focused.background = null; DeadButton.normal.textColor = Color.white; DeadButton.hover.textColor = Color.white; DeadButton.active.textColor = Color.white; DeadButton.focused.textColor = Color.white; DeadButton.fontSize = 14; DeadButton.fontStyle = FontStyle.Bold; DeadButtonRed = new GUIStyle(GUI.skin.button); DeadButtonRed.normal.background = null; DeadButtonRed.hover.background = null; DeadButtonRed.active.background = null; DeadButtonRed.focused.background = null; DeadButtonRed.normal.textColor = Color.red; DeadButtonRed.hover.textColor = Color.yellow; DeadButtonRed.active.textColor = Color.red; DeadButtonRed.focused.textColor = Color.red; DeadButtonRed.fontSize = 12; DeadButtonRed.fontStyle = FontStyle.Bold; BoxNoBorder = new GUIStyle(GUI.skin.box); BoxNoBorder.normal.background = null; BoxNoBorder.normal.textColor = Color.white; string smessage = ""; ScreenMessageStyle smsStyle = (ScreenMessageStyle)2; GUILayout.BeginHorizontal(); { GUI.enabled = false; GUILayout.Button("-KK-", DeadButton, GUILayout.Height(21)); GUILayout.FlexibleSpace(); GUILayout.Button("Launchsite Selector", DeadButton, GUILayout.Height(21)); GUILayout.FlexibleSpace(); GUI.enabled = true; if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(21))) { InputLockManager.RemoveControlLock("KKEditorLock"); InputLockManager.RemoveControlLock("KKEditorLock2"); KerbalKonstructs.instance.showSiteSelector = false; } } GUILayout.EndHorizontal(); GUILayout.Space(1); GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); GUILayout.BeginHorizontal(); { GUILayout.Space(5); if (MiscUtils.isCareerGame()) { if (bOpenOn) { tHolder = tOpenBasesOn; } else { tHolder = tOpenBasesOff; } if (GUILayout.Button(new GUIContent(tHolder, "Open"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32))) { if (bOpenOn) { bOpenOn = false; bClosedOn = true; } else { bOpenOn = true; } } if (bClosedOn) { tHolder = tClosedBasesOn; } else { tHolder = tClosedBasesOff; } if (GUILayout.Button(new GUIContent(tHolder, "Closed"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32))) { if (bClosedOn) { bClosedOn = false; bOpenOn = true; } else { bClosedOn = true; } } GUILayout.FlexibleSpace(); } if (bFavesOnly) { tHolder = tFavesOn; } else { tHolder = tFavesOff; } if (GUILayout.Button(new GUIContent(tHolder, "Only Favourites"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32))) { if (bFavesOnly) { bFavesOnly = false; } else { bFavesOnly = true; } } GUILayout.FlexibleSpace(); if (editorType == SiteType.SPH) { GUI.enabled = false; } if (bRocketpadsOn) { tHolder = tLaunchpadsOn; } else { tHolder = tLaunchpadsOff; } if (GUILayout.Button(new GUIContent(tHolder, "Rocketpads"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32))) { bRocketpadsOn = true; bHelipadsOn = false; bRunwaysOn = false; bOtherOn = false; sites = (editorType == SiteType.Any) ? LaunchSiteManager.getLaunchSites() : LaunchSiteManager.getLaunchSites(editorType, true, "RocketPad"); } GUI.enabled = true; GUILayout.Space(2); if (editorType == SiteType.VAB) { GUI.enabled = false; } if (bRunwaysOn) { tHolder = tRunwaysOn; } else { tHolder = tRunwaysOff; } if (GUILayout.Button(new GUIContent(tHolder, "Runways"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32))) { bRunwaysOn = true; bHelipadsOn = false; bRocketpadsOn = false; bOtherOn = false; sites = (editorType == SiteType.Any) ? LaunchSiteManager.getLaunchSites() : LaunchSiteManager.getLaunchSites(editorType, true, "Runway"); } GUI.enabled = true; GUILayout.Space(2); if (editorType == SiteType.VAB) { GUI.enabled = false; } if (bHelipadsOn) { tHolder = tHelipadsOn; } else { tHolder = tHelipadsOff; } if (GUILayout.Button(new GUIContent(tHolder, "Helipads"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32))) { bRocketpadsOn = false; bHelipadsOn = true; bRunwaysOn = false; bOtherOn = false; sites = (editorType == SiteType.Any) ? LaunchSiteManager.getLaunchSites() : LaunchSiteManager.getLaunchSites(editorType, true, "Helipad"); } GUI.enabled = true; GUILayout.Space(2); if (bOtherOn) { tHolder = tOtherOn; } else { tHolder = tOtherOff; } if (GUILayout.Button(new GUIContent(tHolder, "Other"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32))) { bRocketpadsOn = false; bHelipadsOn = false; bRunwaysOn = false; bOtherOn = true; sites = (editorType == SiteType.Any) ? LaunchSiteManager.getLaunchSites() : LaunchSiteManager.getLaunchSites(editorType, true, "Other"); } GUILayout.FlexibleSpace(); if (GUILayout.Button("ALL", GUILayout.Width(32), GUILayout.Height(32))) { bRocketpadsOn = true; bHelipadsOn = true; bRunwaysOn = true; bOtherOn = true; sites = (editorType == SiteType.Any) ? LaunchSiteManager.getLaunchSites() : LaunchSiteManager.getLaunchSites(editorType, true, "ALL"); } } GUILayout.EndHorizontal(); GUILayout.Space(10); sitesScrollPosition = GUILayout.BeginScrollView(sitesScrollPosition); { if (sites == null) { sites = (editorType == SiteType.Any) ? LaunchSiteManager.getLaunchSites() : LaunchSiteManager.getLaunchSites(editorType, true, "ALL"); } sites.Sort(delegate(LaunchSite a, LaunchSite b) { return((a.name).CompareTo(b.name)); }); foreach (LaunchSite site in sites) { if (bFavesOnly) { if (site.favouritesite != "Yes") { continue; } } if (MiscUtils.isCareerGame()) { if (!bOpenOn) { if (site.openclosestate == "Open" || site.opencost == 0) { continue; } } if (!bClosedOn) { if (site.openclosestate == "Closed") { continue; } } GUILayout.BeginHorizontal(); if (site.openclosestate == "Open" || site.opencost == 0) { site.setOpenClose("Open"); GUILayout.Label(tIconOpen, GUILayout.Height(30), GUILayout.Width(30)); } else { GUILayout.Label(tIconClosed, GUILayout.Height(30), GUILayout.Width(30)); } } GUI.enabled = !(selectedSite == site); string sButtonName = ""; sButtonName = site.name; if (site.name == "Runway") { sButtonName = "KSC Runway"; } if (site.name == "LaunchPad") { sButtonName = "KSC LaunchPad"; } if (GUILayout.Button(sButtonName, GUILayout.Height(30))) { selectedSite = site; if (!MiscUtils.isCareerGame()) { LaunchSiteManager.setLaunchSite(site); smessage = "Launchsite set to " + sButtonName; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } } GUI.enabled = true; if (MiscUtils.isCareerGame()) { if (site.openclosestate == "Open" || site.opencost == 0) { site.setOpenClose("Open"); GUILayout.Label(tIconOpen, GUILayout.Height(30), GUILayout.Width(30)); } else { GUILayout.Label(tIconClosed, GUILayout.Height(30), GUILayout.Width(30)); } GUILayout.EndHorizontal(); } } } GUILayout.EndScrollView(); GUILayout.Space(5); sCurrentSite = LaunchSiteManager.getCurrentLaunchSite(); if (sCurrentSite != null) { if (sCurrentSite == "Runway") { GUILayout.Box("Current Launchsite: KSC Runway"); } else if (sCurrentSite == "LaunchPad") { GUILayout.Box("Current Launchsite: KSC LaunchPad"); } else { GUILayout.Box("Current Launchsite: " + sCurrentSite); } } GUILayout.BeginHorizontal(); { if (editorType == SiteType.SPH) { GUI.enabled = (KerbalKonstructs.instance.defaultSPHlaunchsite != sCurrentSite); } if (editorType == SiteType.VAB) { GUI.enabled = (KerbalKonstructs.instance.defaultVABlaunchsite != sCurrentSite); } if (GUILayout.Button("Set as Default", GUILayout.Height(23))) { if (sCurrentSite != null) { if (editorType == SiteType.SPH) { KerbalKonstructs.instance.defaultSPHlaunchsite = sCurrentSite; } if (editorType == SiteType.VAB) { KerbalKonstructs.instance.defaultVABlaunchsite = sCurrentSite; } } } GUI.enabled = true; LaunchSite DefaultSite = null; if (GUILayout.Button("Use Default", GUILayout.Height(23))) { if (editorType == SiteType.SPH) { foreach (LaunchSite site in sites) { if (site.name == KerbalKonstructs.instance.defaultSPHlaunchsite) { DefaultSite = site; } } if (DefaultSite != null) { if (MiscUtils.isCareerGame()) { if (DefaultSite.openclosestate == "Closed" && DefaultSite.opencost != 0) { smessage = "Default site is closed."; ScreenMessages.PostScreenMessage(smessage, 10, 0); } else { LaunchSiteManager.setLaunchSite(DefaultSite); } } else { LaunchSiteManager.setLaunchSite(DefaultSite); } } } if (editorType == SiteType.VAB) { foreach (LaunchSite site in sites) { if (site.name == KerbalKonstructs.instance.defaultVABlaunchsite) { DefaultSite = site; } } if (DefaultSite != null) { if (MiscUtils.isCareerGame()) { if (DefaultSite.openclosestate == "Closed" && DefaultSite.opencost != 0) { smessage = "Default site is closed."; ScreenMessages.PostScreenMessage(smessage, 10, 0); } else { LaunchSiteManager.setLaunchSite(DefaultSite); } } else { LaunchSiteManager.setLaunchSite(DefaultSite); } } } if (DefaultSite != null) { smessage = DefaultSite.name + " has been set as the launchsite"; ScreenMessages.PostScreenMessage(smessage, 10, 0); } else { smessage = "KK could not determine the default launchsite."; ScreenMessages.PostScreenMessage(smessage, 10, 0); } } } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); GUI.enabled = true; if (selectedSite != null) { BaseManager.setSelectedSite(selectedSite); KerbalKonstructs.instance.showBaseManager = true; } else { if (LaunchSiteManager.getLaunchSites().Count > 0) { selectedSite = LaunchSiteManager.getLaunchSites(editorType)[0]; LaunchSiteManager.setLaunchSite(selectedSite); BaseManager.setSelectedSite(selectedSite); KerbalKonstructs.instance.showBaseManager = true; } else { Debug.LogError("KK: ERROR Launch Selector cannot find KSC Runway or Launch Pad! PANIC! Runaway! Hide!"); } } if (GUI.tooltip != "") { var labelSize = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(GUI.tooltip)); GUI.Box(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y + 20, labelSize.x + 2, labelSize.y + 2), GUI.tooltip, BoxNoBorder); } GUI.DragWindow(new Rect(0, 0, 10000, 10000)); }
/// <summary> /// Posts a message in the screen /// </summary> public static ScreenMessage PostScreenMessage(string text, float durationInSeconds, ScreenMessageStyle location) { return(PostScreenMessage(text, durationInSeconds, location, Color.green)); }
/// <summary> /// Posts a message in the screen /// </summary> public static ScreenMessage PostScreenMessage(string text, float durationInSeconds, ScreenMessageStyle location, Color color) { if (MainSystem.IsUnityThread) { return(ScreenMessages.PostScreenMessage(text, durationInSeconds, location, color)); } Queue.Enqueue(CreateMessage(text, durationInSeconds, location, color)); return(null); }
public extern ScreenMessage(string msg, float dur, ScreenMessageStyle s, GUIStyle guiStyle);
public extern ScreenMessage(string msg, float dur, bool persistAcrossScenes, ScreenMessageStyle s, GUIStyle guiStyle);
public extern ScreenMessage(string msg, float dur, ScreenMessageStyle s);
public void drawStaticInfoWindow(int WindowID) { if (mModel == null) { return; } BoxNoBorder = new GUIStyle(GUI.skin.box); BoxNoBorder.normal.background = null; BoxNoBorder.normal.textColor = Color.white; DeadButton = new GUIStyle(GUI.skin.button); DeadButton.normal.background = null; DeadButton.hover.background = null; DeadButton.active.background = null; DeadButton.focused.background = null; DeadButton.normal.textColor = Color.yellow; DeadButton.hover.textColor = Color.white; DeadButton.active.textColor = Color.yellow; DeadButton.focused.textColor = Color.yellow; DeadButton.fontSize = 14; DeadButton.fontStyle = FontStyle.Normal; DeadButtonRed = new GUIStyle(GUI.skin.button); DeadButtonRed.normal.background = null; DeadButtonRed.hover.background = null; DeadButtonRed.active.background = null; DeadButtonRed.focused.background = null; DeadButtonRed.normal.textColor = Color.red; DeadButtonRed.hover.textColor = Color.yellow; DeadButtonRed.active.textColor = Color.red; DeadButtonRed.focused.textColor = Color.red; DeadButtonRed.fontSize = 12; DeadButtonRed.fontStyle = FontStyle.Bold; if (currPreview != null) { double dTicker = Planetarium.GetUniversalTime(); if ((dTicker - dUpdater) > 0.01) { dUpdater = Planetarium.GetUniversalTime(); if (bSpinning) { SpinPreview(currPreview); } } } bool shouldUpdateSelection = false; string smessage = ""; ScreenMessageStyle smsStyle = (ScreenMessageStyle)2; GUILayout.BeginHorizontal(); { GUI.enabled = false; GUILayout.Button("-KK-", DeadButton, GUILayout.Height(21)); GUILayout.FlexibleSpace(); GUILayout.Button("Static Model Config Editor", DeadButton, GUILayout.Height(21)); GUILayout.FlexibleSpace(); GUI.enabled = true; if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(21))) { if (currPreview != null) { DestroyPreviewInstance(currPreview); } KerbalKonstructs.instance.showModelInfo = false; mModel = null; KerbalKonstructs.instance.selectedModel = null; } } GUILayout.EndHorizontal(); GUILayout.Space(1); GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); GUILayout.Box(" " + infTitle + " "); GUILayout.Space(3); GUILayout.Box("Mesh: " + infMesh + ".mu"); GUILayout.Box("Manufacturer: " + infManufacturer); GUILayout.Box("Author: " + infAuthor); GUILayout.Space(3); GUILayout.BeginHorizontal(); GUILayout.Label("Category: "); GUILayout.FlexibleSpace(); infCategory = GUILayout.TextField(infCategory, GUILayout.Width(150)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Cost: "); GUILayout.FlexibleSpace(); infCost = GUILayout.TextField(infCost, GUILayout.Width(150)); GUILayout.EndHorizontal(); GUILayout.Label("Description"); infDescription = GUILayout.TextArea(infDescription, GUILayout.Height(100)); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Save", GUILayout.Height(23))) { updateSettings(mModel); KerbalKonstructs.instance.saveObjects(); smessage = "Saved all changes to all static models and instances."; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } if (GUILayout.Button("Close", GUILayout.Height(23))) { if (currPreview != null) { DestroyPreviewInstance(currPreview); } KerbalKonstructs.instance.showModelInfo = false; mModel = null; KerbalKonstructs.instance.selectedModel = null; } GUILayout.EndHorizontal(); if (currPreview != null) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Delete Preview", GUILayout.Height(23))) { DestroyPreviewInstance(currPreview); } if (bSpinning) { if (GUILayout.Button("Stop Spin", GUILayout.Height(23))) { bSpinning = false; } } else { if (GUILayout.Button("Resume Spin", GUILayout.Height(23))) { bSpinning = true; } } GUILayout.EndHorizontal(); } if (Event.current.keyCode == KeyCode.Return) { ScreenMessages.PostScreenMessage("Applied changes to object.", 10, smsStyle); shouldUpdateSelection = true; } if (shouldUpdateSelection) { updateSettings(mModel); updateSelection(mModel); } GUILayout.Space(1); GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); GUI.DragWindow(new Rect(0, 0, 10000, 10000)); }
public static void FuelTanksInterface(StaticObject selectedObject) { string smessage = ""; ScreenMessageStyle smsStyle = (ScreenMessageStyle)2; string sFacilityName = (string)selectedObject.model.getSetting("title"); string sFacilityRole = (string)selectedObject.getSetting("FacilityType"); fLqFMax = (float)selectedObject.model.getSetting("LqFMax"); fLqFCurrent = (float)selectedObject.getSetting("LqFCurrent"); fOxFMax = (float)selectedObject.model.getSetting("OxFMax"); fOxFCurrent = (float)selectedObject.getSetting("OxFCurrent"); fMoFMax = (float)selectedObject.model.getSetting("MoFMax"); fMoFCurrent = (float)selectedObject.getSetting("MoFCurrent"); float fPurchaseRate = fTransferRate * 100f; LabelInfo = new GUIStyle(GUI.skin.label); LabelInfo.normal.background = null; LabelInfo.normal.textColor = Color.white; LabelInfo.fontSize = 13; LabelInfo.fontStyle = FontStyle.Bold; LabelInfo.padding.left = 3; LabelInfo.padding.top = 0; LabelInfo.padding.bottom = 0; BoxInfo = new GUIStyle(GUI.skin.box); BoxInfo.normal.textColor = Color.cyan; BoxInfo.fontSize = 13; BoxInfo.padding.top = 2; BoxInfo.padding.bottom = 1; BoxInfo.padding.left = 5; BoxInfo.padding.right = 5; BoxInfo.normal.background = null; if (!FlightGlobals.ActiveVessel.Landed) { GUILayout.Box("A vessel must be landed to use this facility.", BoxInfo); LockFuelTank(); } var vDist = Vector3.Distance(selectedObject.gameObject.transform.position, FlightGlobals.ActiveVessel.transform.position); if ((double)vDist < KerbalKonstructs.instance.facilityUseRange) { } else { GUILayout.Box("A vessel must be in range to use this facility.", BoxInfo); LockFuelTank(); } GUILayout.Space(3); GUILayout.Label("Fuel Stores", LabelInfo); scrollPos4 = GUILayout.BeginScrollView(scrollPos4); if (fLqFMax > 0) { GUILayout.Label("LiquidFuel", LabelInfo); GUILayout.BeginHorizontal(); GUILayout.Label("Max ", LabelInfo); GUI.enabled = false; GUILayout.TextField(string.Format("{0}", fLqFMax), GUILayout.Height(18)); GUI.enabled = true; GUILayout.Label("Current ", LabelInfo); GUI.enabled = false; GUILayout.TextField(fLqFCurrent.ToString("#0.00"), GUILayout.Height(18)); GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Order", GUILayout.Height(18))) { LockFuelTank(); PersistenceUtils.saveStaticPersistence(selectedObject); bOrderedLqF = true; } GUI.enabled = !bLqFIn; if (GUILayout.Button("In", GUILayout.Height(18))) { bLqFIn = true; bLqFOut = false; PersistenceUtils.saveStaticPersistence(selectedObject); } GUI.enabled = !bLqFOut; if (GUILayout.Button("Out", GUILayout.Height(18))) { bLqFOut = true; bLqFIn = false; PersistenceUtils.saveStaticPersistence(selectedObject); } GUI.enabled = bLqFIn || bLqFOut; if (GUILayout.Button("Stop", GUILayout.Height(18))) { bLqFIn = false; bLqFOut = false; PersistenceUtils.saveStaticPersistence(selectedObject); smessage = "Fuel transfer stopped"; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } GUI.enabled = true; GUILayout.EndHorizontal(); } if (bOrderedLqF) { GUILayout.BeginHorizontal(); if (GUILayout.RepeatButton("-", GUILayout.Height(18))) { fLqFAmount = (float.Parse(fLqFAmount) - fPurchaseRate).ToString(); if ((float.Parse(fLqFAmount)) < 0f) { fLqFAmount = "0.00"; } } GUI.enabled = false; GUILayout.TextField(fLqFAmount, GUILayout.Height(18)); GUI.enabled = true; if (GUILayout.RepeatButton("+", GUILayout.Height(18))) { fLqFAmount = (float.Parse(fLqFAmount) + fPurchaseRate).ToString(); if ((float.Parse(fLqFAmount)) > (fLqFMax - fLqFCurrent)) { fLqFAmount = (fLqFMax - fLqFCurrent).ToString(); } } if (GUILayout.Button("Max", GUILayout.Height(18))) { fLqFAmount = (fLqFMax - fLqFCurrent).ToString(); if ((float.Parse(fLqFAmount)) < 0f) { fLqFAmount = "0.00"; } PersistenceUtils.saveStaticPersistence(selectedObject); } float flqFPrice = 0.5f; float fLqFCost = (float.Parse(fLqFAmount)) * flqFPrice; GUILayout.Label("Cost: " + fLqFCost.ToString("#0") + " \\F", LabelInfo); if (GUILayout.Button("Buy", GUILayout.Height(18))) { if ((float)selectedObject.getSetting("LqFCurrent") + (float.Parse(fLqFAmount)) > fLqFMax) { ScreenMessages.PostScreenMessage("Insufficient fuel capacity!", 10, 0); fLqFAmount = "0.00"; } else { if (MiscUtils.isCareerGame()) { double currentfunds = Funding.Instance.Funds; if (fLqFCost > currentfunds) { ScreenMessages.PostScreenMessage("Insufficient funds!", 10, 0); } else { Funding.Instance.AddFunds(-fLqFCost, TransactionReasons.Cheating); selectedObject.setSetting("LqFCurrent", (float)selectedObject.getSetting("LqFCurrent") + (float.Parse(fLqFAmount))); } } else { selectedObject.setSetting("LqFCurrent", (float)selectedObject.getSetting("LqFCurrent") + (float.Parse(fLqFAmount))); } } PersistenceUtils.saveStaticPersistence(selectedObject); } if (GUILayout.Button("Done", GUILayout.Height(18))) { PersistenceUtils.saveStaticPersistence(selectedObject); bOrderedLqF = false; } GUILayout.EndHorizontal(); } if (fOxFMax > 0) { GUILayout.Label("Oxidizer", LabelInfo); GUILayout.BeginHorizontal(); GUILayout.Label("Max ", LabelInfo); GUI.enabled = false; GUILayout.TextField(string.Format("{0}", fOxFMax), GUILayout.Height(18)); GUI.enabled = true; GUILayout.Label("Current ", LabelInfo); GUI.enabled = false; GUILayout.TextField(fOxFCurrent.ToString("#0.00"), GUILayout.Height(18)); GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Order", GUILayout.Height(18))) { LockFuelTank(); PersistenceUtils.saveStaticPersistence(selectedObject); bOrderedOxF = true; } GUI.enabled = !bOxFIn; if (GUILayout.Button("In", GUILayout.Height(18))) { bOxFIn = true; bOxFOut = false; PersistenceUtils.saveStaticPersistence(selectedObject); } GUI.enabled = !bOxFOut; if (GUILayout.Button("Out", GUILayout.Height(18))) { bOxFOut = true; bOxFIn = false; PersistenceUtils.saveStaticPersistence(selectedObject); } GUI.enabled = bOxFIn || bOxFOut; if (GUILayout.Button("Stop", GUILayout.Height(18))) { bOxFIn = false; bOxFOut = false; PersistenceUtils.saveStaticPersistence(selectedObject); smessage = "Fuel transfer stopped"; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } GUI.enabled = true; GUILayout.EndHorizontal(); } if (bOrderedOxF) { GUILayout.BeginHorizontal(); if (GUILayout.RepeatButton("-", GUILayout.Height(18))) { fOxFAmount = (float.Parse(fOxFAmount) - fPurchaseRate).ToString(); if ((float.Parse(fOxFAmount)) < 0f) { fOxFAmount = "0.00"; } } GUI.enabled = false; GUILayout.TextField(fOxFAmount, GUILayout.Height(18)); GUI.enabled = true; if (GUILayout.RepeatButton("+", GUILayout.Height(18))) { fOxFAmount = (float.Parse(fOxFAmount) + fPurchaseRate).ToString(); if ((float.Parse(fOxFAmount)) > (fOxFMax - fOxFCurrent)) { fOxFAmount = (fOxFMax - fOxFCurrent).ToString(); } } if (GUILayout.Button("Max", GUILayout.Height(18))) { fOxFAmount = (fOxFMax - fOxFCurrent).ToString(); if ((float.Parse(fOxFAmount)) < 0f) { fOxFAmount = "0.00"; } PersistenceUtils.saveStaticPersistence(selectedObject); } float fOxFPrice = 1.5f; float fOxFCost = (float.Parse(fOxFAmount)) * fOxFPrice; GUILayout.Label("Cost: " + fOxFCost.ToString("#0") + " \\F", LabelInfo); if (GUILayout.Button("Buy", GUILayout.Height(18))) { if ((float)selectedObject.getSetting("OxFCurrent") + (float.Parse(fOxFAmount)) > fOxFMax) { ScreenMessages.PostScreenMessage("Insufficient fuel capacity!", 10, 0); fOxFAmount = "0.00"; } else { if (MiscUtils.isCareerGame()) { double currentfunds = Funding.Instance.Funds; if (fOxFCost > currentfunds) { ScreenMessages.PostScreenMessage("Insufficient funds!", 10, 0); } else { Funding.Instance.AddFunds(-fOxFCost, TransactionReasons.Cheating); selectedObject.setSetting("OxFCurrent", (float)selectedObject.getSetting("OxFCurrent") + (float.Parse(fOxFAmount))); } } else { selectedObject.setSetting("OxFCurrent", (float)selectedObject.getSetting("OxFCurrent") + (float.Parse(fOxFAmount))); } } PersistenceUtils.saveStaticPersistence(selectedObject); } if (GUILayout.Button("Done", GUILayout.Height(18))) { PersistenceUtils.saveStaticPersistence(selectedObject); bOrderedOxF = false; } GUILayout.EndHorizontal(); } if (fMoFMax > 0) { GUILayout.Label("Monopropellant", LabelInfo); GUILayout.BeginHorizontal(); GUILayout.Label("Max ", LabelInfo); GUI.enabled = false; GUILayout.TextField(string.Format("{0}", fMoFMax), GUILayout.Height(18)); GUI.enabled = true; GUILayout.Label("Current ", LabelInfo); GUI.enabled = false; GUILayout.TextField(fMoFCurrent.ToString("#0.00"), GUILayout.Height(18)); GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Order", GUILayout.Height(18))) { LockFuelTank(); PersistenceUtils.saveStaticPersistence(selectedObject); bOrderedMoF = true; } GUI.enabled = !bMoFIn; if (GUILayout.Button("In", GUILayout.Height(18))) { bMoFIn = true; bMoFOut = false; PersistenceUtils.saveStaticPersistence(selectedObject); } GUI.enabled = !bMoFOut; if (GUILayout.Button("Out", GUILayout.Height(18))) { bMoFOut = true; bMoFIn = false; PersistenceUtils.saveStaticPersistence(selectedObject); } GUI.enabled = bMoFIn || bMoFOut; if (GUILayout.Button("Stop", GUILayout.Height(18))) { bMoFIn = false; bMoFOut = false; PersistenceUtils.saveStaticPersistence(selectedObject); smessage = "Fuel transfer stopped"; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } GUI.enabled = true; GUILayout.EndHorizontal(); } if (bOrderedMoF) { GUILayout.BeginHorizontal(); if (GUILayout.RepeatButton("-", GUILayout.Height(18))) { fMoFAmount = (float.Parse(fMoFAmount) - fPurchaseRate).ToString(); if ((float.Parse(fMoFAmount)) < 0f) { fMoFAmount = "0.00"; } } GUI.enabled = false; GUILayout.TextField(fMoFAmount, GUILayout.Height(18)); GUI.enabled = true; if (GUILayout.RepeatButton("+", GUILayout.Height(18))) { fMoFAmount = (float.Parse(fMoFAmount) + fPurchaseRate).ToString(); if ((float.Parse(fMoFAmount)) > (fMoFMax - fMoFCurrent)) { fMoFAmount = (fMoFMax - fMoFCurrent).ToString(); } } if (GUILayout.Button("Max", GUILayout.Height(18))) { fMoFAmount = (fMoFMax - fMoFCurrent).ToString(); if ((float.Parse(fMoFAmount)) < 0f) { fMoFAmount = "0.00"; } PersistenceUtils.saveStaticPersistence(selectedObject); } float fMoFPrice = 1.2f; float fMoFCost = (float.Parse(fMoFAmount)) * fMoFPrice; GUILayout.Label("Cost: " + fMoFCost.ToString("#0") + " \\F", LabelInfo); if (GUILayout.Button("Buy", GUILayout.Height(18))) { if ((float)selectedObject.getSetting("MoFCurrent") + (float.Parse(fMoFAmount)) > fMoFMax) { ScreenMessages.PostScreenMessage("Insufficient fuel capacity!", 10, 0); fMoFAmount = "0.00"; } else { if (MiscUtils.isCareerGame()) { double currentfunds = Funding.Instance.Funds; if (fMoFCost > currentfunds) { ScreenMessages.PostScreenMessage("Insufficient funds!", 10, 0); } else { Funding.Instance.AddFunds(-fMoFCost, TransactionReasons.Cheating); selectedObject.setSetting("MoFCurrent", (float)selectedObject.getSetting("MoFCurrent") + (float.Parse(fMoFAmount))); } } else { selectedObject.setSetting("MoFCurrent", (float)selectedObject.getSetting("MoFCurrent") + (float.Parse(fMoFAmount))); } } PersistenceUtils.saveStaticPersistence(selectedObject); } if (GUILayout.Button("Done", GUILayout.Height(18))) { PersistenceUtils.saveStaticPersistence(selectedObject); bOrderedMoF = false; } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); if (fOxFMax > 0 || fLqFMax > 0 || fMoFMax > 0) { GUILayout.BeginHorizontal(); GUILayout.Label("Transfer Rate", LabelInfo); GUI.enabled = (fTransferRate != 0.01f); if (GUILayout.Button(" x1", GUILayout.Height(18))) { fTransferRate = 0.01f; PersistenceUtils.saveStaticPersistence(selectedObject); smessage = "Fuel transfer rate set to x1"; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } GUI.enabled = (fTransferRate != 0.04f); if (GUILayout.Button(" x4", GUILayout.Height(18))) { fTransferRate = 0.04f; PersistenceUtils.saveStaticPersistence(selectedObject); smessage = "Fuel transfer rate set to x4"; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } GUI.enabled = (fTransferRate != 0.1f); if (GUILayout.Button("x10", GUILayout.Height(18))) { fTransferRate = 0.1f; PersistenceUtils.saveStaticPersistence(selectedObject); smessage = "Fuel transfer rate set to x10"; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } GUI.enabled = true; GUILayout.EndHorizontal(); if (!FlightGlobals.ActiveVessel.isEVA && FlightGlobals.ActiveVessel.Landed) { GUILayout.Label(FlightGlobals.ActiveVessel.vesselName + "'s Tanks", LabelInfo); scrollPos3 = GUILayout.BeginScrollView(scrollPos3); foreach (Part fTank in FlightGlobals.ActiveVessel.parts) { foreach (PartResource rResource in fTank.Resources) { if (rResource.resourceName == "LiquidFuel" || rResource.resourceName == "Oxidizer" || rResource.resourceName == "MonoPropellant") { if (SelectedTank == fTank && SelectedResource == rResource) { PartSelected = true; } else { PartSelected = false; } GUILayout.BeginHorizontal(); GUILayout.Box("" + fTank.gameObject.name, GUILayout.Height(18)); GUILayout.Box("" + rResource.resourceName, GUILayout.Height(18)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Fuel", LabelInfo); GUI.enabled = false; GUILayout.TextField("" + rResource.amount.ToString("#0.00"), GUILayout.Height(18)); GUI.enabled = true; GUI.enabled = !PartSelected; if (GUILayout.Button(" Select ", GUILayout.Height(18))) { SelectedResource = rResource; SelectedTank = fTank; PersistenceUtils.saveStaticPersistence(selectedObject); } GUI.enabled = PartSelected; if (GUILayout.Button("Deselect", GUILayout.Height(18))) { SelectedResource = null; SelectedTank = null; PersistenceUtils.saveStaticPersistence(selectedObject); } GUI.enabled = true; GUILayout.EndHorizontal(); } else { continue; } } } GUILayout.EndScrollView(); GUI.enabled = true; if (SelectedResource != null && SelectedTank != null) { if (bMoFOut || bOxFOut || bLqFOut) { doFuelOut(selectedObject); } if (bMoFIn || bOxFIn || bLqFIn) { doFuelIn(selectedObject); } } } } GUI.DragWindow(new Rect(0, 0, 10000, 10000)); }
private static ScreenMessage CreateMessage(string text, float durationInSeconds, ScreenMessageStyle location, Color color) { return(new ScreenMessage(text, durationInSeconds, location) { color = color }); }
public static void HUDMessage(string sMessage, float fDuration = 10f, int iStyle = 2) { ScreenMessageStyle smsStyle = (ScreenMessageStyle)iStyle; ScreenMessages.PostScreenMessage(sMessage, fDuration, smsStyle); }
/// <summary> /// Posts a message in the screen /// </summary> public static ScreenMessage PostScreenMessage(string text, float durationInSeconds, ScreenMessageStyle location) { if (MainSystem.IsUnityThread) { return(ScreenMessages.PostScreenMessage(text, durationInSeconds, location)); } Queue.Enqueue(new ScreenMsgEntry(text, durationInSeconds, location)); return(null); }
private void writeScreenMessage(ScreenMessageStyle position, string Message, float duration = 1.5f) { ScreenMessages.PostScreenMessage(Message, duration, position); }
/// <summary>Shows a formatted message with the specified location and timeout.</summary> /// <param name="style">A <c>ScreenMessageStyle</c> specifier.</param> /// <param name="duration">Delay before hiding the message in seconds.</param> /// <param name="fmt"><c>String.Format()</c> formatting string.</param> /// <param name="args">Arguments for the formattign string.</param> public static void ShowScreenMessage(ScreenMessageStyle style, float duration, String fmt, params object[] args) { ScreenMessages.PostScreenMessage(String.Format(fmt, args), duration, style); }
void drawBaseManagerWindow(int windowID) { string Base; float Range; LaunchSite lNearest; LaunchSite lBase; string smessage = ""; ScreenMessageStyle smsStyle = (ScreenMessageStyle)2; BoxNoBorder = new GUIStyle(GUI.skin.box); BoxNoBorder.normal.background = null; BoxNoBorder.normal.textColor = Color.white; LabelInfo = new GUIStyle(GUI.skin.label); LabelInfo.normal.background = null; LabelInfo.normal.textColor = Color.white; LabelInfo.fontSize = 13; LabelInfo.fontStyle = FontStyle.Bold; LabelInfo.padding.left = 3; LabelInfo.padding.top = 0; LabelInfo.padding.bottom = 0; DeadButton = new GUIStyle(GUI.skin.button); DeadButton.normal.background = null; DeadButton.hover.background = null; DeadButton.active.background = null; DeadButton.focused.background = null; DeadButton.normal.textColor = Color.white; DeadButton.hover.textColor = Color.white; DeadButton.active.textColor = Color.white; DeadButton.focused.textColor = Color.white; DeadButton.fontSize = 14; DeadButton.fontStyle = FontStyle.Bold; DeadButtonRed = new GUIStyle(GUI.skin.button); DeadButtonRed.normal.background = null; DeadButtonRed.hover.background = null; DeadButtonRed.active.background = null; DeadButtonRed.focused.background = null; DeadButtonRed.normal.textColor = Color.red; DeadButtonRed.hover.textColor = Color.yellow; DeadButtonRed.active.textColor = Color.red; DeadButtonRed.focused.textColor = Color.red; DeadButtonRed.fontSize = 12; DeadButtonRed.fontStyle = FontStyle.Bold; GUILayout.BeginHorizontal(); { GUI.enabled = false; GUILayout.Button("-KK-", DeadButton, GUILayout.Height(16)); GUILayout.FlexibleSpace(); GUILayout.Button("Inflight Base Boss", DeadButton, GUILayout.Height(16)); GUILayout.FlexibleSpace(); GUI.enabled = true; if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(16))) { bShowFacilities = false; KerbalKonstructs.instance.showFlightManager = false; } } GUILayout.EndHorizontal(); GUILayout.Space(1); GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(5); GUILayout.Box("Flight Tools", BoxNoBorder); GUILayout.BeginHorizontal(); { GUILayout.Space(2); GUILayout.Label("ATC ", LabelInfo); if (KerbalKonstructs.instance.enableATC) { tToggle = tIconOpen; } else { tToggle = tIconClosed; } if (GUILayout.Button(tToggle, GUILayout.Height(18), GUILayout.Width(18))) { if (KerbalKonstructs.instance.enableATC) { KerbalKonstructs.instance.enableATC = false; } else { KerbalKonstructs.instance.enableATC = true; } } KerbalKonstructs.instance.showATC = (KerbalKonstructs.instance.enableATC); GUILayout.FlexibleSpace(); GUILayout.Label("NGS ", LabelInfo); if (KerbalKonstructs.instance.enableNGS) { tToggle2 = tIconOpen; } else { tToggle2 = tIconClosed; } if (GUILayout.Button(tToggle2, GUILayout.Height(18), GUILayout.Width(18))) { if (KerbalKonstructs.instance.enableNGS) { KerbalKonstructs.instance.enableNGS = false; } else { KerbalKonstructs.instance.enableNGS = true; } } KerbalKonstructs.instance.showNGS = (KerbalKonstructs.instance.enableNGS); GUILayout.FlexibleSpace(); GUILayout.Label("Downlink ", LabelInfo); if (KerbalKonstructs.instance.enableDownlink) { tToggle2 = tIconOpen; } else { tToggle2 = tIconClosed; } if (GUILayout.Button(tToggle2, GUILayout.Height(18), GUILayout.Width(18))) { if (KerbalKonstructs.instance.enableDownlink) { KerbalKonstructs.instance.enableDownlink = false; } else { KerbalKonstructs.instance.enableDownlink = true; } } KerbalKonstructs.instance.showDownlink = (KerbalKonstructs.instance.enableDownlink); GUILayout.Space(2); } GUILayout.EndHorizontal(); GUILayout.Space(6); GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); GUILayout.Box("Base Proximity", BoxNoBorder); if (MiscUtils.isCareerGame()) { GUILayout.BeginHorizontal(); { string snearestopen = ""; LaunchSiteManager.getNearestOpenBase(FlightGlobals.ActiveVessel.GetTransform().position, out Base, out Range, out lNearest); if (Range < 10000) { snearestopen = Base + " at " + Range.ToString("#0.0") + " m"; } else { snearestopen = Base + " at " + (Range / 1000).ToString("#0.0") + " km"; } GUILayout.Space(5); GUILayout.Label("Nearest Open: ", LabelInfo); GUILayout.Label(snearestopen, LabelInfo, GUILayout.Width(150)); if (KerbalKonstructs.instance.enableNGS) { GUILayout.FlexibleSpace(); if (GUILayout.Button("NGS", GUILayout.Height(21))) { NavGuidanceSystem.setTargetSite(lNearest); smessage = "NGS set to " + Base; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } } } GUILayout.EndHorizontal(); GUILayout.Space(2); } GUILayout.BeginHorizontal(); { string sNearestbase = ""; LaunchSiteManager.getNearestBase(FlightGlobals.ActiveVessel.GetTransform().position, out Base, out Range, out lBase); if (Range < 10000) { sNearestbase = Base + " at " + Range.ToString("#0.0") + " m"; } else { sNearestbase = Base + " at " + (Range / 1000).ToString("#0.0") + " km"; } GUILayout.Space(5); GUILayout.Label("Nearest Base: ", LabelInfo); GUILayout.Label(sNearestbase, LabelInfo, GUILayout.Width(150)); if (KerbalKonstructs.instance.enableNGS) { GUILayout.FlexibleSpace(); if (GUILayout.Button("NGS", GUILayout.Height(21))) { NavGuidanceSystem.setTargetSite(lBase); smessage = "NGS set to " + Base; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } } } GUILayout.EndHorizontal(); if (MiscUtils.isCareerGame()) { bool bLanded = (FlightGlobals.ActiveVessel.Landed); if (Range < 2000) { string sClosed; float fOpenCost; LaunchSiteManager.getSiteOpenCloseState(Base, out sClosed, out fOpenCost); fOpenCost = fOpenCost / 2f; if (bLanded && sClosed == "Closed") { GUILayout.Space(2); GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); if (GUILayout.Button("Open Base for " + fOpenCost + " funds", GUILayout.Height(23))) { double currentfunds = Funding.Instance.Funds; if (fOpenCost > currentfunds) { ScreenMessages.PostScreenMessage("Insufficient funds to open this site!", 10, 0); } else { Funding.Instance.AddFunds(-fOpenCost, TransactionReasons.Cheating); LaunchSiteManager.setSiteOpenCloseState(Base, "Open"); smessage = Base + " opened"; ScreenMessages.PostScreenMessage(smessage, 10, smsStyle); } } } if (bLanded && sClosed == "Open") { GUI.enabled = false; GUILayout.Button("Base is Open", GUILayout.Height(23)); GUI.enabled = true; } GUILayout.Space(2); GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); } if (Range > 100000) { if (bLanded) { GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); if (GUILayout.Button("Found a New Base", GUILayout.Height(23))) { foundingBase = true; } GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); } } } if (FlightGlobals.ActiveVessel.Landed) { if (GUILayout.Button("Nearby Facilities", GUILayout.Height(23))) { if (bShowFacilities) { bShowFacilities = false; } else { foreach (StaticObject soStaticobj in KerbalKonstructs.instance.getStaticDB().getAllStatics()) { if ((string)soStaticobj.model.getSetting("DefaultFacilityType") == "None") { continue; } if (soStaticobj.pqsCity.sphere == FlightGlobals.currentMainBody.pqsController) { var dist2 = Vector3.Distance(FlightGlobals.ActiveVessel.GetTransform().position, soStaticobj.gameObject.transform.position); if (dist2 > 5000f) { continue; } } else { continue; } PersistenceUtils.loadStaticPersistence(soStaticobj); } bShowFacilities = true; } } scrollPos = GUILayout.BeginScrollView(scrollPos); if (bShowFacilities) { foreach (StaticObject obj in KerbalKonstructs.instance.getStaticDB().getAllStatics()) { bool isLocal = true; if (obj.pqsCity.sphere == FlightGlobals.currentMainBody.pqsController) { var dist = Vector3.Distance(FlightGlobals.ActiveVessel.GetTransform().position, obj.gameObject.transform.position); isLocal = dist < 5000f; } else { isLocal = false; } if ((string)obj.model.getSetting("DefaultFacilityType") == "None") { isLocal = false; } if (isLocal) { GUILayout.BeginHorizontal(); { bIsOpen = ((string)obj.getSetting("OpenCloseState") == "Open"); if (!bIsOpen) { iFundsOpen2 = (float)obj.model.getSetting("cost"); if (iFundsOpen2 == 0) { bIsOpen = true; } } if (GUILayout.Button((string)obj.model.getSetting("title"), GUILayout.Height(23))) { selectedObject = obj; KerbalKonstructs.instance.selectObject(obj, false, true, false); PersistenceUtils.loadStaticPersistence(obj); FacilityManager.setSelectedFacility(obj); KerbalKonstructs.instance.showFacilityManager = true; } if (bIsOpen) { GUILayout.Label(tIconOpen, GUILayout.Height(23), GUILayout.Width(23)); } if (!bIsOpen) { GUILayout.Label(tIconClosed, GUILayout.Height(23), GUILayout.Width(23)); } } GUILayout.EndHorizontal(); } } } else { GUILayout.Label("Click the button above to display a list of nearby operational facilities.", LabelInfo); if (KerbalKonstructs.instance.DebugMode) { GUILayout.Box("Debug Mode ActiveVessel Report"); GUILayout.Label("Name " + FlightGlobals.ActiveVessel.vesselName); GUILayout.Label("Acceleration " + FlightGlobals.ActiveVessel.acceleration.ToString()); GUILayout.Label("Angular Momentum " + FlightGlobals.ActiveVessel.angularMomentum.ToString("#0.000")); GUILayout.Label("Angular Velocity " + FlightGlobals.ActiveVessel.angularVelocity.ToString("#0.000")); GUILayout.Label("Centrifugal Acc " + FlightGlobals.ActiveVessel.CentrifugalAcc.ToString()); GUILayout.Label("Horiz Srf Speed " + FlightGlobals.ActiveVessel.horizontalSrfSpeed.ToString("#0.00")); GUILayout.Label("Indicated Air Speed " + FlightGlobals.ActiveVessel.indicatedAirSpeed.ToString("#0.00")); GUILayout.Label("Mach " + FlightGlobals.ActiveVessel.mach.ToString("#0.00")); GUILayout.Label("Orbit Speed " + FlightGlobals.ActiveVessel.obt_speed.ToString("#0.00")); GUILayout.Label("Orbit Velocity " + FlightGlobals.ActiveVessel.obt_velocity.ToString()); GUILayout.Label("Perturbation " + FlightGlobals.ActiveVessel.perturbation.ToString()); GUILayout.Label("rb_velocity " + FlightGlobals.ActiveVessel.rb_velocity.ToString("#0.000")); GUILayout.Label("Specific Acc " + FlightGlobals.ActiveVessel.specificAcceleration.ToString("#0.00")); GUILayout.Label("speed " + FlightGlobals.ActiveVessel.speed.ToString("#0.00")); GUILayout.Label("srf_velocity " + FlightGlobals.ActiveVessel.srf_velocity.ToString()); GUILayout.Label("srfspeed " + FlightGlobals.ActiveVessel.srfSpeed.ToString("#0.00")); } } } GUILayout.EndScrollView(); GUILayout.Space(2); GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); GUILayout.FlexibleSpace(); GUILayout.Space(3); if (GUILayout.Button("I want to race!", GUILayout.Height(23))) { KerbalKonstructs.instance.showRacingApp = true; AirRacing.runningRace = true; KerbalKonstructs.instance.showNGS = false; KerbalKonstructs.instance.showFlightManager = false; } GUILayout.Space(5); GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); GUI.DragWindow(new Rect(0, 0, 10000, 10000)); }
protected void writeScreenMessage(string Message, float duration = 3f, ScreenMessageStyle messagePosition = ScreenMessageStyle.UPPER_RIGHT) { ScreenMessages.PostScreenMessage(Message, duration, messagePosition); }
public static void Message(string message, float duration = 2f, ScreenMessageStyle style = ScreenMessageStyle.UPPER_CENTER) { ScreenMessages.PostScreenMessage(new ScreenMessage(message, duration, style)); }