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));
     }
 }
Example #2
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();
 }
 public void UpdateValues()
 {
     ApA.UpdateValue();
     Inclination.UpdateValue();
 }
Example #4
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;
            }
        }