00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021
00022 #include "movie.h"
00023
00024 FlashMovie::FlashMovie()
00025 {
00026 gd = NULL;
00027 sm = NULL;
00028 getSwf = NULL;
00029 getUrl = NULL;
00030 cursorOnOff = NULL;
00031 buttons_updated = 0;
00032 scheduledTime.tv_sec = -1;
00033 cur_focus = NULL;
00034 lost_over = NULL;
00035 msPerFrame = 0;
00036
00037
00038 mouse_active = 0;
00039 mouse_x = -1;
00040 mouse_y = -1;
00041 button_pressed = 0;
00042 refresh = 1;
00043 }
00044
00045 FlashMovie::~FlashMovie()
00046 {
00047 CInputScript *n;
00048
00049 while (main != NULL) {
00050 n = main->next;
00051 delete main;
00052 main = n;
00053 }
00054
00055 if (gd) delete gd;
00056 if (sm) delete sm;
00057 }
00058
00059 int
00060 FlashMovie::processMovie(GraphicDevice *gd, SoundMixer *sm)
00061 {
00062 CInputScript *script;
00063 int wakeUp = 0;
00064
00065 if (sm && sm->playSounds()) {
00066 wakeUp = 1;
00067 }
00068 for (script = this->main; script != NULL; script = script->next) {
00069 if (script->program == NULL) continue;
00070 if (script->program->nbFrames == 0) continue;
00071 if (script->program->processMovie(gd,sm)) {
00072 wakeUp = 1;
00073 }
00074 }
00075 renderMovie();
00076 return wakeUp;
00077 }
00078
00079 int
00080 FlashMovie::handleEvent(GraphicDevice *gd, SoundMixer *sm, FlashEvent *event)
00081 {
00082 int wakeUp = 0;
00083
00084 if (sm && sm->playSounds()) {
00085 wakeUp = 1;
00086 }
00087 if (this->main == 0) return 0;
00088 if (this->main->program == 0) return 0;
00089 if (this->main->program->handleEvent(gd, sm, event)) {
00090 wakeUp = 1;
00091 }
00092 renderMovie();
00093 return wakeUp;
00094 }
00095
00096
00097 void
00098 FlashMovie::renderFocus()
00099 {
00100 Rect rect,boundary;
00101 Matrix mat;
00102
00103 if (mouse_active || !cur_focus) return;
00104
00105
00106
00107
00108 cur_focus->character->getBoundingBox(&boundary,cur_focus);
00109 mat = (*gd->adjust) * cur_focus->renderMatrix;
00110 transformBoundingBox(&rect, &mat, &boundary, 1);
00111
00112 gd->drawBox(rect.xmin, rect.ymin, rect.xmax, rect.ymax);
00113 }
00114
00115 void
00116 FlashMovie::renderMovie()
00117 {
00118 CInputScript *script,*prev,*next;
00119 Rect clipping;
00120 Matrix identity;
00121
00122 clipping.reset();
00123
00124
00125 for (script = this->main; script != NULL; script = script->next) {
00126 if (script->level == -1) {
00127 clipping.xmin = -32768;
00128 clipping.ymin = -32768;
00129 clipping.xmax = 32767;
00130 clipping.ymax = 32767;
00131 continue;
00132 }
00133 if (script->program == NULL) continue;
00134 if (script->program->dl->bbox.xmin == LONG_MAX) continue;
00135 transformBoundingBox(&clipping, &identity, &script->program->dl->bbox, 0);
00136 script->program->render = 0;
00137 }
00138
00139 if (clipping.xmin == LONG_MAX) return;
00140
00141
00142 gd->updateClippingRegion(&clipping);
00143 gd->clearCanvas();
00144
00145
00146 for (script = this->main; script != NULL; script = script->next) {
00147 if (script->level == -1) continue;
00148 if (script->program == NULL) continue;
00149 script->program->dl->render(gd);
00150 }
00151 renderFocus();
00152
00153
00154 script = this->main;
00155 prev = 0;
00156 while (script != NULL) {
00157 if (script->level == -1) {
00158 next = script->next;
00159 if (prev == 0) {
00160 this->main = next;
00161 } else {
00162 prev->next = next;
00163 }
00164 delete script;
00165 script = next;
00166 } else {
00167 prev = script;
00168 script = script->next;
00169 }
00170 }
00171 }