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

Commits on May 18, 2017

  1. classes

    eggrobin committed May 18, 2017
    Copy the full SHA
    9e9e784 View commit details
  2. use HorizontalLayout

    eggrobin committed May 18, 2017
    Copy the full SHA
    21bd824 View commit details
  3. use VerticalLayout

    eggrobin committed May 18, 2017
    Copy the full SHA
    2085fc1 View commit details
  4. Fix #1376.

    eggrobin committed May 18, 2017
    Copy the full SHA
    aeafeba View commit details
  5. after pleroy's review

    eggrobin committed May 18, 2017
    Copy the full SHA
    92f0d45 View commit details
  6. Merge pull request #1381 from eggrobin/disposables

    Window code cleanup
    eggrobin authored May 18, 2017
    Copy the full SHA
    9c2a9ed View commit details
98 changes: 49 additions & 49 deletions ksp_plugin_adapter/burn_editor.cs
Original file line number Diff line number Diff line change
@@ -60,60 +60,60 @@ public BurnEditor(PrincipiaPluginAdapter adapter,
public bool Render(bool enabled) {
var old_skin = UnityEngine.GUI.skin;
UnityEngine.GUI.skin = null;
UnityEngine.GUILayout.BeginVertical();
var warning_style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.textArea);
warning_style.normal.textColor = XKCDColors.Orange;
bool changed = false;
// When we are first rendered, the |initial_mass_in_tonnes_| will just have
// been set. If we have fallen back to instant impulse, we should use this
// mass to set the thrust.
if (first_time_rendering) {
first_time_rendering = false;
changed = true;
engine_warning_ = "";
ComputeEngineCharacteristics();
}
if (enabled) {
UnityEngine.GUILayout.BeginHorizontal();
if (UnityEngine.GUILayout.Button("Active Engines")) {
engine_warning_ = "";
ComputeEngineCharacteristics();
using (new VerticalLayout()) {
var warning_style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.textArea);
warning_style.normal.textColor = XKCDColors.Orange;
// When we are first rendered, the |initial_mass_in_tonnes_| will just have
// been set. If we have fallen back to instant impulse, we should use this
// mass to set the thrust.
if (first_time_rendering) {
first_time_rendering = false;
changed = true;
} else if (UnityEngine.GUILayout.Button("Active RCS")) {
engine_warning_ = "";
ComputeRCSCharacteristics();
changed = true;
} else if (UnityEngine.GUILayout.Button("Instant Impulse")) {
engine_warning_ = "";
UseTheForceLuke();
changed = true;
ComputeEngineCharacteristics();
}
UnityEngine.GUILayout.EndHorizontal();
UnityEngine.GUILayout.TextArea(engine_warning_, warning_style);
reference_frame_selector_.RenderButton();
} else {
reference_frame_selector_.Hide();
}
string frame_warning = "";
if (!reference_frame_selector_.FrameParameters().Equals(
adapter_.plotting_frame_selector_.get().FrameParameters())) {
frame_warning = "Manœuvre frame differs from plotting frame";
if (enabled) {
using (new HorizontalLayout()) {
if (UnityEngine.GUILayout.Button("Active Engines")) {
engine_warning_ = "";
ComputeEngineCharacteristics();
changed = true;
} else if (UnityEngine.GUILayout.Button("Active RCS")) {
engine_warning_ = "";
ComputeRCSCharacteristics();
changed = true;
} else if (UnityEngine.GUILayout.Button("Instant Impulse")) {
engine_warning_ = "";
UseTheForceLuke();
changed = true;
}
}
UnityEngine.GUILayout.TextArea(engine_warning_, warning_style);
reference_frame_selector_.RenderButton();
} else {
reference_frame_selector_.Hide();
}
string frame_warning = "";
if (!reference_frame_selector_.FrameParameters().Equals(
adapter_.plotting_frame_selector_.get().FrameParameters())) {
frame_warning = "Manœuvre frame differs from plotting frame";
}
UnityEngine.GUILayout.TextArea(frame_warning, warning_style);
changed |= Δv_tangent_.Render(enabled);
changed |= Δv_normal_.Render(enabled);
changed |= Δv_binormal_.Render(enabled);
changed |= initial_time_.Render(enabled);
changed |= changed_reference_frame_;
using (new HorizontalLayout()) {
UnityEngine.GUILayout.Label(
"Manœuvre Δv : " + Δv().ToString("0.000") + " m/s",
UnityEngine.GUILayout.Width(200));
UnityEngine.GUILayout.Label("Duration : " + duration_.ToString("0.0") +
" s");
}
changed_reference_frame_ = false;
}
UnityEngine.GUILayout.TextArea(frame_warning, warning_style);
changed |= Δv_tangent_.Render(enabled);
changed |= Δv_normal_.Render(enabled);
changed |= Δv_binormal_.Render(enabled);
changed |= initial_time_.Render(enabled);
changed |= changed_reference_frame_;
UnityEngine.GUILayout.BeginHorizontal();
UnityEngine.GUILayout.Label(
"Manœuvre Δv : " + Δv().ToString("0.000") + " m/s",
UnityEngine.GUILayout.Width(200));
UnityEngine.GUILayout.Label("Duration : " + duration_.ToString("0.0") +
" s");
UnityEngine.GUILayout.EndHorizontal();
changed_reference_frame_ = false;
UnityEngine.GUILayout.EndVertical();
UnityEngine.GUI.skin = old_skin;
return changed && enabled;
}
96 changes: 48 additions & 48 deletions ksp_plugin_adapter/differential_slider.cs
Original file line number Diff line number Diff line change
@@ -38,59 +38,59 @@ internal class DifferentialSlider {
public bool Render(bool enabled) {
var old_skin = UnityEngine.GUI.skin;
UnityEngine.GUI.skin = null;
UnityEngine.GUILayout.BeginHorizontal();

var style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.label);
if (text_colour_.HasValue) {
style.normal.textColor = text_colour_.Value;
}
UnityEngine.GUILayout.Label(
text : label_,
options : UnityEngine.GUILayout.Width(75),
style : style);

var old_alignment = UnityEngine.GUI.skin.label.alignment;
UnityEngine.GUI.skin.label.alignment = UnityEngine.TextAnchor.UpperRight;
UnityEngine.GUILayout.Label(
text : format_(value),
options : UnityEngine.GUILayout.Width(125 + (unit_ == null ? 50 : 0)));
UnityEngine.GUI.skin.label.alignment = old_alignment;
UnityEngine.GUILayout.Label(
text : unit_ ?? "",
options : UnityEngine.GUILayout.Width(unit_ == null ? 0 : 50));

bool value_changed = false;
if (enabled) {
if (!UnityEngine.Input.GetMouseButton(0)) {
slider_position_ = 0;
}
UnityEngine.GUI.skin.horizontalSlider.fixedHeight = 21;
UnityEngine.GUI.skin.horizontalSliderThumb.fixedHeight = 21;
slider_position_ = UnityEngine.GUILayout.HorizontalSlider(
value : slider_position_,
leftValue : -1,
rightValue : 1,
options : UnityEngine.GUILayout.ExpandWidth(true));

if (UnityEngine.GUILayout.Button("0", UnityEngine.GUILayout.Width(20))) {
value_changed = true;
value = 0;
using (new HorizontalLayout()) {
var style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.label);
if (text_colour_.HasValue) {
style.normal.textColor = text_colour_.Value;
}
if (slider_position_ != 0.0) {
value_changed = true;
value += Math.Sign(slider_position_) *
Math.Pow(10, log10_lower_rate_ +
(log10_upper_rate_ - log10_lower_rate_) *
Math.Abs(slider_position_)) *
(System.DateTime.Now - last_time_).TotalSeconds;
value = Math.Min(Math.Max(min_value_, value), max_value_);
UnityEngine.GUILayout.Label(
text : label_,
options : UnityEngine.GUILayout.Width(75),
style : style);

var old_alignment = UnityEngine.GUI.skin.label.alignment;
UnityEngine.GUI.skin.label.alignment = UnityEngine.TextAnchor.UpperRight;
UnityEngine.GUILayout.Label(
text : format_(value),
options : UnityEngine.GUILayout.Width(125 + (unit_ == null ? 50 : 0)));
UnityEngine.GUI.skin.label.alignment = old_alignment;
UnityEngine.GUILayout.Label(
text : unit_ ?? "",
options : UnityEngine.GUILayout.Width(unit_ == null ? 0 : 50));

if (enabled) {
if (!UnityEngine.Input.GetMouseButton(0)) {
slider_position_ = 0;
}
UnityEngine.GUI.skin.horizontalSlider.fixedHeight = 21;
UnityEngine.GUI.skin.horizontalSliderThumb.fixedHeight = 21;
slider_position_ = UnityEngine.GUILayout.HorizontalSlider(
value : slider_position_,
leftValue : -1,
rightValue : 1,
options : UnityEngine.GUILayout.ExpandWidth(true));

if (UnityEngine.GUILayout.Button("0",
UnityEngine.GUILayout.Width(20))) {
value_changed = true;
value = 0;
}
if (slider_position_ != 0.0) {
value_changed = true;
value += Math.Sign(slider_position_) *
Math.Pow(10, log10_lower_rate_ +
(log10_upper_rate_ - log10_lower_rate_) *
Math.Abs(slider_position_)) *
(System.DateTime.Now - last_time_).TotalSeconds;
value = Math.Min(Math.Max(min_value_, value), max_value_);
}
} else {
slider_position_ = 0;
}
} else {
slider_position_ = 0;
last_time_ = System.DateTime.Now;
}
last_time_ = System.DateTime.Now;

UnityEngine.GUILayout.EndHorizontal();

UnityEngine.GUI.skin = old_skin;
return value_changed;
Loading