cage.core
Class ResourceEngine

java.lang.Object
  extended by cage.core.ResourceEngine

public class ResourceEngine
extends java.lang.Object

Cage and Carl Resource Engine This class contains static maps for each datatype used within the engine. All data classes (Overlay, VisualItem, Sound, etc) should call register[TYPE] within their constructors so that they are always registered when created. A notable exception to this is TextImage, which is intended to be temporary and so it is not registered by default. This is important because the maps here act as a bridge between the XML scene definitions, the Carl scripts and the actual engine methods and data.

Author:
Seth Marinello

Constructor Summary
ResourceEngine()
           
 
Method Summary
static void clearScenes()
          Removes/Deletes all loaded scenes.
static java.util.Collection<Overlay> getAllOverlays()
          Get all Overlays
static java.util.Collection<cage.carl.Closure> getAllRountines()
           
static java.util.Collection<Scene> getAllScenes()
          Gets the all scenes.
static java.util.Collection<VisualItem> getAllVisualItems()
          Gets the all visual items.
static Binding getBinding(java.lang.Integer keyConst)
          Get a binding from the global bindings.
static Overlay getOverlay(java.lang.String key)
          Gets the overlay.
static Scene getScene(java.lang.String key)
          Gets the scene.
static Sound getSound(java.lang.String key)
          Gets the sound.
static VisualItem getVisualItem(java.lang.String key)
          Gets the visual item.
static java.net.URL locateResource(java.lang.String filename)
          Locate resource.
static java.io.InputStream locateResourceAsStream(java.lang.String filename)
          Locate resource as stream.
static void printOverlays()
          Prints the overlays.
static void printScenes()
          Prints the scenes.
static void printSounds()
          Prints the sounds.
static void printVisualItems()
          Prints the visual items.
static void registerBinding(java.lang.Integer keyConst, Binding bind)
          Adds a binding to the global bindings
static void registerOverlay(Overlay s)
          Register overlay.
static void registerRountine(java.lang.String name)
          Adds an action to a list of actions which will be called each tick of the engine clock
static void registerScene(Scene s)
          Register scene.
static void registerSound(java.lang.String name, Sound snd)
          Register sound.
static void registerVisualItem(java.lang.String name, VisualItem img)
          Registers an VisualItem for use by different sprites in the Graphics Engine.
static void setResourceLoader(java.lang.ClassLoader resourceLoader)
          Sets the ClassLoader to be used by the ResourceEngine when locating resources
static void unregisterBinding(java.lang.Integer keyConst)
          Removes a binding from the global bindings
static Overlay unregisterOverlay(java.lang.String key)
          Unregister overlay.
static void unregisterRoutine(java.lang.String name)
          Removes an action from a list of actions which will be called each tick of the engine clock
static Scene unregisterScene(java.lang.String key)
          Unregister scene.
static void unregisterSound(java.lang.String key)
          Unregister sound.
static void unregisterVisualItem(java.lang.String key)
          Unregister visual item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceEngine

public ResourceEngine()
Method Detail

registerVisualItem

public static void registerVisualItem(java.lang.String name,
                                      VisualItem img)
Registers an VisualItem for use by different sprites in the Graphics Engine.

Parameters:
name - The name to use as a key in the VisualItem map
img - The VisualItem data to store with the key

getVisualItem

public static VisualItem getVisualItem(java.lang.String key)
Gets the visual item.

Parameters:
key - the key
Returns:
the visual item

getAllVisualItems

public static java.util.Collection<VisualItem> getAllVisualItems()
Gets the all visual items.

Returns:
the all visual items

unregisterVisualItem

public static void unregisterVisualItem(java.lang.String key)
Unregister visual item.

Parameters:
key - the key

registerSound

public static void registerSound(java.lang.String name,
                                 Sound snd)
Register sound.

Parameters:
name - the name
snd - the snd

getSound

public static Sound getSound(java.lang.String key)
Gets the sound.

Parameters:
key - the key
Returns:
the sound

unregisterSound

public static void unregisterSound(java.lang.String key)
Unregister sound.

Parameters:
key - the key

registerScene

public static void registerScene(Scene s)
Register scene.

Parameters:
s - the s

unregisterScene

public static Scene unregisterScene(java.lang.String key)
Unregister scene.

Parameters:
key - the key
Returns:
the scene

registerOverlay

public static void registerOverlay(Overlay s)
Register overlay.

Parameters:
s - the s

unregisterOverlay

public static Overlay unregisterOverlay(java.lang.String key)
Unregister overlay.

Parameters:
key - the key
Returns:
the overlay

getOverlay

public static Overlay getOverlay(java.lang.String key)
Gets the overlay.

Parameters:
key - the key
Returns:
the overlay

getAllOverlays

public static java.util.Collection<Overlay> getAllOverlays()
Get all Overlays

Returns:
A collection of all Overlays.

getScene

public static Scene getScene(java.lang.String key)
Gets the scene.

Parameters:
key - the key
Returns:
the scene

getAllScenes

public static java.util.Collection<Scene> getAllScenes()
Gets the all scenes.

Returns:
the all scenes

clearScenes

public static void clearScenes()
Removes/Deletes all loaded scenes.


registerBinding

public static void registerBinding(java.lang.Integer keyConst,
                                   Binding bind)
Adds a binding to the global bindings

Parameters:
keyConst - the value of the key the bind is for
bind - the Binding for the key value.

unregisterBinding

public static void unregisterBinding(java.lang.Integer keyConst)
Removes a binding from the global bindings

Parameters:
keyConst - the value of the key the bind is for

getBinding

public static Binding getBinding(java.lang.Integer keyConst)
Get a binding from the global bindings.

Parameters:
keyConst - the KeyValue of the binding desired.
Returns:
The Binding object for that key or null.

registerRountine

public static void registerRountine(java.lang.String name)
Adds an action to a list of actions which will be called each tick of the engine clock

Parameters:
name - The name of the action to add

unregisterRoutine

public static void unregisterRoutine(java.lang.String name)
Removes an action from a list of actions which will be called each tick of the engine clock

Parameters:
name - The name of the action to remove

getAllRountines

public static java.util.Collection<cage.carl.Closure> getAllRountines()

printOverlays

public static void printOverlays()
Prints the overlays.


printScenes

public static void printScenes()
Prints the scenes.


printSounds

public static void printSounds()
Prints the sounds.


printVisualItems

public static void printVisualItems()
Prints the visual items.


setResourceLoader

public static void setResourceLoader(java.lang.ClassLoader resourceLoader)
Sets the ClassLoader to be used by the ResourceEngine when locating resources

Parameters:
resourceLoader - The custom ClassLoader to use.

locateResource

public static java.net.URL locateResource(java.lang.String filename)
Locate resource.

Parameters:
filename - the filename
Returns:
the uRL

locateResourceAsStream

public static java.io.InputStream locateResourceAsStream(java.lang.String filename)
Locate resource as stream.

Parameters:
filename - the filename
Returns:
the input stream