|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.common.tiles.TileRegistry
This is a simple database that establishes a unique integer ID, called a tile number for every game tile, where a tile is any game image to be displayed on the client.
The database exists so the server doesn't have to send image pathnames over the network on every screen update. The server looks up a tile's ID given its path, and the client retrieves the path from the ID.
The basic functions provided here are:
Field Summary | |
static int |
NO_IMAGE
|
Constructor Summary | |
TileRegistry()
|
Method Summary | |
static boolean |
contains(java.lang.String path)
Queries whether the specified image exists. |
static boolean |
contains(java.lang.String category,
java.lang.String image)
Deprecated. use contains(path) instead |
static java.lang.String |
getAbsolutePath(java.lang.String path)
Returns the absolute path to an image file, given its relative path. |
static java.lang.String |
getDirectory(java.lang.String path)
Returns the absolute directory on disk for the given relative image path. |
static TileInfo |
getInfo(java.lang.String relpath)
Finds any images that are related to this one and caches them. |
static TileInfo |
getInfo(java.lang.String category,
java.lang.String image)
Deprecated. use lookup(relpath) instead |
static long |
getLastModified(java.lang.String path)
Returns the time when the file was last modified. |
static java.lang.String |
getRoot(java.lang.String path)
Returns the root directory in which to look for artwork. |
static byte[] |
getTileMappings()
Returns the current tile-number assignments that have been given out by the server. |
static int |
getUnknownImage()
Returns the "question-mark" image to display if we don't know what the object looks like. |
static java.lang.String |
lookup(int ID)
Given an integer, retrieves the corresponding tile name. |
static int |
lookup(java.lang.String image)
Given relative path to a tile, not split into 2 components, returns its ID. |
static int |
lookup(java.lang.String category,
java.lang.String image)
Deprecated. use lookup(path) instead |
static void |
main(java.lang.String[] args)
For testing functions. |
static byte[] |
readImageFile(java.lang.String path)
Returns a byte array containing the contents of the specified image file, for sending to a client. |
void |
store(java.lang.String path,
int ID)
Stores a tile in the database under the specified key. |
static void |
store(java.lang.String cat,
java.lang.String name,
int ID)
Deprecated. use store(path, ID) instead |
static boolean |
uncache(java.lang.String path)
Removes an image from the cache (e.g. a Wizard uploaded a new version and wants to test it). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int NO_IMAGE
Constructor Detail |
public TileRegistry()
Method Detail |
public static java.lang.String lookup(int ID)
ID
- the unique integer ID of the tile to retrieve
public static int lookup(java.lang.String category, java.lang.String image)
category
- the relative path to the image in the art directoryimage
- the image file name in that category
public static int lookup(java.lang.String image)
image
- the category + image
public static boolean uncache(java.lang.String path)
path
- the category + "/"+ image
public static boolean contains(java.lang.String category, java.lang.String image)
category
- the relative path to the image in the art directoryimage
- the image file name in that category
public static boolean contains(java.lang.String path)
path
- the image path, such as "monsters/goblin/ogre"
public static void store(java.lang.String cat, java.lang.String name, int ID)
cat
- the relative path to the tile under the artwork dirname
- the filename minus extensionID
- the integer ID to give to the tile.public void store(java.lang.String path, int ID)
On the server side, the most common lookup will be obtaining an ID from a string, so we key on the string with IDs as values.
path
- the relative path to the image, including its nameID
- the integer ID to give to the tile.public static int getUnknownImage()
public static TileInfo getInfo(java.lang.String category, java.lang.String image)
category
- the relative path to the imageimage
- the base image name, such as "fireball"
public static TileInfo getInfo(java.lang.String relpath)
relpath
- the relative path to the image, plus its name.
You can include the ".N1" extension if you like, or leave it off.
public static byte[] readImageFile(java.lang.String path)
path
- path to the file
public static byte[] getTileMappings()
The disadvantages are:
public static long getLastModified(java.lang.String path)
path
- relative path to the file
public static java.lang.String getAbsolutePath(java.lang.String path)
path
- relative image path, extension optional
public static java.lang.String getDirectory(java.lang.String path)
path
- e.g. "objects/jade_key" or "wiz/foo/bar"
public static java.lang.String getRoot(java.lang.String path)
path
- the relative path to the picture. If it starts
with "wiz", then the root will be the game root, else the
root is the game root plus "art/game" (the default art directory).public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |