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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "xeen/dialogs/dialogs_control_panel.h"
#include "xeen/dialogs/dialogs_query.h"
#include "xeen/party.h"
#include "xeen/resources.h"
#include "xeen/xeen.h"
namespace Xeen {
int ControlPanel::show(XeenEngine *vm) {
ControlPanel *dlg = new ControlPanel(vm);
int result = dlg->execute();
delete dlg;
return result;
}
int ControlPanel::execute() {
EventsManager &events = *_vm->_events;
Interface &intf = *_vm->_interface;
Map &map = *_vm->_map;
Party &party = *_vm->_party;
SavesManager &saves = *_vm->_saves;
Sound &sound = *_vm->_sound;
Windows &windows = *_vm->_windows;
Window &w = windows[23];
Window &w3 = windows[3];
loadButtons();
int result = 0, debugCtr = 0;
w.open();
do {
Common::String btnText = getButtonText();
Common::String text = Common::String::format(Res.CONTROL_PANEL_TEXT, btnText.c_str());
drawButtons(&w);
w.writeString(text);
w.writeString("\xB""000\t000\x1");
w.update();
do {
events.updateGameCounter();
intf.draw3d(false, false);
w.writeString("\r");
drawButtons(&w);
w.writeString(text);
w.writeString("\v000\t000");
w.frame();
if (_debugFlag)
w.writeString(getTimeText());
w3.update();
w.update();
events.pollEventsAndWait();
checkEvents(_vm);
if (_vm->shouldExit())
return 0;
} while (!_buttonValue && !events.timeElapsed());
switch (_buttonValue) {
case Common::KEYCODE_q:
if (Confirm::show(g_vm, Res.CONFIRM_QUIT)) {
g_vm->_gameMode = GMODE_QUIT;
result = 1;
}
break;
case Common::KEYCODE_w:
if (Confirm::show(g_vm, Res.MR_WIZARD)) {
w.close();
if (!windows[2]._enabled) {
sound.playFX(51);
if (g_vm->getGameID() == GType_WorldOfXeen) {
map._loadCcNum = 0;
map.load(28);
party._mazeDirection = DIR_EAST;
} else {
map._loadCcNum = 1;
map.load(29);
party._mazeDirection = DIR_SOUTH;
}
party.moveToRunLocation();
}
party._gems = 0;
result = 2;
}
break;
case Common::KEYCODE_l:
if (_vm->_mode == MODE_COMBAT) {
ErrorScroll::show(_vm, Res.NO_LOADING_IN_COMBAT);
} else {
// Close dialog and show loading dialog
result = 3;
}
break;
case Common::KEYCODE_s:
if (_vm->_mode == MODE_COMBAT) {
ErrorScroll::show(_vm, Res.NO_SAVING_IN_COMBAT);
} else {
// Close dialog and show saving dialog
result = 4;
}
break;
case Common::KEYCODE_e:
sound.setFxOn(!sound._fxOn);
break;
case Common::KEYCODE_m:
sound.setMusicOn(!sound._musicOn);
break;
case Common::KEYCODE_ESCAPE:
result = 1;
break;
// Goober cheat sequence
case Common::KEYCODE_g:
debugCtr = 1;
break;
case Common::KEYCODE_o:
debugCtr = (debugCtr == 1 || debugCtr == 2) ? 2 : 0;
break;
case Common::KEYCODE_b:
debugCtr = (debugCtr == 2) ? 3 : 0;
break;
case Common::KEYCODE_r:
if (debugCtr == 3)
_debugFlag = true;
else
debugCtr = 0;
break;
default:
break;
}
} while (!result);
w.close();
intf.drawParty(true);
if (result == 3) {
if (g_vm->canLoadGameStateCurrently())
saves.loadGame();
} else if (result == 4) {
saves.saveGame();
}
return result;
}
void ControlPanel::loadButtons() {
_iconSprites.load("cpanel.icn");
addButton(Common::Rect(214, 56, 244, 69), Common::KEYCODE_e, 0, &_iconSprites);
addButton(Common::Rect(214, 75, 244, 88), Common::KEYCODE_m, 0, &_iconSprites);
addButton(Common::Rect(135, 56, 165, 69), Common::KEYCODE_l, 0, &_iconSprites);
addButton(Common::Rect(135, 75, 165, 88), Common::KEYCODE_s, 0, &_iconSprites);
// For ScummVM we've merged both Save and Save As into a single
// save item, so we don't need this one
addButton(Common::Rect(), 0);
addButton(Common::Rect(135, 94, 165, 107), Common::KEYCODE_q, 0, &_iconSprites);
addButton(Common::Rect(175, 113, 205, 126), Common::KEYCODE_w, 0, &_iconSprites);
}
Common::String ControlPanel::getButtonText() {
Sound &sound = *g_vm->_sound;
_btnSoundText = sound._fxOn ? Res.ON : Res.OFF;
_btnMusicText = sound._musicOn ? Res.ON : Res.OFF;
return Common::String::format(Res.CONTROL_PANEL_BUTTONS,
_btnSoundText.c_str(), _btnMusicText.c_str());
}
Common::String ControlPanel::getTimeText() const {
TimeDate td;
g_system->getTimeAndDate(td);
Common::String timeStr = Common::String::format("%d:%.2d:%.2d%c",
td.tm_hour == 0 || td.tm_hour == 12 ? 12 : (td.tm_hour % 12),
td.tm_min, td.tm_sec, (td.tm_hour >= 12) ? 'p' : 'c');
uint32 playtime = g_vm->_events->playTime() / GAME_FRAME_RATE;
Common::String playtimeStr = Common::String::format("%d:%.2d:%.2d",
playtime / 3600, (playtime / 60) % 60, playtime % 60);
return Common::String::format(
"\x2\x3l\xB""000\t000\x4""160%s\x3r\xB""000\t000%s\x1",
timeStr.c_str(), playtimeStr.c_str());
}
} // End of namespace Xeen
|