Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2aaa0628a4cd
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 44d75edf04a4
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Apr 8, 2019

  1. Copy the full SHA
    436e130 View commit details
  2. :

    eggrobin committed Apr 8, 2019
    Copy the full SHA
    6d75bce View commit details
  3. Merge pull request #2126 from eggrobin/time-base

    Refer manœuvre times to a time base, not to the current time
    pleroy authored Apr 8, 2019
    Copy the full SHA
    44d75ed View commit details
Showing with 31 additions and 10 deletions.
  1. +16 −3 ksp_plugin_adapter/burn_editor.cs
  2. +15 −7 ksp_plugin_adapter/flight_planner.cs
19 changes: 16 additions & 3 deletions ksp_plugin_adapter/burn_editor.cs
Original file line number Diff line number Diff line change
@@ -10,10 +10,13 @@ class BurnEditor : ScalingRenderer {
public BurnEditor(PrincipiaPluginAdapter adapter,
IntPtr plugin,
Vessel vessel,
double initial_time) {
double initial_time,
int index,
BurnEditor previous_burn) {
adapter_ = adapter;
plugin_ = plugin;
vessel_ = vessel;
index_ = index;
Δv_tangent_ =
new DifferentialSlider(label : "Δv tangent",
unit : "m / s",
@@ -41,9 +44,11 @@ public BurnEditor(PrincipiaPluginAdapter adapter,
min_value : 0,
max_value : double.PositiveInfinity,
formatter : value =>
FlightPlanner.FormatTimeSpan(
FlightPlanner.FormatPositiveTimeSpan(
TimeSpan.FromSeconds(
Planetarium.GetUniversalTime() - value)));
value - (previous_burn?.final_time ??
plugin_.FlightPlanGetInitialTime(
vessel_.id.ToString())))));
initial_time_.value = initial_time;
reference_frame_selector_ = new ReferenceFrameSelector(
adapter_,
@@ -109,6 +114,11 @@ public bool Render(bool enabled) {
changed |= Δv_normal_.Render(enabled);
changed |= Δv_binormal_.Render(enabled);
changed |= initial_time_.Render(enabled);
UnityEngine.GUILayout.Label(
index_ == 0 ? "Time base: start of flight plan"
: $"Time base: end of manœuvre #{index_}",
style : new UnityEngine.GUIStyle(UnityEngine.GUI.skin.label){
alignment = UnityEngine.TextAnchor.UpperLeft});
changed |= changed_reference_frame_;
using (new UnityEngine.GUILayout.HorizontalScope()) {
UnityEngine.GUILayout.Label(
@@ -245,6 +255,8 @@ private void UseTheForceLuke() {
specific_impulse_in_seconds_g0_ = range;
}

private double final_time => initial_time_.value + duration_;

private bool is_inertially_fixed_;
private DifferentialSlider Δv_tangent_;
private DifferentialSlider Δv_normal_;
@@ -266,6 +278,7 @@ private void UseTheForceLuke() {
// Not owned.
private readonly IntPtr plugin_;
private readonly Vessel vessel_;
private readonly int index_;
private readonly PrincipiaPluginAdapter adapter_;

private bool changed_reference_frame_ = false;
22 changes: 15 additions & 7 deletions ksp_plugin_adapter/flight_planner.cs
Original file line number Diff line number Diff line change
@@ -104,10 +104,13 @@ private void UpdateVesselAndBurnEditors() {
// Dummy initial time, we call |Reset| immediately afterwards.
final_time_.value =
plugin_.FlightPlanGetDesiredFinalTime(vessel_guid);
burn_editors_.Add(new BurnEditor(adapter_,
plugin_,
vessel_,
initial_time: 0));
burn_editors_.Add(
new BurnEditor(adapter_,
plugin_,
vessel_,
initial_time : 0,
index : burn_editors_.Count,
previous_burn : burn_editors_.LastOrDefault()));
burn_editors_.Last().Reset(
plugin_.FlightPlanGetManoeuvre(vessel_guid, i));
}
@@ -200,13 +203,13 @@ private void RenderFlightPlan(string vessel_guid) {
}
for (int i = 0; i < burn_editors_.Count - 1; ++i) {
UnityEngine.GUILayout.TextArea("Manœuvre #" + (i + 1) + ":");
burn_editors_[i].Render(enabled: false);
burn_editors_[i].Render(enabled : false);
}
if (burn_editors_.Count > 0) {
BurnEditor last_burn = burn_editors_.Last();
UnityEngine.GUILayout.TextArea("Editing manœuvre #" +
(burn_editors_.Count) + ":");
if (last_burn.Render(enabled: true)) {
if (last_burn.Render(enabled : true)) {
plugin_.FlightPlanReplaceLast(vessel_guid, last_burn.Burn());
last_burn.Reset(
plugin_.FlightPlanGetManoeuvre(vessel_guid,
@@ -234,7 +237,12 @@ private void RenderFlightPlan(string vessel_guid) {
burn_editors_.Count - 1).final_time + 60;
}
var editor =
new BurnEditor(adapter_, plugin_, vessel_, initial_time);
new BurnEditor(adapter_,
plugin_,
vessel_,
initial_time,
index : burn_editors_.Count,
previous_burn : burn_editors_.LastOrDefault());
Burn candidate_burn = editor.Burn();
bool inserted = plugin_.FlightPlanAppend(vessel_guid,
candidate_burn);