Repository navigation
Expand file tree
/
Copy pathBuildFacilitiesState.cpp
More file actions
132 lines (115 loc) · 4.32 KB
/
Copy pathBuildFacilitiesState.cpp
File metadata and controls
132 lines (115 loc) · 4.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* Copyright 2010 OpenXcom Developers.
*
* This file is part of OpenXcom.
*
* OpenXcom is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenXcom is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
*/
#include "BuildFacilitiesState.h"
#include "../Engine/Game.h"
#include "../Resource/ResourcePack.h"
#include "../Engine/Language.h"
#include "../Engine/Font.h"
#include "../Engine/Palette.h"
#include "../Interface/TextButton.h"
#include "../Interface/Window.h"
#include "../Interface/Text.h"
#include "../Interface/TextList.h"
#include "../Ruleset/Ruleset.h"
#include "../Ruleset/RuleBaseFacility.h"
#include "PlaceFacilityState.h"
namespace OpenXcom
{
/**
* Initializes all the elements in the Build Facilities window.
* @param game Pointer to the core game.
* @param base Pointer to the base to get info from.
* @param state Pointer to the base state to refresh.
*/
BuildFacilitiesState::BuildFacilitiesState(Game *game, Base *base, State *state) : State(game), _base(base), _state(state), _facilities()
{
_screen = false;
// Create objects
_window = new Window(this, 128, 160, 192, 40, POPUP_VERTICAL);
_btnOk = new TextButton(112, 16, 200, 176);
_txtTitle = new Text(118, 16, 197, 48);
_lstFacilities = new TextList(115, 110, 200, 64);
// Set palette
_game->setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(6)), Palette::backPos, 16);
add(_window);
add(_btnOk);
add(_txtTitle);
add(_lstFacilities);
// Set up objects
_window->setColor(Palette::blockOffset(13)+8);
_window->setBackground(_game->getResourcePack()->getSurface("BACK05.SCR"));
_btnOk->setColor(Palette::blockOffset(13)+8);
_btnOk->setText(_game->getLanguage()->getString("STR_OK"));
_btnOk->onMouseClick((ActionHandler)&BuildFacilitiesState::btnOkClick);
_txtTitle->setColor(Palette::blockOffset(13));
_txtTitle->setBig();
_txtTitle->setAlign(ALIGN_CENTER);
_txtTitle->setText(_game->getLanguage()->getString("STR_INSTALLATION"));
_lstFacilities->setColor(Palette::blockOffset(13)+5);
_lstFacilities->setArrowColor(Palette::blockOffset(13)+8);
_lstFacilities->setColumns(1, 115);
_lstFacilities->setSelectable(true);
_lstFacilities->setBackground(_window);
_lstFacilities->setMargin(2);
_lstFacilities->onMouseClick((ActionHandler)&BuildFacilitiesState::lstFacilitiesClick);
_facilities.push_back(_game->getRuleset()->getBaseFacility("STR_LIVING_QUARTERS"));
_facilities.push_back(_game->getRuleset()->getBaseFacility("STR_LABORATORY"));
_facilities.push_back(_game->getRuleset()->getBaseFacility("STR_WORKSHOP"));
_facilities.push_back(_game->getRuleset()->getBaseFacility("STR_GENERAL_STORES"));
_facilities.push_back(_game->getRuleset()->getBaseFacility("STR_ALIEN_CONTAINMENT"));
_facilities.push_back(_game->getRuleset()->getBaseFacility("STR_SMALL_RADAR_SYSTEM"));
_facilities.push_back(_game->getRuleset()->getBaseFacility("STR_LARGE_RADAR_SYSTEM"));
_facilities.push_back(_game->getRuleset()->getBaseFacility("STR_MISSILE_DEFENSES"));
_facilities.push_back(_game->getRuleset()->getBaseFacility("STR_HANGAR"));
for (std::vector<RuleBaseFacility*>::iterator i = _facilities.begin(); i != _facilities.end(); ++i)
{
_lstFacilities->addRow(1, _game->getLanguage()->getString((*i)->getType()).c_str());
}
}
/**
*
*/
BuildFacilitiesState::~BuildFacilitiesState()
{
}
/**
* The player can change the selected base
* or change info on other screens.
*/
void BuildFacilitiesState::init()
{
_state->init();
}
/**
* Returns to the previous screen.
* @param action Pointer to an action.
*/
void BuildFacilitiesState::btnOkClick(Action *action)
{
_game->popState();
}
/**
* Places the selected facility.
* @param action Pointer to an action.
*/
void BuildFacilitiesState::lstFacilitiesClick(Action *action)
{
_game->pushState(new PlaceFacilityState(_game, _base, _facilities[_lstFacilities->getSelectedRow()]));
}
}