Skip to content

Commit 152edce

Browse files
committed
Add base destroyed screen
for those undefended bases.
1 parent 2279a20 commit 152edce

10 files changed

Lines changed: 202 additions & 17 deletions

‎CHANGELOG.txt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ Bugfixes:
4747
- Battlescape buttons now unavailable during alien turn.
4848
- Fixed Craft not rearming after refuelling.
4949
- Fixed strange spawn behaviour.
50-
- Fixed jumbled Reaper corpse.
5150
- Camera now correctly centers on explosions, and properly detects explosion visibility.
5251
- UFO walls can no longer be seen through from certain angles.
5352
- Units on stairs will now correctly reveal tiles on the level above.
5453
- Opening doors now uses time units correctly.
55-
- (hopefully) Fixed Large unit spawning inside walls.
5654

5755
Version 0.4.5 (04-11-2012)
5856
---------------------------

‎Makefile.am‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ openxcom_SOURCES = \
282282
src/Geoscape/AlienTerrorState.h \
283283
src/Geoscape/AllocatePsiTrainingState.cpp \
284284
src/Geoscape/AllocatePsiTrainingState.h \
285+
src/Geoscape/BaseDestroyedState.cpp \
286+
src/Geoscape/BaseDestroyedState.h \
285287
src/Geoscape/BaseDefenseState.cpp \
286288
src/Geoscape/BaseDefenseState.h \
287289
src/Geoscape/BaseNameState.cpp \

‎src/CMakeLists.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ set ( geoscape_src
259259
Geoscape/GeoscapeOptionsState.cpp
260260
Geoscape/BaseNameState.cpp
261261
Geoscape/BaseNameState.h
262+
Geoscape/BaseDestroyedState.cpp
263+
Geoscape/BaseDestroyedState.h
262264
Geoscape/BaseDefenseState.cpp
263265
Geoscape/BaseDefenseState.h
264266
Geoscape/MultipleTargetsState.cpp

‎src/Geoscape/BaseDefenseState.cpp‎

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "../Battlescape/BattlescapeGenerator.h"
4040
#include "../Engine/SoundSet.h"
4141
#include "../Engine/Sound.h"
42+
#include "BaseDestroyedState.h"
4243
#include <ctime>
4344

4445
namespace OpenXcom
@@ -156,23 +157,30 @@ void BaseDefenseState::btnOkClick(Action *)
156157
{
157158
_game->setPalette(_game->getResourcePack()->getPalette("PALETTES.DAT_0")->getColors());
158159
_game->popState();
159-
if(_ufo->getStatus() != 3)
160+
if(_ufo->getStatus() != 3 && _base->getSoldiers())
160161
{
161162
_game->popState();
162-
int month = _game->getSavedGame()->getMonthsPassed();
163-
if (month > _game->getRuleset()->getAlienItemLevels().size()-1)
164-
month = _game->getRuleset()->getAlienItemLevels().size()-1;
165-
SavedBattleGame *bgame = new SavedBattleGame();
166-
_game->getSavedGame()->setBattleGame(bgame);
167-
bgame->setMissionType("STR_BASE_DEFENSE");
168-
BattlescapeGenerator bgen = BattlescapeGenerator(_game);
169-
bgen.setBase(_base);
170-
bgen.setUfo(_ufo);
171-
bgen.setAlienRace(_ufo->getAlienRace());
172-
bgen.setAlienItemlevel(_game->getRuleset()->getAlienItemLevels().at(month).at(RNG::generate(0,9)));
173-
bgen.run();
163+
if (_base->getSoldiers())
164+
{
165+
int month = _game->getSavedGame()->getMonthsPassed();
166+
if (month > _game->getRuleset()->getAlienItemLevels().size()-1)
167+
month = _game->getRuleset()->getAlienItemLevels().size()-1;
168+
SavedBattleGame *bgame = new SavedBattleGame();
169+
_game->getSavedGame()->setBattleGame(bgame);
170+
bgame->setMissionType("STR_BASE_DEFENSE");
171+
BattlescapeGenerator bgen = BattlescapeGenerator(_game);
172+
bgen.setBase(_base);
173+
bgen.setUfo(_ufo);
174+
bgen.setAlienRace(_ufo->getAlienRace());
175+
bgen.setAlienItemlevel(_game->getRuleset()->getAlienItemLevels().at(month).at(RNG::generate(0,9)));
176+
bgen.run();
174177

175-
_game->pushState(new BriefingState(_game, 0, _base));
178+
_game->pushState(new BriefingState(_game, 0, _base));
179+
}
180+
else
181+
{
182+
_game->pushState(new BaseDestroyedState(_game, _base));
183+
}
176184
}
177185
}
178186

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
}

‎src/Geoscape/BaseDestroyedState.h‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
#ifndef OPENXCOM_BASEDESTROYEDSTATE_H
20+
#define OPENXCOM_BASEDESTROYEDSTATE_H
21+
22+
#include "../Engine/State.h"
23+
24+
namespace OpenXcom
25+
{
26+
class Base;
27+
class Window;
28+
class Text;
29+
class TextButton;
30+
31+
/**
32+
* Screen that allows the player
33+
* to pick a target for a craft on the globe.
34+
*/
35+
class BaseDestroyedState : public State
36+
{
37+
private:
38+
Window *_window;
39+
Text *_txtMessage;
40+
TextButton *_btnConfirm;
41+
Base *_base;
42+
public:
43+
/// Creates the Select Destination state.
44+
BaseDestroyedState(Game *game, Base *base);
45+
/// Cleans up the Select Destination state.
46+
~BaseDestroyedState();
47+
/// Updates the palette.
48+
void init();
49+
/// Handler for clicking the Cancel button.
50+
void btnCancelClick(Action *action);
51+
/// Handler for clicking the Cydonia mission button.
52+
void btnConfirmClick(Action *action);
53+
54+
};
55+
56+
}
57+
58+
#endif

‎src/Geoscape/GeoscapeState.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
#include "../Battlescape/BriefingState.h"
9393
#include "../Ruleset/UfoTrajectory.h"
9494
#include "BaseDefenseState.h"
95+
#include "BaseDestroyedState.h"
9596
#include "DefeatState.h"
9697
#include <ctime>
9798
#include <algorithm>
@@ -576,7 +577,7 @@ void GeoscapeState::time5Seconds()
576577
{
577578
popup(new BaseDefenseState(_game, base, *i));
578579
}
579-
else
580+
else if (base->getSoldiers())
580581
{
581582
int month = _game->getSavedGame()->getMonthsPassed();
582583
if (month > _game->getRuleset()->getAlienItemLevels().size()-1)
@@ -592,6 +593,10 @@ void GeoscapeState::time5Seconds()
592593

593594
popup(new BriefingState(_game, 0, base, *i));
594595
}
596+
else
597+
{
598+
popup(new BaseDestroyedState(_game, base));
599+
}
595600
}
596601
}
597602
}

‎src/OpenXcom.2008.vcproj‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,14 @@
12781278
RelativePath=".\Geoscape\AllocatePsiTrainingState.h"
12791279
>
12801280
</File>
1281+
<File
1282+
RelativePath=".\Geoscape\BaseDestroyedState.cpp"
1283+
>
1284+
</File>
1285+
<File
1286+
RelativePath=".\Geoscape\BaseDestroyedState.h"
1287+
>
1288+
</File>
12811289
<File
12821290
RelativePath=".\Geoscape\BaseDefenseState.cpp"
12831291
>

‎src/OpenXcom.2010.vcxproj‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@
298298
<ClCompile Include="Geoscape\AlienTerrorState.cpp" />
299299
<ClCompile Include="Geoscape\AllocatePsiTrainingState.cpp" />
300300
<ClCompile Include="Geoscape\BaseDefenseState.cpp" />
301+
<ClCompile Include="Geoscape\BaseDestroyedState.cpp" />
301302
<ClCompile Include="Geoscape\BaseNameState.cpp" />
302303
<ClCompile Include="Geoscape\BuildNewBaseState.cpp" />
303304
<ClCompile Include="Geoscape\CraftErrorState.cpp" />
@@ -538,6 +539,7 @@
538539
<ClInclude Include="Geoscape\AlienTerrorState.h" />
539540
<ClInclude Include="Geoscape\AllocatePsiTrainingState.h" />
540541
<ClInclude Include="Geoscape\BaseDefenseState.h" />
542+
<ClInclude Include="Geoscape\BaseDestroyedState.h" />
541543
<ClInclude Include="Geoscape\BaseNameState.h" />
542544
<ClInclude Include="Geoscape\BuildNewBaseState.h" />
543545
<ClInclude Include="Geoscape\CraftErrorState.h" />

‎src/OpenXcom.2010.vcxproj.filters‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,9 @@
705705
<ClCompile Include="Menu\DeleteGameState.cpp">
706706
<Filter>Menu</Filter>
707707
</ClCompile>
708+
<ClCompile Include="Geoscape\BaseDestroyedState.cpp">
709+
<Filter>Geoscape</Filter>
710+
</ClCompile>
708711
</ItemGroup>
709712
<ItemGroup>
710713
<ClInclude Include="resource.h" />
@@ -1415,6 +1418,9 @@
14151418
<ClInclude Include="Menu\DeleteGameState.h">
14161419
<Filter>Menu</Filter>
14171420
</ClInclude>
1421+
<ClInclude Include="Geoscape\BaseDestroyedState.h">
1422+
<Filter>Geoscape</Filter>
1423+
</ClInclude>
14181424
</ItemGroup>
14191425
<ItemGroup>
14201426
<ResourceCompile Include="OpenXcom.rc" />

0 commit comments

Comments
 (0)