1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 #include "UfoLostState.h"
20 #include "../Engine/Game.h"
21 #include "../Resource/ResourcePack.h"
22 #include "../Engine/Language.h"
23 #include "../Engine/Palette.h"
24 #include "../Interface/TextButton.h"
25 #include "../Interface/Window.h"
26 #include "../Interface/Text.h"
27 #include "../Engine/Options.h"
28 
29 namespace OpenXcom
30 {
31 
32 /**
33  * Initializes all the elements in the Ufo Lost window.
34  * @param game Pointer to the core game.
35  * @param id Name of the UFO.
36  */
UfoLostState(Game * game,std::wstring id)37 UfoLostState::UfoLostState(Game *game, std::wstring id) : State(game), _id(id)
38 {
39 	_screen = false;
40 
41 	// Create objects
42 	_window = new Window(this, 192, 104, 32, 48, POPUP_BOTH);
43 	_btnOk = new TextButton(60, 12, 98, 112);
44 	_txtTitle = new Text(160, 32, 48, 72);
45 
46 	// Set palette
47 	setPalette("PAL_GEOSCAPE", 7);
48 
49 	add(_window);
50 	add(_btnOk);
51 	add(_txtTitle);
52 
53 	centerAllSurfaces();
54 
55 	// Set up objects
56 	_window->setColor(Palette::blockOffset(8)+5);
57 	_window->setBackground(_game->getResourcePack()->getSurface("BACK15.SCR"));
58 
59 	_btnOk->setColor(Palette::blockOffset(8)+5);
60 	_btnOk->setText(tr("STR_OK"));
61 	_btnOk->onMouseClick((ActionHandler)&UfoLostState::btnOkClick);
62 	_btnOk->onKeyboardPress((ActionHandler)&UfoLostState::btnOkClick, Options::keyOk);
63 	_btnOk->onKeyboardPress((ActionHandler)&UfoLostState::btnOkClick, Options::keyCancel);
64 
65 	_txtTitle->setColor(Palette::blockOffset(8)+5);
66 	_txtTitle->setBig();
67 	_txtTitle->setAlign(ALIGN_CENTER);
68 	std::wstring s = _id;
69 	s += L'\n';
70 	s += tr("STR_TRACKING_LOST");
71 	_txtTitle->setText(s);
72 }
73 
74 /**
75  *
76  */
~UfoLostState()77 UfoLostState::~UfoLostState()
78 {
79 
80 }
81 
82 /**
83  * Returns to the previous screen.
84  * @param action Pointer to an action.
85  */
btnOkClick(Action *)86 void UfoLostState::btnOkClick(Action *)
87 {
88 	_game->popState();
89 }
90 
91 }
92