game.h

00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Mike Polan                                      *
00003  *   kanadakid@gmail.com                                                   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 // game.h: the Game class
00021 
00022 #ifndef GAME_H
00023 #define GAME_H
00024 
00025 #include <iostream>
00026 #include <vector>
00027 
00028 #include "case.h"
00029 #include "common.h"
00030 #include "textparser.h"
00031 #include "uimanager.h"
00032 
00033 class Game;
00034 
00036 enum GameFlags {
00037         STATE_QUEUED=                   1 << 0,  
00038         STATE_COURT_REC_BTN=            1 << 1,  
00039         STATE_EVIDENCE_BTN=             1 << 2,  
00040         STATE_PROFILES_BTN=             1 << 3,  
00041         STATE_BACK_BTN=                 1 << 4,  
00042         STATE_PRESENT_BTN=              1 << 5,  
00043         STATE_EVIDENCE_PAGE=            1 << 6,  
00044         STATE_PROFILES_PAGE=            1 << 7,  
00045         STATE_EVIDENCE_INFO_PAGE=       1 << 8,  
00046         STATE_PROFILE_INFO_PAGE=        1 << 9,  
00047         STATE_NEXT_BTN=                 1 << 10, 
00048         STATE_TEXT_BOX=                 1 << 11, 
00049         STATE_CONTROLS=                 1 << 12, 
00050         STATE_EXAMINE=                  1 << 13, 
00051         STATE_MOVE=                     1 << 14, 
00052         STATE_TALK=                     1 << 15, 
00053         STATE_PRESENT_TOP_BTN=          1 << 16, 
00054         STATE_CROSS_EXAMINE_BTNS=       1 << 17, 
00055         STATE_PRESS_BTN=                1 << 18, 
00056         STATE_COURT_GREEN_BAR=          1 << 19, 
00057         STATE_CHECK_BTN=                1 << 20, 
00058         STATE_CHECK_EVIDENCE_IMAGE=     1 << 21, 
00059         STATE_CONFIRM_BTN=              1 << 22, 
00060         STATE_INITIAL_SCREEN=           1 << 23, 
00061         STATE_EPISODE_SELECTION=        1 << 24, 
00062         STATE_CONTINUE_SCREEN=          1 << 25  
00063                                                 };
00064 
00066 enum Controls {
00067         CONTROLS_ALL=           1 << 0,
00068         CONTROLS_EXAMINE=       1 << 1,
00069         CONTROLS_MOVE=          1 << 2,
00070         CONTROLS_TALK=          1 << 3,
00071         CONTROLS_PRESENT=       1 << 4 };
00072 
00074 enum Position {
00075         POSITION_LEFT=  1,
00076         POSITION_RIGHT= 2 };
00077 
00079 enum Screen {
00080         SCREEN_MAIN=    0,
00081         SCREEN_EXAMINE= 1,
00082         SCREEN_MOVE=    2,
00083         SCREEN_TALK=    3,
00084         SCREEN_PRESENT= 4 };
00085 
00087 enum Stand {
00088         COURT_PROSECUTOR_STAND=0,
00089         COURT_DEFENSE_STAND,
00090         COURT_WITNESS_STAND };
00091 
00103 struct _GameState {
00105         int drawFlags;
00106         
00108         int evidencePage;
00109         
00111         int profilesPage;
00112         
00113         // selections
00114         int selectedEvidence;
00115         int selectedProfile;
00116         int selectedControl;
00117         int selectedLocation;
00118         int selectedTalkOption;
00119         
00120         // trial variables
00121         bool requestingEvidence;
00122         bool requestingAnswer;
00123         ustring requestedEvidenceParams;
00124         ustring requestedAnswerParams;
00125         ustring requestedContrParams;
00126         
00128         ustring tempImage;
00129         
00131         Point examinePt;
00132         
00133         // region of contradiction in provided image of evidence
00134         ustring contradictionImg;
00135         Rect contradictionRegion;
00136         
00138         int prevScreen;
00139         
00141         bool hideTextBox;
00142         
00144         bool continueMusic;
00145         
00146         // testimony variables
00147         ustring curTestimony;
00148         int curTestimonyPiece;
00149         int barPercent; // amount of green bar filled in
00150         bool curExamination;
00151         bool curExaminationPaused; // for temporarily breaking away from cross examinations
00152         
00153         // special effects
00154         int shake;
00155         ustring fadeOut;
00156         ustring fadeIn;
00157         ustring flash;
00158         ustring blink;
00159         ustring gavel;
00160         ustring courtCamera;
00161         ustring testimonySequence;
00162         ustring crossExamineSequence;
00163         ustring exclamation;
00164         ustring addEvidence;
00165         
00167         StringPair crossExamineLawyers;
00168         
00169         // the current evidence being shown
00170         ustring shownEvidence;
00171         Position shownEvidencePos;
00172         
00173         // images to display for various parts of the courtroom
00174         ustring crOverviewDefense;
00175         ustring crOverviewProsecutor;
00176         ustring crOverviewWitness;
00177         
00179         ustring currentLocation;
00180         
00181         // scheduled events
00182         int queuedFlags;
00183         ustring queuedLocation;
00184         ustring queuedBlock;
00185         ustring resetAnimations;
00186         
00188         std::vector<StringPair> custom;
00189         
00191         std::vector<StringPair> talkOptions;
00192         
00194         std::vector<ustring> visibleEvidence;
00195         
00197         std::vector<ustring> visibleProfiles;
00198 };
00199 typedef struct _GameState GameState;
00200 
00220 class Game {
00221         public:
00226                 Game(const ustring &rootPath, Case::Case *pcase);
00227                 
00229                 ~Game();
00230                 
00234                 static Game* instance();
00235                 
00239                 bool loadStockTextures();
00240                 
00242                 void render();
00243                 
00247                 Case::Case* getCase() { return m_Case; }
00248                 
00252                 void onKeyboardEvent(SDL_KeyboardEvent *e);
00253                 
00257                 void onMouseEvent(SDL_MouseButtonEvent *e);
00258                 
00259         private:
00261                 void registerAnimations();
00262                 
00264                 void checkInputState();
00265                 
00269                 ustring getSelectedEvidence();
00270                 
00274                 ustring getSelectedProfile();
00275                 
00279                 void toggle(int flags);
00280                 
00285                 bool flagged(int flag);
00286                 
00290                 bool shouldDrawTextBox();
00291                 
00295                 bool canExamineRegion();
00296                 
00300                 void setLocation(const ustring &location);
00301                 
00306                 void setShownEvidence(const ustring &id, const Position &pos);
00307                 
00312                 void displayTestimony(const ustring &id, bool crossExamine);
00313                 
00318                 void selectEvidence(bool evidence=true, bool increment=true);
00319                 
00323                 bool isCourtLocation(const ustring &id);
00324                 
00326                 void updateFlags();
00327                 
00329                 void renderTopView();
00330                 
00332                 void renderMenuView();
00333                 
00337                 bool renderSpecialEffects();
00338                 
00340                 void renderTextBox();
00341                 
00345                 void renderControls(int flags);
00346                 
00348                 void renderCourtroomOverview();
00349                 
00353                 void renderStand(const Stand stand);
00354                 
00358                 void onInitialScreenClicked(const ustring &id);
00359                 
00361                 void onTopRightButtonClicked();
00362                 
00364                 void onTopLeftButtonClicked();
00365                 
00367                 void onBottomLeftButtonClicked();
00368                 
00370                 void onBottomRightButtonClicked();
00371                 
00373                 void onPresentCenterClicked();
00374                 
00376                 void onCheckButtonClicked();
00377                 
00381                 void onControlsClicked(const Point &p);
00382                 
00386                 void onMoveSceneClicked(const ustring &button);
00387                 
00391                 void onTalkSceneClicked(const ustring &button);
00392                 
00396                 void onRecPageClickEvent(const Point &p);
00397                 
00401                 void onRecInfoPageClickEvent(const Point &p);
00402                 
00404                 void onExamineButtonActivated();
00405                 
00407                 void onMoveButtonActivated();
00408                 
00410                 void onTalkButtonActivated();
00411                 
00413                 void onPresentButtonActivated();
00414                 
00418                 void onExamineThing(const Point &p);
00419                 
00421                 Case::Case *m_Case;
00422                 
00424                 TextParser *m_Parser;
00425                 
00427                 UI::Manager *m_UI;
00428                 
00430                 ustring m_CurBlock;
00431                 
00433                 ustring m_RootPath;
00434                 
00436                 GameState m_State;
00437                 
00438                 // friend classes
00439                 friend class TextParser;
00440 };
00441 
00442 #endif

Generated on Fri Feb 22 22:29:23 2008 for Phoenix Wright Case Player API by  doxygen 1.5.3