Click or drag to resize

ResourceType Class

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

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

The ResourceType type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleResourceType(Int32)
Constructs an object from a resource ID.
Public methodCode exampleResourceType(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 full localized name.

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

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

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

Reference

KSPDev.GUIUtils.TypeFormattersResourceType