示例#1
0
 public MainWindow(PrincipiaPluginAdapter adapter,
                   FlightPlanner flight_planner,
                   OrbitAnalyser orbit_analyser,
                   ReferenceFrameSelector plotting_frame_selector,
                   PredictedVessel predicted_vessel)
     : base(adapter, predicted_vessel) {
   adapter_ = adapter;
   flight_planner_ = flight_planner;
   orbit_analyser_ = orbit_analyser;
   plotting_frame_selector_ = plotting_frame_selector;
   Show();
 }
示例#2
0
            private bool RenderCoast(int index, out double?orbital_period)
            {
                string vessel_guid    = predicted_vessel.id.ToString();
                var    coast_analysis = plugin.FlightPlanGetCoastAnalysis(
                    vessel_guid,
                    revolutions_per_cycle: null,
                    days_per_cycle: null,
                    ground_track_revolution: 0,
                    index);
                string orbit_description = null;

                orbital_period = coast_analysis.elements?.nodal_period;
                if (coast_analysis.primary_index.HasValue)
                {
                    var primary           = FlightGlobals.Bodies[coast_analysis.primary_index.Value];
                    int?nodal_revolutions = (int?)(coast_analysis.mission_duration /
                                                   coast_analysis.elements?.nodal_period);
                    orbit_description = OrbitAnalyser.OrbitDescription(
                        primary,
                        coast_analysis.elements,
                        coast_analysis.recurrence,
                        coast_analysis.ground_track,
                        nodal_revolutions);
                }
                using (new UnityEngine.GUILayout.HorizontalScope()) {
                    if (index == burn_editors_.Count)
                    {
                        final_trajectory_analyser_.index = index;
                        final_trajectory_analyser_.RenderButton();
                    }
                    else
                    {
                        double start_of_coast = index == 0
                                    ? plugin.FlightPlanGetInitialTime(
                            vessel_guid)
                                    : burn_editors_[index - 1].final_time;
                        string coast_duration =
                            (burn_editors_[index].initial_time - start_of_coast).FormatDuration(
                                show_seconds: false);
                        string coast_description = orbit_description == null
                                       ? L10N.CacheFormat(
                            "#Principia_FlightPlan_Coast",
                            coast_duration)
                                       : L10N.CacheFormat(
                            "#Principia_FlightPlan_CoastInOrbit",
                            orbit_description,
                            coast_duration);

                        UnityEngine.GUILayout.Label(coast_description);
                    }
                    if (UnityEngine.GUILayout.Button(
                            L10N.CacheFormat("#Principia_FlightPlan_AddManœuvre"),
                            GUILayoutWidth(4)))
                    {
                        double initial_time;
                        if (index == 0)
                        {
                            initial_time = plugin.CurrentTime() + 60;
                        }
                        else
                        {
                            initial_time =
                                plugin.FlightPlanGetManoeuvre(vessel_guid,
                                                              index - 1).final_time + 60;
                        }
                        var editor = new BurnEditor(adapter_,
                                                    predicted_vessel,
                                                    initial_time,
                                                    index,
                                                    get_burn_at_index: burn_editors_.
                                                    ElementAtOrDefault);
                        editor.minimized = false;
                        Burn candidate_burn = editor.Burn();
                        var  status         = plugin.FlightPlanInsert(
                            vessel_guid,
                            candidate_burn,
                            index);

                        // The previous call did not necessarily create a manœuvre.  Check if
                        // we need to add an editor.
                        int number_of_manœuvres =
                            plugin.FlightPlanNumberOfManoeuvres(vessel_guid);
                        if (number_of_manœuvres > burn_editors_.Count)
                        {
                            editor.Reset(plugin.FlightPlanGetManoeuvre(vessel_guid, index));
                            burn_editors_.Insert(index, editor);
                            UpdateBurnEditorIndices();
                            UpdateStatus(status, index);
                            Shrink();
                            return(true);
                        }
                        // TODO(phl): The error messaging here will be either confusing or
                        // wrong.  The messages should mention the new manœuvre without
                        // numbering it, since the numbering has not changed (“the new manœuvre
                        // would overlap with manœuvre #1 or manœuvre #2” or something along
                        // these lines).
                        UpdateStatus(status, index);
                    }
                }
                return(false);
            }