diff options
author | Treeki <treeki@gmail.com> | 2013-04-08 00:28:13 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2013-04-08 00:34:36 +0200 |
commit | 016c9e74f5d444e20753cb84bd41b5a60354ef59 (patch) | |
tree | 868433e109601bd3add9ed077206efa02f9a192e /src | |
parent | 6829b6540ff8438d07908b603e069ee7711ee474 (diff) | |
download | kamek-016c9e74f5d444e20753cb84bd41b5a60354ef59.tar.gz kamek-016c9e74f5d444e20753cb84bd41b5a60354ef59.zip |
cutscene sounds, skip dialog, widescreen fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/cutScene.cpp | 195 | ||||
-rw-r--r-- | src/cutScene.h | 16 |
2 files changed, 173 insertions, 38 deletions
diff --git a/src/cutScene.cpp b/src/cutScene.cpp index 6cb1e3b..7b14ccb 100644 --- a/src/cutScene.cpp +++ b/src/cutScene.cpp @@ -15,6 +15,9 @@ dScCutScene_c::dScCutScene_c() { data = 0; layout = 0; sceneLoaders = 0; + + yesNoWindow = (dYesNoWindow_c*)CreateParentedObject(YES_NO_WINDOW, this, 0, 0); + CreateParentedObject(SELECT_CURSOR, this, 0, 0); } dScCutScene_c::~dScCutScene_c() { @@ -32,6 +35,12 @@ static const char *CutsceneNames[] = { "/CS/Ending.cs" }; +static const char *WideCutsceneNames[] = { + "/CS/WideOpening.cs", + "/CS/Kamek.cs", + "/CS/Ending.cs" +}; + int dScCutScene_c::onCreate() { *CurrentDrawFunc = CutSceneDrawFunc; @@ -39,7 +48,10 @@ int dScCutScene_c::onCreate() { currentScene = -1; int csNumber = settings >> 28; - if (settingsLoader.load(CutsceneNames[csNumber])) { + const char *csName = IsWideScreen() ? + WideCutsceneNames[csNumber] : CutsceneNames[csNumber]; + + if (settingsLoader.load(csName)) { // only deal with this once! if (data) return 1; @@ -72,8 +84,70 @@ int dScCutScene_c::onDelete() { } int dScCutScene_c::onExecute() { + int nowPressed = Remocon_GetPressed(GetActiveRemocon()); + + switch (yesNoStage) { + case 1: + // Opening + if (!yesNoWindow->animationActive) + yesNoStage = 2; + return true; + case 2: + // Opened + if (nowPressed & WPAD_LEFT) + yesNoWindow->current = 1; + else if (nowPressed & WPAD_RIGHT) + yesNoWindow->current = 0; + else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + yesNoWindow->close = true; + + if (yesNoWindow->current != 1) + yesNoWindow->hasBG = true; + yesNoStage = 3; + + } else { + // Cancel using B or 1 + if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) { + yesNoWindow->cancelled = true; + yesNoWindow->current = 1; + yesNoStage = 3; + } + } + return true; + case 3: + // Closing + if (!yesNoWindow->visible) { + if (yesNoWindow->current == 1) { + yesNoStage = 0; + for (int i = 0; i < 40; i++) + if (handles[i].Exists()) { + handles[i].Pause(false, 3); + } + } else { + yesNoStage = 4; + goToNextScene(); + } + } + return true; + case 4: + // Waiting for exit transition + return true; + } + + if (yesNoWindow->layoutLoaded && (nowPressed & WPAD_PLUS)) { + yesNoStage = 1; + yesNoWindow->type = 3; + yesNoWindow->visible = true; + + for (int i = 0; i < 40; i++) + if (handles[i].Exists()) { + handles[i].Pause(true, 3); + } + return true; + } + // deal with loading first - + // what do we want to load? if (currentScene >= 0 || nextScene >= 0) { int whatToLoad = (nextScene >= 0) ? nextScene : (currentScene + 1); @@ -85,37 +159,12 @@ int dScCutScene_c::onExecute() { // now, do all other processing if (currentScene >= 0) { - int nowPressed = Remocon_GetPressed(GetActiveRemocon()); - if (!layout->isAnyAnimOn() || nowPressed & WPAD_TWO) { + if (!layout->isAnyAnimOn()) { // we're at the end // what now? if ((currentScene + 1) == data->sceneCount) { - // we're TOTALLY done! - OSReport("playback complete\n"); - int nsmbwMovieType = settings & 3; - int newerMovieType = settings >> 28; - - switch (newerMovieType) { - case 0: - // OPENING - switch (nsmbwMovieType) { - case 0: - SaveGame(0, false); - DoSceneChange(WORLD_MAP, 0x80000000, 0); - break; - case 1: - StartTitleScreenStage(false, 0); - break; - } - break; - - case 1: - // KAMEK (W7 => W8) - ActivateWipe(WIPE_MARIO); - DoSceneChange(WORLD_MAP, 0x40000000, 0); - break; - } + goToNextScene(); } else { nextScene = currentScene + 1; OSReport("switching to scene %d\n", nextScene); @@ -132,6 +181,56 @@ int dScCutScene_c::onExecute() { frameOffset++; + // check if we gotta do anything + dMovieScene_s *scene = data->scenes[currentScene]; + int cmdsParsed = 0; + int cmdOffset = 0; + while (cmdsParsed < scene->commandCount) { + u32 cmdType = scene->command[cmdOffset++]; + cmdsParsed++; + + switch (cmdType) { + case 1: + { + u32 delay = scene->command[cmdOffset++]; + u32 soundID = scene->command[cmdOffset++]; + if (delay != frameOffset) + continue; + + nw4r::snd::SoundHandle *handle = 0; + for (int i = 20; i < 40; i++) { + if (!handles[i].Exists()) { + handle = &handles[i]; + break; + } + } + if (handle) + PlaySoundWithFunctionB4(SoundRelatedClass, handle, soundID, 1); + } break; + case 2: + { + u32 handleID = scene->command[cmdOffset++]; + u32 delay = scene->command[cmdOffset++]; + u32 soundID = scene->command[cmdOffset++]; + if (delay != frameOffset) + continue; + + PlaySoundWithFunctionB4(SoundRelatedClass, &handles[handleID], soundID, 1); + } break; + case 3: + { + u32 handleID = scene->command[cmdOffset++]; + u32 delay = scene->command[cmdOffset++]; + u32 frameCount = scene->command[cmdOffset++]; + if (delay != frameOffset) + continue; + + handles[handleID].Stop(frameCount); + handles[handleID].DetachSound(); + } break; + } + } + if (nowPressed & WPAD_ONE) { OSReport("Currently: Scene %d; Frame %d\n", currentScene, frameOffset); } @@ -159,7 +258,8 @@ int dScCutScene_c::onExecute() { layout->disableAllAnimations(); layout->enableNonLoopAnim(0); - if (data->scenes[nextScene]->widescreenFlag) { + u8 widescreenFlag = data->scenes[nextScene]->widescreenFlag; + if (widescreenFlag == 1) { // Native on 16:9, letterboxed on 4:3 if (!IsWideScreen()) { layout->clippingEnabled = true; @@ -170,7 +270,7 @@ int dScCutScene_c::onExecute() { layout->layout.rootPane->scale.x = 0.7711f; layout->layout.rootPane->scale.y = 0.7711f; } - } else { + } else if (widescreenFlag == 0) { // Native on 4:3, black bars on 16:9 if (IsWideScreen()) { layout->clippingEnabled = true; @@ -225,3 +325,36 @@ void CutSceneDrawFunc() { SetCurrentCameraID(0); } + +void dScCutScene_c::goToNextScene() { + // we're TOTALLY done! + OSReport("playback complete\n"); + int nsmbwMovieType = settings & 3; + int newerMovieType = settings >> 28; + + for (int i = 0; i < 40; i++) + if (handles[i].Exists()) + handles[i].Stop(5); + + switch (newerMovieType) { + case 0: + // OPENING + switch (nsmbwMovieType) { + case 0: + SaveGame(0, false); + DoSceneChange(WORLD_MAP, 0x80000000, 0); + break; + case 1: + StartTitleScreenStage(false, 0); + break; + } + break; + + case 1: + // KAMEK (W7 => W8) + ActivateWipe(WIPE_MARIO); + DoSceneChange(WORLD_MAP, 0x40000000, 0); + break; + } +} + diff --git a/src/cutScene.h b/src/cutScene.h index 07c665e..ce1ab0d 100644 --- a/src/cutScene.h +++ b/src/cutScene.h @@ -20,10 +20,14 @@ class dScCutScene_c : public dScene_c { int onExecute(); int onDraw(); + void goToNextScene(); + int currentScene; int nextScene; int frameOffset; + nw4r::snd::SoundHandle handles[40]; + dMovieData_s *data; dDvdLoader_c settingsLoader; @@ -31,21 +35,19 @@ class dScCutScene_c : public dScene_c { m2d::EmbedLayout_c *layout; + dYesNoWindow_c *yesNoWindow; + int yesNoStage; + static dScCutScene_c *build(); static dScCutScene_c *instance; }; -struct dMovieSound_s { - u32 delay; - u32 soundID; -}; - struct dMovieScene_s { char *sceneName; u8 widescreenFlag; - u32 soundCount; - dMovieSound_s sounds[1]; + u32 commandCount; + u32 command[1]; }; struct dMovieData_s { |