summaryrefslogtreecommitdiff
path: root/src/cutScene.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-09-01 05:09:47 +0200
committerTreeki <treeki@gmail.com>2012-09-01 05:09:47 +0200
commitf1d937694dc9d9f9637af8c72293dab9edeaf7a2 (patch)
treed02dca08e9077b77f3ce85516689110f3825dce8 /src/cutScene.cpp
parentfbcd0d0d86409976ab22caeea25dc934486345a1 (diff)
downloadkamek-f1d937694dc9d9f9637af8c72293dab9edeaf7a2.tar.gz
kamek-f1d937694dc9d9f9637af8c72293dab9edeaf7a2.zip
the beginnings of a working cutscene player
Diffstat (limited to '')
-rw-r--r--src/cutScene.cpp130
1 files changed, 128 insertions, 2 deletions
diff --git a/src/cutScene.cpp b/src/cutScene.cpp
index 27fbafc..f60122f 100644
--- a/src/cutScene.cpp
+++ b/src/cutScene.cpp
@@ -11,26 +11,152 @@ dScCutScene_c *dScCutScene_c::build() {
return c;
}
-dScCutScene_c::dScCutScene_c() : state(this) {
+dScCutScene_c::dScCutScene_c() {
+ data = 0;
+ layout = 0;
+ sceneLoaders = 0;
}
+dScCutScene_c::~dScCutScene_c() {
+ if (layout)
+ delete layout;
+
+ if (sceneLoaders)
+ delete[] sceneLoaders;
+}
+
+
+static const char *CutsceneNames[] = {
+ "/CS/Opening.cs",
+ "/CS/Kamek.cs",
+ "/CS/Ending.cs"
+};
int dScCutScene_c::onCreate() {
*CurrentDrawFunc = CutSceneDrawFunc;
- return true;
+ currentScene = -1;
+
+ int csNumber = settings >> 28;
+ if (settingsLoader.load(CutsceneNames[csNumber])) {
+ // only deal with this once!
+ if (data) return 1;
+
+ data = (dMovieData_s*)settingsLoader.buffer;
+
+ // fix up the settings
+ for (int i = 0; i < data->sceneCount; i++) {
+ data->scenes[i] =
+ (dMovieScene_s*)((u32)data + (u32)data->scenes[i]);
+
+ data->scenes[i]->sceneName =
+ (char*)((u32)data + (u32)data->scenes[i]->sceneName);
+ }
+
+ sceneLoaders = new dDvdLoader_c[data->sceneCount];
+
+ nextScene = 0;
+
+ return 1;
+ }
+
+ return 0;
}
int dScCutScene_c::onDelete() {
+ if (layout)
+ return layout->free();
+
return true;
}
int dScCutScene_c::onExecute() {
+ // deal with loading first
+
+ // what do we want to load?
+ int loadBegin, loadEnd;
+ if (nextScene == 0) {
+ loadBegin = 0;
+ loadEnd = 1;
+ } else {
+ loadBegin = ((currentScene + 1) > nextScene) ? (currentScene + 1) : nextScene;
+ loadEnd = data->sceneCount;
+ }
+
+ for (int i = loadBegin; i < loadEnd; i++) {
+ sceneLoaders[i].load(data->scenes[i]->sceneName);
+ }
+
+
+
+ // now, do all other processing
+
+ if (currentScene >= 0) {
+ if (!layout->isAnyAnimOn()) {
+ // we're at the end
+ // what now?
+
+ if ((currentScene + 1) == data->sceneCount) {
+ // we're TOTALLY done!
+ OSReport("playback complete\n");
+ } else {
+ nextScene = currentScene + 1;
+ OSReport("switching to scene %d\n", nextScene);
+ }
+
+ sceneLoaders[currentScene].unload();
+ currentScene = -1;
+ delete layout;
+ layout = 0;
+ return true;
+ }
+
+ layout->execAnimations();
+ layout->update();
+ }
+
+ if (nextScene >= 0) {
+ // is this scene loaded yet?
+ if (sceneLoaders[nextScene].buffer) {
+ currentScene = nextScene;
+
+ OSReport("Loading scene %d\n", currentScene);
+
+ layout = new m2d::EmbedLayout_c;
+ layout->loader.buffer = sceneLoaders[nextScene].buffer;
+ layout->loader.attachArc(layout->loader.buffer, "arc");
+ layout->resAccPtr = &layout->loader;
+
+ bool result = layout->build("cutscene.brlyt");
+ OSReport("Result: %d\n", result);
+ layout->loadAnimations((const char *[1]){"cutscene.brlan"}, 1);
+ layout->loadGroups((const char *[1]){"cutscene"}, (int[1]){0}, 1);
+ layout->disableAllAnimations();
+ layout->enableNonLoopAnim(0);
+
+ if (IsWideScreen()) {
+ layout->clippingEnabled = true;
+ layout->clipX = 66;
+ layout->clipY = 0;
+ layout->clipWidth = 508;
+ layout->clipHeight = 456;
+ layout->layout.rootPane->scale.x = 0.794f;
+ }
+
+ OSReport("Loaded scene %d\n", currentScene);
+
+ nextScene = -1;
+ }
+ }
+
return true;
}
int dScCutScene_c::onDraw() {
+ if (currentScene >= 0)
+ layout->scheduleForDrawing();
+
return true;
}