net.sf.freecol.client
Class FreeColClient

java.lang.Object
  extended by net.sf.freecol.client.FreeColClient

public final class FreeColClient
extends java.lang.Object

The main control class for the FreeCol client. This class both starts and keeps references to the GUI and the control objects.


Field Summary
static java.lang.String COPYRIGHT
           
static java.lang.String LICENSE
           
static java.lang.String REVISION
           
 Worker worker
           
 
Constructor Summary
FreeColClient(boolean windowed, java.awt.Rectangle windowSize, ImageLibrary imageLibrary, MusicLibrary musicLibrary, SfxLibrary sfxLibrary)
          Creates a new FreeColClient.
 
Method Summary
 ActionManager getActionManager()
          Gets the object responsible for keeping and updating the actions.
 Canvas getCanvas()
          Gets the Canvas this client uses to display the GUI-components.
 Client getClient()
          Gets the Client that can be used to send messages to the server.
 ClientOptions getClientOptions()
          Returns the object keeping the current client options.
 ConnectController getConnectController()
          Gets the controller responsible for starting a server and connecting to it.
 FreeColServer getFreeColServer()
          Gets the FreeColServer started by the client.
 Game getGame()
          Gets the Game that we are currently playing.
 GUI getGUI()
          Gets the GUI that is beeing used to draw the map on the Canvas.
 ImageLibrary getImageLibrary()
          Gets the ImageLibrary.
 InGameController getInGameController()
          Gets the controller that will be used when the game has been started.
 InGameInputHandler getInGameInputHandler()
          Gets the input handler that will be used when the game has been started.
 ClientModelController getModelController()
          Gets the ClientModelController.
 Player getMyPlayer()
          Gets the Player that uses this client.
 PreGameController getPreGameController()
          Gets the controller that will be used before the game has been started.
 PreGameInputHandler getPreGameInputHandler()
          Gets the input handler that will be used before the game has been started.
 PseudoRandom getPseudoRandom()
          Get the pseudo-random number generator for the client.
 boolean isAdmin()
          Checks if this client is the game admin.
 boolean isLoggedIn()
          Returns true if this client is logged in to a server or false otherwise.
 boolean isSingleplayer()
          Is the user playing in singleplayer mode.
 void loadClientOptions()
          Reads the ClientOptions from the given file.
 void loadClientOptions(java.io.File loadFile)
          Reads the ClientOptions from the given file.
 void playSound(int sound)
          Plays the given sound effect.
 void quit()
          Quits the application without any questions.
 void saveClientOptions()
          Writes the client options to the default location.
 void saveClientOptions(java.io.File saveFile)
          Writes the client options to the given file.
 void setClient(Client client)
          Sets the Client that shall be used to send messages to the server.
 void setFreeColServer(FreeColServer freeColServer)
          Sets the FreeColServer which has been started by the client gui.
 void setGame(Game game)
          Sets the Game that we are currently playing.
 void setLoggedIn(boolean loggedIn)
          Sets whether or not this client is logged in to a server.
 void setMyPlayer(Player player)
          Sets the Player that uses this client.
 void setSingleplayer(boolean singleplayer)
          Sets wether or not this game is a singleplayer game.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

LICENSE

public static final java.lang.String LICENSE
See Also:
Constant Field Values

REVISION

public static final java.lang.String REVISION
See Also:
Constant Field Values

worker

public final Worker worker
Constructor Detail

FreeColClient

public FreeColClient(boolean windowed,
                     java.awt.Rectangle windowSize,
                     ImageLibrary imageLibrary,
                     MusicLibrary musicLibrary,
                     SfxLibrary sfxLibrary)
Creates a new FreeColClient. Creates the control objects and starts the GUI.

Parameters:
windowed - Determines if the Canvas should be displayed within a JFrame (when true) or in fullscreen mode (when false).
windowSize - The size of the window if not in fullscreen mode.
imageLibrary - The object holding the images.
musicLibrary - The object holding the music.
sfxLibrary - The object holding the sound effects.
Method Detail

saveClientOptions

public void saveClientOptions()
Writes the client options to the default location.

See Also:
ClientOptions

saveClientOptions

public void saveClientOptions(java.io.File saveFile)
Writes the client options to the given file.

Parameters:
saveFile - The file where the client options should be written.
See Also:
ClientOptions

getImageLibrary

public ImageLibrary getImageLibrary()
Gets the ImageLibrary.

Returns:
The ImageLibrary.

loadClientOptions

public void loadClientOptions()
Reads the ClientOptions from the given file.


loadClientOptions

public void loadClientOptions(java.io.File loadFile)
Reads the ClientOptions from the given file.

Parameters:
loadFile - The File to read the ClientOptions from.

getActionManager

public ActionManager getActionManager()
Gets the object responsible for keeping and updating the actions.

Returns:
The ActionManager.

getClientOptions

public ClientOptions getClientOptions()
Returns the object keeping the current client options.

Returns:
The ClientOptions.

getMyPlayer

public Player getMyPlayer()
Gets the Player that uses this client.

Returns:
The Player made to represent this clients user.
See Also:
setMyPlayer(Player)

setMyPlayer

public void setMyPlayer(Player player)
Sets the Player that uses this client.

Parameters:
player - The Player made to represent this clients user.
See Also:
getMyPlayer()

setFreeColServer

public void setFreeColServer(FreeColServer freeColServer)
Sets the FreeColServer which has been started by the client gui.

Parameters:
freeColServer - The FreeColServer.
See Also:
getFreeColServer()

getFreeColServer

public FreeColServer getFreeColServer()
Gets the FreeColServer started by the client.

Returns:
The FreeColServer or null if no server has been started.

setGame

public void setGame(Game game)
Sets the Game that we are currently playing.

Parameters:
game - The Game.
See Also:
getGame()

getGame

public Game getGame()
Gets the Game that we are currently playing.

Returns:
The Game.
See Also:
setGame(net.sf.freecol.common.model.Game)

getCanvas

public Canvas getCanvas()
Gets the Canvas this client uses to display the GUI-components.

Returns:
The Canvas.

getGUI

public GUI getGUI()
Gets the GUI that is beeing used to draw the map on the Canvas.

Returns:
The GUI.

quit

public void quit()
Quits the application without any questions.


isAdmin

public boolean isAdmin()
Checks if this client is the game admin.

Returns:
true if the client is the game admin and false otherwise. false is also returned if a game have not yet been started.

setSingleplayer

public void setSingleplayer(boolean singleplayer)
Sets wether or not this game is a singleplayer game.

Parameters:
singleplayer - Indicates wether or not this game is a singleplayer game.
See Also:
isSingleplayer()

isSingleplayer

public boolean isSingleplayer()
Is the user playing in singleplayer mode.

Returns:
true if the user is playing in singleplayer mode and false otherwise.
See Also:
setSingleplayer(boolean)

getConnectController

public ConnectController getConnectController()
Gets the controller responsible for starting a server and connecting to it.

Returns:
The ConnectController.

getPreGameController

public PreGameController getPreGameController()
Gets the controller that will be used before the game has been started.

Returns:
The PreGameController.

getPreGameInputHandler

public PreGameInputHandler getPreGameInputHandler()
Gets the input handler that will be used before the game has been started.

Returns:
The PreGameInputHandler.

getInGameController

public InGameController getInGameController()
Gets the controller that will be used when the game has been started.

Returns:
The InGameController.

getInGameInputHandler

public InGameInputHandler getInGameInputHandler()
Gets the input handler that will be used when the game has been started.

Returns:
The InGameInputHandler.

getModelController

public ClientModelController getModelController()
Gets the ClientModelController.

Returns:
The ClientModelController.

setClient

public void setClient(Client client)
Sets the Client that shall be used to send messages to the server.

Parameters:
client - the Client
See Also:
getClient()

getClient

public Client getClient()
Gets the Client that can be used to send messages to the server.

Returns:
the Client
See Also:
setClient(net.sf.freecol.client.networking.Client)

playSound

public void playSound(int sound)
Plays the given sound effect.

Parameters:
sound - The key sound effect given by SfxLibrary.

isLoggedIn

public boolean isLoggedIn()
Returns true if this client is logged in to a server or false otherwise.

Returns:
true if this client is logged in to a server or false otherwise.

setLoggedIn

public void setLoggedIn(boolean loggedIn)
Sets whether or not this client is logged in to a server.

Parameters:
loggedIn - An indication of whether or not this client is logged in to a server.

getPseudoRandom

public PseudoRandom getPseudoRandom()
Get the pseudo-random number generator for the client.

Returns:
random number generator.