Game Class Reference

The player's game engine. More...

#include <game.h>

List of all members.

Public Member Functions

 Game (const ustring &rootPath, Case::Case *pcase)
 Constructor.
 ~Game ()
 Destructor.
bool loadStockTextures ()
 Load stock textures.
void render ()
 Render the current scene.
Case::CasegetCase ()
 Get a pointer the current case.
void onKeyboardEvent (SDL_KeyboardEvent *e)
 Handle keyboard events.
void onMouseEvent (SDL_MouseButtonEvent *e)
 Handle mouse click events.

Static Public Member Functions

static Gameinstance ()
 Get a pointer to an instance of this object.

Private Member Functions

void registerAnimations ()
 register default animations for UI elements
void checkInputState ()
 Check the current input device state.
ustring getSelectedEvidence ()
 Get the ID of the selected Court Record evidence.
ustring getSelectedProfile ()
 Get the ID of the selected Court Record profile.
void toggle (int flags)
 Toggle a game state flag.
bool flagged (int flag)
 See if an element is flagged to be drawn.
bool shouldDrawTextBox ()
 See if the textbox should be drawn.
bool canExamineRegion ()
 Check to see if the area under examine cursors can be examined.
void setLocation (const ustring &location)
 Set the current location.
void setShownEvidence (const ustring &id, const Position &pos)
 Set the evidence to draw on top screen.
void displayTestimony (const ustring &id, bool crossExamine)
 Begin displaying a witness testimony.
void selectEvidence (bool evidence=true, bool increment=true)
 Change the selected evidence or profile.
bool isCourtLocation (const ustring &id)
 See if a location is a court location.
void updateFlags ()
 Update the current flags for game state.
void renderTopView ()
 Render the game view (top screen).
void renderMenuView ()
 Render the menu view (lower screen).
bool renderSpecialEffects ()
 Render special effects.
void renderTextBox ()
 Render the textbox.
void renderControls (int flags)
 Render the menu controls (move, talk, etc).
void renderCourtroomOverview ()
 Render the courtroom overview.
void renderStand (const Stand stand)
 Render the defense or prosecutor stand.
void onInitialScreenClicked (const ustring &id)
 Handler for clicks on the initial screen.
void onTopRightButtonClicked ()
 Handler for clicks on the top right button.
void onTopLeftButtonClicked ()
 Handler for clicks on the top left button.
void onBottomLeftButtonClicked ()
 Handler for clicks on the bottom left button.
void onBottomRightButtonClicked ()
 Handler for clicks on the bottom right button.
void onPresentCenterClicked ()
 Handler for Present button clicks.
void onCheckButtonClicked ()
 Handler for clicks on the Check button for evidence with check images.
void onControlsClicked (const Point &p)
 Handler for clicks on menu controls.
void onMoveSceneClicked (const ustring &button)
 Handler for clicks on the Move screen.
void onTalkSceneClicked (const ustring &button)
 Handler for clicks on the Talk screen.
void onRecPageClickEvent (const Point &p)
 Handler for clicks on the Court Record.
void onRecInfoPageClickEvent (const Point &p)
 Handler for clicks on the Court Record information page.
void onExamineButtonActivated ()
 Handler for Examine control button clicks.
void onMoveButtonActivated ()
 Handler for Move control button clicks.
void onTalkButtonActivated ()
 Handler for Talk control button clicks.
void onPresentButtonActivated ()
 Handler for Present control button clicks.
void onExamineThing (const Point &p)
 Handler for examining the hotspot in the provided coordinate range.

Private Attributes

Case::Casem_Case
 Pointer to current case.
TextParserm_Parser
 TextParser instance.
UI::Managerm_UI
 UI::Manager instance.
ustring m_CurBlock
 Current text block being executed.
ustring m_RootPath
 Path where case file resides.
GameState m_State
 The current state of the game.

Friends

class TextParser


Detailed Description

The player's game engine.

The Game class is the central engine that runs the entire player. Everything from input handling, to drawing is done from this class's render() function, which also makes sure to manage the flags in the GameState struct so everything is drawn correctly.

This class also relies on the TextParser class to run the script, and responds to triggers and other user related commands. Every animation is registered here, and use of the UI::Manager and Renderer namespaces is handled mainly through the functions in this class.

Furthermore, all memory related management, that is, deletion of allocated memory, is done in the Game class's destructor. Specifically, the Case::Case object, along with all of the images used in the player, are freed internally through the Game class.

Any functions that need to make use of this class, can call the Game::instance() function, which will return a pointer to the only allocated Game object.


Constructor & Destructor Documentation

Game::Game ( const ustring &  rootPath,
Case::Case pcase 
)

Constructor.

Parameters:
rootPath The root path to the case file
pcase Pointer to a loaded Case::Case object


Member Function Documentation

Game * Game::instance (  )  [static]

Get a pointer to an instance of this object.

Returns:
Pointer to an instance of this class

bool Game::loadStockTextures (  ) 

Load stock textures.

Returns:
true if no errors occurred, false otherwise

Case::Case* Game::getCase (  )  [inline]

Get a pointer the current case.

Returns:
Pointer to the case bound to this engine

void Game::onKeyboardEvent ( SDL_KeyboardEvent *  e  ) 

Handle keyboard events.

Parameters:
e An SDL_KeyboardEvent struct

void Game::onMouseEvent ( SDL_MouseButtonEvent *  e  ) 

Handle mouse click events.

Parameters:
e An SDL_MouseButtonEvent struct

ustring Game::getSelectedEvidence (  )  [private]

Get the ID of the selected Court Record evidence.

Returns:
The ID of the selected evidence

ustring Game::getSelectedProfile (  )  [private]

Get the ID of the selected Court Record profile.

Returns:
The ID of the selected profile

void Game::toggle ( int  flags  )  [private]

Toggle a game state flag.

Parameters:
flags The flags to toggle

bool Game::flagged ( int  flag  )  [private]

See if an element is flagged to be drawn.

Parameters:
flag The flag to test
Returns:
true if flagged, false otherwise

bool Game::shouldDrawTextBox (  )  [private]

See if the textbox should be drawn.

Returns:
true if yes, false otherwise

bool Game::canExamineRegion (  )  [private]

Check to see if the area under examine cursors can be examined.

Returns:
true if the area can be examined, false otherwise

void Game::setLocation ( const ustring &  location  )  [private]

Set the current location.

Parameters:
location The ID of the location to set

void Game::setShownEvidence ( const ustring &  id,
const Position &  pos 
) [private]

Set the evidence to draw on top screen.

Parameters:
id The ID of the evidence
pos Which place on the screen should the evidence be drawn at

void Game::displayTestimony ( const ustring &  id,
bool  crossExamine 
) [private]

Begin displaying a witness testimony.

Parameters:
id The ID of the testimony
crossExamine true if the testimony is to be cross examined, false otherwise

void Game::selectEvidence ( bool  evidence = true,
bool  increment = true 
) [private]

Change the selected evidence or profile.

Parameters:
evidence true to change evidence, false to change profile
increment true to increment position, false to decrement

bool Game::isCourtLocation ( const ustring &  id  )  [private]

See if a location is a court location.

Returns:
true if the location is a court location, false otherwise

bool Game::renderSpecialEffects (  )  [private]

Render special effects.

Returns:
true if all animations are done, false otherwise

void Game::renderControls ( int  flags  )  [private]

Render the menu controls (move, talk, etc).

Parameters:
flags Additional flags to take notice of

void Game::renderStand ( const Stand  stand  )  [private]

Render the defense or prosecutor stand.

Parameters:
stand The court stand to draw

void Game::onInitialScreenClicked ( const ustring &  id  )  [private]

Handler for clicks on the initial screen.

Parameters:
id The ID of the element clicked

void Game::onControlsClicked ( const Point p  )  [private]

Handler for clicks on menu controls.

Parameters:
p The position of the cursor

void Game::onMoveSceneClicked ( const ustring &  button  )  [private]

Handler for clicks on the Move screen.

Parameters:
button The button ID

void Game::onTalkSceneClicked ( const ustring &  button  )  [private]

Handler for clicks on the Talk screen.

Parameters:
button The button ID

void Game::onRecPageClickEvent ( const Point p  )  [private]

Handler for clicks on the Court Record.

Parameters:
p The position of the cursor

void Game::onRecInfoPageClickEvent ( const Point p  )  [private]

Handler for clicks on the Court Record information page.

Parameters:
p The position of the cursor

void Game::onExamineThing ( const Point p  )  [private]

Handler for examining the hotspot in the provided coordinate range.

Parameters:
p The point under the examination cursor


The documentation for this class was generated from the following files:
Generated on Fri Feb 22 22:29:23 2008 for Phoenix Wright Case Player API by  doxygen 1.5.3