2 Copyright (C) 2004 Parallel Realities
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 void createSceneList()
28 Cutscene
*scene
= NULL
;
32 line
= strtok(NULL
, "\n");
36 if (strcmp(sceneLine
, "@EOF@") == 0)
42 if (strcmp(line
, "END") == 0)
45 if (strcmp(line
, "NEW") == 0)
47 scene
= new Cutscene();
50 // Assume graphics is first line after new
51 line
= strtok(NULL
, "\n");
52 if (strcmp(line
, "@none@") != 0)
54 strcpy(scene
->sprite
, line
);
55 debug(("Loading cutscene image %s\n", scene
->sprite
));
56 graphics
.quickSprite(scene
->sprite
, graphics
.loadImage(scene
->sprite
));
58 line
= strtok(NULL
, "\n");
59 sscanf(line
, "%d", &waitTime
);
60 scene
->waitTime
= (waitTime
* 100);
61 line
= strtok(NULL
, "\n");
64 if (strcmp(line
, "@none@") != 0)
66 scene
->appendText(line
);
71 bool setupScene(char *stagename
)
77 if (!engine
.loadData(_("data/ending")))
78 graphics
.showErrorAndExit("Couldn't load cutscene data file (%s)", _("data/ending"));
80 char *line
= strtok((char*)engine
.dataBuffer
, "\n");
83 graphics
.clearChatString();
91 sscanf(line
, "%*c %[^]]", sceneLine
);
92 if (strcmp(sceneLine
, stagename
) == 0)
100 line
= strtok(NULL
, "\n");
122 void showScene(bool allowSkip
)
124 graphics
.setFontSize(0);
125 graphics
.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
127 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
130 Cutscene
*scene
= (Cutscene
*)sceneList
.getHead();
132 SDL_Surface
*panel
= graphics
.quickSprite("panel", graphics
.createSurface(640, 90));
133 SDL_Surface
*image
= NULL
;
134 SDL_FillRect(panel
, NULL
, graphics
.black
);
136 float panelAlpha
= 0;
138 SDL_SetAlpha(panel
, SDL_SRCALPHA
|SDL_RLEACCEL
, 0);
143 float changeTime
= 100;
145 engine
.resetTimeDifference();
147 audio
.playMusicOnce();
151 graphics
.updateScreen();
155 engine
.doTimeDifference();
157 if ((engine
.userAccepts()) && (allowSkip
))
164 if (panelAlpha
< 256)
166 panelAlpha
+= (1 * engine
.getTimeDifference());
167 SDL_SetAlpha(panel
, SDL_SRCALPHA
|SDL_RLEACCEL
, (int)panelAlpha
);
170 SDL_SetAlpha(image
, SDL_SRCALPHA
|SDL_RLEACCEL
, (int)panelAlpha
);
171 graphics
.blit(image
, 0, 0, graphics
.screen
, false);
173 graphics
.blit(panel
, 0, 390, graphics
.screen
, false);
176 changeTime
-= (1 * engine
.getTimeDifference());
180 if (scene
->next
!= NULL
)
182 scene
= (Cutscene
*)scene
->next
;
184 changeTime
= scene
->waitTime
;
185 graphics
.clearChatString();
186 graphics
.createChatString(scene
->text
);
187 SDL_FillRect(panel
, NULL
, graphics
.black
);
188 graphics
.drawChatString(panel
, 0);
191 if (strcmp(scene
->sprite
, "") != 0)
193 debug(("Getting cutscene %s\n", scene
->sprite
));
194 image
= graphics
.getSprite(scene
->sprite
, true)->image
[0];
195 SDL_SetColorKey(image
, 0, SDL_MapRGB(image
->format
, 0, 0, 0));
207 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
211 void checkStartCutscene()
213 // Easy mode doesn't have cutscenes!
219 audio
.loadMusic("music/daisyChain2.mod");
221 char sceneName
[1024];
222 sprintf(sceneName
, "%s Start", game
.stageName
);
224 if (setupScene(sceneName
))
233 void checkEndCutscene()
235 // Easy mode doesn't have cutscenes!
241 if (strcmp(game
.stageName
, "Final Battle") != 0)
243 audio
.loadMusic("music/daisyChain2.mod");
247 audio
.loadMusic("music/sweetDreams.xm");
250 char sceneName
[1024];
251 sprintf(sceneName
, "%s End", game
.stageName
);
253 debug(("%s\n", sceneName
));
255 bool allowSkip
= true;
257 // Don't let the player skip the end of game cutscene...
258 // So we get the music timed well! :)
259 if (strcmp(game
.stageName
, "Final Battle") == 0)
264 if (setupScene(sceneName
))
266 showScene(allowSkip
);
273 void easyGameFinished()
278 audio
.loadMusic("music/friendDied.mod");
279 setupScene("Easy Game Finished");
282 graphics
.delay(3500);