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

Commits on Nov 10, 2019

  1. Copy the full SHA
    7c4da6c View commit details

Commits on Nov 17, 2019

  1. Copy the full SHA
    8aba8ac View commit details
  2. Merge pull request #2373 from eggrobin/human-readable-history

    Human readable history
    eggrobin authored Nov 17, 2019
    Copy the full SHA
    8f09402 View commit details
Showing with 22 additions and 31 deletions.
  1. +0 −5 ksp_plugin_adapter/ksp_plugin_adapter.cs
  2. +22 −26 ksp_plugin_adapter/main_window.cs
5 changes: 0 additions & 5 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
@@ -77,10 +77,6 @@ internal IntPtr Plugin() {
[KSPField(isPersistant = true)]
private string serialization_encoding_ = "hexadecimal";

// For compatibility only. Do not use in real code.
[KSPField(isPersistant = true)]
private const int history_length_index_ = 10;

// Whether the plotting frame must be set to something convenient at the next
// opportunity.
private bool must_set_plotting_frame_ = false;
@@ -611,7 +607,6 @@ public override void OnLoad(ConfigNode node) {
if (is_bad_installation_) {
return;
}
main_window_.LoadCompatibilityDataIfNeeded(history_length_index_);
if (node.HasValue(principia_serialized_plugin_)) {
Cleanup();
RemoveBuggyTidalLocking();
48 changes: 22 additions & 26 deletions ksp_plugin_adapter/main_window.cs
Original file line number Diff line number Diff line change
@@ -50,13 +50,7 @@ public void SelectActiveVesselTarget(MapObject map_object,

public bool display_patched_conics { get; private set; } = false;

public double history_length => history_lengths_[history_length_index_];

public void LoadCompatibilityDataIfNeeded(int history_length_index) {
if (should_load_compatibility_data_) {
history_length_index_ = history_length_index;
}
}
public double history_length => history_length_.value;

public override void Load(ConfigNode node) {
base.Load(node);
@@ -78,11 +72,10 @@ public override void Load(ConfigNode node) {
Convert.ToBoolean(show_prediction_settings_value);
}

string history_length_index_value =
node.GetAtMostOneValue("history_length_index");
if (history_length_index_value != null) {
should_load_compatibility_data_ = false;
history_length_index_ = Convert.ToInt32(history_length_index_value);
string history_length_value =
node.GetAtMostOneValue("history_length");
if (history_length_value != null) {
history_length_.value = Convert.ToDouble(history_length_value);
}

string buffered_logging_value =
@@ -134,10 +127,9 @@ public override void Save(ConfigNode node) {
show_prediction_settings_,
createIfNotFound : true);

node.SetValue("history_length_index",
history_length_index_,
node.SetValue("history_length",
history_length,
createIfNotFound : true);

node.SetValue("buffered_logging",
buffered_logging_,
createIfNotFound : true);
@@ -189,11 +181,7 @@ protected override void RenderWindow(int window_id) {
UnityEngine.GUILayout.Label(
version,
style : Style.Info(UnityEngine.GUI.skin.label));
RenderSelector(history_lengths_,
ref history_length_index_,
"Max history length",
"{0:0.00e00} s",
enabled: true);
history_length_.Render(enabled : true);
if (MapView.MapIsEnabled &&
FlightGlobals.ActiveVessel?.orbitTargeter != null) {
show_selection_ui_ = true;
@@ -493,10 +481,20 @@ private void RenderToggleableSection(string name,
prediction_length_tolerances_[prediction_length_tolerance_index_];
private long prediction_steps => prediction_steps_[prediction_steps_index_];

private static readonly double[] history_lengths_ =
{1 << 10, 1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15, 1 << 16, 1 << 17,
1 << 18, 1 << 19, 1 << 20, 1 << 21, 1 << 22, 1 << 23, 1 << 24, 1 << 25,
1 << 26, 1 << 27, 1 << 28, 1 << 29, double.PositiveInfinity};
private DifferentialSlider history_length_ = new DifferentialSlider(
label : "Max history length",
unit : null,
log10_lower_rate : 0,
log10_upper_rate : 7,
min_value : 10,
max_value : double.PositiveInfinity,
formatter : Formatters.FormatMissionDuration,
parser : Formatters.TryParseMissionDuration,
label_width : 5,
field_width : 5) {
value = 7 * 24 * 60 * 60
};

private static readonly double[] prediction_length_tolerances_ =
{1e-3, 1e-2, 1e0, 1e1, 1e2, 1e3, 1e4};
private static readonly long[] prediction_steps_ =
@@ -520,11 +518,9 @@ private void RenderToggleableSection(string name,

private bool show_selection_ui_ = false;

private bool should_load_compatibility_data_ = true;
private int prediction_length_tolerance_index_ =
default_prediction_length_tolerance_index_;
private int prediction_steps_index_ = default_prediction_steps_index_;
private int history_length_index_ = 10;

private int buffered_logging_ = 0;
private int stderr_logging_ = 2;