Skip to content

Commit

Permalink
Fixed a character-limit bug; Added bearing and distance readouts for …
Browse files Browse the repository at this point in the history
…targets and waypoints from CYBUTEK#132 (with bugs fixed)
  • Loading branch information
J2583 committed May 17, 2024
1 parent 8e85965 commit 0e5fea6
Show file tree
Hide file tree
Showing 10 changed files with 458 additions and 4 deletions.
4 changes: 4 additions & 0 deletions KerbalEngineer/Flight/Readouts/ReadoutLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ static ReadoutLibrary() {
readouts.Add(new ImpactMarker());
readouts.Add(new ImpactAltitude());
readouts.Add(new ImpactBiome());
readouts.Add(new SurfaceDistanceToWaypoint());
readouts.Add(new BearingToWaypoint());

// Vessel
readouts.Add(new Name());
Expand Down Expand Up @@ -183,6 +185,8 @@ static ReadoutLibrary() {
readouts.Add(new Rendezvous.SpeedAtClosestApproach());
readouts.Add(new TargetLatitude());
readouts.Add(new TargetLongitude());
readouts.Add(new SurfaceDistanceToTarget());
readouts.Add(new BearingToTarget());

// Thermal
readouts.Add(new InternalFlux());
Expand Down
8 changes: 4 additions & 4 deletions KerbalEngineer/Flight/Readouts/ReadoutModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ protected void DrawLine(string value, Unity.Flight.ISectionModule section) {
GUILayout.BeginHorizontal(GUILayout.Width(section.Width * GuiDisplaySize.Offset));
GUILayout.Label(this.Name, NameStyle);
GUILayout.FlexibleSpace();
GUILayout.Label(value.ToLength(HudCharacterLimit), ValueStyle);
GUILayout.Label(value.ToLength(CharacterLimit), ValueStyle);
} else {
GUILayout.BeginHorizontal(GUILayout.Width(section.HudWidth * GuiDisplaySize.Offset));
GUILayout.Label(this.Name, NameStyle, GUILayout.Height(NameStyle.fontSize * 1.2f));
GUILayout.FlexibleSpace();
GUILayout.Label(value.ToLength(CharacterLimit), ValueStyle, GUILayout.Height(ValueStyle.fontSize * 1.2f));
GUILayout.Label(value.ToLength(HudCharacterLimit), ValueStyle, GUILayout.Height(ValueStyle.fontSize * 1.2f));
}
GUILayout.EndHorizontal();

Expand All @@ -212,12 +212,12 @@ protected void DrawLine(string name, string value, Unity.Flight.ISectionModule s
GUILayout.BeginHorizontal(GUILayout.Width(section.Width * GuiDisplaySize.Offset));
GUILayout.Label(name, NameStyle);
GUILayout.FlexibleSpace();
GUILayout.Label(value.ToLength(HudCharacterLimit), ValueStyle);
GUILayout.Label(value.ToLength(CharacterLimit), ValueStyle);
} else {
GUILayout.BeginHorizontal(GUILayout.Width(section.HudWidth * GuiDisplaySize.Offset));
GUILayout.Label(name, NameStyle, GUILayout.Height(NameStyle.fontSize * 1.2f));
GUILayout.FlexibleSpace();
GUILayout.Label(value.ToLength(CharacterLimit), ValueStyle, GUILayout.Height(ValueStyle.fontSize * 1.2f));
GUILayout.Label(value.ToLength(HudCharacterLimit), ValueStyle, GUILayout.Height(ValueStyle.fontSize * 1.2f));
}
GUILayout.EndHorizontal();
this.lineCountEnd++;
Expand Down
76 changes: 76 additions & 0 deletions KerbalEngineer/Flight/Readouts/Rendezvous/BearingToTarget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

/*using KerbalEngineer.Flight.Sections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
*/


//
// Kerbal Engineer Redux
//
// Copyright (C) 2017 fat-lobyte
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

#region Using Directives

using KerbalEngineer.Extensions;
using KerbalEngineer.Flight.Readouts.Surface;
using KerbalEngineer.Flight.Sections;

#endregion

namespace KerbalEngineer.Flight.Readouts.Rendezvous
{
public class BearingToTarget : ReadoutModule
{
#region Constructors

public BearingToTarget()
{
this.Name = "Bearing to Target";
this.Category = ReadoutCategory.GetCategory("Rendezvous");
this.HelpString = "Bearing to the target on the surface";
this.IsDefault = false;
}

#endregion

#region Methods: public

public override void Draw(Unity.Flight.ISectionModule section)
{
if (SurfaceDistanceProcessor.ShowTargetDetails)
{
this.DrawLine(SurfaceDistanceProcessor.SurfaceBearingToTarget.ToAngle(section.IsHud ? HudDecimalPlaces : DecimalPlaces), section);
}
}

public override void Reset()
{
FlightEngineerCore.Instance.AddUpdatable(SurfaceDistanceProcessor.Instance);
}

public override void Update()
{
SurfaceDistanceProcessor.RequestUpdate();
}

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// Kerbal Engineer Redux
//
// Copyright (C) 2017 fat-lobyte
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

#region Using Directives

using KerbalEngineer.Extensions;
using KerbalEngineer.Flight.Readouts.Surface;

#endregion

namespace KerbalEngineer.Flight.Readouts.Rendezvous
{
public class SurfaceDistanceToTarget : ReadoutModule
{
#region Constructors

public SurfaceDistanceToTarget()
{
this.Name = "Distance (Surface)";
this.Category = ReadoutCategory.GetCategory("Rendezvous");
this.HelpString = "Great-circle distance from the current vessel to the target on the surface";
this.IsDefault = false;
}

#endregion

#region Methods: public

public override void Draw(Unity.Flight.ISectionModule section)
{
if (SurfaceDistanceProcessor.ShowTargetDetails)
{
this.DrawLine(SurfaceDistanceProcessor.TargetInSameSOI ? SurfaceDistanceProcessor.SurfaceDistanceToTarget.ToDistance(section.IsHud ? HudDecimalPlaces : DecimalPlaces) : "Different SOI", section);
}
}

public override void Reset()
{
FlightEngineerCore.Instance.AddUpdatable(SurfaceDistanceProcessor.Instance);
}

public override void Update()
{
SurfaceDistanceProcessor.RequestUpdate();
}

#endregion
}
}
66 changes: 66 additions & 0 deletions KerbalEngineer/Flight/Readouts/Surface/BearingToWaypoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// Kerbal Engineer Redux
//
// Copyright (C) 2017 fat-lobyte
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

#region Using Directives

using KerbalEngineer.Extensions;
using KerbalEngineer.Flight.Readouts.Surface;
using KerbalEngineer.Flight.Sections;

#endregion

namespace KerbalEngineer.Flight.Readouts.Rendezvous
{
public class BearingToWaypoint : ReadoutModule
{
#region Constructors

public BearingToWaypoint()
{
this.Name = "Bearing to Waypoint";
this.Category = ReadoutCategory.GetCategory("Surface");
this.HelpString = "Bearing to the waypoint along the surface";
this.IsDefault = false;
}

#endregion

#region Methods: public

public override void Draw(Unity.Flight.ISectionModule section)
{
if (SurfaceDistanceProcessor.ShowWaypointDetails)
{
this.DrawLine(SurfaceDistanceProcessor.SurfaceBearingToWaypoint.ToAngle(section.IsHud ? HudDecimalPlaces : DecimalPlaces), section);
}
}

public override void Reset()
{
FlightEngineerCore.Instance.AddUpdatable(SurfaceDistanceProcessor.Instance);
}

public override void Update()
{
SurfaceDistanceProcessor.RequestUpdate();
}

#endregion
}
}
Loading

0 comments on commit 0e5fea6

Please sign in to comment.