monrovia.client.ui
Class CommandMenu

java.lang.Object
  |
  +--monrovia.client.ui.CommandMenu
All Implemented Interfaces:
com.sun.kjava.ScrollOwner

public class CommandMenu
extends java.lang.Object
implements com.sun.kjava.ScrollOwner

This class handles the command menu functionality. It returns the menu command actions of the user and shows the correct commands depending the current game situation. The menu consists of direction buttons, command buttons and a scrollbar which can be used to scroll the command buttons. The direction buttons are always visible and the visibility of other buttons depend on the game situation. Before the commands can be displayed, they must be initialized with command ID and button text. Command class is used to store the commands and making the buttons.


Constructor Summary
CommandMenu(int pX, int pY, int pW, int pH)
          Constructor for the class.
 
Method Summary
 void addCommand(Command pCommand)
          Add a new command to the menu.
 void clear()
          Deletes all the commands from the command list.
 void handleKeyDown(int pKeyCode)
          The user pressed a key.
 MenuCommand handlePenDown(int pX, int pY)
          Indicates the the pen has gone down at (x, y).
 void handlePenMove(int pX, int pY)
          The pen has moved at (x, y).
 void refresh(boolean pForce)
          Clear and repaint the menu.
 void removeCommand(int pCommandID)
          Remove a command from the menu.
 void setScrollValue(int pValue)
          Set the current scroll value and repaint.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandMenu

public CommandMenu(int pX,
                   int pY,
                   int pW,
                   int pH)
Constructor for the class. Constructs also the walking buttons and the scrollbar.
Parameters:
pX - X coordinate for the upper left corner of the menu.
pY - Y coordinate for the upper left corner of the menu.
pW - Width of the menu.
pH - Height of the menu.
Method Detail

setScrollValue

public void setScrollValue(int pValue)
Set the current scroll value and repaint.
Specified by:
setScrollValue in interface com.sun.kjava.ScrollOwner
Parameters:
pValue - the new scroll value

addCommand

public void addCommand(Command pCommand)
Add a new command to the menu.
Parameters:
pCommand - The command object to be added to the menu.

removeCommand

public void removeCommand(int pCommandID)
Remove a command from the menu.
Parameters:
pCommandID - The ID of the command to be removed from the menu.

refresh

public void refresh(boolean pForce)
Clear and repaint the menu.
Parameters:
pForce - true if we want to paint even if nothing was changed, false otherwise

clear

public void clear()
Deletes all the commands from the command list.

handlePenDown

public MenuCommand handlePenDown(int pX,
                                 int pY)
Indicates the the pen has gone down at (x, y).
Parameters:
pX - the X coordinate of the pen position
pY - the Y coordinate of the pen position
Returns:
command object which the user has pressed or null if none was

handlePenMove

public void handlePenMove(int pX,
                          int pY)
The pen has moved at (x, y).
Parameters:
pX - the X coordinate of the pen position
pY - the Y coordinate of the pen position

handleKeyDown

public void handleKeyDown(int pKeyCode)
The user pressed a key.
Parameters:
pKeyCode - a code representing the key the user pressed