Altitude (terrain) readout now shows the altitude above underwater terrain when splashed down.
Altitude (terrain) readout now shows the altitude above underwater terrain when splashed down.

// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2016 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
//  
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives  
   
#endregion  
   
namespace KerbalEngineer.Flight.Readouts.Surface namespace KerbalEngineer.Flight.Readouts.Surface
{ {
#region Using Directives  
   
using Extensions; using Extensions;
using Sections; using Sections;
  using Vessel = global::Vessel;
#endregion  
   
public class AltitudeTerrain : ReadoutModule public class AltitudeTerrain : ReadoutModule
{ {
#region Constructors  
   
public AltitudeTerrain() public AltitudeTerrain()
{ {
this.Name = "Altitude (Terrain)"; Name = "Altitude (Terrain)";
this.Category = ReadoutCategory.GetCategory("Surface"); Category = ReadoutCategory.GetCategory("Surface");
this.HelpString = "Shows the vessel's altitude above the terrain. Turns off if splashed."; HelpString = "Shows the vessel's altitude above the terrain and water's surface, or altitude above underwater terrain whilst splashed down.";
this.IsDefault = true; IsDefault = true;
} }
   
#endregion  
   
#region Methods  
   
public override void Draw(SectionModule section) public override void Draw(SectionModule section)
{ {
if (ScienceUtil.GetExperimentSituation (FlightGlobals.ActiveVessel) != ExperimentSituations.SrfSplashed) if (FlightGlobals.ActiveVessel.terrainAltitude > 0.0 || FlightGlobals.ActiveVessel.situation == Vessel.Situations.SPLASHED)
{ {
if (FlightGlobals.ActiveVessel.terrainAltitude > 0.0) DrawLine((FlightGlobals.ship_altitude - FlightGlobals.ActiveVessel.terrainAltitude).ToDistance(), section.IsHud);
{ }
this.DrawLine ((FlightGlobals.ship_altitude - FlightGlobals.ActiveVessel.terrainAltitude).ToDistance (), section.IsHud); else
} {
else DrawLine((FlightGlobals.ship_altitude).ToDistance(), section.IsHud);
{ }
this.DrawLine ((FlightGlobals.ship_altitude).ToDistance (), section.IsHud);  
}  
}  
} }
   
#endregion  
} }
} }