de.adom.jade.ui
Class UserInterface

java.lang.Object
  extended by de.adom.jade.ui.UserInterface
Direct Known Subclasses:
DefaultUserInterface

public abstract class UserInterface
extends java.lang.Object

Defines all the operations that a user interface has to provide in order to present the internal game data in an adequate way to the player. The user interface makes no specific assumptions about the way the data should be presented to the player athough the basic map structure somewhat limits arbitrariy complex displays.

See the comments for the class UserInterfaceFactory about how to build a user interface.

User interfaces will be instantiated by calling the methods defined below in the following order:

  1. getName and maybe getDescription are called to allow the player to choose a specific interface.
  2. getProgressAddition is called to determine how much the initialization of the user interface will add to the overall initialization of the game.
  3. initialize is called when the specific user interface has been chosen. This allows the detailed initialization.

Important: JADE itself runs in a separate thread. Thus all methods below that require user input need some way to block the game thread (probably with some notify/wait mechanic).

See Also:
UserInterfaceFactory

Constructor Summary
UserInterface()
           
 
Method Summary
abstract  void centerMap()
          Centers the map on the centrail being.
abstract  void clearMessages()
          Clears the message display area provided by the UI implementation.
abstract  boolean displayErrorDialog(java.lang.String message, java.lang.Throwable error)
          Displays a runtime error together with a message.
abstract  Command getCommand()
          Returns a command from the user interface.
abstract  java.lang.String getDescription()
          Returns the extended description for this user interface (not more than 400 characters).
abstract  java.lang.String getName()
          Returns the short name of this specific user interface (not more than 40 characters).
abstract  int getProgressAddition()
          Returns the numerical amount added to the startup progress maximum by the initialize method of this class.
abstract  TileRepresentation getTileRepresentation(int id)
          Returns a specific tile representation for a tile ID.
abstract  void hideGameWindow()
          Hides the game window.
abstract  void initialize(SplashScreen splashScreen)
          Initializes this particular user interface by executing all CPU intensive initializaton routines.
abstract  void message(java.lang.String message)
          Displays a message to the user.
 void observe(Being originator, Being target, java.lang.String message)
          Displays a message to the user if this being is visible to the PC.
 void observe(Being originator, java.lang.String message)
          Displays a message to the user if this being is visible to the PC.
abstract  void setMap(Map currentMap)
          Sets the map to use.
abstract  void setNonKeyCommandInput(boolean active)
          Enables / disables non-keyboard input methods.
abstract  void setPointOfView(Being being)
          Sets the point of view for the map.
abstract  void showGameWindow()
          Displays the game window.
abstract  void update()
          Requires the UI implementation to update the screen right away.
abstract  void updateStatistics()
          Updates the statistics area.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserInterface

public UserInterface()
Method Detail

getName

public abstract java.lang.String getName()
Returns the short name of this specific user interface (not more than 40 characters).

Returns:
the short name of this user interface

getDescription

public abstract java.lang.String getDescription()
Returns the extended description for this user interface (not more than 400 characters).

Returns:
the extended description for this user interface

getProgressAddition

public abstract int getProgressAddition()
Returns the numerical amount added to the startup progress maximum by the initialize method of this class.

Returns:
the numerical amount added to the startup progress by this class

initialize

public abstract void initialize(SplashScreen splashScreen)
Initializes this particular user interface by executing all CPU intensive initializaton routines. The initialization routine is expected to call the message and progress routines of the splash screen supplied to protocol its actions. The progress changes should fit to the changes indicated by getProgressAddition. Don't forget to add StartupConstants.PL_PRE_UI_INITIALIZATION to the progress values you set in this method!

Parameters:
splashScreen - the splash screen to use during initialization
See Also:
getProgressAddition(), SplashScreen, SplashScreen.setMessage(java.lang.String), SplashScreen.setProgress(int), SplashScreen.setStatus(java.lang.String, int), StartupConstants

setMap

public abstract void setMap(Map currentMap)
Sets the map to use.

Parameters:
currentMap - the map to use for now

getCommand

public abstract Command getCommand()
Returns a command from the user interface.

Returns:
the next command

update

public abstract void update()
Requires the UI implementation to update the screen right away.


setPointOfView

public abstract void setPointOfView(Being being)
Sets the point of view for the map.

Parameters:
being - the being to use as the reference being for the next map view

showGameWindow

public abstract void showGameWindow()
Displays the game window.


hideGameWindow

public abstract void hideGameWindow()
Hides the game window.


observe

public void observe(Being originator,
                    java.lang.String message)
Displays a message to the user if this being is visible to the PC.

Parameters:
originator - the being responsible for the message
message - the message to display

observe

public void observe(Being originator,
                    Being target,
                    java.lang.String message)
Displays a message to the user if this being is visible to the PC.

Parameters:
originator - the being responsible for the message
target - the target of the message
message - the message to display

message

public abstract void message(java.lang.String message)
Displays a message to the user.

Parameters:
message - the message to display

clearMessages

public abstract void clearMessages()
Clears the message display area provided by the UI implementation. JADE usually calls this method after asking for the next command and occasional other opportunities after retrieving information (always assuming that information will be retrieved by using the message display area).


updateStatistics

public abstract void updateStatistics()
Updates the statistics area.


displayErrorDialog

public abstract boolean displayErrorDialog(java.lang.String message,
                                           java.lang.Throwable error)
Displays a runtime error together with a message. The information needs to be displayed in a modal dialog. The user should get a choice to view the detailed crash information, continue with the program or abort.

Parameters:
message - the message to display
error - the runtime error that occurred
Returns:
a boolean value to indicate whether the program should continue

setNonKeyCommandInput

public abstract void setNonKeyCommandInput(boolean active)
Enables / disables non-keyboard input methods.

Parameters:
active - a boolean value indicating whether other command input methods are enabled or not

centerMap

public abstract void centerMap()
Centers the map on the centrail being.


getTileRepresentation

public abstract TileRepresentation getTileRepresentation(int id)
Returns a specific tile representation for a tile ID.

Parameters:
id - the tile ID
Returns:
the tile representation for the tile ID