MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / DefeatState

Method DefeatState

src/Geoscape/DefeatState.cpp:42–91  ·  view source on GitHub ↗

* Initializes all the elements in the Defeat screen. * @param game Pointer to the core game. */

Source from the content-addressed store, hash-verified

40 * @param game Pointer to the core game.
41 */
42DefeatState::DefeatState(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[] = {"PICT4.LBM", "PICT5.LBM"};
48
49 _timer = new Timer(30000);
50
51 _text[0] = new Text(190, 104, 0, 0);
52 _text[1] = new Text(200, 34, 32, 0);
53
54 for (int i = 0; i < SCREENS; ++i)
55 {
56 Surface *screen = _game->getResourcePack()->getSurface(files[i]);
57 _bg[i] = new InteractiveSurface(320, 200, 0, 0);
58
59 setPalette(screen->getPalette());
60
61 add(_bg[i]);
62 add(_text[i]);
63
64 screen->blit(_bg[i]);
65 _bg[i]->setVisible(false);
66 _bg[i]->onMouseClick((ActionHandler)&DefeatState::screenClick);
67
68 std::ostringstream ss;
69 ss << "STR_GAME_OVER_" << i + 1;
70 _text[i]->setText(tr(ss.str()));
71 _text[i]->setColor(Palette::blockOffset(15)+9);
72 _text[i]->setWordWrap(true);
73 _text[i]->setVisible(false);
74 }
75
76 _game->getResourcePack()->playMusic("GMLOSE");
77
78 centerAllSurfaces();
79
80 _timer->onTimer((StateHandler)&DefeatState::screenClick);
81 _timer->start();
82
83 screenClick(0);
84
85 // Ironman is over
86 if (_game->getSavedGame()->isIronman())
87 {
88 std::string filename = CrossPlatform::sanitizeFilename(Language::wstrToFs(_game->getSavedGame()->getName())) + ".sav";
89 CrossPlatform::deleteFile(Options::getUserFolder() + filename);
90 }
91}
92
93/**
94 *

Callers

nothing calls this directly

Calls 15

sanitizeFilenameFunction · 0.85
deleteFileFunction · 0.85
getUserFolderFunction · 0.85
resetDisplayMethod · 0.80
getScreenMethod · 0.80
onMouseClickMethod · 0.80
playMusicMethod · 0.80
onTimerMethod · 0.80
isIronmanMethod · 0.80
getSavedGameMethod · 0.80
getSurfaceMethod · 0.45
getResourcePackMethod · 0.45

Tested by

no test coverage detected