1+ /*
2+ * Copyright 2010-2012 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 " BaseDestroyedState.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 " ../Savegame/SavedGame.h"
29+ #include " ../Savegame/Base.h"
30+
31+ namespace OpenXcom
32+ {
33+
34+ BaseDestroyedState::BaseDestroyedState (Game *game, Base *base) : State(game), _base(base)
35+ {
36+ _game->setPalette (_game->getResourcePack ()->getPalette (" BACKPALS.DAT" )->getColors (Palette::blockOffset (7 )), Palette::backPos, 16 );
37+ _screen = false ;
38+ // Create objects
39+ _window = new Window (this , 256 , 160 , 32 , 20 );
40+ _btnConfirm = new TextButton (100 , 20 , 110 , 142 );
41+ _txtMessage = new Text (224 , 48 , 48 , 76 );
42+
43+ add (_window);
44+ add (_btnConfirm);
45+ add (_txtMessage);
46+
47+ // Set up objects
48+ _window->setColor (Palette::blockOffset (8 )+5 );
49+ _window->setBackground (_game->getResourcePack ()->getSurface (" BACK15.SCR" ));
50+
51+ _btnConfirm->setColor (Palette::blockOffset (8 )+5 );
52+ _btnConfirm->setText (_game->getLanguage ()->getString (" STR_OK" ));
53+ _btnConfirm->onMouseClick ((ActionHandler)&BaseDestroyedState::btnConfirmClick);
54+
55+ _txtMessage->setAlign (ALIGN_CENTER );
56+ _txtMessage->setBig ();
57+ _txtMessage->setWordWrap (true );
58+ _txtMessage->setColor (Palette::blockOffset (8 )+5 );
59+ std::wstringstream ss;
60+ ss << _game->getLanguage ()->getString (" STR_THE_ALIENS_HAVE_DESTROYED_THE_UNDEFENDED_BASE" ) << _base->getName ();
61+ _txtMessage->setText (ss.str ());
62+ }
63+
64+ /* *
65+ *
66+ */
67+ BaseDestroyedState::~BaseDestroyedState ()
68+ {
69+ }
70+
71+ /* *
72+ *
73+ */
74+ void BaseDestroyedState::init ()
75+ {
76+ }
77+
78+ /* *
79+ * Returns to the previous screen.
80+ * @param action Pointer to an action.
81+ */
82+ void BaseDestroyedState::btnConfirmClick (Action *)
83+ {
84+ _game->popState ();
85+ for (std::vector<Base*>::iterator i = _game->getSavedGame ()->getBases ()->begin (); i != _game->getSavedGame ()->getBases ()->end (); ++i)
86+ {
87+ if ((*i) == _base)
88+ {
89+ (*i)->~Base ();
90+ _game->getSavedGame ()->getBases ()->erase (i);
91+ break ;
92+ }
93+ }
94+ }
95+
96+ }
0 commit comments