mhframework
Class MHScreenManager

java.lang.Object
  extended by mhframework.MHScreenManager

public final class MHScreenManager
extends java.lang.Object

The MHScreenManager class maintains references to the current screen, the application's data model, and encapsulates a screen stack (MHScreenStack) for providing the ability to backtrack through multiple game screens.

AN IDEA: Maybe this class could contain a generic loading screen that displays automatically if the new screen being loaded is not ready to be displayed. So, if it's told to change screens, it can query the new screen to see if it's ready. If not, it can display a generic loading screen until the new screen is ready. Consider this for the next version.


Constructor Summary
MHScreenManager(MHScreen screen)
          Constructor.
 
Method Summary
 void addScreen(MHScreen newScreen)
          Adds a new screen to the screen stack.
 void advance()
          Tells the current screen to update its data.
 void gc()
          Runs the screen manager's garbage collector to deallocate screens that are no longer needed (i.e.
 MHScreen getScreen()
          Retrieves the current screen.
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void removeScreen()
          Removes a screen from the screen stack.
 void render(java.awt.Graphics2D g)
          Tells the current screen to draw itself onto the input Graphics2D object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MHScreenManager

public MHScreenManager(MHScreen screen)
Constructor. Constructs a stack with the given screen.

Parameters:
screen - An initial screen object used to create the stack. This is often a loading screen, title screen, copyright notice, etc.
Method Detail

getScreen

public MHScreen getScreen()
Retrieves the current screen. The current screen is the one at the top of the screen stack.

Returns:
A reference to the top screen on the stack.

gc

public void gc()
Runs the screen manager's garbage collector to deallocate screens that are no longer needed (i.e. marked as disposable).


addScreen

public void addScreen(MHScreen newScreen)
Adds a new screen to the screen stack.


removeScreen

public void removeScreen()
Removes a screen from the screen stack.


advance

public void advance()
Tells the current screen to update its data. If the current screen has finished executing, change to a different screen.


render

public void render(java.awt.Graphics2D g)
Tells the current screen to draw itself onto the input Graphics2D object.


keyTyped

public void keyTyped(java.awt.event.KeyEvent e)

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)