JTP
Class LevelChooser

java.lang.Object
  extended by JTP.LevelChooser

public class LevelChooser
extends Object

Defines function and rendering of the level chooser component.

Author:
V.Termanis

Field Summary
static int CLOSE
           
static int COOP
           
static int CUSTOM
           
static int EXIT
           
static int FIRST
           
static int LAST
           
static int LEVEL_CHANGED
           
static int LEVEL_CHOSEN
           
static int NEXT
           
static int NONE
           
static int PLAY
           
static int PREVIOUS
           
static int SINGLE
           
 
Constructor Summary
LevelChooser(TilePainter painter, Images imgData, ScreenFrames frames, LevelSet[] defaultLevelSets, Font txtFont, Color txtColor, Graphics2D g)
          Create a new LevelChooser instance with the given attributes.
 
Method Summary
 int clickResult(Point mouseLocation)
           
 void drawAll(Graphics2D g)
           
 void drawUpdate(Graphics2D g)
           
 int getChosenLevel()
          Returns currently highlighted level
 int keyResult(int keyCode)
           
 void mousePressed(int button, Point mouseLocation)
           
 void setCustomLevelSet(LevelSet ls, boolean twoPlayer)
          Specify a levelset which can be previewed in CUSTOM mode.
 void setLevelSet(int type)
          Specify which levelset to display.
 Rectangle updateUI(Point mouseLocation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
See Also:
Constant Field Values

FIRST

public static final int FIRST
See Also:
Constant Field Values

PREVIOUS

public static final int PREVIOUS
See Also:
Constant Field Values

NEXT

public static final int NEXT
See Also:
Constant Field Values

LAST

public static final int LAST
See Also:
Constant Field Values

PLAY

public static final int PLAY
See Also:
Constant Field Values

CLOSE

public static final int CLOSE
See Also:
Constant Field Values

LEVEL_CHANGED

public static final int LEVEL_CHANGED
See Also:
Constant Field Values

LEVEL_CHOSEN

public static final int LEVEL_CHOSEN
See Also:
Constant Field Values

EXIT

public static final int EXIT
See Also:
Constant Field Values

SINGLE

public static final int SINGLE
See Also:
Constant Field Values

COOP

public static final int COOP
See Also:
Constant Field Values

CUSTOM

public static final int CUSTOM
See Also:
Constant Field Values
Constructor Detail

LevelChooser

public LevelChooser(TilePainter painter,
                    Images imgData,
                    ScreenFrames frames,
                    LevelSet[] defaultLevelSets,
                    Font txtFont,
                    Color txtColor,
                    Graphics2D g)
Create a new LevelChooser instance with the given attributes.

Parameters:
painter - used to draw previews and buttons
imgData - provides access to global resources
frames - used to draw frames
defaultLevelSets - holds single, cooperative, versus and versus alternative levelsets (at most single and cooperative sets are required in that order)
txtFont - font style to use (not for buttons)
txtColor - colour to use for text
g - the graphics context for drawing
Method Detail

setCustomLevelSet

public void setCustomLevelSet(LevelSet ls,
                              boolean twoPlayer)
                       throws NullPointerException
Specify a levelset which can be previewed in CUSTOM mode.

Parameters:
ls - the levelset to load
twoPlayer - if false then two player levelsets are rendered without 2nd start (when choosing to play 2P levelset in 1P mode)
Throws:
NullPointerException - if ls is null.

setLevelSet

public void setLevelSet(int type)
                 throws IllegalArgumentException,
                        NullPointerException
Specify which levelset to display.

Parameters:
type - one of SINGLE, COOP or CUSTOM .
Throws:
IllegalArgumentException - if type is invalid
NullPointerException - if CUSTOM type has been chosen without previously choosing a custom set via the setCustomLevelSet method.

drawAll

public void drawAll(Graphics2D g)

drawUpdate

public void drawUpdate(Graphics2D g)

updateUI

public Rectangle updateUI(Point mouseLocation)

clickResult

public int clickResult(Point mouseLocation)

getChosenLevel

public int getChosenLevel()
Returns currently highlighted level


mousePressed

public void mousePressed(int button,
                         Point mouseLocation)

keyResult

public int keyResult(int keyCode)