Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
pleroy committed Feb 15, 2025
1 parent 02b9087 commit 1c6c47e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 36 deletions.
6 changes: 3 additions & 3 deletions ksp_plugin_adapter/interface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ internal interface IReferenceFrameParameters {
int[] SecondaryIndices { get; set; }
}

internal partial class PlottingFrameParameters : IReferenceFrameParameters, IConfigNode {
internal partial class PlottingFrameParameters : IReferenceFrameParameters,
IConfigNode {
public PlottingFrameParameters() {
primary_index = new int[]{};
secondary_index = new int[]{};
Expand All @@ -120,8 +121,7 @@ public override bool Equals(object obj) {
}

public override int GetHashCode() =>
(extension, centre_index,
primary_index.DefaultIfEmpty(-1).First(),
(extension, centre_index, primary_index.DefaultIfEmpty(-1).First(),
secondary_index.DefaultIfEmpty(-1).First()).GetHashCode();

public void Load(ConfigNode node) {
Expand Down
9 changes: 5 additions & 4 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ internal readonly ReferenceFrameSelector<PlottingFrameParameters>

public bool show_celestial_trajectory(CelestialBody celestial) {
return plotting_frame_selector_.pinned[celestial] ||
!main_window_.frames_that_hide_unpinned_celestials.Contains(
plotting_frame_selector_.FrameParameters());
!main_window_.frames_that_hide_unpinned_celestials.Contains(
plotting_frame_selector_.FrameParameters());
}

public event Action LockClearing;
Expand Down Expand Up @@ -353,8 +353,9 @@ public bool show_celestial_trajectory(CelestialBody celestial) {
map_node_pool_ = new MapNodePool(
this,
visibility_modifiers: () => new MapNodePool.VisibilityModifiers(
show_unpinned: !main_window_.frames_that_hide_unpinned_markers
.Contains(plotting_frame_selector_.FrameParameters()),
show_unpinned: !main_window_.frames_that_hide_unpinned_markers.
Contains(
plotting_frame_selector_.FrameParameters()),
can_hover: !ManœuvreMarker.has_interacting_marker)
);
flight_planner_ = new FlightPlanner(this, PredictedVessel);
Expand Down
58 changes: 29 additions & 29 deletions ksp_plugin_adapter/main_window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ internal class MainWindow : VesselSupervisedWindowRenderer {
private readonly DateTimeOffset next_release_date_ =
new DateTimeOffset(2025, 02, 28, 00, 44, 50, TimeSpan.Zero);

public MainWindow(
PrincipiaPluginAdapter adapter,
FlightPlanner flight_planner,
OrbitAnalyser orbit_analyser,
ReferenceFrameSelector<PlottingFrameParameters> plotting_frame_selector,
PredictedVessel predicted_vessel) : base(
public MainWindow(PrincipiaPluginAdapter adapter,
FlightPlanner flight_planner,
OrbitAnalyser orbit_analyser,
ReferenceFrameSelector<PlottingFrameParameters>
plotting_frame_selector,
PredictedVessel predicted_vessel) : base(
adapter,
predicted_vessel) {
adapter_ = adapter;
Expand Down Expand Up @@ -52,6 +52,7 @@ public HashSet<PlottingFrameParameters> frames_that_hide_unpinned_markers {
get;
private set;
} = new HashSet<PlottingFrameParameters>();

public HashSet<PlottingFrameParameters> frames_that_hide_unpinned_celestials {
get;
private set;
Expand Down Expand Up @@ -83,22 +84,21 @@ public override void Load(ConfigNode node) {
}

frames_that_hide_unpinned_celestials.Clear();
foreach (ConfigNode frame_node in
node.GetNodes("frames_that_hide_unpinned_celestials")) {
foreach (ConfigNode frame_node in node.GetNodes(
"frames_that_hide_unpinned_celestials")) {
var frame = new PlottingFrameParameters();
frame.Load(frame_node);
frames_that_hide_unpinned_celestials.Add(frame);
}

frames_that_hide_unpinned_markers.Clear();
foreach (ConfigNode frame_node in
node.GetNodes("frames_that_hide_unpinned_markers")) {
foreach (ConfigNode frame_node in node.GetNodes(
"frames_that_hide_unpinned_markers")) {
var frame = new PlottingFrameParameters();
frame.Load(frame_node);
frames_that_hide_unpinned_markers.Add(frame);
}


string buffered_logging_value = node.GetAtMostOneValue("buffered_logging");
if (buffered_logging_value != null) {
buffered_logging_ = Convert.ToInt32(buffered_logging_value);
Expand Down Expand Up @@ -255,13 +255,13 @@ protected override void RenderWindowContents(int window_id) {
bool show_unpinned_markers =
!frames_that_hide_unpinned_markers.Contains(
plotting_frame_parameters);
if (show_unpinned_markers != UnityEngine.GUILayout.Toggle(
show_unpinned_markers,
L10N.CacheFormat(
"#Principia_MainWindow_Declutter_UnpinnedMarkers"))) {
if (show_unpinned_markers !=
UnityEngine.GUILayout.Toggle(
show_unpinned_markers,
L10N.CacheFormat(
"#Principia_MainWindow_Declutter_UnpinnedMarkers"))) {
if (show_unpinned_markers) {
frames_that_hide_unpinned_markers.Add(
plotting_frame_parameters);
frames_that_hide_unpinned_markers.Add(plotting_frame_parameters);
} else {
frames_that_hide_unpinned_markers.Remove(
plotting_frame_parameters);
Expand All @@ -270,10 +270,11 @@ protected override void RenderWindowContents(int window_id) {
bool show_unpinned_celestials =
!frames_that_hide_unpinned_celestials.Contains(
plotting_frame_parameters);
if (show_unpinned_celestials != UnityEngine.GUILayout.Toggle(
show_unpinned_celestials,
L10N.CacheFormat(
"#Principia_MainWindow_Declutter_UnpinnedCelestials"))) {
if (show_unpinned_celestials !=
UnityEngine.GUILayout.Toggle(
show_unpinned_celestials,
L10N.CacheFormat(
"#Principia_MainWindow_Declutter_UnpinnedCelestials"))) {
if (show_unpinned_celestials) {
frames_that_hide_unpinned_celestials.Add(
plotting_frame_parameters);
Expand Down Expand Up @@ -323,8 +324,9 @@ private void RenderKSPFeatures() {
target_celestial.Name()),
UnityEngine.GUILayout.ExpandWidth(true));
if (UnityEngine.GUILayout.Button(
L10N.CacheFormat("#Principia_MainWindow_TargetCelestial_Clear"),
GUILayoutWidth(2))) {
L10N.CacheFormat(
"#Principia_MainWindow_TargetCelestial_Clear"),
GUILayoutWidth(2))) {
selecting_target_celestial_ = false;
FlightGlobals.fetch.SetVesselTarget(null);
}
Expand Down Expand Up @@ -439,9 +441,7 @@ private void RenderLoggingSettings() {
"#Principia_MainWindow_LoggingSettings_JournalingStatus_ON")
: L10N.CacheFormat(
"#Principia_MainWindow_LoggingSettings_JournalingStatus_OFF")),
style : Style.Info(
Style.RightAligned(
UnityEngine.GUI.skin.label)));
style : Style.Info(Style.RightAligned(UnityEngine.GUI.skin.label)));
}
if (journaling_ && !must_record_journal_) {
// We can deactivate a recorder at any time, but in order for replaying to
Expand Down Expand Up @@ -574,7 +574,7 @@ private void RenderToggleableSection(string name,

private readonly DifferentialSlider history_length_ = new DifferentialSlider(
label :
L10N.CacheFormat("#Principia_MainWindow_HistoryLength"),
L10N.CacheFormat("#Principia_MainWindow_HistoryLength"),
unit : null,
log10_lower_rate : log10_history_lower_rate,
log10_upper_rate : log10_history_upper_rate,
Expand All @@ -588,9 +588,9 @@ private void RenderToggleableSection(string name,
};

private static readonly double[] prediction_length_tolerances_ =
{1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3, 1e4};
{ 1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3, 1e4 };
private static readonly string[] prediction_length_tolerance_names_ =
{"1 mm", "1 cm", "10 cm", "1 m", "10 m", "100 m", "1 km", "10 km"};
{ "1 mm", "1 cm", "10 cm", "1 m", "10 m", "100 m", "1 km", "10 km" };
// Keep this consistent with `max_steps_in_prediction` in `plugin.cpp`.
private static readonly long[] prediction_steps_ = {
1 << 2, 1 << 4, 1 << 6, 1 << 8, 1 << 10, 1 << 12, 1 << 14, 1 << 16,
Expand Down

0 comments on commit 1c6c47e

Please sign in to comment.