|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<Script>
net.kolls.railworld.play.script.ScriptManager
public class ScriptManager
The "master" script access point. Handles loading scripts and will also dispatch calls to all scripts within it.
| Field Summary | |
|---|---|
protected java.util.ArrayList<DrawListener> |
drawables
All drawing listeners |
protected java.util.ArrayList<TalCondition> |
tals
All train listeners |
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
ScriptManager()
Create an empty script manager. |
|
| Method Summary | |
|---|---|
void |
addDrawListener(DrawListener d)
Add a listener to be notified when the canvas is drawn. |
void |
addTrainActionListener(TrainActionListener tal,
Train t,
java.lang.String event)
Add a train action listener in the form of a condition. |
static ScriptManager |
allScripts(java.io.File loc)
Return a ScriptManager containing all internal scripts
as well as those found in the given directory. |
void |
draw(java.awt.Graphics2D gc,
java.awt.Rectangle onScreen)
The canvas is being drawn. |
static ScriptManager |
getScripts(java.io.File loc)
Return a ScriptManager containing all scripts
found in the given directory. |
void |
init(PlayFrame pf)
The game is being started. |
static Script |
loadScript(java.io.File script)
Load a script from a File. |
static Script |
loadScript(java.net.URL script)
Load a script from a URL. |
boolean |
playFrameAction(java.lang.String s)
An action has occurred in the PlayFrame. |
void |
removeDrawListener(DrawListener d)
Remove a draw listener. |
void |
removeTrainActionListener(TrainActionListener tal,
Train t,
java.lang.String event)
Remove a train action listener. |
boolean |
trainAction(Train t,
java.lang.String s)
A train has performed an action. |
void |
trainStep(Train t)
A train has taken a "step". |
| Methods inherited from class java.util.ArrayList |
|---|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
| Methods inherited from class java.util.AbstractList |
|---|
equals, hashCode, iterator, listIterator, listIterator, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, removeAll, retainAll, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList |
| Field Detail |
|---|
protected java.util.ArrayList<DrawListener> drawables
protected java.util.ArrayList<TalCondition> tals
| Constructor Detail |
|---|
public ScriptManager()
| Method Detail |
|---|
public static Script loadScript(java.io.File script)
throws javax.script.ScriptException,
java.io.IOException
Script interface.
script - File of the script to load.
javax.script.ScriptException - If the script file cannot be run or does not conform to the interface
java.io.IOException - If the script file cannot be accessed
public static Script loadScript(java.net.URL script)
throws javax.script.ScriptException,
java.io.IOException
Script interface.
script - URL of the script to load.
javax.script.ScriptException - If the script file cannot be run or does not conform to the interface
java.io.IOException - If the script file cannot be accessedpublic static ScriptManager getScripts(java.io.File loc)
ScriptManager containing all scripts
found in the given directory. Does not include internal scripts.
loc - The directory to search.
public static ScriptManager allScripts(java.io.File loc)
ScriptManager containing all internal scripts
as well as those found in the given directory.
loc - Directory to search for additional scripts. May be null to indicate
only internal scripts should be used.
public void addDrawListener(DrawListener d)
d - A DrawListener to add.public void removeDrawListener(DrawListener d)
d - The DrawListener to remove.
public void addTrainActionListener(TrainActionListener tal,
Train t,
java.lang.String event)
tal - The train action listener.t - The train to notify on, or null for all trains.event - The event name to notify on.TalCondition
public void removeTrainActionListener(TrainActionListener tal,
Train t,
java.lang.String event)
tal - Action listenert - Trainevent - Event name
public void draw(java.awt.Graphics2D gc,
java.awt.Rectangle onScreen)
gc - The canvas' graphics contextonScreen - The on-screen rectanglepublic void init(PlayFrame pf)
pf - The game's PlayFrame.public boolean playFrameAction(java.lang.String s)
s - The name of the event.
public boolean trainAction(Train t,
java.lang.String s)
t - The train involveds - Name of event
public void trainStep(Train t)
throws RailAccident
t - The train that is being processed
RailAccident - An accident, if one occurs. Note that this exception is not thrown by
Java code but by the scripts, so that is why you don't see a throw anywhere here.
It isn't checked so doesn't need to be declared.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||