de.adom.jade.ui
Class DefaultUserInterface

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

public abstract class DefaultUserInterface
extends UserInterface

Implements some of the basic functions required by user interfaces to reduce the burden of implementation somewhat.


Constructor Summary
DefaultUserInterface()
           
 
Method Summary
 void addCommand(Command command)
          Adds a command to the command queue.
 Command getCommand()
          Returns a command from the user interface.
protected  void requestCommand()
          Is called when a command is requested and the command queue is empty.
 
Methods inherited from class de.adom.jade.ui.UserInterface
centerMap, clearMessages, displayErrorDialog, getDescription, getName, getProgressAddition, getTileRepresentation, hideGameWindow, initialize, message, observe, observe, setMap, setNonKeyCommandInput, setPointOfView, showGameWindow, update, updateStatistics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultUserInterface

public DefaultUserInterface()
Method Detail

getCommand

public Command getCommand()
Returns a command from the user interface. This implementation is optimized for Swing-based user interfaces. Commands can be added to the command queue at any point and will be stored until they are requested by the game engine. Adding commands is done by calling addCommand which wakes up a sleeping game thread (if it was weaiting for a command) and initiates the retrieval of the command.

If the command queue is empty, the method requestCommand will be called, which allows the UI implementation to tell the user that he now should enter some kind of command.

Specified by:
getCommand in class UserInterface
Returns:
the next command

addCommand

public void addCommand(Command command)
Adds a command to the command queue. The command will be returned after all commands before it have been requested by the game engine. If the game engine thread already requested a command and was asleep, it will be woken up to return the newly discovered command.

Parameters:
command - the command to be added to the command queue

requestCommand

protected void requestCommand()
Is called when a command is requested and the command queue is empty. This allows the UI implementation to notify the user of the need to enter a command. By default this method does nothing but you can override it to provide some specific UI behaviour. If the UI e.g. displays some kind of visible request, any such displays should be undone before the UI implementation calls addCommand.