Click or drag to resize

ResourceShortType Class

Localized message formatting class for a string value that represents an abbreviated resource type.
Inheritance Hierarchy
SystemObject
  KSPDev.GUIUtils.TypeFormattersResourceShortType

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 ResourceShortType
Request Example View Source

The ResourceShortType type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleResourceShortType(Int32)
Constructs an object from a resource ID.
Public methodCode exampleResourceShortType(String)
Constructs an object from a resource nane.
Top
Methods
  NameDescription
Public methodStatic memberCode exampleFormat(Int32)
Formats the value into a human friendly localized string.
Public methodStatic memberCode exampleFormat(String)
Formats the value into a human friendly localized string.
Public methodToString
Returns a string formatted as a human friendly resource name.
(Overrides ObjectToString.)
Top
Operators
Fields
  NameDescription
Public fieldresourceId
A wrapped resource ID value.
Top
Remarks

This class resolves the resource type/ID into it's short localized name. It's usually 2 letters long, but it's not mandatory.

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

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

  void Show() {
    Debug.Log(msg1.Format(StockResourceNames.ElectricCharge));
    // Prints: "Resource is: EC"
    Debug.Log(msg1.Format(PartResourceLibrary.ElectricityHashcode));
    // Prints: "Resource is: EC"
  }
}
Examples
Debug.Log(ResourceShortType.Format(StockResourceNames.ElectricCharge));
// Prints: "Resource is: EC"
Debug.Log(ResourceShortType.Format(PartResourceLibrary.ElectricityHashcode));
// Prints: "Resource is: EC"
See Also

Reference

KSPDev.GUIUtils.TypeFormattersResourceShortType