forked from OpenXcom/OpenXcom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLowFuelState.cpp
More file actions
109 lines (91 loc) · 2.89 KB
/
Copy pathLowFuelState.cpp
File metadata and controls
109 lines (91 loc) · 2.89 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
/*
* Copyright 2010-2016 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 "LowFuelState.h"
#include "../Engine/Game.h"
#include "../Mod/Mod.h"
#include "../Engine/LocalizedText.h"
#include "../Interface/TextButton.h"
#include "../Interface/Window.h"
#include "../Interface/Text.h"
#include "../Savegame/Craft.h"
#include "GeoscapeState.h"
#include "../Engine/Options.h"
namespace OpenXcom
{
/**
* Initializes all the elements in the Low Fuel window.
* @param game Pointer to the core game.
* @param craft Pointer to the craft to display.
* @param state Pointer to the Geoscape.
*/
LowFuelState::LowFuelState(Craft *craft, GeoscapeState *state) : _craft(craft), _state(state)
{
_screen = false;
// Create objects
_window = new Window(this, 224, 120, 16, 40, POPUP_BOTH);
_btnOk = new TextButton(90, 18, 30, 120);
_btnOk5Secs = new TextButton(90, 18, 136, 120);
_txtTitle = new Text(214, 17, 21, 60);
_txtMessage = new Text(214, 17, 21, 90);
// Set palette
setInterface("lowFuel");
add(_window, "window", "lowFuel");
add(_btnOk, "button", "lowFuel");
add(_btnOk5Secs, "button", "lowFuel");
add(_txtTitle, "text", "lowFuel");
add(_txtMessage, "text", "lowFuel");
centerAllSurfaces();
// Set up objects
_window->setBackground(_game->getMod()->getSurface("BACK12.SCR"));
_btnOk->setText(tr("STR_OK"));
_btnOk->onMouseClick((ActionHandler)&LowFuelState::btnOkClick);
_btnOk->onKeyboardPress((ActionHandler)&LowFuelState::btnOkClick, Options::keyCancel);
_btnOk5Secs->setText(tr("STR_OK_5_SECONDS"));
_btnOk5Secs->onMouseClick((ActionHandler)&LowFuelState::btnOk5SecsClick);
_btnOk5Secs->onKeyboardPress((ActionHandler)&LowFuelState::btnOk5SecsClick, Options::keyOk);
_txtTitle->setAlign(ALIGN_CENTER);
_txtTitle->setBig();
_txtTitle->setText(_craft->getName(_game->getLanguage()));
_txtMessage->setAlign(ALIGN_CENTER);
_txtMessage->setText(tr("STR_IS_LOW_ON_FUEL_RETURNING_TO_BASE"));
}
/**
*
*/
LowFuelState::~LowFuelState()
{
}
/**
* Closes the window.
* @param action Pointer to an action.
*/
void LowFuelState::btnOkClick(Action *)
{
_game->popState();
}
/**
* Closes the window and sets the timer to 5 Secs.
* @param action Pointer to an action.
*/
void LowFuelState::btnOk5SecsClick(Action *)
{
_state->timerReset();
_game->popState();
}
}