/// <summary> /// Draws UI for module control /// </summary> /// <param name="rcGuiId">Rc GUI identifier.</param> public void DrawRcGUI(int rcGuiId) { if (currentModule == null) { rcVisible = false; return; } double currentTime = Planetarium.GetUniversalTime(); string tooltip = ""; GUILayout.BeginVertical(); //TimeSpan t = TimeSpan.FromSeconds (currentTime - currentModule.lastTime); //Layout.Label ( // string.Format ( // "Idle for {0:D2}h:{1:D2}m:{2:D2}s", // t.Hours, // t.Minutes, // t.Seconds // ) //); // If required power is greater ther total power generated, then average speed can be lowered up to 50% double speedReduction = 0; if (currentModule.powerRequired > (currentModule.solarPower + currentModule.otherPower)) { speedReduction = (currentModule.powerRequired - (currentModule.solarPower + currentModule.otherPower)) / currentModule.powerRequired * 100; } Layout.LabelAndText("Target latitude", currentModule.targetLatitude.ToString()); Layout.LabelAndText("Target longitude", currentModule.targetLongitude.ToString()); Layout.LabelAndText("Distance to target", (currentModule.distanceToTarget - currentModule.distanceTravelled).ToString("N0")); //Layout.LabelAndText ("Distance to target", currentModule.distanceToTarget.ToString("N0")); //Layout.LabelAndText ("Distance travelled", currentModule.distanceTravelled.ToString("N0")); if (currentModule.averageSpeed > 0) { tooltip = "Average speed base: " + currentModule.maxSpeedBase.ToString("F") + "\n"; tooltip += "Online wheels modifier: " + currentModule.wheelsPercentualModifier.ToString() + "%\n"; if (currentModule.isManned) { tooltip += "Driver bonus: " + currentModule.crewSpeedBonus.ToString() + "%\n"; } else { tooltip += "Unmanned rover penalty: 80%\n"; } if (speedReduction > 0) { tooltip += "Unsufficient power penalty: " + (speedReduction > 75 ? "100" : speedReduction.ToString("F")) + "%\n"; } tooltip += "Speed at night: " + currentModule.averageSpeedAtNight.ToString("F"); } else { tooltip = "Wheels aren't online"; } Layout.LabelTextAndButton("Average speed", currentModule.averageSpeed.ToString("F"), tooltip); tooltip = "Solar power: " + currentModule.solarPower.ToString("F") + "\n"; tooltip += "Generators and reactors: " + currentModule.otherPower.ToString("F"); Layout.LabelTextAndButton("Generated power", (currentModule.solarPower + currentModule.otherPower).ToString("F"), tooltip); //Layout.LabelAndText ("Solar power", currentModule.solarPower.ToString("F")); //Layout.LabelAndText ("Other power", currentModule.otherPower.ToString("F")); Layout.LabelAndText("Required power", currentModule.powerRequired.ToString("F") + (speedReduction == 0 ? "" : (((speedReduction > 0) && (speedReduction <= 75)) ? " (Not enough power, average speed was reduced by " + speedReduction.ToString("F") + "%)" : " (Not enough power!)"))); //Layout.LabelAndText ("Solar powered", currentModule.solarPowered.ToString ()); //Layout.LabelAndText ("Is manned", currentModule.isManned.ToString ()); if (Layout.Button("Pick target on map", Palette.yellow)) { currentModule.PickTarget(); } if (Layout.Button("Set to active target", Palette.yellow)) { currentModule.SetToActive(); } if (Layout.Button("Set to active waypoint", Palette.yellow)) { currentModule.SetToWaypoint(); } if (!currentModule.isActive) { if (Layout.Button("Poehali!!!", Palette.green)) { currentModule.Activate(); } } else { if (Layout.Button("Deactivate", Palette.red)) { currentModule.Deactivate(); } } if (Layout.Button("System Check", Palette.yellow)) { currentModule.SystemCheck(); } if (Layout.Button("Close", Palette.red)) { rcVisible = false; } GUILayout.EndVertical(); GUI.DragWindow(); if (Event.current.type == EventType.Repaint) { //Show tooltip if (!string.IsNullOrEmpty(GUI.tooltip)) { GUIContent tooltipContent = new GUIContent(GUI.tooltip); Vector2 tooltipSize = Styles.tooltip.CalcSize(tooltipContent); Vector2 mouseScreenPos = new Vector2(Input.mousePosition.x - rcRect.x - tooltipSize.x / 2, Screen.height - Input.mousePosition.y - rcRect.y + 20); GUI.Label(new Rect(mouseScreenPos, tooltipSize), GUI.tooltip, Styles.tooltip); } } }
/// <summary> /// Draws UI for module control /// </summary> /// <param name="rcGuiId">Rc GUI identifier.</param> public void DrawRcGUI(int rcGuiId) { if (currentModule == null) { rcVisible = false; return; } double currentTime = Planetarium.GetUniversalTime(); GUILayout.BeginVertical(); TimeSpan t = TimeSpan.FromSeconds(currentTime - currentModule.lastTime); Layout.Label( string.Format( "Idle for {0:D2}h:{1:D2}m:{2:D2}s", t.Hours, t.Minutes, t.Seconds ) ); Layout.LabelAndText("Target latitude", currentModule.targetLatitude.ToString()); Layout.LabelAndText("Target longitude", currentModule.targetLatitude.ToString()); Layout.LabelAndText("Distance to target", currentModule.distanceToTarget.ToString("N0")); Layout.LabelAndText("Distance travelled", currentModule.distanceTravelled.ToString("N0")); Layout.LabelAndText("Average speed", currentModule.averageSpeed.ToString("F")); Layout.LabelAndText("Solar power", currentModule.solarPower.ToString("F")); Layout.LabelAndText("Other power", currentModule.otherPower.ToString("F")); Layout.LabelAndText("Power required", currentModule.powerRequired.ToString("F")); Layout.LabelAndText("Solar powered", currentModule.solarPowered.ToString()); Layout.LabelAndText("Is manned", currentModule.isManned.ToString()); // Layout.TextField ("lat"); // Layout.TextField ("lon"); if (Layout.Button("Pick target on map", Palette.yellow)) { currentModule.PickTarget(); } if (Layout.Button("Set to active target", Palette.yellow)) { currentModule.SetToActive(); } if (Layout.Button("Set to active waypoint", Palette.yellow)) { currentModule.SetToWaypoint(); } if (!currentModule.isActive) { if (Layout.Button("Poehali!!!", Palette.green)) { currentModule.Activate(); } } else { if (Layout.Button("Deactivate", Palette.red)) { currentModule.Deactivate(); } } if (Layout.Button("System Check", Palette.yellow)) { currentModule.SystemCheck(); } if (Layout.Button("Close", Palette.red)) { rcVisible = false; } // if (Layout.Button ("LZString test")) { // currentModule.TestLZString (); // } GUILayout.EndVertical(); GUI.DragWindow(); }