monrovia.client
Class MonroviaClient

java.lang.Object
  |
  +--com.sun.kjava.Spotlet
        |
        +--monrovia.client.MonroviaClient
All Implemented Interfaces:
ClientProtocolHandler, com.sun.kjava.DialogOwner, org.precipice.kvm.form.MenuOwner

public class MonroviaClient
extends com.sun.kjava.Spotlet
implements com.sun.kjava.DialogOwner, org.precipice.kvm.form.MenuOwner, ClientProtocolHandler

This is the main class of the client application and user interface. It handles the game events and initializes other user interface classes. The class initializes the other user interface objects based on the default values set in the class. If some other window is opened, leave that window do all the event handling until closed. MonroviaClient implements a couple of interfaces which are used by the menu and the dialogs. It contains also the interface which is used by the clientside protocol.


Fields inherited from class com.sun.kjava.Spotlet
CALCICON, KEY_HARD1, KEY_HARD2, KEY_HARD3, KEY_HARD4, KEY_POWER, MENUICON, NO_EVENT_OPTIONS, PAGEDOWN, PAGEUP, WANT_SYSTEM_KEYS
 
Constructor Summary
MonroviaClient()
          Constructor for the Spotlet class.
 
Method Summary
 void arena(short[][] pMapBytes, short[][] pBitmapBytes, Command[] pMapCommands, Stat[] pPlayerStats)
          Receives the arena and player information from the protocol.
 void changedStat(int pStatID, int pStatValue)
          Gives a new integer value for a named statistics information.
 void changedStat(int pStatID, java.lang.String pStatValue)
          Gives a new string value for a named statistics information.
 void command(Command pCommand)
          adds or removes a command
 void connectionError(java.lang.String pMessage)
          This indicates that an error occurred while connecting.
 void dialogDismissed(java.lang.String pTitle)
          This method defines the DialogOwner interface.
 void giveSenders(UdpSender pUdpSender, TcpSender pTcpSender)
          Gives the handles for sending data.
 void init()
          Initializes the stuff we do not want to create before connecting.
 void keyDown(int pKeyCode)
          This method is invoked if the user presses either of the page up or page down hard keys, taps the calculator or menu icon, or enters a character (e.g.
static void main(java.lang.String[] args)
          This is the first function to be executed when starting the code.
 void menuClose(org.precipice.kvm.form.Menu pMenu, org.precipice.kvm.form.MenuItem pItem)
          This method is called when the menu is closed.
 void newLocation(int pXMap, int pYMap)
          Sets the location of the player in this arena.
 void newMessage(java.lang.String pMessage)
          Adds a new message to the message window.
 void newObject(int pBitmapID, int pXDelta, int pYDelta)
          Adds new dynamic map object to the map.
 void paint(boolean pForce)
          Draw the borders, command menu, message window, statistics information and other buttons.
 void penDown(int pX, int pY)
          This method is invoked if the user places the pen on the display.
 void penMove(int pX, int pY)
          This method is invoked if the user moves the pen over the display.
 void refresh()
          Tells the client that all the information for this turn has arrived.
 void serverExit()
          Informs that the server has exited/killed our connection.
 void serverReconnect()
          Informs that the server wishes to reconnect the TCP connection for example when changing the arena.
 
Methods inherited from class com.sun.kjava.Spotlet
beamReceive, beamSend, dispatch, getFlashID, penUp, register, setPalmEventOptions, unknownEvent, unregister
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MonroviaClient

public MonroviaClient()
Constructor for the Spotlet class. Construct other componentes and set some default values.
Method Detail

paint

public void paint(boolean pForce)
Draw the borders, command menu, message window, statistics information and other buttons.
Parameters:
pForce - true if we want to paint even if nothing was changed, false otherwise

dialogDismissed

public void dialogDismissed(java.lang.String pTitle)
This method defines the DialogOwner interface. The method is called when a dialog owned by us is closed.
Specified by:
dialogDismissed in interface com.sun.kjava.DialogOwner
Parameters:
pTitle - the name of the dialog that was closed

menuClose

public void menuClose(org.precipice.kvm.form.Menu pMenu,
                      org.precipice.kvm.form.MenuItem pItem)
This method is called when the menu is closed. Executes the menu functions.
Specified by:
menuClose in interface org.precipice.kvm.form.MenuOwner
Parameters:
pMenu - handle to the menu
pItem - handle to the menu item

init

public void init()
Initializes the stuff we do not want to create before connecting.

penDown

public void penDown(int pX,
                    int pY)
This method is invoked if the user places the pen on the display. Execute command or ask more information.
Overrides:
penDown in class com.sun.kjava.Spotlet
Parameters:
pX - the x coordinate of the point at which the pen was placed
pY - the y coordinate of the point at which the pen was placed

penMove

public void penMove(int pX,
                    int pY)
This method is invoked if the user moves the pen over the display. Dispatch the movement information to other UI classes.
Overrides:
penMove in class com.sun.kjava.Spotlet
Parameters:
pX - the x coordinate of the destination point of the move
pY - the y coordinate of the destination point of the move

keyDown

public void keyDown(int pKeyCode)
This method is invoked if the user presses either of the page up or page down hard keys, taps the calculator or menu icon, or enters a character (e.g. via Graffiti). If it is one of the hard key presses, then it will match one of the corresponding constants defined in this class.
Overrides:
keyDown in class com.sun.kjava.Spotlet
Parameters:
pKeyCode - the code of the key the user entered

main

public static void main(java.lang.String[] args)
This is the first function to be executed when starting the code. No parameters will be used.

giveSenders

public void giveSenders(UdpSender pUdpSender,
                        TcpSender pTcpSender)
Gives the handles for sending data.
Specified by:
giveSenders in interface ClientProtocolHandler
Parameters:
pUdpSender - handle for sending UDP data
pTcpSender - handle for sending TCP data

arena

public void arena(short[][] pMapBytes,
                  short[][] pBitmapBytes,
                  Command[] pMapCommands,
                  Stat[] pPlayerStats)
Receives the arena and player information from the protocol. This is done when entering an arena.
Specified by:
arena in interface ClientProtocolHandler
Parameters:
pMapBytes - map structure for this arena
pBitmapBytes - bitmaps used in this arena
pMapCommands - commands
pPlayerStats - player statistics information

serverExit

public void serverExit()
Informs that the server has exited/killed our connection.
Specified by:
serverExit in interface ClientProtocolHandler

refresh

public void refresh()
Tells the client that all the information for this turn has arrived. It's time to repaint the map and clear the dynamic map objects after that.
Specified by:
refresh in interface ClientProtocolHandler

serverReconnect

public void serverReconnect()
Informs that the server wishes to reconnect the TCP connection for example when changing the arena.
Specified by:
serverReconnect in interface ClientProtocolHandler

newLocation

public void newLocation(int pXMap,
                        int pYMap)
Sets the location of the player in this arena.
Specified by:
newLocation in interface ClientProtocolHandler
Parameters:
pXMap - the X coordinate on the map
pYMap - the Y coordinate on the map

changedStat

public void changedStat(int pStatID,
                        int pStatValue)
Gives a new integer value for a named statistics information.
Specified by:
changedStat in interface ClientProtocolHandler
Parameters:
pStatID - the ID of the statistics info to be set
pStatValue - the value that the statistics info should be set to

changedStat

public void changedStat(int pStatID,
                        java.lang.String pStatValue)
Gives a new string value for a named statistics information.
Specified by:
changedStat in interface ClientProtocolHandler
Parameters:
pStatID - the ID of the statistics info to be set
pStatValue - the value that the statistics info should be set to

command

public void command(Command pCommand)
adds or removes a command
Specified by:
command in interface ClientProtocolHandler
Parameters:
pCommand - the command object

newMessage

public void newMessage(java.lang.String pMessage)
Adds a new message to the message window.
Specified by:
newMessage in interface ClientProtocolHandler
Parameters:
pMessage - the message string

newObject

public void newObject(int pBitmapID,
                      int pXDelta,
                      int pYDelta)
Adds new dynamic map object to the map.
Specified by:
newObject in interface ClientProtocolHandler
Parameters:
pBitmapID - the ID of the bitmap to be displayed
pXDelta - the X distance from the player
pYDelta - the Y distance from the player

connectionError

public void connectionError(java.lang.String pMessage)
This indicates that an error occurred while connecting.
Specified by:
connectionError in interface ClientProtocolHandler
Parameters:
pMessage - the description of the error