Skip to content

Commit

Permalink
Beautify station marker and add toggle button to hide/show station ma…
Browse files Browse the repository at this point in the history
…rkers
  • Loading branch information
KSP-TaxiService committed Apr 20, 2018
1 parent 0b448f3 commit c7199b7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
Binary file modified GameData/CommNetConstellation/Textures/groundStationMark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/CommNetConstellation/CommNetLayer/CNCCommNetHome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public void OnGUI()
if ((!HighLogic.CurrentGame.Parameters.CustomParams<CommNetParams>().enableGroundStations && !this.isKSC) || !MapView.MapIsEnabled || MapView.MapCamera == null)
return;

if (CNCCommNetScenario.Instance.hideGroundStations)
return;

Vector3d worldPos = ScaledSpace.LocalToScaledSpace(nodeTransform.transform.position);

if (MapView.MapCamera.transform.InverseTransformPoint(worldPos).z < 0f)
Expand Down
5 changes: 5 additions & 0 deletions src/CommNetConstellation/CommNetLayer/CNCCommNetScenario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class CNCCommNetScenario : CommNetScenario
private List<CNCCommNetHome> persistentGroundStations; // leave the initialisation to OnLoad()
private List<CNCCommNetVessel> commVessels;
private bool dirtyCommNetVesselList;
public bool hideGroundStations;

public static new CNCCommNetScenario Instance
{
Expand Down Expand Up @@ -153,6 +154,9 @@ public override void OnLoad(ConfigNode gameNode)
case "DisplayModeFlight":
CNCCommNetUI.CustomModeFlightMap = (CNCCommNetUI.CustomDisplayMode)((int)Enum.Parse(typeof(CNCCommNetUI.CustomDisplayMode), value.value));
break;
case "HideGroundStations":
this.hideGroundStations = Boolean.Parse(value.value);
break;
}
}

Expand Down Expand Up @@ -230,6 +234,7 @@ public override void OnSave(ConfigNode gameNode)
//Other variables
gameNode.AddValue("DisplayModeTracking", CNCCommNetUI.CustomModeTrackingStation);
gameNode.AddValue("DisplayModeFlight", CNCCommNetUI.CustomModeFlightMap);
gameNode.AddValue("HideGroundStations", this.hideGroundStations);

//Constellations
if (!gameNode.HasNode("Constellations"))
Expand Down
8 changes: 7 additions & 1 deletion src/CommNetConstellation/UI/ConstellationControlDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,12 @@ private List<DialogGUIHorizontalLayout> populateVesselRows(VesselTypeFilter filt
private List<DialogGUIBase> getGroundstationContentLayout()
{
List<DialogGUIBase> stationComponments = new List<DialogGUIBase>();

//toggle button for ground station markers
DialogGUIToggleButton toggleStationButton = new DialogGUIToggleButton(CNCCommNetScenario.Instance.hideGroundStations, "Hide all station markers", delegate (bool b) { CNCCommNetScenario.Instance.hideGroundStations = !CNCCommNetScenario.Instance.hideGroundStations; }, 60, 25);
DialogGUIHorizontalLayout toggleStationGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { new DialogGUIFlexibleSpace(), toggleStationButton, new DialogGUIFlexibleSpace() });
stationComponments.Add(toggleStationGroup);

List<DialogGUIHorizontalLayout> rows = populateGroundStationRows();
for (int i = 0; i < rows.Count; i++)
{
Expand Down Expand Up @@ -485,7 +491,7 @@ private DialogGUIHorizontalLayout createGroundStationRow(CNCCommNetHome thisStat
DialogGUIImage colorImage = new DialogGUIImage(new Vector2(16, 16), Vector2.one, thisStation.Color, groundstationTexture);
DialogGUILabel stationNameLabel = new DialogGUILabel(thisStation.stationName, 170, 12);
DialogGUILabel locationLabel = new DialogGUILabel(string.Format("LAT: {0:0.0}\nLON: {1:0.0}", thisStation.latitude, thisStation.longitude), 100, 24);
DialogGUILabel freqsLabel = new DialogGUILabel(getFreqString(thisStation.Frequencies), 200, 12);
DialogGUILabel freqsLabel = new DialogGUILabel(getFreqString(thisStation.Frequencies), 210, 12);
DialogGUIButton updateButton = new DialogGUIButton("Edit", delegate { groundstationEditClick(thisStation); }, 50, 32, false);

DialogGUIBase[] rowGUIBase = new DialogGUIBase[] { colorImage, stationNameLabel, locationLabel, freqsLabel, updateButton };
Expand Down
Binary file added src/groundStationMark.psd
Binary file not shown.

0 comments on commit c7199b7

Please sign in to comment.