private void AcquireProcessors() { pMList.Clear(); foreach (Part p in FlightGlobals.ActiveVessel.Parts) { CactEyeProcessor cP = p.GetComponent <CactEyeProcessor>(); if (cP != null) { if (!pMList.Contains(cP)) { pMList.Add(cP); } } } }
private void mainGUI(int windowID) { if (procModule == null && pMList.Count != 0) procModule = pMList[0]; GUILayout.BeginVertical(GUILayout.ExpandHeight(true)); if (procModule != null) { if (opticsModule != null && tex != null) { if (!opticsModule.isDamaged) { if (!opticsModule.isSmallOptics ^ opticsModule.smallApertureOpen) { GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft; GUILayout.Label("Zoom"); //Formatting zoom amount string zoom; if (opticsModule.fov > 0.064) zoom = "X " + string.Format("{0:##0.0}", 64 / opticsModule.fov); else { zoom = "X " + string.Format("{0:0.00E+0}", (64 / opticsModule.fov)); int pow = int.Parse(zoom.Substring(zoom.Length - 1)); if (pow > 9) print("ERROR: Telescope zooms in more than 10^" + pow + "!!!"); zoom = zoom.Replace("E+", "x10"); zoom = zoom.Remove(zoom.Length - 1); zoom += uPow[pow]; } GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperRight; GUILayout.Label(zoom); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperCenter; fov = GUILayout.HorizontalSlider(fov, 0f, 1f); //print("minFOV: " + procModule.minFOV + " || ^1/3: " + Mathf.Pow(procModule.minFOV, 1f / 3f)); opticsModule.fov = 0.5f * Mathf.Pow(4f - fov * (4f - Mathf.Pow(procModule.minFOV, 1f / 3f)), 3); GUILayout.EndHorizontal(); GUILayout.Space(texRect.height); tex = opticsModule.outputTex; GUI.Box(new Rect(texRect.xMin - 2, texRect.yMin - 2, texRect.width + 4, texRect.height + 4), ""); GUI.DrawTexture(texRect, tex); //GUILayout.Box("", GUILayout.Width(texRect.width), GUILayout.Height(texRect.height)); GUI.DrawTexture(new Rect(texRect.xMin, texRect.yMax - 32f, 128f, 32f), preview); GUI.DrawTexture(new Rect(texRect.xMin + (0.5f * texRect.width) - 64, texRect.yMin + (0.5f * texRect.height) - 64, 128, 128), crosshair); if (timer < 5f) { GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft; GUI.Label(new Rect(texRect.xMin, texRect.yMin, 480, 50), new GUIContent(dispText)); } if (FlightGlobals.fetch.VesselTarget != null) { string targetName = FlightGlobals.fetch.VesselTarget.GetName(); Vector2 vec = opticsModule.GetTargetPos(FlightGlobals.fetch.VesselTarget.GetTransform().position, texRect.width); if (vec.x > 16 && vec.y > 16 && vec.x < texRect.width - 16 && vec.y < texRect.height - 16) { GUI.DrawTexture(new Rect(vec.x + texRect.xMin - 16, vec.y + texRect.yMin - 16, 32, 32), targetPointer); Vector2 size = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(targetName)); if (vec.x > 0.5 * size.x && vec.x < texRect.width - (0.5 * size.x) && vec.y < texRect.height - 16 - size.y) { GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperCenter; GUI.Label(new Rect(vec.x + texRect.xMin - (0.5f * size.x), vec.y + texRect.yMin + 20, size.x, size.y), targetName); } } if (procModule.techType == "Planetary" && procModule.isActive && procModule.isFunctional) { if (GUI.Button(new Rect(texRect.xMax - 36, texRect.yMax - 36, 32, 32), save)) DisplayText("Saved screenshot to " + opticsModule.GetTex(true, targetName)); } } } else { GUILayout.BeginHorizontal(); GUILayout.Label("FungEye optics aperture closed."); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Note that you can never close the aperture again once you open them with these optics!"); GUILayout.EndHorizontal(); } } else { GUILayout.BeginHorizontal(); GUILayout.Label("Optics module has been damaged by the sun! Repair must be made to optics module during an EVA."); //print("FONT SIZE: " + GUI.skin.GetStyle("Label").fontSize); GUILayout.EndHorizontal(); } } else { GUILayout.BeginHorizontal(); GUILayout.Label("No optics detected!"); GUILayout.EndHorizontal(); } GUILayout.Space(10f); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleCenter; string targetstring; if (FlightGlobals.fetch.VesselTarget == null) targetstring = "No target selected"; else targetstring = "Target: " + FlightGlobals.fetch.VesselTarget.GetName(); GUILayout.Label(targetstring, GUILayout.Height(30f), GUILayout.Width(370f)); if (GUILayout.Button("Select Target", GUILayout.Height(30f))) targetOpen = !targetOpen; GUILayout.EndHorizontal(); GUILayout.Space(10f); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleLeft; GUILayout.Label("Processor: ", GUILayout.Width(100f), GUILayout.Height(30f)); GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleCenter; if (GUILayout.Button(procModule.pName, GUILayout.Height(30f))) { int pI = pMList.IndexOf(procModule) + 1; if (pI > pMList.Count - 1) procModule = pMList[0]; else procModule = pMList[pI]; } GUILayout.Space(15); GUILayout.Label(procModule.status, GUILayout.Height(30f)); GUILayout.FlexibleSpace(); if (procModule.isFunctional) { if (GUILayout.Button(procModule.isActive ? "Disable" : "Activate", GUILayout.Height(30f), GUILayout.Width(80f))) { procModule.toggle(null); } } GUILayout.EndHorizontal(); if (procModule.isActive && procModule.isFunctional && HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX) { GUILayout.BeginHorizontal(); GUILayout.Label("", GUILayout.Width(100f), GUILayout.Height(30f)); if (procModule.GetScienceCount() == 0) { if (GUILayout.Button("Make Observation", GUILayout.Height(30f))) procModule.observation(); } else { if (GUILayout.Button("Review Data", GUILayout.Height(30f))) procModule.eventReviewScience(); GUILayout.Space(80); if (GUILayout.Button("Dump Data", GUILayout.Height(30f))) procModule.eventReviewScience(); } GUILayout.EndHorizontal(); if (procModule.techType == "Occultation") { GUILayout.BeginHorizontal(); GUILayout.Label("", GUILayout.Width(100f), GUILayout.Height(30f)); CelestialBody planetBody = CactEyeVars.GetPlanetBody(FlightGlobals.ActiveVessel.mainBody); if (planetBody != null) { if (!CactEyeVars.occultationExpTypes.ContainsKey(planetBody)) CactEyeVars.GenerateOccultationExp(planetBody); if (CactEyeVars.occultationExpTypes[planetBody] == "Asteroid") GUILayout.Label("Next occultation: " + CactEyeVars.occultationExpAsteroids[planetBody].vesselName + ", at " + CactEyeVars.GetOccultationExpTimeString(planetBody), GUILayout.Height(30f)); else GUILayout.Label("Next occultation: " + CactEyeVars.occultationExpBodies[planetBody].bodyName + ", at " + CactEyeVars.GetOccultationExpTimeString(planetBody), GUILayout.Height(30f)); //I sure wish I could put a button here to auto create a KAC alarm. Hint hint TriggerAu - make a KAC wrapper! } else GUILayout.Label("Occultation experiment not available in solar orbit!"); GUILayout.EndHorizontal(); } } if (HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX) { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.Label("Science experiments unavailable in sandbox mode!"); GUILayout.EndHorizontal(); } if (gMList.Count != 0) { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleLeft; GUILayout.Label("Gyro Speed: ", GUILayout.Width(100f), GUILayout.Height(30f)); GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleCenter; gSel = GUILayout.SelectionGrid(gSel, gModes, 3, GUILayout.Height(30f)); if (gSel != gSelSt) { if (gSel == 0) { foreach (CactEyeGyro gM in gMList) gM.normScale(null); } if (gSel == 1) { foreach (CactEyeGyro gM in gMList) gM.redScale(null); } if (gSel == 2) { foreach (CactEyeGyro gM in gMList) gM.fineScale(null); } gSelSt = gSel; } GUILayout.EndHorizontal(); } } else { GUILayout.BeginHorizontal(); GUILayout.Label("No processors detected!"); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUI.DragWindow(); GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft; }
private void mainGUI(int windowID) { if (procModule == null && pMList.Count != 0) { procModule = pMList[0]; } GUILayout.BeginVertical(GUILayout.ExpandHeight(true)); if (procModule != null) { if (opticsModule != null && tex != null) { if (!opticsModule.isDamaged) { if (!opticsModule.isSmallOptics ^ opticsModule.smallApertureOpen) { GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft; GUILayout.Label("Zoom"); //Formatting zoom amount string zoom; if (opticsModule.fov > 0.064) { zoom = "X " + string.Format("{0:##0.0}", 64 / opticsModule.fov); } else { zoom = "X " + string.Format("{0:0.00E+0}", (64 / opticsModule.fov)); int pow = int.Parse(zoom.Substring(zoom.Length - 1)); if (pow > 9) { print("ERROR: Telescope zooms in more than 10^" + pow + "!!!"); } zoom = zoom.Replace("E+", "x10"); zoom = zoom.Remove(zoom.Length - 1); zoom += uPow[pow]; } GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperRight; GUILayout.Label(zoom); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperCenter; fov = GUILayout.HorizontalSlider(fov, 0f, 1f); //print("minFOV: " + procModule.minFOV + " || ^1/3: " + Mathf.Pow(procModule.minFOV, 1f / 3f)); opticsModule.fov = 0.5f * Mathf.Pow(4f - fov * (4f - Mathf.Pow(procModule.minFOV, 1f / 3f)), 3); GUILayout.EndHorizontal(); GUILayout.Space(texRect.height); tex = opticsModule.outputTex; GUI.Box(new Rect(texRect.xMin - 2, texRect.yMin - 2, texRect.width + 4, texRect.height + 4), ""); GUI.DrawTexture(texRect, tex); //GUILayout.Box("", GUILayout.Width(texRect.width), GUILayout.Height(texRect.height)); GUI.DrawTexture(new Rect(texRect.xMin, texRect.yMax - 32f, 128f, 32f), preview); GUI.DrawTexture(new Rect(texRect.xMin + (0.5f * texRect.width) - 64, texRect.yMin + (0.5f * texRect.height) - 64, 128, 128), crosshair); if (timer < 5f) { GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft; GUI.Label(new Rect(texRect.xMin, texRect.yMin, 480, 50), new GUIContent(dispText)); } if (FlightGlobals.fetch.VesselTarget != null) { string targetName = FlightGlobals.fetch.VesselTarget.GetName(); Vector2 vec = opticsModule.GetTargetPos(FlightGlobals.fetch.VesselTarget.GetTransform().position, texRect.width); if (vec.x > 16 && vec.y > 16 && vec.x < texRect.width - 16 && vec.y < texRect.height - 16) { GUI.DrawTexture(new Rect(vec.x + texRect.xMin - 16, vec.y + texRect.yMin - 16, 32, 32), targetPointer); Vector2 size = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(targetName)); if (vec.x > 0.5 * size.x && vec.x < texRect.width - (0.5 * size.x) && vec.y < texRect.height - 16 - size.y) { GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperCenter; GUI.Label(new Rect(vec.x + texRect.xMin - (0.5f * size.x), vec.y + texRect.yMin + 20, size.x, size.y), targetName); } } if (procModule.techType == "Planetary" && procModule.isActive && procModule.isFunctional) { if (GUI.Button(new Rect(texRect.xMax - 36, texRect.yMax - 36, 32, 32), save)) { DisplayText("Saved screenshot to " + opticsModule.GetTex(true, targetName)); } } } } else { GUILayout.BeginHorizontal(); GUILayout.Label("FungEye optics aperture closed."); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Note that you can never close the aperture again once you open them with these optics!"); GUILayout.EndHorizontal(); } } else { GUILayout.BeginHorizontal(); GUILayout.Label("Optics module has been damaged by the sun! Repair must be made to optics module during an EVA."); //print("FONT SIZE: " + GUI.skin.GetStyle("Label").fontSize); GUILayout.EndHorizontal(); } } else { GUILayout.BeginHorizontal(); GUILayout.Label("No optics detected!"); GUILayout.EndHorizontal(); } GUILayout.Space(10f); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleCenter; string targetstring; if (FlightGlobals.fetch.VesselTarget == null) { targetstring = "No target selected"; } else { targetstring = "Target: " + FlightGlobals.fetch.VesselTarget.GetName(); } GUILayout.Label(targetstring, GUILayout.Height(30f), GUILayout.Width(370f)); if (GUILayout.Button("Select Target", GUILayout.Height(30f))) { targetOpen = !targetOpen; } GUILayout.EndHorizontal(); GUILayout.Space(10f); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleLeft; GUILayout.Label("Processor: ", GUILayout.Width(100f), GUILayout.Height(30f)); GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleCenter; if (GUILayout.Button(procModule.pName, GUILayout.Height(30f))) { int pI = pMList.IndexOf(procModule) + 1; if (pI > pMList.Count - 1) { procModule = pMList[0]; } else { procModule = pMList[pI]; } } GUILayout.Space(15); GUILayout.Label(procModule.status, GUILayout.Height(30f)); GUILayout.FlexibleSpace(); if (procModule.isFunctional) { if (GUILayout.Button(procModule.isActive ? "Disable" : "Activate", GUILayout.Height(30f), GUILayout.Width(80f))) { procModule.toggle(null); } } GUILayout.EndHorizontal(); if (procModule.isActive && procModule.isFunctional && HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX) { GUILayout.BeginHorizontal(); GUILayout.Label("", GUILayout.Width(100f), GUILayout.Height(30f)); if (procModule.GetScienceCount() == 0) { if (GUILayout.Button("Make Observation", GUILayout.Height(30f))) { procModule.observation(); } } else { if (GUILayout.Button("Review Data", GUILayout.Height(30f))) { procModule.eventReviewScience(); } GUILayout.Space(80); if (GUILayout.Button("Dump Data", GUILayout.Height(30f))) { procModule.eventReviewScience(); } } GUILayout.EndHorizontal(); if (procModule.techType == "Occultation") { GUILayout.BeginHorizontal(); GUILayout.Label("", GUILayout.Width(100f), GUILayout.Height(30f)); CelestialBody planetBody = CactEyeVars.GetPlanetBody(FlightGlobals.ActiveVessel.mainBody); if (planetBody != null) { if (!CactEyeVars.occultationExpTypes.ContainsKey(planetBody)) { CactEyeVars.GenerateOccultationExp(planetBody); } if (CactEyeVars.occultationExpTypes[planetBody] == "Asteroid") { GUILayout.Label("Next occultation: " + CactEyeVars.occultationExpAsteroids[planetBody].vesselName + ", at " + CactEyeVars.GetOccultationExpTimeString(planetBody), GUILayout.Height(30f)); } else { GUILayout.Label("Next occultation: " + CactEyeVars.occultationExpBodies[planetBody].bodyName + ", at " + CactEyeVars.GetOccultationExpTimeString(planetBody), GUILayout.Height(30f)); } //I sure wish I could put a button here to auto create a KAC alarm. Hint hint TriggerAu - make a KAC wrapper! } else { GUILayout.Label("Occultation experiment not available in solar orbit!"); } GUILayout.EndHorizontal(); } } if (HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX) { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.Label("Science experiments unavailable in sandbox mode!"); GUILayout.EndHorizontal(); } if (gMList.Count != 0) { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleLeft; GUILayout.Label("Gyro Speed: ", GUILayout.Width(100f), GUILayout.Height(30f)); GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleCenter; gSel = GUILayout.SelectionGrid(gSel, gModes, 3, GUILayout.Height(30f)); if (gSel != gSelSt) { if (gSel == 0) { foreach (CactEyeGyro gM in gMList) { gM.normScale(null); } } if (gSel == 1) { foreach (CactEyeGyro gM in gMList) { gM.redScale(null); } } if (gSel == 2) { foreach (CactEyeGyro gM in gMList) { gM.fineScale(null); } } gSelSt = gSel; } GUILayout.EndHorizontal(); } } else { GUILayout.BeginHorizontal(); GUILayout.Label("No processors detected!"); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUI.DragWindow(); GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft; }