* Play the intro. */
| 402 | * Play the intro. |
| 403 | */ |
| 404 | void IntroState::init() |
| 405 | { |
| 406 | State::init(); |
| 407 | Options::keepAspectRatio = _wasLetterBoxed; |
| 408 | if (CrossPlatform::fileExists(_introFile) && (CrossPlatform::fileExists(_introSoundFileDOS) || CrossPlatform::fileExists(_introSoundFileWin))) |
| 409 | { |
| 410 | audioSequence = new AudioSequence(_game->getResourcePack()); |
| 411 | Flc::flc.realscreen = _game->getScreen(); |
| 412 | Flc::FlcInit(_introFile.c_str()); |
| 413 | Flc::flc.dx = (Options::baseXResolution - Screen::ORIGINAL_WIDTH) / 2; |
| 414 | Flc::flc.dy = (Options::baseYResolution - Screen::ORIGINAL_HEIGHT) / 2; |
| 415 | Flc::flc.loop = 0; // just the one time, please |
| 416 | Flc::FlcMain(&audioHandler); |
| 417 | Flc::FlcDeInit(); |
| 418 | delete audioSequence; |
| 419 | |
| 420 | |
| 421 | #ifndef __NO_MUSIC |
| 422 | // fade out! |
| 423 | Mix_FadeOutChannel(-1, 45 * 20); |
| 424 | if (Mix_GetMusicType(0) != MUS_MID) { Mix_FadeOutMusic(45 * 20); func_fade(); } // SDL_Mixer has trouble with native midi and volume on windows, which is the most likely use case, so f@%# it. |
| 425 | else { Mix_HaltMusic(); } |
| 426 | #endif |
| 427 | |
| 428 | SDL_Color pal[256]; |
| 429 | SDL_Color pal2[256]; |
| 430 | memcpy(pal, _game->getScreen()->getPalette(), sizeof(SDL_Color) * 256); |
| 431 | for (int i = 20; i > 0; --i) |
| 432 | { |
| 433 | SDL_Event event; |
| 434 | if (SDL_PollEvent(&event) && event.type == SDL_KEYDOWN) break; |
| 435 | for (int color = 0; color < 256; ++color) |
| 436 | { |
| 437 | pal2[color].r = (((int)pal[color].r) * i) / 20; |
| 438 | pal2[color].g = (((int)pal[color].g) * i) / 20; |
| 439 | pal2[color].b = (((int)pal[color].b) * i) / 20; |
| 440 | pal2[color].unused = pal[color].unused; |
| 441 | } |
| 442 | _game->getScreen()->setPalette(pal2, 0, 256, true); |
| 443 | _game->getScreen()->flip(); |
| 444 | SDL_Delay(45); |
| 445 | } |
| 446 | _game->getScreen()->clear(); |
| 447 | _game->getScreen()->flip(); |
| 448 | Options::musicVolume = _oldMusic; |
| 449 | Options::soundVolume = _oldSound; |
| 450 | _game->setVolume(Options::soundVolume, Options::musicVolume, Options::uiVolume); |
| 451 | |
| 452 | #ifndef __NO_MUSIC |
| 453 | Sound::stop(); |
| 454 | Music::stop(); |
| 455 | #endif |
| 456 | } |
| 457 | Screen::updateScale(Options::geoscapeScale, Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true); |
| 458 | _game->getScreen()->resetDisplay(false); |
| 459 | _game->setState(new MainMenuState(_game)); |
| 460 | } |
| 461 |
nothing calls this directly
no test coverage detected