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: 16e6105d38c4
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a25af81208b1
Choose a head ref
  • 5 commits
  • 2 files changed
  • 2 contributors

Commits on Dec 11, 2020

  1. Copy the full SHA
    5650d7e View commit details
  2. Copy the full SHA
    cdf14d9 View commit details
  3. Removed dead function

    RCrockford committed Dec 11, 2020
    Copy the full SHA
    5517d85 View commit details
  4. Copy the full SHA
    db10f84 View commit details
  5. Merge pull request #2816 from RCrockford/draw-style-configuration

    Added drawing style configuration
    eggrobin authored Dec 11, 2020
    Copy the full SHA
    a25af81 View commit details
Showing with 73 additions and 11 deletions.
  1. +13 −1 ksp_plugin_adapter/config_node_parsers.cs
  2. +60 −10 ksp_plugin_adapter/ksp_plugin_adapter.cs
14 changes: 13 additions & 1 deletion ksp_plugin_adapter/config_node_parsers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;

namespace principia {
namespace ksp_plugin_adapter {
@@ -117,6 +118,17 @@ private static List<BodyGeopotentialElement> GetBodyGeopotentialElements(
return elements;
}

public static void GetDrawStyle(
this ConfigNode node,
out UnityEngine.Color colour,
out GLLines.Style style) {
colour = XKCDColors.ColorTranslator.FromHtml(node.GetUniqueValue("colour"));
style = (GLLines.Style)Enum.Parse(
typeof(GLLines.Style),
node.GetUniqueValue("style"),
true);
}

}

} // namespace ksp_plugin_adapter
70 changes: 60 additions & 10 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
@@ -59,6 +59,8 @@ private enum UnityLayers {
private const string principia_override_version_check_config_name_ =
"principia_override_version_check";
private const string principia_flags_ = "principia_flags";
private const string principia_draw_styles_config_name_ =
"principia_draw_styles";

private KSP.UI.Screens.ApplicationLauncherButton toolbar_button_;
// Whether the user has hidden the UI.
@@ -110,6 +112,19 @@ internal IntPtr Plugin() {
private ReferenceFrameSelector.FrameType last_non_surface_frame_type_ =
ReferenceFrameSelector.FrameType.BODY_CENTRED_NON_ROTATING;

private UnityEngine.Color history_colour = XKCDColors.Lime;
private GLLines.Style history_style = GLLines.Style.Faded;
private UnityEngine.Color prediction_colour = XKCDColors.Fuchsia;
private GLLines.Style prediction_style = GLLines.Style.Solid;
private UnityEngine.Color flight_plan_colour = XKCDColors.PeriwinkleBlue;
private GLLines.Style flight_plan_style = GLLines.Style.Dashed;
private UnityEngine.Color burn_colour = XKCDColors.Pink;
private GLLines.Style burn_style = GLLines.Style.Solid;
private UnityEngine.Color target_history_colour = XKCDColors.Goldenrod;
private GLLines.Style target_history_style = GLLines.Style.Faded;
private UnityEngine.Color target_prediction_colour = XKCDColors.LightMauve;
private GLLines.Style target_prediction_style = GLLines.Style.Solid;

private readonly List<IntPtr> vessel_futures_ = new List<IntPtr>();

// The RSAS is the component of the stock KSP autopilot that deals with
@@ -642,6 +657,11 @@ public override void OnAwake() {
LoadTextureOrDie(out surface_navball_texture_, "navball_surface.png");
LoadTextureOrDie(out target_navball_texture_, "navball_target.png");

ConfigNode draw_styles =
GameDatabase.Instance.GetAtMostOneNode(
principia_draw_styles_config_name_);
LoadDrawStyles(draw_styles);

if (unmodified_orbits_ == null) {
unmodified_orbits_ = new Dictionary<CelestialBody, Orbit>();
foreach (CelestialBody celestial in
@@ -2064,17 +2084,17 @@ private void RenderTrajectories() {
main_vessel_guid,
main_window_.history_length)) {
GLLines.PlotRP2Lines(rp2_lines_iterator,
XKCDColors.Lime,
GLLines.Style.Faded);
history_colour,
history_style);
}
using (DisposableIterator rp2_lines_iterator =
planetarium.PlanetariumPlotPrediction(
plugin_,
чебышёв_plotting_method_,
main_vessel_guid)) {
GLLines.PlotRP2Lines(rp2_lines_iterator,
XKCDColors.Fuchsia,
GLLines.Style.Solid);
prediction_colour,
prediction_style);
}
// Target psychohistory and prediction.
string target_id =
@@ -2089,17 +2109,17 @@ private void RenderTrajectories() {
target_id,
main_window_.history_length)) {
GLLines.PlotRP2Lines(rp2_lines_iterator,
XKCDColors.Goldenrod,
GLLines.Style.Faded);
target_history_colour,
target_history_style);
}
using (DisposableIterator rp2_lines_iterator =
planetarium.PlanetariumPlotPrediction(
plugin_,
чебышёв_plotting_method_,
target_id)) {
GLLines.PlotRP2Lines(rp2_lines_iterator,
XKCDColors.LightMauve,
GLLines.Style.Solid);
target_prediction_colour,
target_prediction_style);
}
}
// Main vessel flight plan.
@@ -2131,8 +2151,8 @@ private void RenderTrajectories() {
i)) {
GLLines.PlotRP2Lines(
rp2_lines_iterator,
is_burn ? XKCDColors.Pink : XKCDColors.PeriwinkleBlue,
is_burn ? GLLines.Style.Solid : GLLines.Style.Dashed);
is_burn ? burn_colour : flight_plan_colour,
is_burn ? burn_style : flight_plan_style);
}
if (is_burn) {
int manœuvre_index = i / 2;
@@ -2384,6 +2404,36 @@ private void UpdateRenderingFrame(
planetarium_camera_adjuster_.should_transfer_camera_coordinates = true;
}

private void LoadDrawStyles(ConfigNode draw_styles) {
if (draw_styles == null) {
return;
}
ConfigNode history_parameters = draw_styles.GetAtMostOneNode("history");
history_parameters?.GetDrawStyle(out history_colour, out history_style);
ConfigNode prediction_parameters =
draw_styles.GetAtMostOneNode("prediction");
prediction_parameters?.GetDrawStyle(
out prediction_colour,
out prediction_style);
ConfigNode flight_plan_parameters =
draw_styles.GetAtMostOneNode("flight_plan");
flight_plan_parameters?.GetDrawStyle(
out flight_plan_colour,
out flight_plan_style);
ConfigNode burn_parameters = draw_styles.GetAtMostOneNode("burn");
burn_parameters?.GetDrawStyle(out burn_colour, out burn_style);
ConfigNode target_history_parameters =
draw_styles.GetAtMostOneNode("target_history");
target_history_parameters?.GetDrawStyle(
out target_history_colour,
out target_history_style);
ConfigNode target_prediction_parameters =
draw_styles.GetAtMostOneNode("target_prediction");
target_prediction_parameters?.GetDrawStyle(
out target_prediction_colour,
out target_prediction_style);
}

private static void InitializeIntegrators(
IntPtr plugin,
ConfigNode numerics_blueprint) {