Skip to content

Commit

Permalink
Per-frame hiding.
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Feb 15, 2025
1 parent f2c6bbe commit 2268bf7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
8 changes: 5 additions & 3 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,9 @@ internal readonly ReferenceFrameSelector<PlottingFrameParameters>
private readonly MainWindow main_window_;

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

public event Action LockClearing;
Expand Down Expand Up @@ -352,7 +353,8 @@ public bool show_celestial_trajectory(CelestialBody celestial) {
map_node_pool_ = new MapNodePool(
this,
visibility_modifiers: () => new MapNodePool.VisibilityModifiers(
show_unpinned: main_window_.show_unpinned_markers,
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
49 changes: 37 additions & 12 deletions ksp_plugin_adapter/main_window.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using KSP.Localization;

Expand Down Expand Up @@ -47,8 +48,14 @@ public void SelectActiveVesselTarget(MapObject map_object,
}
}

public bool show_unpinned_markers { get; private set; } = true;
public bool show_unpinned_celestials { get; private set; } = true;
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;
} = new HashSet<PlottingFrameParameters>();

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

Expand Down Expand Up @@ -218,22 +225,40 @@ protected override void RenderWindowContents(int window_id) {
if (adapter_.PluginRunning()) {
plotting_frame_selector_.RenderButton();
using (new UnityEngine.GUILayout.HorizontalScope()) {
if (UnityEngine.GUILayout.Button(
L10N.CacheFormat("#Principia_MainWindow_Declutter"),
GUILayoutWidth(5))) {
show_unpinned_markers = false;
show_unpinned_celestials = false;
}
UnityEngine.GUILayout.Label(
L10N.CacheFormat("#Principia_MainWindow_Declutter_Show"));
show_unpinned_markers = UnityEngine.GUILayout.Toggle(
var plotting_frame_parameters =
plotting_frame_selector_.FrameParameters();
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"));
show_unpinned_celestials = UnityEngine.GUILayout.Toggle(
"#Principia_MainWindow_Declutter_UnpinnedMarkers"))) {
if (show_unpinned_markers) {
frames_that_hide_unpinned_markers.Remove(
plotting_frame_parameters);
} else {
frames_that_hide_unpinned_markers.Add(
plotting_frame_parameters);
}
}
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"));
"#Principia_MainWindow_Declutter_UnpinnedCelestials"))) {
if (show_unpinned_celestials) {
frames_that_hide_unpinned_celestials.Remove(
plotting_frame_parameters);
} else {
frames_that_hide_unpinned_celestials.Add(
plotting_frame_parameters);
}
}
}
using (new UnityEngine.GUILayout.HorizontalScope()) {
flight_planner_.RenderButton();
Expand Down

0 comments on commit 2268bf7

Please sign in to comment.