Repository navigation
Expand file tree
/
Copy pathTransfersState.cpp
More file actions
121 lines (104 loc) · 3.65 KB
/
Copy pathTransfersState.cpp
File metadata and controls
121 lines (104 loc) · 3.65 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
/*
* 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 "TransfersState.h"
#include <sstream>
#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 "../Savegame/SavedGame.h"
#include "../Savegame/Base.h"
#include "../Savegame/Transfer.h"
namespace OpenXcom
{
/**
* Initializes all the elements in the Transfers window.
* @param game Pointer to the core game.
* @param base Pointer to the base to get info from.
*/
TransfersState::TransfersState(Game *game, Base *base) : State(game), _base(base)
{
_screen = false;
// Create objects
_window = new Window(this, 288, 180, 16, 10, POPUP_BOTH);
_btnOk = new TextButton(272, 16, 24, 166);
_txtTitle = new Text(278, 16, 21, 18);
_txtItem = new Text(114, 8, 26, 34);
_txtQuantity = new Text(54, 8, 131, 34);
_txtArrivalTime = new Text(112, 8, 186, 34);
_lstTransfers = new TextList(256, 112, 24, 50);
// Set palette
_game->setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(6)), Palette::backPos, 16);
add(_window);
add(_btnOk);
add(_txtTitle);
add(_txtItem);
add(_txtQuantity);
add(_txtArrivalTime);
add(_lstTransfers);
// Set up objects
_window->setColor(Palette::blockOffset(15)+9);
_window->setBackground(_game->getResourcePack()->getSurface("BACK13.SCR"));
_btnOk->setColor(Palette::blockOffset(15)+9);
_btnOk->setText(_game->getLanguage()->getString("STR_OK"));
_btnOk->onMouseClick((ActionHandler)&TransfersState::btnOkClick);
_txtTitle->setColor(Palette::blockOffset(15)+6);
_txtTitle->setBig();
_txtTitle->setAlign(ALIGN_CENTER);
_txtTitle->setText(_game->getLanguage()->getString("STR_TRANSFERS"));
_txtItem->setColor(Palette::blockOffset(15)+6);
_txtItem->setText(_game->getLanguage()->getString("STR_ITEM"));
_txtQuantity->setColor(Palette::blockOffset(15)+6);
_txtQuantity->setText(_game->getLanguage()->getString("STR_QUANTITY_UC"));
_txtArrivalTime->setColor(Palette::blockOffset(15)+6);
_txtArrivalTime->setText(_game->getLanguage()->getString("STR_ARRIVAL_TIME_HOURS"));
_lstTransfers->setColor(Palette::blockOffset(13)+10);
_lstTransfers->setArrowColor(Palette::blockOffset(15)+9);
_lstTransfers->setColumns(3, 155, 55, 46);
_lstTransfers->setSelectable(true);
_lstTransfers->setBackground(_window);
_lstTransfers->setMargin(2);
for (std::vector<Transfer*>::iterator i = _base->getTransfers()->begin(); i != _base->getTransfers()->end(); ++i)
{
std::wstringstream ss, ss2;
ss << (*i)->getQuantity();
ss2 << (*i)->getHours();
_lstTransfers->addRow(3, (*i)->getName(_game->getLanguage()).c_str(), ss.str().c_str(), ss2.str().c_str());
}
}
/**
*
*/
TransfersState::~TransfersState()
{
}
/**
* Returns to the previous screen.
* @param action Pointer to an action.
*/
void TransfersState::btnOkClick(Action *action)
{
_game->popState();
}
}