* Initializes all the elements in the Victory screen. * @param game Pointer to the core game. */
| 40 | * @param game Pointer to the core game. |
| 41 | */ |
| 42 | VictoryState::VictoryState(Game *game) : State(game), _screen(-1) |
| 43 | { |
| 44 | Options::baseXResolution = Screen::ORIGINAL_WIDTH; |
| 45 | Options::baseYResolution = Screen::ORIGINAL_HEIGHT; |
| 46 | game->getScreen()->resetDisplay(false); |
| 47 | const char *files[] = {"PICT1.LBM", "PICT2.LBM", "PICT3.LBM", "PICT6.LBM", "PICT7.LBM"}; |
| 48 | |
| 49 | _timer = new Timer(30000); |
| 50 | |
| 51 | _text[0] = new Text(195, 56, 5, 0); |
| 52 | _text[1] = new Text(232, 64, 88, 136); |
| 53 | _text[2] = new Text(254, 48, 66, 152); |
| 54 | _text[3] = new Text(300, 200, 5, 0); |
| 55 | _text[4] = new Text(310, 42, 5, 158); |
| 56 | |
| 57 | for (int i = 0; i < SCREENS; ++i) |
| 58 | { |
| 59 | Surface *screen = _game->getResourcePack()->getSurface(files[i]); |
| 60 | _bg[i] = new InteractiveSurface(320, 200, 0, 0); |
| 61 | |
| 62 | setPalette(screen->getPalette()); |
| 63 | |
| 64 | add(_bg[i]); |
| 65 | add(_text[i]); |
| 66 | |
| 67 | screen->blit(_bg[i]); |
| 68 | _bg[i]->setVisible(false); |
| 69 | _bg[i]->onMouseClick((ActionHandler)&VictoryState::screenClick); |
| 70 | |
| 71 | std::ostringstream ss; |
| 72 | ss << "STR_VICTORY_" << i + 1; |
| 73 | _text[i]->setText(tr(ss.str())); |
| 74 | _text[i]->setColor(Palette::blockOffset(15)+9); |
| 75 | _text[i]->setWordWrap(true); |
| 76 | _text[i]->setVisible(false); |
| 77 | } |
| 78 | |
| 79 | _game->getResourcePack()->playMusic("GMWIN"); |
| 80 | |
| 81 | centerAllSurfaces(); |
| 82 | |
| 83 | _timer->onTimer((StateHandler)&VictoryState::screenClick); |
| 84 | _timer->start(); |
| 85 | |
| 86 | screenClick(0); |
| 87 | |
| 88 | // Ironman is over |
| 89 | if (_game->getSavedGame()->isIronman()) |
| 90 | { |
| 91 | std::string filename = CrossPlatform::sanitizeFilename(Language::wstrToFs(_game->getSavedGame()->getName())) + ".sav"; |
| 92 | CrossPlatform::deleteFile(Options::getUserFolder() + filename); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * |
nothing calls this directly
no test coverage detected