00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef UIMANAGER_H
00023 #define UIMANAGER_H
00024
00025 #include <iostream>
00026 #include <map>
00027 #include "SDL.h"
00028
00029 #include "common.h"
00030
00031 class Case::Case;
00032 class Game;
00033
00035 namespace UI {
00036
00037 typedef void (Game::*Callback) (const ustring &);
00038
00040 enum Limit { LIMIT_NONE=0,
00041 LIMIT_DEFENSE_STAND,
00042 LIMIT_PROSECUTOR_STAND,
00043 LIMIT_WITNESS_STAND };
00044
00046 enum AnimType { ANIM_SIDE_HBOUNCE=0,
00047 ANIM_SIDE_VBOUNCE,
00048 ANIM_FADE_OUT_TOP,
00049 ANIM_FADE_OUT_BOTTOM,
00050 ANIM_FADE_OUT_BOTTOM_GUI,
00051 ANIM_FADE_OUT_BOTH,
00052 ANIM_FADE_OUT_TOP_HALF,
00053 ANIM_FADE_OUT_BOTTOM_HALF,
00054 ANIM_FADE_OUT_BOTH_HALF,
00055 ANIM_FLASH,
00056 ANIM_COURT_CAMERA,
00057 ANIM_TESTIMONY_SPR,
00058 ANIM_CROSS_EXAMINE_SPR,
00059 ANIM_BLINK,
00060 ANIM_SYNC_BOUNCE,
00061 ANIM_GREEN_BAR,
00062 ANIM_EXCLAMATION,
00063 ANIM_GUI_BUTTON,
00064 ANIM_BG_SLIDE,
00065 ANIM_ADD_EVIDENCE };
00066
00071 struct _Animation {
00073 ustring texture;
00074
00076 ustring texture2;
00077
00079 bool texture1Active;
00080
00082 bool texture2Active;
00083
00085 SDL_Surface *surface;
00086
00088 ustring txt;
00089
00091 ustring sfx;
00092
00094 Callback callback;
00095
00097 int w;
00098
00100 int h;
00101
00103 Point current;
00104
00106
00107 Point p1;
00108 Point p2;
00110
00112 Point delta;
00113
00115 AnimType type;
00116
00118
00119 int leftLimit;
00120 int rightLimit;
00121 int topLimit;
00122 int bottomLimit;
00124
00126 int velocity;
00127
00129 int multiplier;
00130
00132 int alpha;
00133
00135 int ticks;
00136
00138 int speed;
00139
00141 int lastDraw;
00142 };
00143 typedef struct _Animation Animation;
00144
00150 class Button {
00151 public:
00158 Button(const ustring &text, const Point &p, Callback slot, const ustring &sfx=STR_NULL) {
00159 m_Text=text;
00160 m_Point=p;
00161 m_Slot=slot;
00162 m_SFX=sfx;
00163 }
00164
00168 ustring getText() const { return m_Text; }
00169
00173 ustring getSFX() const { return m_SFX; }
00174
00178 Point getPoint() const { return m_Point; }
00179
00183 Callback getSlot() const { return m_Slot; }
00184
00185 private:
00186 ustring m_Text;
00187 ustring m_SFX;
00188 Point m_Point;
00189 Callback m_Slot;
00190 };
00191
00206 class Manager {
00207 public:
00211 Manager(Case::Case *pcase);
00212
00216 static Manager* instance();
00217
00221 Animation* getAnimation(const ustring &id);
00222
00227 void handleGUIClick(const Point &mouse, const ustring &id);
00228
00233 void handleGUIClick(const Point &mouse, const StringVector &ids);
00234
00238 void reverseVelocity(const ustring &id);
00239
00244 void unsyncBounceTexture(const ustring &id, bool left);
00245
00250 void resyncBounceTexture(const ustring &id, bool left);
00251
00255 bool isGUIBusy();
00256
00261 void setGUIButtonText(const ustring &id, const ustring &text);
00262
00268 bool mouseOverButton(const ustring &id, const Point &p);
00269
00273 void clickGUIButton(const ustring &id);
00274
00280 void registerGUIButton(const ustring &id, int w, const Button &button);
00281
00293 void registerSideBounceAnimation(const ustring &id, const ustring &texture, bool horizontal,
00294 const Point &origin, int limitA, int limitB, int speed);
00295
00301 void registerFadeOut(const ustring &id, int speed, const AnimType &type);
00302
00307 void registerFlash(const ustring &id, int speed);
00308
00312 void registerCourtCameraMovement(const ustring &id);
00313
00317 void registerTestimonySequence(const ustring &id);
00318
00322 void registerCrossExamineSequence(const ustring &id);
00323
00330 void registerBlink(const ustring &id, const ustring &texture, const Point &p, int speed);
00331
00344 void registerSyncBounce(const ustring &id, const ustring &tex1, const ustring &tex2,
00345 const Point &p1, const Point &p2, int limA, int limB, int speed);
00346
00352 void registerGreenBarControl(const ustring &id, const ustring &texture, const Point &p);
00353
00359 void registerExclamation(const ustring &id, const ustring &texture, const Point &p);
00360
00364 void registerBGSlide(const ustring &id);
00365
00369 void registerAddEvidenceSequence(const ustring &id);
00370
00374 void drawAnimation(const ustring &id);
00375
00380 int fadeOut(const ustring &id);
00381
00387 int animateAddEvidence(const ustring &id, const Case::Evidence *evidence);
00388
00393 bool flash(const ustring &id);
00394
00399 bool blink(const ustring &id);
00400
00406 bool exclamation(const ustring &id, const Character *source);
00407
00413 bool slideBG(const ustring &id, SDL_Surface *bg);
00414
00422 bool moveCourtCamera(const ustring &id, SDL_Surface *panorama, Limit start, Limit end);
00423
00428 bool animateTestimonySequence(const ustring &id);
00429
00436 bool animateCrossExamineSequence(const ustring &id, SDL_Surface *leftLawyer, SDL_Surface *rightLawyer);
00437
00442 bool animateSyncBounce(const ustring &id);
00443
00448 bool animateGreenBar(const ustring &id);
00449
00454 bool animateGUIButton(const ustring &id);
00455
00456 private:
00458 Case::Case *m_Case;
00459
00461 std::map<ustring, Animation> m_Animations;
00462 };
00463
00464 };
00465
00466 #endif