#include <game.h>
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::Case * | getCase () |
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 Game * | instance () |
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::Case * | m_Case |
Pointer to current case. | |
TextParser * | m_Parser |
TextParser instance. | |
UI::Manager * | m_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 |
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.
Game::Game | ( | const ustring & | rootPath, | |
Case::Case * | pcase | |||
) |
Constructor.
rootPath | The root path to the case file | |
pcase | Pointer to a loaded Case::Case object |
Game * Game::instance | ( | ) | [static] |
Get a pointer to an instance of this object.
bool Game::loadStockTextures | ( | ) |
Load stock textures.
Case::Case* Game::getCase | ( | ) | [inline] |
Get a pointer the current case.
void Game::onKeyboardEvent | ( | SDL_KeyboardEvent * | e | ) |
Handle keyboard events.
e | An SDL_KeyboardEvent struct |
void Game::onMouseEvent | ( | SDL_MouseButtonEvent * | e | ) |
Handle mouse click events.
e | An SDL_MouseButtonEvent struct |
ustring Game::getSelectedEvidence | ( | ) | [private] |
Get the ID of the selected Court Record evidence.
ustring Game::getSelectedProfile | ( | ) | [private] |
Get the ID of the selected Court Record profile.
void Game::toggle | ( | int | flags | ) | [private] |
Toggle a game state flag.
flags | The flags to toggle |
bool Game::flagged | ( | int | flag | ) | [private] |
See if an element is flagged to be drawn.
flag | The flag to test |
bool Game::shouldDrawTextBox | ( | ) | [private] |
See if the textbox should be drawn.
bool Game::canExamineRegion | ( | ) | [private] |
Check to see if the area under examine cursors can be examined.
void Game::setLocation | ( | const ustring & | location | ) | [private] |
Set the current location.
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.
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.
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.
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.
bool Game::renderSpecialEffects | ( | ) | [private] |
Render special effects.
void Game::renderControls | ( | int | flags | ) | [private] |
Render the menu controls (move, talk, etc).
flags | Additional flags to take notice of |
void Game::renderStand | ( | const Stand | stand | ) | [private] |
Render the defense or prosecutor stand.
stand | The court stand to draw |
void Game::onInitialScreenClicked | ( | const ustring & | id | ) | [private] |
Handler for clicks on the initial screen.
id | The ID of the element clicked |
void Game::onControlsClicked | ( | const Point & | p | ) | [private] |
Handler for clicks on menu controls.
p | The position of the cursor |
void Game::onMoveSceneClicked | ( | const ustring & | button | ) | [private] |
Handler for clicks on the Move screen.
button | The button ID |
void Game::onTalkSceneClicked | ( | const ustring & | button | ) | [private] |
Handler for clicks on the Talk screen.
button | The button ID |
void Game::onRecPageClickEvent | ( | const Point & | p | ) | [private] |
Handler for clicks on the Court Record.
p | The position of the cursor |
void Game::onRecInfoPageClickEvent | ( | const Point & | p | ) | [private] |
Handler for clicks on the Court Record information page.
p | The position of the cursor |
void Game::onExamineThing | ( | const Point & | p | ) | [private] |
Handler for examining the hotspot in the provided coordinate range.
p | The point under the examination cursor |