wyvern.common.config
Class Wyvern

java.lang.Object
  extended bywyvern.common.config.Wyvern

public class Wyvern
extends java.lang.Object

This class provides static information about the environment the game is running in. It differs from wyvern.world.SystemProps in that SystemProps is server-side only; this class provides common initialization for both client and server.

Its primary purpose is to provide path information for various directories in the game server's file tree. All directories are returned in a canonical form, with drive letter removed, and slashes as "/" instead of "\". For example, getAdminDir() might return "/games/wyvern/admin".

Version:
1.0, Feb 03, 1998
Author:
Steve Yegge

Field Summary
static java.lang.String GAME_ROOT
           
static java.lang.String IMAGE_EXTENSION
           
static java.lang.String ROOT_DIR
           
 
Constructor Summary
Wyvern()
           
 
Method Summary
static java.lang.String getAdminDir()
          Returns the administrative directory containing configuration files, banishment lists, etc.
static java.applet.Applet getApplet()
          Returns the Applet for the system, if we're running as an Applet.
static java.lang.String getArchRoot()
          Gets the directory where the standard archetypes are stored.
static java.lang.String getArtDir()
          Returns the top-level art directory.
static java.lang.String getArtRoot()
          Returns the root directory of the game artwork.
static java.lang.String getBanishmentFile()
          Returns the full path to the text file containing banished players.
static java.lang.String getDocDir()
          Returns the top-level documentation directory.
static java.lang.String getEmailDir()
          Returns the administrative directory containing email message bodies for sending to users.
static java.lang.String getGameRoot()
          Returns the directory where the wyvern/ tree is stored.
static java.lang.String getHelpDir()
          Returns the directory where help files are stored.
static java.lang.String getListDir()
          Returns the top-level treasure-lists directory, usually root + "world/lists/".
static java.lang.String getLogDir()
          Returns the administrative directory containing logfiles.
static java.lang.String getMailDir()
          Returns the player mail directory ("world/mail/")
static java.lang.String getMapEditorDir()
          Returns directory where the map editor main class is kept.
static java.lang.String getMapRoot()
          Returns the root directory where the main game maps are stored.
static java.lang.String getMusicDir()
          Returns the directory where the music is kept.
static java.lang.String getPlayerRoot()
          Returns the directory where the player files are stored.
static java.lang.String getPythonDir()
          Returns the wyvern python module and script directory.
static java.lang.String getRelativeArtRoot()
          Returns art root suitable for loading from jar file.
static java.lang.String getRelativeRoot()
          Returns the relative root directory, suitable for looking up images not in the standard art/game directory (e.g.
static java.io.InputStream getResourceAsStream(java.lang.String name)
          Returns an InputStream to a resource from the disk, or jar file (if we're running from a jar).
static java.lang.String getRootDir()
          Returns the directory under which the game is installed, e.g.
static java.lang.String getSkillsDir()
          Returns the top-level spells directory.
static java.lang.String getSkinsDir()
          Returns the default Skins directory.
static java.lang.String getSpellsDir()
          Returns the top-level spells directory.
static java.lang.String getStatueDir()
          Returns the directory where statues (petrified monsters) are kept.
static java.lang.String getTalkDir()
          Returns the directory where NPC talk-files are kept.
static java.lang.String getTempDir()
          Returns the temporary directory to use on this system.
static java.lang.String getToolsDir()
          Returns the top-level tools directory.
static java.lang.String getVaultDir()
          Returns the directory where player vaults are kept.
static java.lang.String getVisitorRoot()
          Returns the directory where visiting player files are stored.
static java.lang.String getWebStartRoot()
          Returns the directory where Java WebStart starts the application - usually some long path on Windows.
static java.lang.String getWizDir()
          Returns the Wizards directory.
static boolean isApplet()
          Returns true if the game (client or server) is currently running as an Applet.
static boolean isWebStart()
          Returns true if we've been passed a "webstart" argument.
static java.awt.Image loadImage(java.lang.String name)
          Loads an image from the JAR file or local filesystem.
static void main(java.lang.String[] args)
          Test.
static void markAsApplet()
          Marks the application as running as an Applet.
static void setApplet(java.applet.Applet applet)
          Sets the Applet for the system.
static void setWebStart()
          Tells the system we're operating in Java WebStart mode, so resources should be loaded from the jar file.
static void waitForImage(java.awt.Image img)
          Waits for specified image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_DIR

public static java.lang.String ROOT_DIR

IMAGE_EXTENSION

public static java.lang.String IMAGE_EXTENSION

GAME_ROOT

public static final java.lang.String GAME_ROOT
Constructor Detail

Wyvern

public Wyvern()
Method Detail

getRootDir

public static java.lang.String getRootDir()
Returns the directory under which the game is installed, e.g. "c:/games/wyvern/". Used for both client & server.

Returns:
a platform-specific directory specification.

getGameRoot

public static java.lang.String getGameRoot()
Returns the directory where the wyvern/ tree is stored.


getArtRoot

public static java.lang.String getArtRoot()
Returns the root directory of the game artwork.

Returns:
a string such as "c:/games/wyvern/art/game/". It is guaranteed to start with the dir returned by getRootDir().

getRelativeArtRoot

public static java.lang.String getRelativeArtRoot()
Returns art root suitable for loading from jar file.

Returns:
e.g. "wyvern/art/game"

getRelativeRoot

public static java.lang.String getRelativeRoot()
Returns the relative root directory, suitable for looking up images not in the standard art/game directory (e.g. wizard artwork).


getArtDir

public static java.lang.String getArtDir()
Returns the top-level art directory. The game-art subdirectory is under this directory, as are the artwork directories for the client & tools.


getArchRoot

public static java.lang.String getArchRoot()
Gets the directory where the standard archetypes are stored.

Returns:
something like "c:/games/wyvern/arch/". It is guaranteed to start with the dir returned by getRootDir().

getMapRoot

public static java.lang.String getMapRoot()
Returns the root directory where the main game maps are stored.

Returns:
the full path

getMailDir

public static java.lang.String getMailDir()
Returns the player mail directory ("world/mail/")

Returns:
the full path to the mail directory

getPlayerRoot

public static java.lang.String getPlayerRoot()
Returns the directory where the player files are stored. They're in subdirectories off this directory, so you should probably use wyvern.kernel.player.PlayerManager.getPathToPlayer() instead.

Returns:
the full path

getVisitorRoot

public static java.lang.String getVisitorRoot()
Returns the directory where visiting player files are stored.

Returns:
the full path

getAdminDir

public static java.lang.String getAdminDir()
Returns the administrative directory containing configuration files, banishment lists, etc.

Returns:
the full path

getEmailDir

public static java.lang.String getEmailDir()
Returns the administrative directory containing email message bodies for sending to users.

Returns:
the full path

getLogDir

public static java.lang.String getLogDir()
Returns the administrative directory containing logfiles.

Returns:
the full path

getMusicDir

public static java.lang.String getMusicDir()
Returns the directory where the music is kept.

Returns:
the full path

getTalkDir

public static java.lang.String getTalkDir()
Returns the directory where NPC talk-files are kept.

Returns:
the full path

getWizDir

public static java.lang.String getWizDir()
Returns the Wizards directory.

Returns:
the full path

getToolsDir

public static java.lang.String getToolsDir()
Returns the top-level tools directory.

Returns:
the full path

getMapEditorDir

public static java.lang.String getMapEditorDir()
Returns directory where the map editor main class is kept.


getSpellsDir

public static java.lang.String getSpellsDir()
Returns the top-level spells directory.

Returns:
the full path

getSkillsDir

public static java.lang.String getSkillsDir()
Returns the top-level spells directory.

Returns:
the full path

getStatueDir

public static java.lang.String getStatueDir()
Returns the directory where statues (petrified monsters) are kept.

Returns:
the full path

getDocDir

public static java.lang.String getDocDir()
Returns the top-level documentation directory.

Returns:
the full path

getBanishmentFile

public static java.lang.String getBanishmentFile()
Returns the full path to the text file containing banished players. Use wyvern.world.Banishments to manipulate this list; don't write the file directly.


getListDir

public static java.lang.String getListDir()
Returns the top-level treasure-lists directory, usually root + "world/lists/".

Returns:
the full path

getPythonDir

public static java.lang.String getPythonDir()
Returns the wyvern python module and script directory.

Returns:
the full path

getVaultDir

public static java.lang.String getVaultDir()
Returns the directory where player vaults are kept.

Returns:
the full path

getSkinsDir

public static java.lang.String getSkinsDir()
Returns the default Skins directory.


getHelpDir

public static java.lang.String getHelpDir()
Returns the directory where help files are stored.


isApplet

public static boolean isApplet()
Returns true if the game (client or server) is currently running as an Applet.

Returns:
true if we're an applet

getApplet

public static java.applet.Applet getApplet()
Returns the Applet for the system, if we're running as an Applet.

Returns:
the Applet

markAsApplet

public static void markAsApplet()
Marks the application as running as an Applet. We do this for the Java WebStart version, even though there's no actual Applet object.


setApplet

public static void setApplet(java.applet.Applet applet)
Sets the Applet for the system. Only called by Applet.

Parameters:
applet - the Applet

setWebStart

public static void setWebStart()
Tells the system we're operating in Java WebStart mode, so resources should be loaded from the jar file.


isWebStart

public static boolean isWebStart()
Returns true if we've been passed a "webstart" argument. This only applies if we're running the map editor.


getWebStartRoot

public static java.lang.String getWebStartRoot()
Returns the directory where Java WebStart starts the application - usually some long path on Windows. We can consider this our "root dir" for storing maps and temp files.


getTempDir

public static java.lang.String getTempDir()
Returns the temporary directory to use on this system.


loadImage

public static java.awt.Image loadImage(java.lang.String name)
Loads an image from the JAR file or local filesystem.

Parameters:
name - the path to the image, relative to the system classpath. Example: "wyvern/art/game/foo/bar". If it's a GIF file, the ".gif" (case matters) extension is optional. For other file formats, extension is required.
Returns:
the Image, if it could be loaded, else null

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String name)
Returns an InputStream to a resource from the disk, or jar file (if we're running from a jar).

Parameters:
name - the resource path, such as "wyvern/art/game/monsters/goblin/goblin.S.gif". If we're running from a jar file, this method prepends "/", since that appears to be required by Class.getResourceAsStream(). If we're running from a filesystem, we want it not to start with a "/", since it turns into a package path by converting "/" with "."

Unfortunately, most of the code in the code base has no idea if it's running from a jar or not, so this method will actually try both - filesystem first, then the jar. This is appropriate for WebStart, since it pulls some images into a filesystem cache, if they're newer than the ones packaged in the jar.

Returns:
an InputStream to the resource, or null if we couldn't load it.

waitForImage

public static void waitForImage(java.awt.Image img)
Waits for specified image. Stolen from wyvern.common.util.Util, because jikes compiler can't handle util.Util.


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Test.

Throws:
java.lang.Exception