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: 3ab32dbf35b8
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1a3dee52aa4b
Choose a head ref
  • 5 commits
  • 3 files changed
  • 1 contributor

Commits on Apr 12, 2019

  1. An attempt that doesn't work.

    pleroy committed Apr 12, 2019
    Copy the full SHA
    cfd6a07 View commit details
  2. Merge.

    pleroy committed Apr 12, 2019
    Copy the full SHA
    5621fa1 View commit details
  3. Copy the full SHA
    3a1a545 View commit details

Commits on Apr 13, 2019

  1. After egg's review.

    pleroy committed Apr 13, 2019
    Copy the full SHA
    418a22d View commit details
  2. Merge pull request #2133 from pleroy/Inconsistent

    Use the warning style if the initial time of a manoeuvre is too large
    pleroy authored Apr 13, 2019
    Copy the full SHA
    1a3dee5 View commit details
Showing with 21 additions and 9 deletions.
  1. +5 −2 ksp_plugin_adapter/burn_editor.cs
  2. +12 −4 ksp_plugin_adapter/differential_slider.cs
  3. +4 −3 ksp_plugin_adapter/flight_planner.cs
7 changes: 5 additions & 2 deletions ksp_plugin_adapter/burn_editor.cs
Original file line number Diff line number Diff line change
@@ -46,7 +46,6 @@ public BurnEditor(PrincipiaPluginAdapter adapter,
// short: that will be indistinguishable.
zero_value : 0.001,
min_value : 0,
max_value : double.PositiveInfinity,
formatter : FormatPreviousCoastDuration,
parser : TryParsePreviousCoastDuration);
previous_coast_duration_.value = initial_time - time_base;
@@ -62,8 +61,12 @@ public BurnEditor(PrincipiaPluginAdapter adapter,

// Renders the |BurnEditor|. Returns true if and only if the settings were
// changed.
public bool Render(string header, bool enabled) {
public bool Render(string header,
bool enabled,
double? actual_final_time = null) {
bool changed = false;
previous_coast_duration_.max_value =
(actual_final_time ?? double.PositiveInfinity) - time_base;
using (new UnityEngine.GUILayout.HorizontalScope()) {
UnityEngine.GUILayout.Label(header);
string frame_info = "";
16 changes: 12 additions & 4 deletions ksp_plugin_adapter/differential_slider.cs
Original file line number Diff line number Diff line change
@@ -48,6 +48,12 @@ public DifferentialSlider(string label,
text_colour_ = text_colour;
}

public double max_value {
set {
max_value_ = value;
}
}

public double value {
get {
return value_ ?? 0.0;
@@ -77,10 +83,12 @@ public bool Render(bool enabled) {
}

if (enabled) {
// If the text is not syntactically correct, inform the user by drawing
// it in the warning style.
// If the text is not syntactically correct, or it exceeds the upper
// bound, inform the user by drawing it in the warning style. Note the
// fudge factor to account for uncertainty in text/double conversions.
var style = Style.RightAligned(UnityEngine.GUI.skin.textField);
if (!parser_(formatted_value_, out double v1)) {
if (!parser_(formatted_value_, out double v1) ||
v1 > max_value_ + 0.1) {
style = Style.Warning(style);
}

@@ -176,14 +184,14 @@ public bool Render(bool enabled) {
private readonly double log10_upper_rate_ = 3.5;
private readonly double zero_value_;
private readonly double min_value_;
private readonly double max_value_;

private readonly ValueFormatter formatter_;
private readonly ValueParser parser_;
private readonly UnityEngine.Color? text_colour_;

private float slider_position_ = 0.0f;
private DateTime last_time_;
private double max_value_;
// It is convenient for the value to be nullable so that we have a way to
// ensure that an assignment to it will actually have an effect and won't be
// optimized due to the existing value. This happens at initialization and
7 changes: 4 additions & 3 deletions ksp_plugin_adapter/flight_planner.cs
Original file line number Diff line number Diff line change
@@ -224,9 +224,10 @@ private void RenderFlightPlan(string vessel_guid) {
if (burn_editors_.Count > 0) {
Style.HorizontalLine();
BurnEditor last_burn = burn_editors_.Last();
if (last_burn.Render(header : "Editing manœuvre #" +
(burn_editors_.Count),
enabled : true)) {
if (last_burn.Render(header : "Editing manœuvre #" +
(burn_editors_.Count),
enabled : true,
actual_final_time : actual_final_time)) {
plugin_.FlightPlanReplaceLast(vessel_guid, last_burn.Burn());
last_burn.Reset(
plugin_.FlightPlanGetManoeuvre(vessel_guid,