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 "ConfirmCydoniaState.h"
20 #include "../Engine/Game.h"
21 #include "../Resource/ResourcePack.h"
22 #include "../Engine/Language.h"
23 #include "../Engine/Palette.h"
24 #include "../Engine/Surface.h"
25 #include "../Interface/Window.h"
26 #include "../Interface/Text.h"
27 #include "../Interface/TextButton.h"
28 #include "../Battlescape/BattlescapeGenerator.h"
29 #include "../Battlescape/BattlescapeState.h"
30 #include "../Battlescape/BriefingState.h"
31 #include "../Savegame/SavedBattleGame.h"
32 #include "../Savegame/SavedGame.h"
33 #include "../Engine/RNG.h"
34 #include "../Ruleset/Ruleset.h"
35 #include "../Engine/Options.h"
36 
37 namespace OpenXcom
38 {
39 
ConfirmCydoniaState(Game * game,Craft * craft)40 ConfirmCydoniaState::ConfirmCydoniaState(Game *game, Craft *craft) : State(game), _craft(craft)
41 {
42 	_screen = false;
43 
44 	// Create objects
45 	_window = new Window(this, 256, 160, 32, 20);
46 	_btnYes = new TextButton(80, 20, 70, 142);
47 	_btnNo = new TextButton(80, 20, 170, 142);
48 	_txtMessage = new Text(224, 48, 48, 76);
49 
50 	// Set palette
51 	setPalette("PAL_GEOSCAPE", 5);
52 
53 	add(_window);
54 	add(_btnYes);
55 	add(_btnNo);
56 	add(_txtMessage);
57 
58 	centerAllSurfaces();
59 
60 	// Set up objects
61 	_window->setColor(Palette::blockOffset(8)+5);
62 	_window->setBackground(_game->getResourcePack()->getSurface("BACK12.SCR"));
63 
64 	_btnYes->setColor(Palette::blockOffset(8)+5);
65 	_btnYes->setText(tr("STR_YES"));
66 	_btnYes->onMouseClick((ActionHandler)&ConfirmCydoniaState::btnYesClick);
67 	_btnYes->onKeyboardPress((ActionHandler)&ConfirmCydoniaState::btnYesClick, Options::keyOk);
68 
69 	_btnNo->setColor(Palette::blockOffset(8)+5);
70 	_btnNo->setText(tr("STR_NO"));
71 	_btnNo->onMouseClick((ActionHandler)&ConfirmCydoniaState::btnNoClick);
72 	_btnNo->onKeyboardPress((ActionHandler)&ConfirmCydoniaState::btnNoClick, Options::keyCancel);
73 
74 	_txtMessage->setAlign(ALIGN_CENTER);
75 	_txtMessage->setBig();
76 	_txtMessage->setWordWrap(true);
77 	_txtMessage->setColor(Palette::blockOffset(8)+10);
78 	_txtMessage->setText(tr("STR_ARE_YOU_SURE_CYDONIA"));
79 }
80 
81 /**
82  *
83  */
~ConfirmCydoniaState()84 ConfirmCydoniaState::~ConfirmCydoniaState()
85 {
86 }
87 
88 /**
89  * Returns to the previous screen.
90  * @param action Pointer to an action.
91  */
btnYesClick(Action *)92 void ConfirmCydoniaState::btnYesClick(Action *)
93 {
94 	_game->popState();
95 	_game->popState();
96 
97 	SavedBattleGame *bgame = new SavedBattleGame();
98 	_game->getSavedGame()->setBattleGame(bgame);
99 	bgame->setMissionType("STR_MARS_CYDONIA_LANDING");
100 	BattlescapeGenerator bgen = BattlescapeGenerator(_game);
101 	bgen.setCraft(_craft);
102 	bgen.setAlienRace("STR_SECTOID");
103 	bgen.setWorldShade(15);
104 	bgen.run();
105 
106 	_game->pushState(new BriefingState(_game, _craft));
107 
108 }
109 
110 /**
111  * Returns to the previous screen.
112  * @param action Pointer to an action.
113  */
btnNoClick(Action *)114 void ConfirmCydoniaState::btnNoClick(Action *)
115 {
116 	_game->popState();
117 }
118 
119 }
120