示例#1
0
 public void Draw()
 {
     GUILayout.BeginHorizontal();
     GUILayout.BeginVertical();
     GUILayout.Label("Radius:", GUILayout.ExpandWidth(true));
     GUILayout.Label("Inclination:", GUILayout.ExpandWidth(true));
     GUILayout.Label("Steepness:", GUILayout.ExpandWidth(true));
     GUILayout.EndVertical();
     GUILayout.BeginVertical();
     GUILayout.FlexibleSpace();
     GUILayout.BeginHorizontal();
     GUILayout.FlexibleSpace();
     if (GUILayout.Button(new GUIContent(DescendingNode? "DN" : "AN", "Launch from Ascending or Descending Node?"),
                          DescendingNode? Styles.danger_button : Styles.enabled_button,
                          GUILayout.ExpandWidth(false)))
     {
         DescendingNode = !DescendingNode;
     }
     if (GUILayout.Button(new GUIContent(RetrogradeOrbit? "RG" : "PG", "Prograde or retrograde orbit?"),
                          RetrogradeOrbit? Styles.danger_button : Styles.enabled_button,
                          GUILayout.ExpandWidth(false)))
     {
         RetrogradeOrbit = !RetrogradeOrbit;
     }
     GUILayout.EndHorizontal();
     GUILayout.FlexibleSpace();
     GUILayout.EndVertical();
     GUILayout.BeginVertical();
     ApA.Draw("km", 5, suffix_width: 25);
     Inclination.Draw("°", 5, suffix_width: 25);
     Slope.Draw("%", 5, suffix_width: 25);
     GUILayout.EndVertical();
     GUILayout.EndHorizontal();
 }
示例#2
0
 public override void Draw()
 {
     if (CFG.BR[BearingMode.Auto] || !DirectionOverride.IsZero())
     {
         GUILayout.Label("AutoBearing", Styles.green, GUILayout.ExpandWidth(false));
                         #if DEBUG
         var dir = DirectionOverride.IsZero()? ForwardDirection : DirectionOverride;
         Utils.GLVec(VSL.Controls.Transform.position, dir.normalized * 2500, Color.green);
                         #endif
     }
     else if (CFG.BR[BearingMode.User])
     {
         if (draw_forward_direction)
         {
             Utils.GLVec(VSL.Physics.wCoM, ForwardDirection.normalized * 2500, Color.green);
             draw_forward_direction = !DirectionLineTimer.TimePassed;
         }
         if (Bearing.Draw("°", increment: 10))
         {
             ForwardDirection = VSL.Physics.Direction(Bearing);
             if (CFG.HF[HFlight.CruiseControl] && !VSL.HorizontalSpeed.NeededVector.IsZero())
             {
                 VSL.HorizontalSpeed.SetNeeded(ForwardDirection * CFG.MaxNavSpeed);
             }
         }
         if (GUILayout.Button(X_cnt, Styles.close_button, GUILayout.ExpandWidth(false)))
         {
             CFG.BR.Off();
         }
     }
     else if (!CFG.BR && GUILayout.Button(Enable_cnt, Styles.active_button, GUILayout.ExpandWidth(false)))
     {
         CFG.BR.XOn(BearingMode.User);
     }
 }
示例#3
0
 public override void Draw()
 {
     if (CFG.BR[BearingMode.Auto] || !DirectionOverride.IsZero())
     {
         GUILayout.Label("AutoBearing", Styles.enabled, GUILayout.ExpandWidth(true));
     }
     else if (CFG.BR[BearingMode.User])
     {
         if (Bearing.Draw("°", increment: 10))
         {
             ForwardDirection = VSL.Physics.Direction(Bearing);
             if (CFG.HF[HFlight.CruiseControl] && !VSL.HorizontalSpeed.NeededVector.IsZero())
             {
                 VSL.HorizontalSpeed.SetNeeded(ForwardDirection * CFG.MaxNavSpeed);
             }
         }
         if (GUILayout.Button(X_cnt, Styles.close_button, GUILayout.ExpandWidth(true)))
         {
             CFG.BR.Off();
         }
     }
     else if (!CFG.BR && GUILayout.Button(Enable_cnt, Styles.active_button, GUILayout.ExpandWidth(true)))
     {
         CFG.BR.XOn(BearingMode.User);
     }
 }
        public override void Draw()
        {
            update_from_cfg();
            var above_ground = VSL.Altitude.AboveGround;
            var style        = above_ground? Styles.green : Styles.red;

            GUILayout.Label(new GUIContent("Alt. (m):", above_ground?
                                           "Desired altitude is above the ground" :
                                           "Warning! Desired altitude is below the ground"),
                            style, GUILayout.ExpandWidth(true));
            if (Altitude.Draw("", 10, "F0", style: style))
            {
                set_altitude();
            }
        }
示例#5
0
        private void DrawFields(Type type, ComponentSystemBase effectiveInstance)
        {
            foreach (var field in cachedFields)
            {
                if (field.FieldType == typeof(System.Int32))
                {
                    IntField.Draw(type, field, effectiveInstance);
                }
                else if (field.FieldType == typeof(System.Single))
                {
                    FloatField.Draw(type, field, effectiveInstance);
                }
                else if (field.FieldType == typeof(System.String))
                {
                    StringField.Draw(type, field, effectiveInstance);
                }
                else if (field.FieldType == typeof(System.Boolean))
                {
                    BoolField.Draw(type, field, effectiveInstance);
                }
                else if (field.FieldType.IsEnum)
                {
                    var underlyingType = Enum.GetUnderlyingType(field.FieldType);
                    if (underlyingType == typeof(short))
                    {
                        MaskField.Draw(type, field, effectiveInstance);
                    }
                    else
                    {
                        EnumField.Draw(type, field, effectiveInstance);
                    }
                }
                else
                {
                    // monobehaviours
                    switch (field.FieldType.ToString())
                    {
                    case "UnityEngine.Mesh":
                        MeshField.Draw(type, field, effectiveInstance);
                        break;

                    case "UnityEngine.Material":
                        MaterialField.Draw(type, field, effectiveInstance);
                        break;
                    }
                }
            }
        }
 public void Draw()
 {
     GUILayout.BeginHorizontal();
     {
         GUILayout.BeginVertical();
         {
             GUILayout.Label(new GUIContent("Apoapsis:",
                                            "Apoapsis of the target circular orbit"),
                             GUILayout.ExpandWidth(true));
             GUILayout.Label(new GUIContent("Inclination:",
                                            "Inclination of the prograde varian of a target orbit. " +
                                            "In case of retrograde orbits the actual target inclination is " +
                                            "180-prograde_inclination."),
                             GUILayout.ExpandWidth(true));
         }
         GUILayout.EndVertical();
         GUILayout.BeginVertical();
         {
             GUILayout.FlexibleSpace();
             GUILayout.BeginHorizontal();
             {
                 GUILayout.FlexibleSpace();
                 if (GUILayout.Button(new GUIContent(DescendingNode ? "DN" : "AN", "Launch from Ascending or Descending Node?"),
                                      DescendingNode ? Styles.danger_button : Styles.enabled_button,
                                      GUILayout.ExpandWidth(false)))
                 {
                     DescendingNode = !DescendingNode;
                 }
                 if (GUILayout.Button(new GUIContent(RetrogradeOrbit ? "RG" : "PG", "Prograde or retrograde orbit?"),
                                      RetrogradeOrbit ? Styles.danger_button : Styles.enabled_button,
                                      GUILayout.ExpandWidth(false)))
                 {
                     RetrogradeOrbit = !RetrogradeOrbit;
                 }
             }
             GUILayout.EndHorizontal();
         }
         GUILayout.EndVertical();
         GUILayout.BeginVertical();
         {
             ApA.Draw("km", 5, "F1", suffix_width: 25);
             Inclination.Draw("°", 5, "F1", suffix_width: 25);
         }
         GUILayout.EndVertical();
     }
     GUILayout.EndHorizontal();
 }
 protected override void DrawThis()
 {
     if (Edit)
     {
         GUILayout.Label(Label, Styles.white, GUILayout.ExpandWidth(false));
         if (GUILayout.Button(OperatorNames[Operator], Styles.yellow, GUILayout.ExpandWidth(false)))
         {
             Operator = (CompareOperator)(((int)Operator + 1) % 3);
         }
         Value.Draw(Suffix);
         if (Operator == CompareOperator.EQ)
         {
             GUILayout.Label(new GUIContent("Error", "Interval of tolerance"),
                             Styles.white, GUILayout.ExpandWidth(false));
             Error.Draw(Suffix);
         }
         GUILayout.Label(new GUIContent("Wait for:", "The condition should be met at least this number of seconds"),
                         Styles.white, GUILayout.ExpandWidth(false));
         Period.Draw("s");
         if (GUILayout.Button("Done", Styles.confirm_button, GUILayout.ExpandWidth(false)))
         {
             Value.UpdateValue();
             Error.UpdateValue();
             if (Period.UpdateValue())
             {
                 negatable        = Period.Equals(0);
                 WaitTimer.Period = Period;
                 WaitTimer.Reset();
             }
             Edit = false;
         }
     }
     else
     {
         var condition_string = string.Format("{0} {1} {2:F1}", Name, OperatorNames[Operator], Value);
         condition_string += Operator == CompareOperator.EQ?
                             string.Format("+/-{0:F2}{1}", Error, Suffix) : Suffix;
         if (Period > 0)
         {
             condition_string += string.Format(" for {0:F1}s", Period);
         }
         Edit |= GUILayout.Button(new GUIContent(condition_string, Label.tooltip),
                                  Styles.normal_button, GUILayout.ExpandWidth(true));
     }
 }
 public void DrawOptions()
 {
     GUILayout.BeginHorizontal();
     {
         GUILayout.BeginVertical();
         {
             GUILayout.Label(new GUIContent("Time to Apoapsis:",
                                            "More time to apoapsis means steeper trajectory " +
                                            "and greater acceleration. Low values can " +
                                            "save a lot of fuel."),
                             GUILayout.ExpandWidth(true));
             GUILayout.Label(new GUIContent("Min. Throttle:",
                                            "Minimum throttle value. " +
                                            "Increasing it will shorten the last stage of the ascent."),
                             GUILayout.ExpandWidth(true));
             GUILayout.Label(new GUIContent("Max. Acceleration:",
                                            "Maximum allowed acceleration (in gees of the current planet). " +
                                            "Smooths gravity turn on low-gravity worlds. Saves fuel."),
                             GUILayout.ExpandWidth(true));
         }
         GUILayout.EndVertical();
         GUILayout.BeginVertical();
         {
             GUILayout.BeginHorizontal();
             {
                 GUILayout.FlexibleSpace();
                 Utils.ButtonSwitch("Auto", ref AutoTimeToApA,
                                    "Tune time to apoapsis automatically",
                                    GUILayout.ExpandWidth(false));
             }
             GUILayout.EndHorizontal();
             GUILayout.FlexibleSpace();
             GUILayout.FlexibleSpace();
         }
         GUILayout.EndVertical();
         GUILayout.BeginVertical();
         {
             TimeToApA.Draw("s", 5, "F1", suffix_width: 25);
             MinThrottle.Draw("%", 5, "F1", suffix_width: 25);
             MaxG.Draw("g", 0.5f, "F1", suffix_width: 25);
         }
         GUILayout.EndVertical();
     }
     GUILayout.EndHorizontal();
 }
 protected override void DrawThis()
 {
     GUILayout.BeginHorizontal();
     if (Edit)
     {
         GUILayout.Label(Name, Styles.white, GUILayout.ExpandWidth(false));
         if (Value.Draw(Suffix))
         {
             OnValueChanged();
             Edit = false;
         }
     }
     else
     {
         Edit |= GUILayout.Button(string.Format("{0} {1}{2}", Name, Value, Suffix), Styles.normal_button);
     }
     GUILayout.EndHorizontal();
 }
 public override void Draw()
 {
     GUILayout.BeginHorizontal();
     {
         GUILayout.BeginVertical();
         {
             GUILayout.Label("Savegame:");
             GUILayout.Label("Latitude spread:");
         }
         GUILayout.EndVertical();
         GUILayout.BeginVertical();
         {
             Save = GUILayout.TextField(Save, GUILayout.ExpandWidth(true));
             latSpread.Draw("°", 5);
         }
         GUILayout.EndVertical();
     }
     GUILayout.EndHorizontal();
 }
示例#11
0
 protected override void DrawThis()
 {
     GUILayout.BeginHorizontal();
     if (Edit)
     {
         GUILayout.Label(Name, Styles.label, GUILayout.ExpandWidth(false));
         if (GUILayout.Button(mode.ToString(), Styles.normal_button, GUILayout.ExpandWidth(false)))
         {
             mode = (Mode)(((int)mode + 1) % 6);
         }
         if (mode == Mode.Bearing)
         {
             Bearing.Draw("°", 10);
         }
         if (mode != Mode.Off)
         {
             Value.Draw(Suffix);
         }
         if (GUILayout.Button("Done", Styles.confirm_button, GUILayout.ExpandWidth(false)))
         {
             Bearing.UpdateValue();
             Value.UpdateValue();
             OnValueChanged();
             Edit = false;
         }
     }
     else
     {
         var title = Name + " " + mode + " ";
         if (mode == Mode.Bearing)
         {
             title += Bearing + "°, ";
         }
         if (mode != Mode.Off)
         {
             title += Value + Suffix;
         }
         Edit |= GUILayout.Button(title, Styles.normal_button);
     }
     GUILayout.EndHorizontal();
 }
示例#12
0
        public override void Draw()
        {
            #if DEBUG
//            var dir = DirectionOverride.IsZero()? ForwardDirection : DirectionOverride;
//            Utils.GLVec(VSL.refT.position, dir.normalized*2500, dir_color);
//            Utils.GLVec(VSL.refT.position, rotation_axis*5, Color.red);
//            Utils.GLVec(VSL.refT.position, VSL.OnPlanetParams.Fwd*5, Color.yellow);
//            Utils.GLVec(VSL.refT.position, VSL.OnPlanetParams.Heading*5, Color.magenta);
            #endif
            if (CFG.BR[BearingMode.Auto] || !DirectionOverride.IsZero())
            {
                GUILayout.Label("AutoBearing", Styles.enabled, GUILayout.ExpandWidth(true));
            }
            else if (CFG.BR[BearingMode.User])
            {
                if (draw_forward_direction)
                {
                    Utils.GLVec(VSL.Physics.wCoM, ForwardDirection.normalized * 2500, dir_color);
                    draw_forward_direction = !DirectionLineTimer.TimePassed;
                }
                if (Bearing.Draw("°", increment: 10))
                {
                    ForwardDirection = VSL.Physics.Direction(Bearing);
                    if (CFG.HF[HFlight.CruiseControl] && !VSL.HorizontalSpeed.NeededVector.IsZero())
                    {
                        VSL.HorizontalSpeed.SetNeeded(ForwardDirection * CFG.MaxNavSpeed);
                    }
                }
                if (GUILayout.Button(X_cnt, Styles.close_button, GUILayout.ExpandWidth(true)))
                {
                    CFG.BR.Off();
                }
            }
            else if (!CFG.BR && GUILayout.Button(Enable_cnt, Styles.active_button, GUILayout.ExpandWidth(true)))
            {
                CFG.BR.XOn(BearingMode.User);
            }
        }
示例#13
0
        void waypoint_editor(int windowID)
        {
            var close = false;

            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Name:", GUILayout.Width(70));
            edited_waypoint_name = GUILayout.TextField(edited_waypoint_name, GUILayout.ExpandWidth(true));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Latitude:", GUILayout.Width(70));
            LatField.Draw("°", 1, "F1");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Longitude:", GUILayout.Width(70));
            LonField.Draw("°", 1, "F1");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Altitude:", GUILayout.Width(70));
            AltField.Draw("°", 100, "F0");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Delete", Styles.danger_button))
            {
                CFG.Path.Remove(edited_waypoint);
                close = true;
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel", Styles.active_button))
            {
                close = true;
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(new GUIContent("◉", "Target this waypoint"), Styles.enabled_button))
            {
                VSL.SetTarget(null, edited_waypoint);
            }
            if (GUILayout.Button(new GUIContent("⊥", "Set altitude to ground level"), Styles.active_button))
            {
                edited_waypoint.Pos.SetAlt2Surface(VSL.Body);
                AltField.Value = (float)edited_waypoint.Pos.Alt;
            }
            if (Utils.ButtonSwitch("||", edited_waypoint.Pause, "Pause on arrival", GUILayout.Width(25)))
            {
                edited_waypoint.Pause = !edited_waypoint.Pause;
            }
            if (LND != null &&
                Utils.ButtonSwitch("Land", edited_waypoint.Land, "Land on arrival"))
            {
                edited_waypoint.Land = !edited_waypoint.Land;
            }
            if (GUILayout.Button("Apply", Styles.confirm_button))
            {
                LatField.UpdateValue(); LonField.UpdateValue(); AltField.UpdateValue();
                edited_waypoint.Name    = edited_waypoint_name;
                edited_waypoint.Pos.Lat = Utils.ClampAngle(LatField.Value);
                edited_waypoint.Pos.Lon = Utils.ClampAngle(LonField.Value);
                edited_waypoint.Pos.Alt = Math.Max(AltField.Value,
                                                   edited_waypoint.Pos.SurfaceAlt(vessel.mainBody));
                edited_waypoint.Update(VSL);
                close = true;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUIWindowBase.TooltipsAndDragWindow();
            if (close)
            {
                edited_waypoint = null;
            }
        }
 public void ManageGUI()
 {
     GUILayout.BeginHorizontal();
     tank_type_gui();
     tank_resource_gui();
     GUILayout.FlexibleSpace();
     if (HighLogic.LoadedSceneIsEditor && manager.Volume > 0)
     {
         if (edit)
         {
             if (VolumeField.Draw("m3", manager.Volume / 20, "F2"))
             {
                 var max_volume = tank.Volume + manager.Volume - manager.TotalVolume;
                 if (VolumeField.Value > max_volume)
                 {
                     VolumeField.Value = max_volume;
                 }
                 if (VolumeField.IsSet)
                 {
                     tank.Volume = VolumeField.Value;
                     tank.UpdateMaxAmount(true);
                     manager.total_volume = -1;
                     edit = false;
                 }
             }
         }
         else
         {
             edit |= GUILayout.Button(new GUIContent(Utils.formatVolume(tank.Volume), "Edit tank volume"),
                                      Styles.add_button, GUILayout.ExpandWidth(true));
         }
     }
     else
     {
         GUILayout.Label(Utils.formatVolume(tank.Volume), Styles.boxed_label, GUILayout.ExpandWidth(true));
     }
     if (!edit)
     {
         var usage = tank.Usage;
         GUILayout.Label("Filled: " + usage.ToString("P1"), Styles.fracStyle(usage), GUILayout.Width(95));
         if (HighLogic.LoadedSceneIsEditor)
         {
             if (GUILayout.Button(new GUIContent("F", "Fill the tank with the resource"),
                                  Styles.add_button, GUILayout.Width(20)))
             {
                 tank.Amount = tank.MaxAmount;
             }
             if (GUILayout.Button(new GUIContent("E", "Empty the tank"),
                                  Styles.active_button, GUILayout.Width(20)))
             {
                 tank.Amount = 0;
             }
         }
         if (manager.AddRemoveEnabled)
         {
             if (GUILayout.Button(new GUIContent("X", "Delete the tank"),
                                  Styles.danger_button, GUILayout.Width(20)))
             {
                 if (HighLogic.LoadedSceneIsEditor)
                 {
                     tank.Amount = 0;
                 }
                 manager.remove_tank(tank);
                 manager.part.UpdatePartMenu();
             }
         }
     }
     GUILayout.EndHorizontal();
 }
示例#15
0
 public void Toggles()
 {
     GUILayout.BeginHorizontal();
     if (VTOL != null)
     {
         if (Utils.ButtonSwitch("VTOL Mode", CFG.CTRL[ControlMode.VTOL],
                                "Keyboard controls thrust direction instead of torque", GUILayout.ExpandWidth(true)))
         {
             CFG.CTRL.XToggle(ControlMode.VTOL);
         }
     }
     if (VLA != null)
     {
         Utils.ButtonSwitch("VTOL Assist", ref CFG.VTOLAssistON,
                            "Assist with vertical takeoff and landing", GUILayout.ExpandWidth(true));
     }
     if (STB != null)
     {
         Utils.ButtonSwitch("Stabilizer", ref CFG.StabilizeFlight,
                            "Try to stabilize flight if spinning uncontrollably", GUILayout.ExpandWidth(true));
     }
     if (CPS != null)
     {
         Utils.ButtonSwitch("CPS", ref CFG.UseCPS,
                            "Enable Collision Prevention System", GUILayout.ExpandWidth(true));
     }
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     Utils.ButtonSwitch("AutoGear", ref CFG.AutoGear,
                        "Automatically deploy/retract landing gear when needed", GUILayout.ExpandWidth(true));
     Utils.ButtonSwitch("AutoBrakes", ref CFG.AutoBrakes,
                        "Automatically ebable/disable brakes when needed", GUILayout.ExpandWidth(true));
     Utils.ButtonSwitch("AutoStage", ref CFG.AutoStage,
                        "Automatically activate next stage when previous falmeouted", GUILayout.ExpandWidth(true));
     Utils.ButtonSwitch("AutoChute", ref CFG.AutoParachutes,
                        "Automatically activate parachutes when needed", GUILayout.ExpandWidth(true));
     if (GUILayout.Button(new GUIContent("Modules", "Show TCA modules installed on this ship"),
                          Styles.active_button, GUILayout.ExpandWidth(true)))
     {
         UI.ModulesGraph.Toggle();
     }
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     if (HSC != null)
     {
         Utils.ButtonSwitch("Hor. Thrust",
                            ref CFG.UseHorizontalThrust,
                            "Use maneuver engines to provide thrust for horizontal flight",
                            GUILayout.ExpandWidth(true));
         if (MinHorizontalAccel.Draw("kN/t",
                                     field_width: 50,
                                     suffix_tooltip:
                                     "Maneuver engines will be used as horizontal thrusters only if they produce more thrust than this.")
             )
         {
             CFG.MinHorizontalAccel = MinHorizontalAccel;
         }
         if (TRA != null)
         {
             Utils.ButtonSwitch("RCS Translation",
                                ref CFG.CorrectWithTranslation,
                                "Use RCS to correct horizontal velocity",
                                GUILayout.ExpandWidth(true));
         }
     }
     Utils.ButtonSwitch("RCS Rotation", ref CFG.RotateWithRCS,
                        "Use RCS for attitude control", GUILayout.ExpandWidth(true));
     GUILayout.EndHorizontal();
 }