Repository navigation
Expand file tree
/
Copy pathTransferConfirmState.cpp
More file actions
118 lines (103 loc) · 3.4 KB
/
Copy pathTransferConfirmState.cpp
File metadata and controls
118 lines (103 loc) · 3.4 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
/*
* 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 "TransferConfirmState.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 "../Savegame/Base.h"
#include "TransferItemsState.h"
namespace OpenXcom
{
/**
* Initializes all the elements in the Confirm Transfer window.
* @param game Pointer to the core game.
* @param base Pointer to the destination base.
* @param state Pointer to the Transfer state.
*/
TransferConfirmState::TransferConfirmState(Game *game, Base *base, TransferItemsState *state) : State(game), _base(base), _state(state)
{
_screen = false;
// Create objects
_window = new Window(this, 320, 80, 0, 60);
_btnCancel = new TextButton(128, 16, 176, 115);
_btnOk = new TextButton(128, 16, 16, 115);
_txtTitle = new Text(310, 16, 5, 75);
_txtCost = new Text(60, 16, 110, 95);
_txtTotal = new Text(100, 16, 170, 95);
// Set palette
_game->setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(6)), Palette::backPos, 16);
add(_window);
add(_btnCancel);
add(_btnOk);
add(_txtTitle);
add(_txtCost);
add(_txtTotal);
// Set up objects
_window->setColor(Palette::blockOffset(13)+8);
_window->setBackground(_game->getResourcePack()->getSurface("BACK13.SCR"));
_btnCancel->setColor(Palette::blockOffset(15)+9);
_btnCancel->setText(_game->getLanguage()->getString("STR_CANCEL_UC"));
_btnCancel->onMouseClick((ActionHandler)&TransferConfirmState::btnCancelClick);
_btnOk->setColor(Palette::blockOffset(15)+9);
_btnOk->setText(_game->getLanguage()->getString("STR_OK"));
_btnOk->onMouseClick((ActionHandler)&TransferConfirmState::btnOkClick);
_txtTitle->setColor(Palette::blockOffset(13)+10);
_txtTitle->setBig();
_txtTitle->setAlign(ALIGN_CENTER);
std::wstring s = _game->getLanguage()->getString("STR_TRANSFER_ITEMS_TO");
s += _base->getName();
_txtTitle->setText(s);
_txtCost->setColor(Palette::blockOffset(13)+10);
_txtCost->setBig();
_txtCost->setText(_game->getLanguage()->getString("STR_COST"));
_txtTotal->setColor(Palette::blockOffset(15)+1);
_txtTotal->setBig();
_txtTotal->setText(Text::formatFunding(_state->getTotal()));
}
/**
*
*/
TransferConfirmState::~TransferConfirmState()
{
}
/**
* Returns to the previous screen.
* @param action Pointer to an action.
*/
void TransferConfirmState::btnCancelClick(Action *action)
{
_game->popState();
}
/**
* Completes the transfer.
* @param action Pointer to an action.
*/
void TransferConfirmState::btnOkClick(Action *action)
{
_state->completeTransfer();
_game->popState();
_game->popState();
_game->popState();
}
}