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

Method MainMenuState

src/Menu/MainMenuState.cpp:45–106  ·  view source on GitHub ↗

* Initializes all the elements in the Main Menu window. * @param game Pointer to the core game. */

Source from the content-addressed store, hash-verified

43 * @param game Pointer to the core game.
44 */
45MainMenuState::MainMenuState(Game *game) : State(game)
46{
47 // Create objects
48 _window = new Window(this, 256, 160, 32, 20, POPUP_BOTH);
49 _btnNewGame = new TextButton(92, 20, 64, 90);
50 _btnNewBattle = new TextButton(92, 20, 164, 90);
51 _btnLoad = new TextButton(92, 20, 64, 118);
52 _btnOptions = new TextButton(92, 20, 164, 118);
53 _btnQuit = new TextButton(192, 20, 64, 146);
54 _txtTitle = new Text(256, 30, 32, 45);
55
56 // Set palette
57 setPalette("PAL_GEOSCAPE", 0);
58
59 add(_window);
60 add(_btnNewGame);
61 add(_btnNewBattle);
62 add(_btnLoad);
63 add(_btnOptions);
64 add(_btnQuit);
65 add(_txtTitle);
66
67 centerAllSurfaces();
68
69 // Set up objects
70 _window->setColor(Palette::blockOffset(8)+5);
71 _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR"));
72
73 _btnNewGame->setColor(Palette::blockOffset(8)+5);
74 _btnNewGame->setText(tr("STR_NEW_GAME"));
75 _btnNewGame->onMouseClick((ActionHandler)&MainMenuState::btnNewGameClick);
76
77 _btnNewBattle->setColor(Palette::blockOffset(8)+5);
78 _btnNewBattle->setText(tr("STR_NEW_BATTLE"));
79 _btnNewBattle->onMouseClick((ActionHandler)&MainMenuState::btnNewBattleClick);
80
81 _btnLoad->setColor(Palette::blockOffset(8)+5);
82 _btnLoad->setText(tr("STR_LOAD_SAVED_GAME"));
83 _btnLoad->onMouseClick((ActionHandler)&MainMenuState::btnLoadClick);
84
85 _btnOptions->setColor(Palette::blockOffset(8)+5);
86 _btnOptions->setText(tr("STR_OPTIONS"));
87 _btnOptions->onMouseClick((ActionHandler)&MainMenuState::btnOptionsClick);
88
89 _btnQuit->setColor(Palette::blockOffset(8)+5);
90 _btnQuit->setText(tr("STR_QUIT"));
91 _btnQuit->onMouseClick((ActionHandler)&MainMenuState::btnQuitClick);
92
93 _txtTitle->setColor(Palette::blockOffset(8)+10);
94 _txtTitle->setAlign(ALIGN_CENTER);
95 _txtTitle->setBig();
96 std::wostringstream title;
97 title << tr("STR_OPENXCOM") << L"\x02";
98 title << Language::utf8ToWstr(OPENXCOM_VERSION_SHORT) << Language::utf8ToWstr(OPENXCOM_VERSION_GIT);
99 _txtTitle->setText(title.str());
100
101 // Set music
102 _game->getResourcePack()->playMusic("GMSTORY");

Callers

nothing calls this directly

Calls 11

onMouseClickMethod · 0.80
playMusicMethod · 0.80
getCursorMethod · 0.80
getFpsCounterMethod · 0.80
setColorMethod · 0.45
setBackgroundMethod · 0.45
getSurfaceMethod · 0.45
getResourcePackMethod · 0.45
setTextMethod · 0.45
setAlignMethod · 0.45
setBigMethod · 0.45

Tested by

no test coverage detected