Package gamedata
Class ConversionMap
- java.lang.Object
-
- gamedata.ConversionMap
-
public class ConversionMap extends java.lang.Object
Represents the possible game component conversion options available in theConvertMenu
and stores the data needed to initiate the conversions. Primarily, this class is used by extensions to register new conversion options from a conversion map file. This class can also be used to examine conversion map file entries programmatically. For example, the following script code prints a list of direct conversion options for themy.example.CustomComponent
component type:var className = 'my.example.CustomComponent'; var conversionMap = gamedata.ConversionMap.shared; for( let entry in Iterator( conversionMap.getDirectConversions(className) ) ) { println( entry.name + ' -> ' + entry.targetClassName ); }
- Author:
- Henrik Rostedt
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConversionMap.Class
Represents a direct conversion group in a conversion map file.static class
ConversionMap.Conversion
Represents a conversion option in a conversion map filestatic class
ConversionMap.Entry
Represent any entry of a conversion map file.static class
ConversionMap.Group
Represents a conversion group in a conversion map file.static class
ConversionMap.NamedEntry
Represents a conversion map entry with a localized name.static class
ConversionMap.Parser
A parser for conversion map files.
-
Constructor Summary
Constructors Constructor Description ConversionMap(java.lang.String... resources)
Creates a new conversion map containing the entries parsed from the specified conversion map resources.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
add(java.lang.String resource)
Adds the specified conversion map resource to the list of such files that is used to generate the contents of the convert menu options.java.util.Set<ConversionMap.Conversion>
getDirectConversions(java.lang.String sourceClassName)
Returns the direct conversions from the specified component type.java.util.Map<ConversionMap.Group,java.util.Set<ConversionMap.Conversion>>
getGroupConversions(java.lang.String sourceClassName)
Returns the group conversions from the specified component type.static ConversionMap
getShared()
Returns a shared instance ofConversionMap
that can be used to look up conversion options.
-
-
-
Constructor Detail
-
ConversionMap
public ConversionMap(java.lang.String... resources) throws java.io.IOException
Creates a new conversion map containing the entries parsed from the specified conversion map resources. Groups entries are cached statically, however, the group members are tracked per instance. An extension wanting to inspect the manual conversion options should generally usegetShared()
instead.- Parameters:
resources
- the conversion map resources to parse- Throws:
java.io.IOException
- if any of the resources can not be read
-
-
Method Detail
-
getDirectConversions
public java.util.Set<ConversionMap.Conversion> getDirectConversions(java.lang.String sourceClassName)
Returns the direct conversions from the specified component type. Only conversions for installed extensions are included. The returned set is immutable and only calculated once per component type.- Parameters:
sourceClassName
- the class name of the source component type- Returns:
- the direct conversions from the component type
-
getGroupConversions
public java.util.Map<ConversionMap.Group,java.util.Set<ConversionMap.Conversion>> getGroupConversions(java.lang.String sourceClassName)
Returns the group conversions from the specified component type. Only conversions for installed extensions are included. The returned map is immutable and only calculated once per component type.- Parameters:
sourceClassName
- the class name of the source component type- Returns:
- the group conversions from the component type
-
add
public static void add(java.lang.String resource)
Adds the specified conversion map resource to the list of such files that is used to generate the contents of the convert menu options. The sample conversion map (/resources/projects/new-conversionmap.txt) describes the format of these files.- Parameters:
resource
- a relative URL within resources/ that points to the file to add
-
getShared
public static ConversionMap getShared() throws java.io.IOException
Returns a shared instance ofConversionMap
that can be used to look up conversion options. The instance is created the first time this is called. Must not be called before all extensions have been loaded.- Returns:
- the shared
ConversionMap
instance - Throws:
java.io.IOException
- if the shared instance could not be created
-
-