1 /*
2 * Copyright 2010-2014 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 "OptionsGeoscapeState.h"
20 #include <sstream>
21 #include "../Engine/Game.h"
22 #include "../Resource/ResourcePack.h"
23 #include "../Engine/Language.h"
24 #include "../Engine/Palette.h"
25 #include "../Interface/TextButton.h"
26 #include "../Interface/Window.h"
27 #include "../Interface/Text.h"
28 #include "../Interface/Slider.h"
29 #include "../Interface/ToggleTextButton.h"
30 #include "../Interface/TextButton.h"
31 #include "../Interface/ComboBox.h"
32 #include "../Engine/Action.h"
33 #include "../Engine/Options.h"
34
35 namespace OpenXcom
36 {
37
38 /**
39 * Initializes all the elements in the Geoscape Options screen.
40 * @param game Pointer to the core game.
41 * @param origin Game section that originated this state.
42 */
OptionsGeoscapeState(Game * game,OptionsOrigin origin)43 OptionsGeoscapeState::OptionsGeoscapeState(Game *game, OptionsOrigin origin) : OptionsBaseState(game, origin)
44 {
45 setCategory(_btnGeoscape);
46
47 // Create objects
48 _txtDragScroll = new Text(114, 9, 206, 8);
49 _cbxDragScroll = new ComboBox(this, 104, 16, 206, 18);
50
51 _txtScrollSpeed = new Text(114, 9, 94, 8);
52 _slrScrollSpeed = new Slider(104, 16, 94, 18);
53
54 _txtDogfightSpeed = new Text(114, 9, 206, 40);
55 _slrDogfightSpeed = new Slider(104, 16, 206, 50);
56
57 _txtClockSpeed = new Text(114, 9, 94, 40);
58 _slrClockSpeed = new Slider(104, 16, 94, 50);
59
60 _txtGlobeDetails = new Text(114, 9, 94, 82);
61 _btnGlobeCountries = new ToggleTextButton(104, 16, 94, 92);
62 _btnGlobeRadars = new ToggleTextButton(104, 16, 94, 110);
63 _btnGlobePaths = new ToggleTextButton(104, 16, 94, 128);
64
65 _txtOptions = new Text(114, 9, 206, 82);
66 _btnShowFunds = new ToggleTextButton(104, 16, 206, 92);
67
68 add(_txtScrollSpeed);
69 add(_slrScrollSpeed);
70
71 add(_txtDogfightSpeed);
72 add(_slrDogfightSpeed);
73
74 add(_txtClockSpeed);
75 add(_slrClockSpeed);
76
77 add(_txtGlobeDetails);
78 add(_btnGlobeCountries);
79 add(_btnGlobeRadars);
80 add(_btnGlobePaths);
81
82 add(_txtOptions);
83 add(_btnShowFunds);
84
85 add(_txtDragScroll);
86 add(_cbxDragScroll);
87
88 centerAllSurfaces();
89
90 // Set up objects
91 _txtDragScroll->setColor(Palette::blockOffset(8)+10);
92 _txtDragScroll->setText(tr("STR_DRAG_SCROLL"));
93
94 std::vector<std::string> dragScrolls;
95 dragScrolls.push_back("STR_DISABLED");
96 dragScrolls.push_back("STR_LEFT_MOUSE_BUTTON");
97 dragScrolls.push_back("STR_MIDDLE_MOUSE_BUTTON");
98 dragScrolls.push_back("STR_RIGHT_MOUSE_BUTTON");
99
100 _cbxDragScroll->setColor(Palette::blockOffset(15)-1);
101 _cbxDragScroll->setOptions(dragScrolls);
102 _cbxDragScroll->setSelected(Options::geoDragScrollButton);
103 _cbxDragScroll->onChange((ActionHandler)&OptionsGeoscapeState::cbxDragScrollChange);
104 _cbxDragScroll->setTooltip("STR_DRAG_SCROLL_DESC");
105 _cbxDragScroll->onMouseIn((ActionHandler)&OptionsGeoscapeState::txtTooltipIn);
106 _cbxDragScroll->onMouseOut((ActionHandler)&OptionsGeoscapeState::txtTooltipOut);
107
108 _txtScrollSpeed->setColor(Palette::blockOffset(8)+10);
109 _txtScrollSpeed->setText(tr("STR_SCROLL_SPEED"));
110
111 _slrScrollSpeed->setColor(Palette::blockOffset(15)-1);
112 _slrScrollSpeed->setRange(100, 10);
113 _slrScrollSpeed->setValue(Options::geoScrollSpeed);
114 _slrScrollSpeed->setTooltip("STR_SCROLL_SPEED_GEO_DESC");
115 _slrScrollSpeed->onChange((ActionHandler)&OptionsGeoscapeState::slrScrollSpeedChange);
116 _slrScrollSpeed->onMouseIn((ActionHandler)&OptionsGeoscapeState::txtTooltipIn);
117 _slrScrollSpeed->onMouseOut((ActionHandler)&OptionsGeoscapeState::txtTooltipOut);
118
119 _txtDogfightSpeed->setColor(Palette::blockOffset(8)+10);
120 _txtDogfightSpeed->setText(tr("STR_DOGFIGHT_SPEED"));
121
122 _slrDogfightSpeed->setColor(Palette::blockOffset(15)-1);
123 _slrDogfightSpeed->setRange(40, 10);
124 _slrDogfightSpeed->setValue(Options::dogfightSpeed);
125 _slrDogfightSpeed->onChange((ActionHandler)&OptionsGeoscapeState::slrDogfightSpeedChange);
126 _slrDogfightSpeed->setTooltip("STR_DOGFIGHT_SPEED_DESC");
127 _slrDogfightSpeed->onMouseIn((ActionHandler)&OptionsGeoscapeState::txtTooltipIn);
128 _slrDogfightSpeed->onMouseOut((ActionHandler)&OptionsGeoscapeState::txtTooltipOut);
129
130 _txtClockSpeed->setColor(Palette::blockOffset(8)+10);
131 _txtClockSpeed->setText(tr("STR_CLOCK_SPEED"));
132
133 _slrClockSpeed->setColor(Palette::blockOffset(15)-1);
134 _slrClockSpeed->setRange(250, 10);
135 _slrClockSpeed->setValue(Options::geoClockSpeed);
136 _slrClockSpeed->setTooltip("STR_CLOCK_SPEED_DESC");
137 _slrClockSpeed->onChange((ActionHandler)&OptionsGeoscapeState::slrClockSpeedChange);
138 _slrClockSpeed->onMouseIn((ActionHandler)&OptionsGeoscapeState::txtTooltipIn);
139 _slrClockSpeed->onMouseOut((ActionHandler)&OptionsGeoscapeState::txtTooltipOut);
140
141 _txtGlobeDetails->setColor(Palette::blockOffset(8)+10);
142 _txtGlobeDetails->setText(tr("STR_GLOBE_DETAILS"));
143
144 _btnGlobeCountries->setColor(Palette::blockOffset(15)-1);
145 _btnGlobeCountries->setText(tr("STR_GLOBE_COUNTRIES"));
146 _btnGlobeCountries->setPressed(Options::globeDetail);
147 _btnGlobeCountries->onMouseClick((ActionHandler)&OptionsGeoscapeState::btnGlobeCountriesClick);
148 _btnGlobeCountries->setTooltip("STR_GLOBE_COUNTRIES_DESC");
149 _btnGlobeCountries->onMouseIn((ActionHandler)&OptionsGeoscapeState::txtTooltipIn);
150 _btnGlobeCountries->onMouseOut((ActionHandler)&OptionsGeoscapeState::txtTooltipOut);
151
152 _btnGlobeRadars->setColor(Palette::blockOffset(15)-1);
153 _btnGlobeRadars->setText(tr("STR_GLOBE_RADARS"));
154 _btnGlobeRadars->setPressed(Options::globeRadarLines);
155 _btnGlobeRadars->onMouseClick((ActionHandler)&OptionsGeoscapeState::btnGlobeRadarsClick);
156 _btnGlobeRadars->setTooltip("STR_GLOBE_RADARS_DESC");
157 _btnGlobeRadars->onMouseIn((ActionHandler)&OptionsGeoscapeState::txtTooltipIn);
158 _btnGlobeRadars->onMouseOut((ActionHandler)&OptionsGeoscapeState::txtTooltipOut);
159
160 _btnGlobePaths->setColor(Palette::blockOffset(15)-1);
161 _btnGlobePaths->setText(tr("STR_GLOBE_FLIGHT_PATHS"));
162 _btnGlobePaths->setPressed(Options::globeFlightPaths);
163 _btnGlobePaths->onMouseClick((ActionHandler)&OptionsGeoscapeState::btnGlobePathsClick);
164 _btnGlobePaths->setTooltip("STR_GLOBE_FLIGHT_PATHS_DESC");
165 _btnGlobePaths->onMouseIn((ActionHandler)&OptionsGeoscapeState::txtTooltipIn);
166 _btnGlobePaths->onMouseOut((ActionHandler)&OptionsGeoscapeState::txtTooltipOut);
167
168 _txtOptions->setColor(Palette::blockOffset(8)+10);
169 _txtOptions->setText(tr("STR_USER_INTERFACE_OPTIONS"));
170
171 _btnShowFunds->setColor(Palette::blockOffset(15)-1);
172 _btnShowFunds->setText(tr("STR_SHOW_FUNDS"));
173 _btnShowFunds->setPressed(Options::showFundsOnGeoscape);
174 _btnShowFunds->onMouseClick((ActionHandler)&OptionsGeoscapeState::btnShowFundsClick);
175 _btnShowFunds->setTooltip("STR_SHOW_FUNDS_DESC");
176 _btnShowFunds->onMouseIn((ActionHandler)&OptionsGeoscapeState::txtTooltipIn);
177 _btnShowFunds->onMouseOut((ActionHandler)&OptionsGeoscapeState::txtTooltipOut);
178 }
179
180 /**
181 *
182 */
~OptionsGeoscapeState()183 OptionsGeoscapeState::~OptionsGeoscapeState()
184 {
185
186 }
187
188 /**
189 * Changes the Drag Scroll option.
190 * @param action Pointer to an action.
191 */
cbxDragScrollChange(Action *)192 void OptionsGeoscapeState::cbxDragScrollChange(Action *)
193 {
194 Options::geoDragScrollButton = _cbxDragScroll->getSelected();
195 }
196
197 /**
198 * Updates the scroll speed.
199 * @param action Pointer to an action.
200 */
slrScrollSpeedChange(Action *)201 void OptionsGeoscapeState::slrScrollSpeedChange(Action *)
202 {
203 Options::geoScrollSpeed = _slrScrollSpeed->getValue();
204 }
205
206 /**
207 * Updates the dogfight speed.
208 * @param action Pointer to an action.
209 */
slrDogfightSpeedChange(Action *)210 void OptionsGeoscapeState::slrDogfightSpeedChange(Action *)
211 {
212 Options::dogfightSpeed = _slrDogfightSpeed->getValue();
213 }
214
215 /**
216 * Updates the clock speed.
217 * @param action Pointer to an action.
218 */
slrClockSpeedChange(Action *)219 void OptionsGeoscapeState::slrClockSpeedChange(Action *)
220 {
221 Options::geoClockSpeed = _slrClockSpeed->getValue();
222 }
223
224 /**
225 * Changes the Globe Country Borders option.
226 * @param action Pointer to an action.
227 */
btnGlobeCountriesClick(Action *)228 void OptionsGeoscapeState::btnGlobeCountriesClick(Action *)
229 {
230 Options::globeDetail = _btnGlobeCountries->getPressed();
231 }
232
233 /**
234 * Changes the Globe Radar Ranges option.
235 * @param action Pointer to an action.
236 */
btnGlobeRadarsClick(Action *)237 void OptionsGeoscapeState::btnGlobeRadarsClick(Action *)
238 {
239 Options::globeRadarLines = _btnGlobeRadars->getPressed();
240 }
241
242 /**
243 * Changes the Globe Flight Paths option.
244 * @param action Pointer to an action.
245 */
btnGlobePathsClick(Action *)246 void OptionsGeoscapeState::btnGlobePathsClick(Action *)
247 {
248 Options::globeFlightPaths = _btnGlobePaths->getPressed();
249 }
250
251 /**
252 * Changes the Show Funds option.
253 * @param action Pointer to an action.
254 */
btnShowFundsClick(Action *)255 void OptionsGeoscapeState::btnShowFundsClick(Action *)
256 {
257 Options::showFundsOnGeoscape = _btnShowFunds->getPressed();
258 }
259
260 }
261