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

Method AlienBaseState

src/Geoscape/AlienBaseState.cpp:47–110  ·  view source on GitHub ↗

* Initializes all the elements in the Aliens Base discovered window. * @param game Pointer to the core game. * @param base Pointer to the alien base to get info from. * @param state Pointer to the Geoscape. */

Source from the content-addressed store, hash-verified

45 * @param state Pointer to the Geoscape.
46 */
47AlienBaseState::AlienBaseState(Game *game, AlienBase *base, GeoscapeState *state) : State(game), _state(state), _base(base)
48{
49 // Create objects
50 _window = new Window(this, 320, 200, 0, 0);
51 _btnOk = new TextButton(50, 12, 135, 180);
52 _txtTitle = new Text(308, 60, 6, 60);
53
54 setPalette("PAL_GEOSCAPE", 3);
55
56 add(_window);
57 add(_btnOk);
58 add(_txtTitle);
59
60 centerAllSurfaces();
61
62
63 // Set up objects
64 _window->setColor(Palette::blockOffset(15)-1);
65 _window->setBackground(_game->getResourcePack()->getSurface("BACK13.SCR"));
66
67 _btnOk->setColor(Palette::blockOffset(8)+10);
68 _btnOk->setText(tr("STR_OK"));
69 _btnOk->onMouseClick((ActionHandler)&AlienBaseState::btnOkClick);
70 _btnOk->onKeyboardPress((ActionHandler)&AlienBaseState::btnOkClick, Options::keyOk);
71 _btnOk->onKeyboardPress((ActionHandler)&AlienBaseState::btnOkClick, Options::keyCancel);
72
73 _txtTitle->setColor(Palette::blockOffset(8)+5);
74 _txtTitle->setAlign(ALIGN_CENTER);
75 _txtTitle->setBig();
76 _txtTitle->setWordWrap(true);
77
78 // Check location of base
79 std::wstring region, country;
80 for (std::vector<Country*>::iterator i = _game->getSavedGame()->getCountries()->begin(); i != _game->getSavedGame()->getCountries()->end(); ++i)
81 {
82 if ((*i)->getRules()->insideCountry(_base->getLongitude(), _base->getLatitude()))
83 {
84 country = tr((*i)->getRules()->getType());
85 break;
86 }
87 }
88 for (std::vector<Region*>::iterator i = _game->getSavedGame()->getRegions()->begin(); i != _game->getSavedGame()->getRegions()->end(); ++i)
89 {
90 if ((*i)->getRules()->insideRegion(_base->getLongitude(), _base->getLatitude()))
91 {
92 region = tr((*i)->getRules()->getType());
93 break;
94 }
95 }
96 std::wstring location;
97 if (!country.empty())
98 {
99 location = tr("STR_COUNTRIES_COMMA").arg(country).arg(region);
100 }
101 else if (!region.empty())
102 {
103 location = region;
104 }

Callers

nothing calls this directly

Calls 15

onMouseClickMethod · 0.80
onKeyboardPressMethod · 0.80
getCountriesMethod · 0.80
getSavedGameMethod · 0.80
insideCountryMethod · 0.80
getRegionsMethod · 0.80
insideRegionMethod · 0.80
argMethod · 0.60
setColorMethod · 0.45
setBackgroundMethod · 0.45
getSurfaceMethod · 0.45
getResourcePackMethod · 0.45

Tested by

no test coverage detected