/// <summary> /// Remove the current maneuver node from MapView /// </summary> /// <param name="computer">FlightComputer instance of the computer of the vessel.</param> private void AbortManeuver(FlightComputer computer) { RTUtil.ScreenMessage("[Flight Computer]: Maneuver node removed"); if (computer.Vessel.patchedConicSolver != null) { this.Node.RemoveSelf(); } // Flight Computer mode after execution based on settings if (RTSettings.Instance.FCOffAfterExecute) { computer.Enqueue(AttitudeCommand.Off(), true, true, true); } if (!RTSettings.Instance.FCOffAfterExecute) { computer.Enqueue(AttitudeCommand.KillRot(), true, true, true); } }
private void DrawHDGContent() { GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_HDGSteer"), Localizer.Format("#RT_RoverFragment_HDGSteer_desc"))); //"Steer: ", "How sharp to turn at max" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), Localizer.Format("#RT_RoverFragment_HDGSteer_desc"))); //"How sharp to turn at max" GUILayout.Label(new GUIContent("max", Localizer.Format("#RT_RoverFragment_HDGSteer_desc")), GUILayout.Width(40)); //"How sharp to turn at max" } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_mHdg"), Localizer.Format("#RT_RoverFragment_mHdg_desc")), GUILayout.Width(50));//"Hdg", "Heading to maintain" GUI.SetNextControlName("RC1"); RTUtil.TextField(ref mHeading, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Dist"), Localizer.Format("#RT_RoverFragment_Dist_desc")), GUILayout.Width(50));//"Dist", "Distance to drive" GUI.SetNextControlName("RC2"); RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(m)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Speed"), Localizer.Format("#RT_RoverFragment_HDGSpeed_desc")), GUILayout.Width(50));//"Speed", "Speed to maintain" GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(m/s)", Localizer.Format("")), GUI.skin.textField, GUILayout.Width(40));//"Speed to maintain" } GUILayout.EndHorizontal(); mHeading = RTUtil.ConstrictNum(mHeading, 360); mDist = RTUtil.ConstrictNum(mDist, false); mSpeed = RTUtil.ConstrictNum(mSpeed, false); }
private void DrawHDGContent() { GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Steer: ", "How sharp to turn at max")); GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), "How sharp to turn at max")); GUILayout.Label(new GUIContent("max", "How sharp to turn at max"), GUILayout.Width(40)); } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Hdg", "Heading to maintain"), GUILayout.Width(50)); GUI.SetNextControlName("RC1"); RTUtil.TextField(ref mHeading, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Dist", "Distance to drive"), GUILayout.Width(50)); GUI.SetNextControlName("RC2"); RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(m)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Speed", "Speed to maintain"), GUILayout.Width(50)); GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(m/s)", "Speed to maintain"), GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); mHeading = RTUtil.ConstrictNum(mHeading, 360); mDist = RTUtil.ConstrictNum(mDist, false); mSpeed = RTUtil.ConstrictNum(mSpeed, false); }
public void Draw() { mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, AbstractWindow.Frame); { Color pushColor = GUI.contentColor; TextAnchor pushAlign = GUI.skin.button.alignment; GUI.skin.button.alignment = TextAnchor.MiddleLeft; foreach (VesselSatellite sat in RTCore.Instance.Satellites) { if ((sat.parentVessel != null && !MapViewFiltering.CheckAgainstFilter(sat.parentVessel)) || FlightGlobals.ActiveVessel == sat.parentVessel) { continue; } String text = sat.Name.Truncate(25); RTUtil.StateButton(text, mSelection == sat ? 1 : 0, 1, s => { mSelection = (s > 0) ? sat : null; if (mSelection != null) { Vessel vessel = sat.SignalProcessor.Vessel; ScaledMovement scaledMovement = new GameObject().AddComponent <ScaledMovement>(); scaledMovement.tgtRef = vessel.transform; scaledMovement.name = sat.Name; scaledMovement.transform.parent = ScaledSpace.Instance.transform; scaledMovement.vessel = vessel; scaledMovement.type = MapObject.MapObjectType.VESSEL; var success = PlanetariumCamera.fetch.SetTarget(PlanetariumCamera.fetch.AddTarget(scaledMovement)); PlanetariumCamera.fetch.targets.Remove(scaledMovement); this.resetTarget(); } else { // go back to the active vessel PlanetariumCamera.fetch.SetTarget(this.resetTarget()); } }); } GUI.skin.button.alignment = pushAlign; GUI.contentColor = pushColor; } GUILayout.EndScrollView(); }
/// <summary> /// Draws the content of the AlternativeRules section /// </summary> private void drawAlternativeRulesContent() { GUILayout.Space(10); this.mSettings.EnableSignalDelay = GUILayout.Toggle(this.mSettings.EnableSignalDelay, (this.mSettings.EnableSignalDelay) ? Localizer.Format("#RT_OptionWindow_AlternativeRules_EnableSignalDelay") : Localizer.Format("#RT_OptionWindow_AlternativeRules_disabledSignalDelay")); //"Signal delay enabled""Signal delay disabled" GUILayout.Label(Localizer.Format("#RT_OptionWindow_AlternativeRules_SignalDelaydesc"), this.mGuiHintText); //"ON: All commands sent to RemoteTech-compatible probe cores are limited by the speed of light and have a delay before executing, based on distance.\nOFF: All commands will be executed immediately, although a working connection to Mission Control is still required." GUILayout.Label(Localizer.Format("#RT_OptionWindow_AlternativeRules_RangeModelMode_head"), GUILayout.Width(OptionWindow.WINDOW_WIDTH * 0.75f)); //"Range Model Mode" GUILayout.Label(Localizer.Format("#RT_OptionWindow_AlternativeRules_RangeModelMode_text"), this.mGuiHintText); //"This setting controls how the game determines whether two antennas are in range of each other.\nRead more on our online manual about the difference for each rule." GUILayout.BeginHorizontal(); { RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_OptionWindow_AlternativeRules_RangeModelMode_Standard")), () => this.mSettings.RangeModelType = RangeModel.RangeModel.Standard, (int)this.mSettings.RangeModelType, (int)RangeModel.RangeModel.Standard, GUILayout.Height(20)); //"Standard" RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_OptionWindow_AlternativeRules_RangeModelMode_Root")), () => this.mSettings.RangeModelType = RangeModel.RangeModel.Additive, (int)this.mSettings.RangeModelType, (int)RangeModel.RangeModel.Additive, GUILayout.Height(20)); //"Root" } GUILayout.EndHorizontal(); GUILayout.Label(Localizer.Format("#RT_OptionWindow_AlternativeRules_MultipleAntennaMulti_head", this.mSettings.MultipleAntennaMultiplier), GUILayout.Width(OptionWindow.WINDOW_WIDTH * 0.75f)); //"Multiple Antenna Multiplier : (" + + ")" GUILayout.Label(Localizer.Format("#RT_OptionWindow_AlternativeRules_MultipleAntennaMulti_text"), this.mGuiHintText); //"Multiple omnidirectional antennas on the same craft work together.\nThe default value of 0 means this is disabled.\nThe largest value of 1.0 sums the range of all omnidirectional antennas to provide a greater effective range.\nThe effective range scales linearly and this option works with both the Standard and Root range models." this.mSettings.MultipleAntennaMultiplier = Math.Round(GUILayout.HorizontalSlider((float)mSettings.MultipleAntennaMultiplier, 0, 1), 2); }
public bool Drive(RemoteTech.FlightComputer.Commands.DriveCommand dc, FlightCtrlState fs) { if (dc != null) { if (mVessel.srf_velocity.magnitude > 0.5) { float degForward = Mathf.Abs(RTUtil.ClampDegrees90(Vector3.Angle(mVessel.srf_velocity, mVessel.ReferenceTransform.forward))); float degUp = Mathf.Abs(RTUtil.ClampDegrees90(Vector3.Angle(mVessel.srf_velocity, mVessel.ReferenceTransform.up))); float degRight = Mathf.Abs(RTUtil.ClampDegrees90(Vector3.Angle(mVessel.srf_velocity, mVessel.ReferenceTransform.right))); if (degForward < degUp && degForward < degRight) { ForwardAxis = Vector3.forward; } else if (degRight < degUp && degRight < degForward) { ForwardAxis = Vector3.right; } else { ForwardAxis = Vector3.up; } } switch (dc.mode) { case RemoteTech.FlightComputer.Commands.DriveCommand.DriveMode.Turn: return(Turn(dc, fs)); case RemoteTech.FlightComputer.Commands.DriveCommand.DriveMode.Distance: return(Distance(dc, fs)); case RemoteTech.FlightComputer.Commands.DriveCommand.DriveMode.DistanceHeading: return(DistanceHeading(dc, fs)); case RemoteTech.FlightComputer.Commands.DriveCommand.DriveMode.Coord: return(Coord(dc, fs)); } return(true); } return(true); }
private void HandleDynamicPressure() { if (vessel == null) { return; } if (!vessel.HoldPhysics && vessel.atmDensity > 0 && MaxQ > 0 && (!this.CanAnimate || this.AnimOpen)) { if (GetDynamicPressure() > MaxQ && GetShieldedState() == false) { // Express flight clock in stockalike formatting string timestamp = RTUtil.FormatTimestamp(FlightLogger.met_years, FlightLogger.met_days, FlightLogger.met_hours, FlightLogger.met_mins, FlightLogger.met_secs); FlightLogger.eventLog.Add(String.Format("[{0}]: {1} was ripped off by strong airflow.", timestamp, part.partInfo.title)); MaxQ = -1.0f; part.decouple(0.0f); } } }
public override string GetInfo() { var info = new StringBuilder(); if (ShowEditor_OmniRange && Mode1OmniRange > 0) { info.AppendFormat("Omni {0}: {1} / {2}", AntennaInfoDescriptionFromRangeModel(), RTUtil.FormatSI(Mode0OmniRange * RangeMultiplier, "m"), RTUtil.FormatSI(Mode1OmniRange * RangeMultiplier, "m")).AppendLine(); } if (ShowEditor_DishRange && Mode1DishRange > 0) { info.AppendFormat("Dish {0}: {1} / {2}", AntennaInfoDescriptionFromRangeModel(), RTUtil.FormatSI(Mode0DishRange * RangeMultiplier, "m"), RTUtil.FormatSI(Mode1DishRange * RangeMultiplier, "m")).AppendLine(); } if (ShowEditor_DishAngle && CanTarget) { info.AppendFormat("Cone angle: {0} degrees", DishAngle.ToString("F3")).AppendLine(); } if (IsRTActive) { info.AppendLine("<color=#89929B>Activated by default</color>"); } if (MaxQ > 0) { info.AppendLine("<b><color=#FDA401>Snaps under high dynamic pressure</color></b>"); } if (this.IsNonRetractable) { info.AppendLine("<b><color=#FDA401>Antenna is not retractable</color></b>"); } if (ShowEditor_EnergyReq && EnergyCost > 0) { info.AppendLine().Append("<b><color=#99ff00ff>Requires:</color></b>").AppendLine(); info.AppendFormat("<b>ElectricCharge: </b>{0}", RTUtil.FormatConsumption(EnergyCost * ConsumptionMultiplier)).AppendLine(); } return(info.ToString().TrimEnd(Environment.NewLine.ToCharArray())); }
/// <summary> /// Loads the ExternalAPICommand from the persistent file. If the loading /// can't find the <see cref="ReflectionType"/> we'll notify a ScreenMessage /// and remove the command. /// </summary> /// <param name="node">Node with the command infos to load</param> /// <param name="computer">Current flightcomputer</param> /// <returns>true - loaded successfull</returns> public override bool Load(ConfigNode node, FlightComputer computer) { try { if (base.Load(node, computer)) { if (node.HasNode("ExternalData")) { this.ConfigNodeToObject(this, node.GetNode("ExternalData")); // try loading the reflectionType this.getReflectionType(this.ReflectionType); return(true); } } } catch (Exception) { RTUtil.ScreenMessage(string.Format("Mod '{0}' not found. Queued command '{1}' will be removed.", this.Executor, this.ShortName)); } return(false); }
public void Draw() { if (Satellite == null) { return; } GUILayout.BeginHorizontal(); { GUILayout.TextField(Satellite.Name.Truncate(25), GUILayout.ExpandWidth(true)); RTUtil.Button(Localizer.Format("#RT_NetworkFB_NameButton"), () =>//"Name" { var vessel = RTUtil.GetVesselById(Satellite.Guid); if (vessel) { vessel.RenameVessel(); } }, GUILayout.ExpandWidth(false), GUILayout.Height(24)); } GUILayout.EndHorizontal(); mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, GUILayout.ExpandHeight(true)); { Color pushColor = GUI.contentColor; TextAnchor pushAlign = GUI.skin.button.alignment; GUI.skin.button.alignment = TextAnchor.MiddleLeft; foreach (var a in Satellite.Antennas.Where(a => a.CanTarget)) { GUI.contentColor = (a.Powered) ? XKCDColors.ElectricLime : XKCDColors.Scarlet; String text = a.Name.Truncate(25) + Environment.NewLine + Localizer.Format("#RT_NetworkFB_Target") + RTUtil.TargetName(a.Target).Truncate(18);//"Target: " RTUtil.StateButton(text, Antenna, a, s => { Antenna = (s > 0) ? a : null; }); } GUI.skin.button.alignment = pushAlign; GUI.contentColor = pushColor; } GUILayout.EndScrollView(); }
public override bool Pop(FlightComputer f) { if (f.Vessel.patchedConicSolver == null) { f.Vessel.AttachPatchedConicsSolver(); f.Vessel.patchedConicSolver.Update(); } if (this.Node.solver == null) // need to repair (due to the scenario of 2 vessels within phyical range) { this.Node = f.Vessel.patchedConicSolver.maneuverNodes.Find(x => x.UT == this.Node.UT); } var burn = f.ActiveCommands.FirstOrDefault(c => c is BurnCommand); if (burn != null) { f.Remove(burn); } OriginalDelta = Node.DeltaV.magnitude; RemainingDelta = this.getRemainingDeltaV(f); this.EngineActivated = true; double thrustToMass = FlightCore.GetTotalThrust(f.Vessel) / f.Vessel.GetTotalMass(); if (thrustToMass == 0.0) { this.EngineActivated = false; RTUtil.ScreenMessage("[Flight Computer]: No engine to carry out the maneuver."); } else { RemainingTime = RemainingDelta / thrustToMass; } f.PIDController.setPIDParameters(FlightComputer.PIDKp, FlightComputer.PIDKi, FlightComputer.PIDKd); return(true); }
public override void OnStart(StartState state) { // workarround for ksp 1.0 if (mTransmitterConfig == null) { mTransmitterConfig = new ConfigNode("TRANSMITTER"); mTransmitterConfig.AddValue("PacketInterval", RTPacketInterval); mTransmitterConfig.AddValue("PacketSize", RTPacketSize); mTransmitterConfig.AddValue("PacketResourceCost", RTPacketResourceCost); mTransmitterConfig.AddValue("name", "ModuleRTDataTransmitter"); } if (RTCore.Instance != null) { GameEvents.onVesselWasModified.Add(OnVesselModified); GameEvents.onPartUndock.Add(OnPartUndock); mRegisteredId = vessel.id; RTCore.Instance.Antennas.Register(vessel.id, this); SetState(true); GUI_OmniRange = RTUtil.FormatSI(Omni, "m"); } }
public void OnFixedUpdate() { if (Vessel != null) { UpdateStateVectors(Vessel, Target); SteeringHelper.AnalyzeParts(Vessel); Vector3 Torque = SteeringHelper.TorqueAvailable; var CoM = Vessel.CoM; var MoI = Vessel.MOI; phiTotal = calculatePhiTotal(); phiVector = calculatePhiVector();//deviation errors from orientation target for (int i = 0; i < 3; i++) { //Edge case: Very low (torque/MoI) (like 0.0078!) rate so need to rise max acceleration artifically StoppingTime = (OmegaThreshold <= (Torque[i] / MoI[i])) ? 1.0f : (float)RTUtil.Clamp((1.0 / (Torque[i] / MoI[i])) * (Math.Abs(phiVector[i]) - Phi1FStoppingTime), 1.0, MaxStoppingTime); MaxOmega[i] = Mathf.Max((Torque[i] * StoppingTime) / MoI[i], 0.0001f); } TargetOmega[0] = pitchRatePI.Update(-phiVector[0], 0, MaxOmega[0]); TargetOmega[1] = rollRatePI.Update(-phiVector[1], 0, MaxOmega[1]); TargetOmega[2] = yawRatePI.Update(-phiVector[2], 0, MaxOmega[2]); if (Math.Abs(phiTotal) > RollControlRange) { TargetOmega[1] = 0; rollRatePI.ResetI(); } TargetTorque[0] = pitchPI.Update(Omega[0], TargetOmega[0], Vessel.MOI[0], Torque[0]); TargetTorque[1] = rollPI.Update(Omega[1], TargetOmega[1], Vessel.MOI[1], Torque[1]); TargetTorque[2] = yawPI.Update(Omega[2], TargetOmega[2], Vessel.MOI[2], Torque[2]); } }
/// <summary> /// given the depth-buffer texture and a screen-pos, return the sampled z-dist /// F: camera farClipPlane /// N: camera nearClipPlane /// FN : F*N /// NsF: N-F /// </summary> public static float GetZDistFromDepthBuffer(Texture2D zbuffer, Vector2 screenPos, float FN, float F, float NsF) { float norX = screenPos.x / zbuffer.width; float norY = screenPos.y / zbuffer.height; Color zBufColor = zbuffer.GetPixel(Mathf.RoundToInt(norX * Screen.width), Mathf.RoundToInt(norY * Screen.height)); float zBufVal = RTUtil.DecodeFloatRGBA(zBufColor); float zBufDist = FN / (F + zBufVal * NsF);//IMPORTANT!!! z-depth is linearized based on reciprocal // ------------------------------ // refer: https://en.wikipedia.org/wiki/Bilinear_filtering // DEPRECATED: not useful, the 4 points all far from right //float u = norX * Screen.width - 0.5f; //float v = norY * Screen.height - 0.5f; //int _x = Mathf.FloorToInt(u); //int x0 = Mathf.Max(0, _x); //int x1 = Mathf.Min(_x + 1, Screen.width - 1); //int _y = Mathf.FloorToInt(v); //int y0 = Mathf.Max(0, _y); //int y1 = Mathf.Min(_y + 1, Screen.height - 1); //float u_ratio = u - _x; //float v_ratio = v - _y; //float u_opposite = 1 - u_ratio; //float v_opposite = 1 - v_ratio; //float v00 = _GetZDist(zbuffer.GetPixel(x0, y0), FN, F, NsF); //float v01 = _GetZDist(zbuffer.GetPixel(x0, y1), FN, F, NsF); //float v10 = _GetZDist(zbuffer.GetPixel(x1, y0), FN, F, NsF); //float v11 = _GetZDist(zbuffer.GetPixel(x1, y1), FN, F, NsF); //Dbg.Log("v00: {0}, v01: {1}, v10: {2}, v11: {3}", v00, v01, v10, v11); //float zBufDist = (v00 * u_opposite + v10 * u_ratio) * v_opposite + // (v01 * u_opposite + v11 * u_ratio) * v_ratio; //------------------------------------------ return(zBufDist); }
public void Draw() { float width3 = 156 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f; GUILayout.BeginVertical(); { selectedModeIndex = GUILayout.Toolbar(selectedModeIndex, Tabs, GUILayout.Width(width3 * 3 + GUI.skin.button.margin.right * 2.0f)); GUILayout.Space(5); switch (selectedModeIndex) { case (int)RoverModes.TargetMode: DrawTargetContent(); break; case (int)RoverModes.HeadingMode: DrawHDGContent(); break; case (int)RoverModes.FineMode: DrawFineContent(); break; } GUILayout.Space(5); GUILayout.BeginHorizontal(); { RTUtil.Button(new GUIContent(Localizer.Format("#RT_RoverFragment_DRIVE"), Localizer.Format("#RT_RoverFragment_DRIVE_desc")),//"DRIVE", "Starts the automatic driving." delegate { OnExecClick(selectedModeIndex); }, GUILayout.Width(width3)); GUILayout.FlexibleSpace(); RTUtil.Button(new GUIContent(">>", Localizer.Format("#RT_RoverFragment_Queue_desc")),//"Toggles the queue and delay functionality." mOnClickQueue, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
public TimeWarpDecorator() { mFlightButtonGreen = GUITextureButtonFactory.CreateFromFilename("texFlightGreen", "texFlightGreenOver", "texFlightGreenDown", "texFlightGreenOver"); mFlightButtonYellow = GUITextureButtonFactory.CreateFromFilename("texFlightYellow", "texFlightYellowOver", "texFlightYellowDown", "texFlightYellowOver"); mFlightButtonRed = GUITextureButtonFactory.CreateFromFilename("texFlightRed", "texFlightRed", "texFlightRed", "texFlightRed"); mFlightButtonGreen.fixedHeight = mFlightButtonGreen.fixedWidth = 0; mFlightButtonYellow.fixedHeight = mFlightButtonYellow.fixedWidth = 0; mFlightButtonRed.fixedHeight = mFlightButtonRed.fixedWidth = 0; mFlightButtonGreen.stretchHeight = mFlightButtonGreen.stretchWidth = true; mFlightButtonYellow.stretchHeight = mFlightButtonYellow.stretchWidth = true; mFlightButtonRed.stretchHeight = mFlightButtonRed.stretchWidth = true; // create the Background RTUtil.LoadImage(out mTexBackground, "TimeQuadrantFcStatus"); // Get the image for positioning the decorator GameObject go = GameObject.Find("TimeQuadrant"); if (go) { mTimewarpTransform = go.GetComponent <UnityEngine.RectTransform>(); } // objects on this scene? if (mTimewarpTransform == null || TimeWarp.fetch == null) { return; } // create a style (for the connection / delay text) from the high logic skin label style. var skin = UnityEngine.Object.Instantiate(HighLogic.Skin); mTextStyle = new GUIStyle(skin.label); mTextStyle.alignment = TextAnchor.MiddleLeft; mTextStyle.wordWrap = false; mTextStyle.font = skin.font; }
private void LateStart() { try { if (inner == null || outer == null) { UnitaleUtil.WriteInLogAndDebugger(outer == null && inner == null ? "outer & inner = null" : (outer == null ? "outer == null" : "inner == null")); inner = GameObject.Find("arena").GetComponent <RectTransform>(); outer = inner.parent.GetComponent <RectTransform>(); } arenaAbs = new Rect(inner.position.x - inner.sizeDelta.x / 2, inner.position.y - inner.sizeDelta.y / 2, inner.rect.width, inner.rect.height); arenaCenter = RTUtil.AbsCenterOf(inner); newX = currentX = 320; newY = currentY = 90; currentWidth = inner.rect.width; currentHeight = inner.rect.height; basisCoordinates = arenaCenter; } catch { LateUpdater.lateActions.Add(LateStart); UnitaleUtil.WriteInLogAndDebugger("Error during the Arena's initialization! (#" + errCount++ + ")"); } //outer.localPosition = new Vector3(0, -50, 0); //outer.position = new Vector3(320, 90, outer.position.z); }
/// <summary> /// Draws all debug logs /// </summary> private void drawRTDebugLogEntrys() { GUIStyle lablestyle = new GUIStyle(GUI.skin.label); lablestyle.wordWrap = false; lablestyle.fontSize = 11; lablestyle.normal.textColor = Color.white; // draw the vertical buttons for each debug lvl GUILayout.BeginHorizontal(); { var pushFontsize = GUI.skin.button.fontSize; GUI.skin.button.fontSize = 11; foreach (RTLogLevel lvl in Enum.GetValues(typeof(RTLogLevel))) { RTUtil.FakeStateButton(new GUIContent(lvl.ToString()), () => { this.currentLogLevel = lvl; }, (int)currentLogLevel, (int)lvl, GUILayout.Height(16)); } GUI.skin.button.fontSize = pushFontsize; } GUILayout.EndHorizontal(); // draw the input of the selected debug list debugLogScrollPosition = GUILayout.BeginScrollView(debugLogScrollPosition); { foreach (var logEntry in RTLog.RTLogList[this.currentLogLevel]) { GUILayout.Label(logEntry, lablestyle, GUILayout.Height(13)); } } GUILayout.EndScrollView(); // If the mouse is not over the debug window we will flip the scrollposition.y to maximum if (!this.backupPosition.ContainsMouse()) { debugLogScrollPosition.y = Mathf.Infinity; } }
public TimeWarpDecorator() { mFlightButtonGreen = GUITextureButtonFactory.CreateFromFilename("texFlightGreen", "texFlightGreenOver", "texFlightGreenDown", "texFlightGreenOver"); mFlightButtonYellow = GUITextureButtonFactory.CreateFromFilename("texFlightYellow", "texFlightYellowOver", "texFlightYellowDown", "texFlightYellowOver"); mFlightButtonRed = GUITextureButtonFactory.CreateFromFilename("texFlightRed", "texFlightRed", "texFlightRed", "texFlightRed"); mFlightButtonGreen.fixedHeight = mFlightButtonGreen.fixedWidth = 0; mFlightButtonYellow.fixedHeight = mFlightButtonYellow.fixedWidth = 0; mFlightButtonRed.fixedHeight = mFlightButtonRed.fixedWidth = 0; mFlightButtonGreen.stretchHeight = mFlightButtonGreen.stretchWidth = true; mFlightButtonYellow.stretchHeight = mFlightButtonYellow.stretchWidth = true; mFlightButtonRed.stretchHeight = mFlightButtonRed.stretchWidth = true; // create the Background RTUtil.LoadImage(out mTexBackground, "TimeQuadrantFcStatus"); // Get the image for positioning the decorator GameObject go = GameObject.Find("TimeQuadrant"); if (go) { mTimewarpImage = go.GetComponent <UnityEngine.UI.Image>(); } // objects on this scene? if (mTimewarpImage == null) { return; } if (TimeWarp.fetch != null && TimeWarp.fetch.timeQuadrantTab != null) { var text = TimeWarp.fetch.timeQuadrantTab.transform.FindChild("MET timer").GetComponent <ScreenSafeGUIText>(); mTextStyle = new GUIStyle(text.textStyle); mTextStyle.fontSize = (int)(text.textSize * ScreenSafeUI.PixelRatio); } }
private bool DistanceHeading(RemoteTech.FlightComputer.Commands.DriveCommand dc, FlightCtrlState fs) { float speed = RoverSpeed; Delta = Math.Abs(dc.target) - Vector3.Distance(RoverOrigPos, mVessel.CoM); DeltaT = Delta / speed; if (Delta > 0) { fs.wheelThrottle = mThrottlePID.Control(BrakeSpeed(dc.speed, speed) - speed); if (ForwardAxis != Vector3.zero) { fs.wheelSteer = mWheelPID.Control(RTUtil.AngleBetween(RoverHDG, dc.target2)); } return(false); } else { fs.wheelThrottle = 0; fs.wheelSteer = 0; mVessel.ActionGroups.SetGroup(KSPActionGroup.Brakes, true); dc.mode = RemoteTech.FlightComputer.Commands.DriveCommand.DriveMode.Off; return(true); } }
public void Draw() { float width3 = 156 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f; GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_PowerFragment_HBNT"), Localizer.Format("#RT_PowerFragment_HBNT_desc")), () => RTCore.Instance.StartCoroutine(OnPowerClick(PowerModes.Hibernate)), (int)mPowerMode, (int)PowerModes.Hibernate, GUILayout.Width(width3)); //"HBNT", "Ultra-low power hibernation with all active antennas shut down." RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_PowerFragment_THLD"), Localizer.Format("#RT_PowerFragment_THLD_desc")), () => RTCore.Instance.StartCoroutine(OnPowerClick(PowerModes.AntennaSaver)), (int)mPowerMode, (int)PowerModes.AntennaSaver, GUILayout.Width(width3)); //"THLD", "Optimally adaptive power-saving threshold control on all antennas" RTUtil.Button(new GUIContent(Localizer.Format("#RT_PowerFragment_WAKE"), Localizer.Format("#RT_PowerFragment_WAKE_desc")), () => RTCore.Instance.StartCoroutine(OnPowerClick(PowerModes.Wake)), GUILayout.Width(width3)); //"WAKE", "Terminate any power-saving state." } GUILayout.EndHorizontal(); GUILayout.Space(200); GUILayout.BeginHorizontal(); { RTUtil.Button(new GUIContent(">>", Localizer.Format("#RT_PowerFragment_Queue_desc")),//"Toggles the queue and delay functionality." mOnClickQueue, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
/// <summary> /// Restores the flightcomputer from the persistant /// </summary> /// <param name="n">Node with the informations for the flightcomputer</param> public void load(ConfigNode n) { RTLog.Notify("Loading Flightcomputer from persistent!"); if (!n.HasNode("FlightComputer")) { return; } // Wait while we are packed and store the current configNode if (Vessel.packed) { RTLog.Notify("Save flightconfig after unpacking"); fcLoadedConfigs = n; return; } // Load the current vessel from signalprocessor if we've no on the flightcomputer if (Vessel == null) { Vessel = SignalProcessor.Vessel; mRoverComputer.SetVessel(Vessel); } // Read Flightcomputer informations ConfigNode FlightNode = n.GetNode("FlightComputer"); TotalDelay = double.Parse(FlightNode.GetValue("TotalDelay")); ConfigNode ActiveCommands = FlightNode.GetNode("ActiveCommands"); ConfigNode Commands = FlightNode.GetNode("Commands"); // Read active commands if (ActiveCommands.HasNode()) { if (mActiveCommands.Count > 0) { mActiveCommands.Clear(); } foreach (ConfigNode cmdNode in ActiveCommands.nodes) { ICommand cmd = AbstractCommand.LoadCommand(cmdNode, this); if (cmd != null) { mActiveCommands[cmd.Priority] = cmd; cmd.Pop(this); } } } // Read queued commands if (Commands.HasNode()) { int qCounter = 0; // clear the current list if (mCommandQueue.Count > 0) { mCommandQueue.Clear(); } RTLog.Notify("Loading queued commands from persistent ..."); foreach (ConfigNode cmdNode in Commands.nodes) { ICommand cmd = AbstractCommand.LoadCommand(cmdNode, this); if (cmd != null) { // if delay = 0 we're ready for the extraDelay if (cmd.Delay == 0) { if (cmd is ManeuverCommand) { // TODO: Need better text RTUtil.ScreenMessage("You missed the maneuver burn!"); continue; } // if extraDelay is set, we've to calculate the elapsed time // and set the new extradelay based on the current time if (cmd.ExtraDelay > 0) { cmd.ExtraDelay = cmd.TimeStamp + cmd.ExtraDelay - RTUtil.GameTime; // Are we ready to handle the command ? if (cmd.ExtraDelay <= 0) { if (cmd is BurnCommand) { // TODO: Need better text RTUtil.ScreenMessage("You missed the burn command!"); continue; } else { // change the extra delay to x/100 cmd.ExtraDelay = (qCounter) / 100; } } } } mCommandQueue.Add(cmd); } } } }
public static Guid GetCelestialBodyGuid(CelestialBody celestialBody) { return(RTUtil.Guid(celestialBody)); }
/// <summary> /// Draws the content of the window /// </summary> public override void Window(int uid) { // push the current GUI.skin var pushSkin = GUI.skin; GUI.skin = HighLogic.Skin; GUILayout.BeginVertical(GUILayout.Width(500), GUILayout.Height(350)); { #region Draw debug menue // Draw the debug menue GUILayout.BeginHorizontal(); { // push the font size of buttons var pushFontsize = GUI.skin.button.fontSize; GUI.skin.button.fontSize = 11; int menueItemCounter = 0; foreach (string menueItem in this.debugMenueItems) { RTUtil.FakeStateButton(new GUIContent(menueItem), () => { this.currentDebugMenue = menueItemCounter; }, currentDebugMenue, menueItemCounter, GUILayout.Height(16)); menueItemCounter++; } // pop the saved button size back GUI.skin.button.fontSize = pushFontsize; } GUILayout.EndHorizontal(); #endregion #region Draw content contentScrollPosition = GUILayout.BeginScrollView(contentScrollPosition); { switch (this.currentDebugMenue) { case 0: { this.drawRTSettingsTab(); break; } case 1: { this.drawAPITester(); break; } case 2: { this.drawGuidReader(); break; } default: { GUILayout.Label("Item " + this.currentDebugMenue.ToString() + " not yet implemented"); break; } } GUILayout.FlexibleSpace(); } GUILayout.EndScrollView(); #endregion #region Draw debug log // Draw a 100 height debug-console at the bottom of the debug-window GUILayout.BeginVertical(GUILayout.Height(150)); this.drawRTDebugLogEntrys(); GUILayout.EndVertical(); // Draw the clear log button // Clear Logs Button GUILayout.BeginHorizontal(); { var pushFontsize = GUI.skin.button.fontSize; GUI.skin.button.fontSize = 12; RTUtil.Button(new GUIContent(Localizer.Format("#RT_DEBUG_Clearbutton", this.currentLogLevel.ToString()), Localizer.Format("#RT_DEBUG_Clearbutton_desc")), () => RTLog.RTLogList[this.currentLogLevel].Clear());//"Clear Logs in ""tbd." GUI.skin.button.fontSize = pushFontsize; } GUILayout.EndHorizontal(); #endregion } GUILayout.EndVertical(); base.Window(uid); // pop back the saved skin GUI.skin = pushSkin; }
/// <summary> /// Draws the RTSettings section /// </summary> private void drawRTSettingsTab() { var settings = RTSettings.Instance; int firstColWidth = 250; var pushLabelSize = GUI.skin.label.fontSize; var pushButtonSize = GUI.skin.button.fontSize; GUI.skin.label.fontSize = 12; GUI.skin.button.fontSize = 12; // Deaktivate Mission Control GUILayout.BeginHorizontal(); { GUILayout.Label(Localizer.Format("#RT_DEBUG_DeactivateKSC"), GUILayout.Width(firstColWidth));//"Deactivate KSC: " RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_DEBUG_Onbtton")), () => { foreach (MissionControlSatellite mcs in settings.GroundStations) { mcs.togglePower(false); } ; deactivatedMissionControls = 1; }, deactivatedMissionControls, 1); //"On" RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_DEBUG_Offbtton")), () => { foreach (MissionControlSatellite mcs in settings.GroundStations) { mcs.togglePower(true); } ; deactivatedMissionControls = 0; }, deactivatedMissionControls, 0); //"Off" } GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.Label(Localizer.Format("#RT_DEBUG_CheatOptions"));//"Cheat Options" GUILayout.BeginHorizontal(); { GUILayout.Label(Localizer.Format("#RT_DEBUG_SignalThroughBodies"), GUILayout.Width(firstColWidth)); //"Signal Through Bodies: " int cheatLineOfSight = (RTSettings.Instance.IgnoreLineOfSight) ? 1 : 0; RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_DEBUG_Onbtton")), () => { RTSettings.Instance.IgnoreLineOfSight = true; }, cheatLineOfSight, 1); //"On" RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_DEBUG_Offbtton")), () => { RTSettings.Instance.IgnoreLineOfSight = false; }, cheatLineOfSight, 0); //"Off" } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(Localizer.Format("#RT_DEBUG_InfiniteFuel"), GUILayout.Width(firstColWidth)); //"Infinite Fuel: " int cheatinfiniteFuel = (CheatOptions.InfinitePropellant) ? 1 : 0; RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_DEBUG_Onbtton")), () => { CheatOptions.InfinitePropellant = true; }, cheatinfiniteFuel, 1); //"On" RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_DEBUG_Offbtton")), () => { CheatOptions.InfinitePropellant = false; }, cheatinfiniteFuel, 0); //"Off" } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(Localizer.Format("#RT_DEBUG_InfiniteRCSFuel"), GUILayout.Width(firstColWidth)); //"Infinite RCS Fuel: " int cheatinfiniteRCSFuel = (CheatOptions.InfinitePropellant) ? 1 : 0; RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_DEBUG_Onbtton")), () => { CheatOptions.InfinitePropellant = true; }, cheatinfiniteRCSFuel, 1); //"On" RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_DEBUG_Offbtton")), () => { CheatOptions.InfinitePropellant = false; }, cheatinfiniteRCSFuel, 0); //"Off" } GUILayout.EndHorizontal(); GUI.skin.label.fontSize = pushLabelSize; GUI.skin.button.fontSize = pushButtonSize; }
// Replaced with new texture handling mechanics. public static GUIStyle CreateFromFilename(String normal) { Texture2D tex = RTUtil.LoadImage(normal); return(CreateFromTextures(tex, tex, tex, tex)); }
// Replaced with new texture handling mechanics. public static GUIStyle CreateFromFilename(String normal, String hover, String active, String focus) { return(CreateFromTextures(RTUtil.LoadImage(normal), RTUtil.LoadImage(hover), RTUtil.LoadImage(active), RTUtil.LoadImage(focus))); }
static Texture() { RTUtil.LoadImage(out Satellite, "texSatellite.png"); }
private string burnLength() { return(Duration > 0 ? RTUtil.FormatDuration(Duration) : (DeltaV.ToString("F2") + "m/s")); }
private void DrawTargetContent() { string targetTypeString = Localizer.Format("#RT_RoverFragment_coordinations"); //"Body coordinations" string tooltip = Localizer.Format("#RT_RoverFragment_coordinations_desc", GameSettings.MODIFIER_KEY.name); //"Hold " + + " and click on ground to input coordinates" ITargetable Target = mFlightComputer.Vessel.targetObject; if (GameSettings.MODIFIER_KEY.GetKey() && ((Input.GetMouseButton(0) || Input.GetMouseButton(1)) != MouseClick)) // on lookout for mouse click on body { MouseClick = Input.GetMouseButton(0) || Input.GetMouseButton(1); Vector2 latlon; if (MouseClick && RTUtil.CBhit(mFlightComputer.Vessel.mainBody, out latlon)) { Latitude = latlon.x; Longitude = latlon.y; } } else if (Target != null) // only if target is vessel not world coord { if (Target.GetType().ToString().Equals("Vessel")) { Vessel TargetVessel = Target as Vessel; Latitude = (float)TargetVessel.latitude; Longitude = (float)TargetVessel.longitude; targetTypeString = Localizer.Format("#RT_RoverFragment_TargetVessel"); //"Designated Vessel" tooltip = Localizer.Format("#RT_RoverFragment_TargetVessel_desc"); //"Drive to this vessel" } } GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_HDGSteer"), Localizer.Format("#RT_RoverFragment_HDGSteer_desc"))); //"Steer: ", "How sharp to turn at max" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), Localizer.Format("#RT_RoverFragment_HDGSteer_desc"))); //"How sharp to turn at max" GUILayout.Label(new GUIContent("max", Localizer.Format("#RT_RoverFragment_HDGSteer_desc")), GUILayout.Width(40)); // "How sharp to turn at max" } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1); GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_ModeLabel", targetTypeString), tooltip));//"Mode: " GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_LAT"), Localizer.Format("#RT_RoverFragment_LAT_desc")), GUILayout.Width(50));//"LAT", "Latitude to drive to" GUI.SetNextControlName("RC1"); RTUtil.TextField(ref mLatitude, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(°)", Localizer.Format("#RT_RoverFragment_coordinations_desc", GameSettings.MODIFIER_KEY.name)), GUI.skin.textField, GUILayout.Width(40));//"Hold " + + " and click on ground to input coordinates" } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_LON"), Localizer.Format("#RT_RoverFragment_LON_desc")), GUILayout.Width(50));//"LON", "Longitude to drive to" GUI.SetNextControlName("RC2"); RTUtil.TextField(ref mLongditude, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(°)", Localizer.Format("#RT_RoverFragment_coordinations_desc", GameSettings.MODIFIER_KEY.name)), GUI.skin.textField, GUILayout.Width(40));//"Hold " + + " and click on ground to input coordinates" } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Speed"), Localizer.Format("#RT_RoverFragment_HDGSpeed_desc")), GUILayout.Width(50));//"Speed", "Speed to maintain" GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(m/s)", Localizer.Format("#RT_RoverFragment_HDGSpeed_desc")), GUI.skin.textField, GUILayout.Width(40));//"Speed to maintain" } GUILayout.EndHorizontal(); mLatitude = RTUtil.ConstrictNum(mLatitude); mLongditude = RTUtil.ConstrictNum(mLongditude); mSpeed = RTUtil.ConstrictNum(mSpeed, false); }