Click or drag to resize

PressureType Class

Localized message formatting class for a numeric value that represents a pressure. The resulted message may have a unit specification.
Inheritance Hierarchy
SystemObject
  KSPDev.GUIUtils.TypeFormattersPressureType

Namespace:  KSPDev.GUIUtils.TypeFormatters
Assembly:  KSPDev_Utils.2.0 (in KSPDev_Utils.2.0.dll) Version: 2.0 for KSP v1.8+
Syntax
C#
public sealed class PressureType
Request Example View Source

The PressureType type exposes the following members.

Constructors
  NameDescription
Public methodCode examplePressureType
Constructs an object from a numeric value.
Top
Methods
  NameDescription
Public methodStatic memberCode exampleFormat
Formats the value into a human friendly string with a unit specification.
Public methodToString
Returns a string formatted as a human friendly pressure specification.
(Overrides ObjectToString.)
Top
Operators
Fields
  NameDescription
Public fieldStatic memberkiloPascal
Localized suffix for the "kilopascal" units. Scale x1.
Public fieldStatic memberKilopascalLocTag
Localization tag for the "kilopascal" units.
Public fieldvalue
A wrapped numeric value.
Top
Remarks

Use it as a generic parameter when creating a LocalizableMessage descendants.

The class uses the unit name localizations from the stock module ModuleEnviroSensor. In case of this module is deprecated or the tags are changed, the default English values will be used for the unit names.

Examples
public class PressureTypeDemo1 : PartModule {
  static readonly Message<PressureType> msg1 = new Message<PressureType>(
      "#TypeDemo_msg1", defaultTemplate: "Pressure is: <<1>>");

  void Show() {
    Debug.Log(msg1.Format(0.051));
    // Prints: "Pressure is: 0.051 kPa"
    Debug.Log(msg1.Format(0.45));
    // Prints: "Pressure is: 0.45 kPa"
    Debug.Log(msg1.Format(95.45));
    // Prints: "Pressure is: 95.5 kPa"
    Debug.Log(msg1.Format(120.45));
    // Prints: "Pressure is: 121 kPa"
    Debug.Log(msg1.Format(9535.45));
    // Prints: "Pressure is: 9,536 kPa"
  }
}
Examples
Debug.Log(PressureType.Format(0.051));
// Prints: "Pressure is: 0.051 kPa"
Debug.Log(PressureType.Format(0.45));
// Prints: "Pressure is: 0.45 kPa"
Debug.Log(PressureType.Format(95.45));
// Prints: "Pressure is: 95.5 kPa"
Debug.Log(PressureType.Format(120.45));
// Prints: "Pressure is: 121 kPa"
Debug.Log(PressureType.Format(9535.45));
// Prints: "Pressure is: 9,536 kPa"
Examples
Debug.Log(PressureType.Format(1234.5678, format: "0.0000"));
// Prints: "1234.5678 kPa"
Debug.Log(PressureType.Format(1234.5678, format: "0.00"));
// Prints: "1234.57 kPa"
Debug.Log(PressureType.Format(1234.5678, format: "#,##0.00"));
// Prints: "1,234.57 kPa"
See Also

Reference

KSPDev.GUIUtils.TypeFormattersPressureType