1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "tsage/blue_force/blueforce_scenes5.h"
24 #include "tsage/scenes.h"
25 #include "tsage/tsage.h"
26 #include "tsage/staticres.h"
27 
28 namespace TsAGE {
29 
30 namespace BlueForce {
31 
32 /*--------------------------------------------------------------------------
33  * Scene 550 - Outside Bikini Hut
34  *
35  *--------------------------------------------------------------------------*/
36 
signal()37 void Scene550::Action1::signal() {
38 	Scene550 *scene = (Scene550 *)BF_GLOBALS._sceneManager._scene;
39 
40 	switch (_actionIndex++) {
41 	case 0:
42 		BF_GLOBALS._player.disableControl();
43 		setDelay(5);
44 		break;
45 	case 1:
46 		scene->_stripManager.start(scene->_sceneMode, this);
47 		break;
48 	case 2:
49 		BF_GLOBALS._player.enableControl();
50 		remove();
51 		break;
52 	}
53 }
54 
55 /*--------------------------------------------------------------------------*/
56 
startAction(CursorType action,Event & event)57 bool Scene550::Lyle::startAction(CursorType action, Event &event) {
58 	Scene550 *scene = (Scene550 *)BF_GLOBALS._sceneManager._scene;
59 
60 	switch (action) {
61 	case CURSOR_TALK:
62 		if ((BF_INVENTORY.getObjectScene(INV_SCHEDULE) == 1) ||
63 				(BF_INVENTORY.getObjectScene(INV_9MM_BULLETS) == 1)) {
64 			if ((BF_INVENTORY.getObjectScene(INV_SCHEDULE) == 1) &&
65 					(BF_INVENTORY.getObjectScene(INV_9MM_BULLETS) == 1)) {
66 				BF_GLOBALS.setFlag(fToldLyleOfSchedule);
67 				BF_GLOBALS._player.disableControl();
68 				scene->_sceneMode = 5501;
69 				scene->setAction(&scene->_sequenceManager, scene, 5514, &BF_GLOBALS._player, this, NULL);
70 			} else {
71 				scene->_sceneMode = 0;
72 				scene->_stripManager.start(5509, scene);
73 			}
74 		} else if (BF_GLOBALS._sceneManager._previousScene == 930) {
75 			scene->_sceneMode = 5512;
76 			scene->setAction(&scene->_action1);
77 		} else {
78 			scene->_sceneMode = BF_INVENTORY.getObjectScene(INV_CARAVAN_KEY) == 1 ? 5513 : 5512;
79 			scene->setAction(&scene->_action1);
80 		}
81 		return true;
82 	case INV_SCHEDULE:
83 		BF_GLOBALS.setFlag(fToldLyleOfSchedule);
84 		BF_GLOBALS._player.disableControl();
85 		scene->_sceneMode = 5501;
86 		scene->setAction(&scene->_sequenceManager, scene, 5514, &BF_GLOBALS._player, this, NULL);
87 		return true;
88 	default:
89 		return NamedObject::startAction(action, event);
90 	}
91 }
92 
startAction(CursorType action,Event & event)93 bool Scene550::CaravanDoor::startAction(CursorType action, Event &event) {
94 	Scene550 *scene = (Scene550 *)BF_GLOBALS._sceneManager._scene;
95 
96 	switch (action) {
97 	case CURSOR_LOOK:
98 		SceneItem::display2(550, 0);
99 		return true;
100 	case CURSOR_USE:
101 		SceneItem::display2(550, 7);
102 		return true;
103 	case INV_CARAVAN_KEY:
104 		if ((BF_GLOBALS._dayNumber != 3) || !BF_GLOBALS.getFlag(fWithLyle))
105 			SceneItem::display2(550, 33);
106 		else {
107 			BF_GLOBALS._player.disableControl();
108 			scene->_sceneMode = 5500;
109 			scene->setAction(&scene->_sequenceManager, scene, 5500, &BF_GLOBALS._player, this, NULL);
110 		}
111 		return true;
112 	default:
113 		return NamedObject::startAction(action, event);
114 	}
115 }
116 
startAction(CursorType action,Event & event)117 bool Scene550::Vechile::startAction(CursorType action, Event &event) {
118 	Scene550 *scene = (Scene550 *)BF_GLOBALS._sceneManager._scene;
119 
120 	switch (action) {
121 	case CURSOR_LOOK:
122 		SceneItem::display2(550, 3);
123 		return true;
124 	case CURSOR_USE:
125 		if (!BF_GLOBALS.getFlag(fWithLyle)) {
126 			BF_GLOBALS._player.disableControl();
127 			scene->_sceneMode = 5510;
128 			scene->setAction(&scene->_sequenceManager, scene, BF_GLOBALS.getFlag(fWithLyle) ? 5510 : 5515,
129 				&BF_GLOBALS._player, this, NULL);
130 		} else if (BF_GLOBALS.getFlag(fToldLyleOfSchedule)) {
131 			BF_GLOBALS._player.disableControl();
132 			scene->_sceneMode = 2;
133 			scene->setAction(&scene->_sequenceManager, scene, 5501, &BF_GLOBALS._player, NULL);
134 		} else if ((BF_INVENTORY.getObjectScene(INV_SCHEDULE) == 1) ||
135 					(BF_INVENTORY.getObjectScene(INV_9MM_BULLETS) == 1)) {
136 			if (BF_INVENTORY.getObjectScene(INV_9MM_BULLETS) == 1) {
137 				scene->_sceneMode = 5501;
138 				scene->_stripManager.start(5511, scene);
139 			} else {
140 				scene->_sceneMode = 0;
141 				scene->_stripManager.start(5509, scene);
142 			}
143 		} else if (BF_GLOBALS._sceneManager._previousScene == 930) {
144 			scene->_sceneMode = 5512;
145 			scene->setAction(&scene->_action1);
146 		} else {
147 			BF_GLOBALS._player.disableControl();
148 			scene->_sceneMode = 2;
149 			scene->setAction(&scene->_sequenceManager, scene, 5501, &BF_GLOBALS._player, NULL);
150 		}
151 		return true;
152 	default:
153 		return NamedObject::startAction(action, event);
154 	}
155 }
156 
157 /*--------------------------------------------------------------------------*/
158 
postInit(SceneObjectList * OwnerList)159 void Scene550::postInit(SceneObjectList *OwnerList) {
160 	BF_GLOBALS._sound1.fadeSound(16);
161 
162 	if ((BF_GLOBALS._bookmark == bInspectionDone) && !BF_GLOBALS.getFlag(fHasDrivenFromDrunk)) {
163 		_sceneMode = 1;
164 		signal();
165 		return;
166 	}
167 
168 	SceneExt::postInit();
169 	loadScene(550);
170 
171 	_stripManager.addSpeaker(&_gameTextSpeaker);
172 	_stripManager.addSpeaker(&_lyleHatSpeaker);
173 	_stripManager.addSpeaker(&_jakeJacketSpeaker);
174 
175 	BF_GLOBALS._player.postInit();
176 	BF_GLOBALS._player.animate(ANIM_MODE_1, NULL);
177 	BF_GLOBALS._player.setObjectWrapper(new SceneObjectWrapper());
178 	BF_GLOBALS._player.setPosition(Common::Point(160, 100));
179 	BF_GLOBALS._player._moveDiff = Common::Point(2, 1);
180 	BF_GLOBALS._player.enableControl();
181 
182 	_caravanDoor.postInit();
183 	_caravanDoor.setVisage(550);
184 	_caravanDoor.setPosition(Common::Point(34, 66));
185 	BF_GLOBALS._sceneItems.push_back(&_caravanDoor);
186 
187 	_vechile.postInit();
188 	_vechile.fixPriority(70);
189 
190 	if (BF_GLOBALS.getFlag(fWithLyle)) {
191 		BF_GLOBALS._walkRegions.disableRegion(10);
192 		BF_GLOBALS._walkRegions.disableRegion(11);
193 
194 		_vechile.setVisage(444);
195 		_vechile.setStrip(4);
196 		_vechile.setFrame2(2);
197 		_vechile.setPosition(Common::Point(110, 85));
198 		_vechile.fixPriority(76);
199 
200 		_lyle.postInit();
201 		_lyle.setVisage(835);
202 		_lyle.setPosition(Common::Point(139, 83));
203 		_lyle.setDetails(550, 29, 30, 31, 1, (SceneItem *)NULL);
204 		_lyle.setStrip(8);
205 
206 		BF_GLOBALS._player.setVisage(303);
207 		BF_GLOBALS._player.setPosition(Common::Point(89, 76));
208 		BF_GLOBALS._player.updateAngle(_lyle._position);
209 	} else {
210 		BF_GLOBALS._walkRegions.disableRegion(12);
211 
212 		_vechile.setPosition(Common::Point(205, 77));
213 		_vechile.changeZoom(80);
214 
215 		if (BF_GLOBALS.getFlag(onDuty)) {
216 			_vechile.setVisage(301);
217 			_vechile.setStrip(1);
218 
219 			BF_GLOBALS._player.setVisage(304);
220 		} else {
221 			_vechile.setVisage(580);
222 			_vechile.setStrip(2);
223 			_vechile.setFrame(2);
224 
225 			BF_GLOBALS._player.setVisage(303);
226 		}
227 	}
228 
229 	BF_GLOBALS._sceneItems.push_back(&_vechile);
230 
231 	if (BF_GLOBALS._sceneManager._previousScene == 930) {
232 		_caravanDoor.setFrame(_caravanDoor.getFrameCount());
233 		BF_GLOBALS._player.disableControl();
234 
235 		_sceneMode = 0;
236 		setAction(&_sequenceManager, this, 5512, &BF_GLOBALS._player, &_caravanDoor, NULL);
237 	} else if (BF_GLOBALS.getFlag(onDuty)) {
238 		BF_GLOBALS._player.disableControl();
239 		_sceneMode = 0;
240 		setAction(&_sequenceManager, this, 5502, &BF_GLOBALS._player, &_vechile, NULL);
241 	} else if (!BF_GLOBALS.getFlag(fWithLyle)) {
242 		BF_GLOBALS._player.setPosition(Common::Point(185, 70));
243 	} else if (BF_GLOBALS._bookmark == bFlashBackOne) {
244 		BF_GLOBALS._player.disableControl();
245 		_sceneMode = 0;
246 		setAction(&_sequenceManager, this, 5513, &_lyle, NULL);
247 	} else {
248 		_sceneMode = 0;
249 	}
250 
251 	_item2.setDetails(Rect(0, 26, 53, 67), 550, 1, -1, 2, 1, NULL);
252 	_item3.setDetails(Rect(53, 12, 173, 65), 550, 4, -1, 5, 1, NULL);
253 	_item1.setDetails(Rect(0, 0, 320, 170), 550, 6, -1, -1, 1, NULL);
254 }
255 
signal()256 void Scene550::signal() {
257 	switch (_sceneMode) {
258 	case 0:
259 		BF_GLOBALS._player.enableControl();
260 		break;
261 	case 1:
262 		BF_GLOBALS._sceneManager.changeScene(551);
263 		break;
264 	case 2:
265 	case 5510:
266 		BF_GLOBALS._sceneManager.changeScene(60);
267 		break;
268 	case 3:
269 		BF_GLOBALS._driveFromScene = 16;
270 		BF_GLOBALS._driveToScene = 128;
271 		BF_GLOBALS._mapLocationId = 128;
272 		BF_GLOBALS._sound1.fadeOut2(NULL);
273 		BF_GLOBALS._sceneManager.changeScene(800);
274 		break;
275 	case 5500:
276 		BF_GLOBALS._sceneManager.changeScene(930);
277 		break;
278 	case 5501:
279 		BF_GLOBALS._player.disableControl();
280 		_sceneMode = 3;
281 		setAction(&_sequenceManager, this, 5501, &BF_GLOBALS._player, NULL);
282 		break;
283 	default:
284 		break;
285 	}
286 }
287 
288 /*--------------------------------------------------------------------------
289  * Scene 551 - Outside Bikini Hut (Drunk Stop)
290  *
291  *--------------------------------------------------------------------------*/
292 
signal()293 void Scene551::Action2::signal() {
294 	Scene551 *scene = (Scene551 *)BF_GLOBALS._sceneManager._scene;
295 
296 	switch (_actionIndex++) {
297 	case 0:
298 		BF_GLOBALS._walkRegions.enableRegion(18);
299 		BF_GLOBALS._walkRegions.enableRegion(4);
300 		scene->_field1CD2 = 1;
301 
302 		scene->_harrison.setObjectWrapper(new SceneObjectWrapper());
303 		scene->_harrison.animate(ANIM_MODE_1, NULL);
304 
305 		BF_GLOBALS._player.setVisage(304);
306 		BF_GLOBALS._player.animate(ANIM_MODE_1, NULL);
307 
308 		if (scene->_drunkStanding._flag != 1) {
309 			ADD_PLAYER_MOVER_THIS(scene->_harrison, 126, 85);
310 		} else {
311 			ADD_PLAYER_MOVER_THIS(scene->_harrison, 88, 91);
312 		}
313 		break;
314 	case 1:
315 		scene->_harrison.updateAngle(BF_GLOBALS._player._position);
316 
317 		if (scene->_drunkStanding._flag == 1) {
318 			BF_GLOBALS._walkRegions.disableRegion(4);
319 			ADD_PLAYER_MOVER(71, 97);
320 		} else {
321 			ADD_PLAYER_MOVER(141, 87);
322 		}
323 		break;
324 	case 2:
325 		scene->_harrison.updateAngle(BF_GLOBALS._player._position);
326 		BF_GLOBALS._player.updateAngle(scene->_harrison._position);
327 		setDelay(10);
328 		break;
329 	case 3:
330 		scene->_stripManager.start(scene->_harrison._flag, this);
331 		break;
332 	case 4:
333 		scene->_field1CD2 = 0;
334 		BF_GLOBALS._player.enableControl();
335 		remove();
336 		break;
337 	default:
338 		break;
339 	}
340 }
341 
342 /*--------------------------------------------------------------------------*/
343 
startAction(CursorType action,Event & event)344 bool Scene551::Vechile::startAction(CursorType action, Event &event) {
345 	Scene551 *scene = (Scene551 *)BF_GLOBALS._sceneManager._scene;
346 
347 	switch (action) {
348 	case CURSOR_LOOK:
349 		SceneItem::display2(550, 3);
350 		return true;
351 	case CURSOR_USE:
352 		if (!BF_GLOBALS.getFlag(didDrunk)) {
353 			BF_GLOBALS._player.disableControl();
354 			scene->_sceneMode = 1;
355 			scene->setAction(&scene->_sequenceManager, scene, 5510, &BF_GLOBALS._player, this, NULL);
356 		} else if (BF_INVENTORY.getObjectScene(INV_CENTER_PUNCH) == 1) {
357 			BF_INVENTORY.setObjectScene(INV_CENTER_PUNCH, 0);
358 			scene->_harrison._flag = 5505;
359 			scene->setAction(&scene->_action2, scene);
360 			scene->_sceneMode = 5509;
361 		} else {
362 			BF_GLOBALS._player.disableControl();
363 			scene->_sceneMode = 1;
364 			scene->setAction(&scene->_sequenceManager, scene, 5510, &BF_GLOBALS._player, this, NULL);
365 		}
366 		return true;
367 	default:
368 		return NamedObject::startAction(action, event);
369 	}
370 }
371 
startAction(CursorType action,Event & event)372 bool Scene551::DrunkStanding::startAction(CursorType action, Event &event) {
373 	Scene551 *scene = (Scene551 *)BF_GLOBALS._sceneManager._scene;
374 
375 	switch (action) {
376 	case CURSOR_LOOK:
377 		SceneItem::display2(550, 15);
378 		return true;
379 	case CURSOR_USE:
380 		SceneItem::display2(550, 16);
381 		return true;
382 	case CURSOR_TALK:
383 		SceneItem::display2(550, 17);
384 		return true;
385 	case INV_HANDCUFFS:
386 		scene->_harrison.animate(ANIM_MODE_1, NULL);
387 		BF_GLOBALS.set2Flags(f1098Drunk);
388 		BF_GLOBALS.setFlag(didDrunk);
389 		_flag = 2;
390 		BF_GLOBALS._player.disableControl();
391 		scene->_sceneMode = 5509;
392 
393 		scene->setAction(&scene->_sequenceManager, scene, 5509, &BF_GLOBALS._player, this, &scene->_harrison, NULL);
394 		BF_GLOBALS.set2Flags(f1015Drunk);
395 		return true;
396 	default:
397 		return NamedObjectExt::startAction(action, event);
398 	}
399 }
400 
startAction(CursorType action,Event & event)401 bool Scene551::Drunk::startAction(CursorType action, Event &event) {
402 	Scene551 *scene = (Scene551 *)BF_GLOBALS._sceneManager._scene;
403 
404 	switch (action) {
405 	case CURSOR_LOOK:
406 		switch (_flag) {
407 		case 0:
408 			BF_GLOBALS._player.disableControl();
409 			scene->_sceneMode = 0;
410 			scene->setAction(&scene->_sequenceManager, scene, 5505, &BF_GLOBALS._player, &scene->_object15, NULL);
411 			break;
412 		case 1:
413 			SceneItem::display2(550, 11);
414 			break;
415 		case 2:
416 			SceneItem::display2(550, 12);
417 			break;
418 		case 3:
419 			SceneItem::display2(550, 27);
420 			break;
421 		}
422 		return true;
423 	case CURSOR_USE:
424 		switch (_flag) {
425 		case 0:
426 			BF_GLOBALS._player.disableControl();
427 			if (BF_GLOBALS.getFlag(fTalkedToDrunkInCar)) {
428 				scene->_sceneMode = 5508;
429 				scene->setAction(&scene->_sequenceManager, scene, 5508, &BF_GLOBALS._player, NULL);
430 			} else {
431 				BF_GLOBALS.setFlag(fTalkedToDrunkInCar);
432 				scene->_sceneMode = 16;
433 				scene->setAction(&scene->_sequenceManager, scene, 5504, &BF_GLOBALS._player, &scene->_object15, NULL);
434 			}
435 			break;
436 		case 2:
437 			SceneItem::display2(550, 13);
438 			break;
439 		case 3:
440 			SceneItem::display2(550, 27);
441 			break;
442 		default:
443 			break;
444 		}
445 		return true;
446 	case CURSOR_TALK:
447 		if (_flag)
448 			break;
449 		BF_GLOBALS._player.disableControl();
450 
451 		if (BF_GLOBALS.getFlag(fTalkedToDrunkInCar)) {
452 			scene->_sceneMode = 5508;
453 			scene->setAction(&scene->_sequenceManager, scene, 5508, &BF_GLOBALS._player, NULL);
454 		} else {
455 			BF_GLOBALS.setFlag(fTalkedToDrunkInCar);
456 			scene->_sceneMode = 0;
457 			scene->setAction(&scene->_sequenceManager, scene, 5504, &BF_GLOBALS._player, &scene->_object15, NULL);
458 		}
459 		return true;
460 	case INV_CENTER_PUNCH:
461 		if (_flag) {
462 			SceneItem::display2(550, 14);
463 		} else {
464 			BF_GLOBALS.set2Flags(f1098Drunk);
465 			BF_GLOBALS.setFlag(didDrunk);
466 			_flag = 1;
467 			T2_GLOBALS._uiElements.addScore(30);
468 
469 			BF_GLOBALS._player.disableControl();
470 			scene->_sceneMode = 5506;
471 			scene->setAction(&scene->_sequenceManager, scene, 5506, &BF_GLOBALS._player, this,
472 				&scene->_object12, NULL);
473 		}
474 		return true;
475 	default:
476 		break;
477 	}
478 
479 	return NamedObjectExt::startAction(action, event);
480 }
481 
startAction(CursorType action,Event & event)482 bool Scene551::PatrolCarTrunk::startAction(CursorType action, Event &event) {
483 	Scene551 *scene = (Scene551 *)BF_GLOBALS._sceneManager._scene;
484 
485 	switch (action) {
486 	case CURSOR_USE:
487 		if (BF_INVENTORY.getObjectScene(INV_CENTER_PUNCH) != 1) {
488 			BF_GLOBALS._walkRegions.enableRegion(18);
489 			BF_GLOBALS._player.disableControl();
490 			scene->_sceneMode = 2;
491 			scene->setAction(&scene->_sequenceManager, scene, 5503, &BF_GLOBALS._player, &scene->_harrison, this, NULL);
492 			return true;
493 		}
494 		break;
495 	default:
496 		break;
497 	}
498 
499 	return NamedObject::startAction(action, event);
500 }
501 
remove()502 void Scene551::TrunkInset::remove() {
503 	Scene551 *scene = (Scene551 *)BF_GLOBALS._sceneManager._scene;
504 	scene->_trunkKits.remove();
505 	BF_GLOBALS._player.disableControl();
506 
507 	scene->_sceneMode = 0;
508 	scene->setAction(&scene->_sequenceManager, scene, 5516, &scene->_harrison,
509 		&scene->_patrolCarTrunk, NULL);
510 
511 	FocusObject::remove();
512 }
513 
startAction(CursorType action,Event & event)514 bool Scene551::TrunkInset::startAction(CursorType action, Event &event) {
515 	switch (action) {
516 	case CURSOR_LOOK:
517 		SceneItem::display2(550, 18);
518 		return true;
519 	case CURSOR_USE:
520 		return true;
521 	default:
522 		return NamedObject::startAction(action, event);
523 	}
524 }
525 
startAction(CursorType action,Event & event)526 bool Scene551::TrunkKits::startAction(CursorType action, Event &event) {
527 	Scene551 *scene = (Scene551 *)BF_GLOBALS._sceneManager._scene;
528 
529 	Rect tempRect = _bounds;
530 	tempRect.collapse(10, 6);
531 	if (!tempRect.contains(event.mousePos))
532 		return false;
533 
534 	switch (action) {
535 	case CURSOR_LOOK:
536 		switch (_frame) {
537 		case 1:
538 			SceneItem::display2(550, 19);
539 			break;
540 		case 2:
541 			SceneItem::display2(550, 20);
542 			break;
543 		case 3:
544 			SceneItem::display2(550, 21);
545 			break;
546 		default:
547 			break;
548 		}
549 		return true;
550 	case CURSOR_USE:
551 		if (event.mousePos.y < _bounds.top) {
552 			setFrame(1);
553 		} else if ((event.mousePos.x < (_bounds.left - 25)) && (_frame > 1)) {
554 			SceneItem::display2(550, 28);
555 		} else {
556 			switch (_frame) {
557 			case 1:
558 				setFrame(BF_INVENTORY.getObjectScene(INV_CENTER_PUNCH) == 1 ? 3 : 2);
559 				break;
560 			case 2:
561 				if (!BF_GLOBALS.getFlag(fShowedBluePrint)) {
562 					T2_GLOBALS._uiElements.addScore(30);
563 					BF_GLOBALS.setFlag(fShowedBluePrint);
564 				}
565 
566 				BF_GLOBALS._player.disableControl();
567 				scene->_sceneMode = 5520;
568 				scene->setAction(&scene->_sequenceManager, scene, 5520, &BF_GLOBALS._player, NULL);
569 				BF_INVENTORY.setObjectScene(INV_CENTER_PUNCH, 1);
570 				setFrame(3);
571 				break;
572 			case 3:
573 				setFrame(1);
574 				break;
575 			default:
576 				break;
577 			}
578 		}
579 		return true;
580 	case INV_CENTER_PUNCH:
581 		SceneItem::display2(550, 22);
582 		BF_INVENTORY.setObjectScene(INV_CENTER_PUNCH, 0);
583 		setFrame(2);
584 		return true;
585 	default:
586 		return NamedObject::startAction(action, event);
587 	}
588 }
589 
startAction(CursorType action,Event & event)590 bool Scene551::Harrison::startAction(CursorType action, Event &event) {
591 	Scene551 *scene = (Scene551 *)BF_GLOBALS._sceneManager._scene;
592 
593 	switch (action) {
594 	case CURSOR_LOOK:
595 		SceneItem::display2(550, 23);
596 		return true;
597 	case CURSOR_USE:
598 		SceneItem::display2(550, 24);
599 		return true;
600 	case CURSOR_TALK:
601 		BF_GLOBALS._player.disableControl();
602 
603 		if (scene->_drunkStanding._flag == 1) {
604 			_flag = 5508;
605 		} else if (!scene->_field1CD0) {
606 			_flag = 5502;
607 		} else {
608 			scene->_field1CD0 = 1;
609 			_flag = 5500;
610 		}
611 		scene->setAction(&scene->_action2);
612 		return true;
613 	default:
614 		return NamedObjectExt::startAction(action, event);
615 	}
616 }
617 
618 /*--------------------------------------------------------------------------*/
619 
startAction(CursorType action,Event & event)620 bool Scene551::Item4::startAction(CursorType action, Event &event) {
621 	Scene551 *scene = (Scene551 *)BF_GLOBALS._sceneManager._scene;
622 
623 	switch (action) {
624 	case CURSOR_LOOK:
625 		SceneItem::display2(550, 34);
626 		BF_GLOBALS._player.disableControl();
627 		scene->_sceneMode = 1;
628 		scene->setAction(&scene->_sequenceManager, scene, 5510, &BF_GLOBALS._player, &scene->_vechile2, NULL);
629 		return true;
630 	default:
631 		return false;
632 	}
633 }
634 
635 /*--------------------------------------------------------------------------*/
636 
Scene551()637 Scene551::Scene551(): Scene550() {
638 	_field1CD0 = _field1CD2 = 0;
639 }
640 
synchronize(Serializer & s)641 void Scene551::synchronize(Serializer &s) {
642 	Scene550::synchronize(s);
643 	s.syncAsSint16LE(_field1CD0);
644 	s.syncAsSint16LE(_field1CD2);
645 }
646 
postInit(SceneObjectList * OwnerList)647 void Scene551::postInit(SceneObjectList *OwnerList) {
648 	SceneExt::postInit();
649 	loadScene(550);
650 	BF_GLOBALS._walkRegions.load(551);
651 	BF_GLOBALS._sound1.fadeSound(16);
652 
653 	_stripManager.addSpeaker(&_gameTextSpeaker);
654 	_stripManager.addSpeaker(&_jakeUniformSpeaker);
655 	_stripManager.addSpeaker(&_gigglesSpeaker);
656 	_stripManager.addSpeaker(&_drunkSpeaker);
657 
658 	if (BF_GLOBALS.getFlag(fHasLeftDrunk)) {
659 		_item4.setBounds(Rect(0, 0, 320, 170));
660 		BF_GLOBALS._sceneItems.push_back(&_item4);
661 	}
662 
663 	BF_GLOBALS._player.postInit();
664 	BF_GLOBALS._player.animate(ANIM_MODE_1, NULL);
665 	BF_GLOBALS._player.setObjectWrapper(new SceneObjectWrapper());
666 	BF_GLOBALS._player.setPosition(Common::Point(160, 100));
667 	BF_GLOBALS._player._moveDiff = Common::Point(2, 1);
668 	BF_GLOBALS._player.enableControl();
669 
670 	_caravanDoor.postInit();
671 	_caravanDoor.setVisage(550);
672 	_caravanDoor.setPosition(Common::Point(34, 66));
673 	BF_GLOBALS._sceneItems.push_back(&_caravanDoor);
674 
675 	_vechile2.postInit();
676 	_vechile2.setVisage(301);
677 	_vechile2.setStrip(1);
678 	_vechile2.setPosition(Common::Point(205, 77));
679 	_vechile2.fixPriority(70);
680 	_vechile2.changeZoom(80);
681 	BF_GLOBALS._sceneItems.push_back(&_vechile2);
682 
683 	BF_GLOBALS._walkRegions.disableRegion(14);
684 
685 	_drunk.postInit();
686 	_drunk.setVisage(550);
687 	_drunk.setStrip(3);
688 	_drunk.fixPriority(84);
689 	_drunk.setPosition(Common::Point(29, 92));
690 	_drunk._flag = 0;
691 	BF_GLOBALS._sceneItems.push_back(&_drunk);
692 
693 	_object12.postInit();
694 	_object12.setVisage(550);
695 	_object12.setStrip(7);
696 	_object12.setPosition(Common::Point(29, 92));
697 	_object12.hide();
698 
699 	_object13.postInit();
700 	_object13.setVisage(550);
701 	_object13.setStrip(2);
702 	_object13.setPosition(Common::Point(29, 92));
703 	_object13.fixPriority(82);
704 	_object13.setDetails(550, 8, -1, 9, 1, (SceneItem *)NULL);
705 
706 	if (BF_GLOBALS.getFlag(didDrunk)) {
707 		_drunk._flag = 3;
708 		_drunk.setStrip(3);
709 
710 		_object12.show();
711 		_object12.setDetails(550, 25, -1, 26, 1, (SceneItem *)NULL);
712 		BF_GLOBALS._sceneItems.push_front(&_object12);
713 
714 		_harrison.postInit();
715 		_harrison.setVisage(304);
716 		_harrison.setPosition(Common::Point(67, 102));
717 		_harrison.setStrip(8);
718 		_harrison.setFrame(1);
719 		_harrison._flag = 1;
720 		BF_GLOBALS._sceneItems.push_back(&_harrison);
721 
722 		_object14.postInit();
723 		_object14.setVisage(550);
724 		_object14.setStrip(5);
725 		_object14.animate(ANIM_MODE_2, NULL);
726 		_object14.fixPriority(80);
727 		_object14.setPosition(Common::Point(122, 57));
728 
729 		_object11.postInit();
730 		_object11.setVisage(550);
731 		_object11.setStrip(2);
732 		_object11.setFrame(2);
733 		_object11.setPosition(Common::Point(116, 84));
734 		_object11.fixPriority(77);
735 		_object11.setDetails(550, 32, -1, 10, 1, (SceneItem *)NULL);
736 
737 		_drunkStanding.postInit();
738 		_drunkStanding._flag = 0;
739 		_drunkStanding.setVisage(554);
740 		_drunkStanding.setStrip(7);
741 		_drunkStanding.setFrame(8);
742 		_drunkStanding.fixPriority(83);
743 		_drunkStanding.setPosition(Common::Point(57, 99));
744 	} else {
745 		_harrison.postInit();
746 		_harrison.setVisage(304);
747 		_harrison.setPosition(Common::Point(126, 83));
748 		_harrison.setObjectWrapper(new SceneObjectWrapper());
749 		_harrison._flag = 0;
750 		_harrison._moveDiff = Common::Point(2, 1);
751 		BF_GLOBALS._sceneItems.push_back(&_harrison);
752 
753 		_object14.postInit();
754 		_object14.setVisage(550);
755 		_object14.setStrip(5);
756 		_object14.animate(ANIM_MODE_2, NULL);
757 		_object14.fixPriority(80);
758 		_object14.setPosition(Common::Point(122, 57));
759 
760 		_patrolCarTrunk.postInit();
761 		_patrolCarTrunk.setVisage(550);
762 		_patrolCarTrunk.setStrip(4);
763 		_patrolCarTrunk.setFrame(1);
764 		_patrolCarTrunk.setPosition(Common::Point(149, 69));
765 		_patrolCarTrunk.fixPriority(79);
766 		_patrolCarTrunk.setDetails(550, 18, -1, 9, 1, (SceneItem *)NULL);
767 
768 		_object11.postInit();
769 		_object11.setVisage(550);
770 		_object11.setStrip(2);
771 		_object11.setFrame(2);
772 		_object11.setPosition(Common::Point(116, 84));
773 		_object11.fixPriority(77);
774 		_object11.setDetails(550, 32, -1, 10, 1, (SceneItem *)NULL);
775 
776 		_drunkStanding.postInit();
777 		_drunkStanding._flag = 0;
778 		_drunkStanding.setVisage(554);
779 		_drunkStanding.fixPriority(83);
780 		_drunkStanding.setPosition(Common::Point(47, 93));
781 
782 		_object15.postInit();
783 		_object15.setVisage(552);
784 		_object15.setPosition(Common::Point(59, 94));
785 		_object15.fixPriority(200);
786 		_object15.hide();
787 	}
788 
789 	BF_GLOBALS._player.disableControl();
790 	_sceneMode = 3;
791 	setAction(&_sequenceManager, this, 5502, &BF_GLOBALS._player, &_vechile2, NULL);
792 
793 	_item2.setDetails(Rect(0, 26, 53, 67), 550, 1, -1, 2, 1, NULL);
794 	_item3.setDetails(Rect(53, 12, 173, 65), 550, 4, -1, 5, 1, NULL);
795 	_item1.setDetails(Rect(0, 0, 320, 170), 550, 6, -1, -1, 1, NULL);
796 }
797 
signal()798 void Scene551::signal() {
799 	switch (_sceneMode) {
800 	case 0:
801 		BF_GLOBALS._player.enableControl();
802 		break;
803 	case 1:
804 		BF_GLOBALS._sound1.fadeOut2(NULL);
805 		BF_GLOBALS.set2Flags(f1027Drunk);
806 		BF_GLOBALS.set2Flags(f1097Drunk);
807 
808 		if (BF_GLOBALS.getFlag(didDrunk))
809 			BF_GLOBALS.setFlag(f1098Drunk);
810 
811 		BF_GLOBALS._sceneManager.changeScene(60);
812 		break;
813 	case 2:
814 		BF_GLOBALS._walkRegions.disableRegion(18);
815 
816 		_trunkInset.postInit();
817 		_trunkInset.setVisage(553);
818 		_trunkInset.setPosition(Common::Point(59, 92));
819 		_trunkInset.fixPriority(252);
820 		BF_GLOBALS._sceneItems.push_front(&_trunkInset);
821 
822 		_trunkKits.postInit();
823 		_trunkKits.setVisage(553);
824 		_trunkKits.setStrip(2);
825 		_trunkKits.setPosition(Common::Point(57, 73));
826 		_trunkKits.fixPriority(254);
827 		BF_GLOBALS._sceneItems.push_front(&_trunkKits);
828 		BF_GLOBALS._player.enableControl();
829 		break;
830 	case 3:
831 		if (BF_GLOBALS.getFlag(talkedToHarrisAboutDrunk)) {
832 			BF_GLOBALS._player.enableControl();
833 		} else {
834 			BF_GLOBALS.setFlag(talkedToHarrisAboutDrunk);
835 			_harrison._flag = 5500;
836 			setAction(&_action2);
837 		}
838 		break;
839 	case 5506:
840 		_harrison.setObjectWrapper(new SceneObjectWrapper());
841 		ADD_PLAYER_MOVER_NULL(_harrison, 88, 91);
842 
843 		_object12.show();
844 		_object12.setDetails(550, 25, -1, 26, 1, (SceneItem *)NULL);
845 		BF_GLOBALS._sceneItems.push_front(&_object12);
846 		BF_GLOBALS._player.enableControl();
847 
848 		_sceneMode = 5507;
849 		setAction(&_sequenceManager, this, 5507, &BF_GLOBALS._player, &_drunk, &_drunkStanding, NULL);
850 		break;
851 	case 5507:
852 		BF_GLOBALS._walkRegions.disableRegion(2);
853 		BF_GLOBALS._walkRegions.disableRegion(4);
854 
855 		_drunkStanding._flag = 1;
856 		BF_GLOBALS._sceneItems.push_front(&_drunkStanding);
857 		BF_GLOBALS._player.enableControl();
858 		break;
859 	case 5508:
860 		BF_GLOBALS._player.disableControl();
861 		_sceneMode = 0;
862 		setAction(&_sequenceManager, this, 5505, &BF_GLOBALS._player, &_object15, NULL);
863 		break;
864 	case 5509:
865 		BF_INVENTORY.setObjectScene(INV_CENTER_PUNCH, 0);
866 		BF_GLOBALS._player.disableControl();
867 		_sceneMode = 5510;
868 		setAction(&_sequenceManager, this, 5510, &BF_GLOBALS._player, &_vechile2, NULL);
869 		break;
870 	case 5510:
871 		BF_GLOBALS._bookmark = bCalledToDrunkStop;
872 		if (BF_GLOBALS.getFlag(didDrunk))
873 			BF_GLOBALS.setFlag(fHasLeftDrunk);
874 
875 		BF_GLOBALS._sceneManager.changeScene(60);
876 		break;
877 	case 5520:
878 		BF_GLOBALS._player.animate(ANIM_MODE_1, NULL);
879 		_harrison.animate(ANIM_MODE_1, NULL);
880 		BF_GLOBALS._player.enableControl();
881 		break;
882 	default:
883 		BF_GLOBALS._player.enableControl();
884 		break;
885 	}
886 }
887 
dispatch()888 void Scene551::dispatch() {
889 	SceneExt::dispatch();
890 
891 	if ((_drunkStanding._flag != 2) && !_harrison._mover && !_field1CD2)
892 		_harrison.updateAngle(BF_GLOBALS._player._position);
893 }
894 
895 /*--------------------------------------------------------------------------
896  * Scene 550 - Study
897  *
898  *--------------------------------------------------------------------------*/
899 
signal()900 void Scene560::Action1::signal() {
901 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
902 
903 	switch (_actionIndex++) {
904 	case 0:
905 		setDelay(10);
906 		break;
907 	case 1:
908 		 ADD_MOVER(BF_GLOBALS._player, 105, 140);
909 		 break;
910 	case 2:
911 		scene->_deskChair.hide();
912 
913 		BF_GLOBALS._player.changeZoom(81);
914 		BF_GLOBALS._player.setVisage(561);
915 		BF_GLOBALS._player.setStrip(2);
916 		BF_GLOBALS._player.setFrame(1);
917 		BF_GLOBALS._player.setPosition(Common::Point(96, 138));
918 		BF_GLOBALS._player.animate(ANIM_MODE_5, this);
919 		break;
920 	case 3:
921 		scene->_deskChair.setVisage(561);
922 		scene->_deskChair.setFrame(BF_GLOBALS._player._frame);
923 		scene->_deskChair.setStrip(BF_GLOBALS._player._strip);
924 		scene->_deskChair.setPosition(BF_GLOBALS._player._position);
925 
926 		scene->_field380 = true;
927 		BF_GLOBALS._player.enableControl();
928 		remove();
929 		break;
930 	default:
931 		break;
932 	}
933 }
934 
signal()935 void Scene560::Action2::signal() {
936 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
937 
938 	switch (_actionIndex++) {
939 	case 0:
940 		BF_GLOBALS._player.disableControl();
941 		setDelay(10);
942 		break;
943 	case 1:
944 		scene->_deskChair.hide();
945 
946 		BF_GLOBALS._player.setVisage(561);
947 		BF_GLOBALS._player.setStrip(2);
948 		BF_GLOBALS._player.setFrame(BF_GLOBALS._player.getFrameCount());
949 		BF_GLOBALS._player.animate(ANIM_MODE_6, this);
950 		break;
951 	case 2:
952 		scene->_field380 = false;
953 		scene->_deskChair.setPosition(Common::Point(81, 149));
954 		scene->_deskChair.setVisage(561);
955 		scene->_deskChair.setStrip(3);
956 		scene->_deskChair.setFrame(1);
957 		scene->_deskChair.fixPriority(151);
958 		scene->_deskChair.show();
959 
960 		BF_GLOBALS._player.setVisage(563);
961 		BF_GLOBALS._player.setPosition(Common::Point(105, 140));
962 		BF_GLOBALS._player.fixPriority(-1);
963 		BF_GLOBALS._player.changeZoom(-1);
964 		BF_GLOBALS._player.animate(ANIM_MODE_1, this);
965 		BF_GLOBALS._player.setObjectWrapper(new SceneObjectWrapper());
966 		BF_GLOBALS._player.enableControl();
967 		ADD_PLAYER_MOVER(scene->_destPosition.x, scene->_destPosition.y);
968 		remove();
969 		break;
970 	default:
971 		break;
972 	}
973 }
974 
signal()975 void Scene560::Action3::signal() {
976 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
977 
978 	switch (_actionIndex++) {
979 	case 0:
980 		BF_GLOBALS._player.disableControl();
981 		setDelay(10);
982 		break;
983 	case 1:
984 		if (scene->_field380) {
985 			setDelay(10);
986 		} else {
987 			setAction(&scene->_action1, this);
988 		}
989 		break;
990 	case 2:
991 		BF_GLOBALS._sceneManager.changeScene(570);
992 		break;
993 	default:
994 		break;
995 	}
996 }
997 
998 /*--------------------------------------------------------------------------*/
999 
startAction(CursorType action,Event & event)1000 bool Scene560::PicturePart::startAction(CursorType action, Event &event) {
1001 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
1002 
1003 	switch (action) {
1004 	case CURSOR_LOOK:
1005 		if (scene->_field380) {
1006 			SceneItem::display2(560, 54);
1007 		} else if ((scene->_sceneMode != 4) && (scene->_sceneMode != 3)) {
1008 			scene->_sceneMode = _flag + 4;
1009 			PlayerMover *mover = new PlayerMover();
1010 			Common::Point destPos(139, 106);
1011 			BF_GLOBALS._player.addMover(mover, &destPos, scene);
1012 		}
1013 		return true;
1014 	default:
1015 		return NamedHotspotExt::startAction(action, event);
1016 	}
1017 }
1018 
1019 /*--------------------------------------------------------------------------*/
1020 
startAction(CursorType action,Event & event)1021 bool Scene560::DeskChair::startAction(CursorType action, Event &event) {
1022 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
1023 
1024 	if ((action == CURSOR_USE) && !scene->_field380) {
1025 		scene->setAction(&scene->_action1);
1026 		return true;
1027 	} else {
1028 		return NamedObject::startAction(action, event);
1029 	}
1030 }
1031 
startAction(CursorType action,Event & event)1032 bool Scene560::Box::startAction(CursorType action, Event &event) {
1033 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
1034 
1035 	switch (action) {
1036 	case CURSOR_USE:
1037 		if (scene->_field380) {
1038 			SceneItem::display2(560, 54);
1039 		} else {
1040 			scene->_sceneMode = 9;
1041 			Common::Point destPos(289, 108);
1042 			PlayerMover *mover = new PlayerMover();
1043 			BF_GLOBALS._player.addMover(mover, &destPos, scene);
1044 		}
1045 		return true;
1046 	default:
1047 		return NamedObjectExt::startAction(action, event);
1048 	}
1049 }
1050 
postInit(SceneObjectList * OwnerList)1051 void Scene560::SafeInset::postInit(SceneObjectList *OwnerList) {
1052 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
1053 	FocusObject::postInit();
1054 
1055 	_cursorVisage.setVisage(1, 5);
1056 
1057 	if (BF_GLOBALS._safeCombination == 172) {
1058 		setFrame(2);
1059 		if (BF_INVENTORY.getObjectScene(INV_NICKEL) == 560) {
1060 			scene->_nickel.postInit();
1061 			scene->_nickel.setVisage(560);
1062 			scene->_nickel.setStrip(2);
1063 			scene->_nickel.setFrame(3);
1064 			scene->_nickel.fixPriority(252);
1065 			scene->_nickel.setPosition(Common::Point(181, 140));
1066 			scene->_nickel.setDetails(560, 47, 48, -1, 1, (SceneItem *)NULL);
1067 			BF_GLOBALS._sceneItems.remove(&scene->_nickel);
1068 			BF_GLOBALS._sceneItems.push_front(&scene->_nickel);
1069 		}
1070 	} else {
1071 		setFrame(1);
1072 		_item1.setDetails(Rect(143, 68, 159, 85), 560, 49, 50, -1, 1, NULL);
1073 		_item2.setDetails(Rect(159, 68, 175, 85), 560, 49, 50, -1, 1, NULL);
1074 		_item3.setDetails(Rect(175, 68, 191, 85), 560, 49, 50, -1, 1, NULL);
1075 		_item4.setDetails(Rect(143, 86, 159, 102), 560, 49, 50, -1, 1, NULL);
1076 		_item5.setDetails(Rect(159, 86, 175, 102), 560, 49, 50, -1, 1, NULL);
1077 		_item6.setDetails(Rect(175, 86, 191, 102), 560, 49, 50, -1, 1, NULL);
1078 
1079 		BF_GLOBALS._sceneItems.remove(&_item1);
1080 		BF_GLOBALS._sceneItems.remove(&_item2);
1081 		BF_GLOBALS._sceneItems.remove(&_item3);
1082 		BF_GLOBALS._sceneItems.remove(&_item4);
1083 		BF_GLOBALS._sceneItems.remove(&_item5);
1084 		BF_GLOBALS._sceneItems.remove(&_item6);
1085 		BF_GLOBALS._sceneItems.push_front(&_item6);
1086 		BF_GLOBALS._sceneItems.push_front(&_item5);
1087 		BF_GLOBALS._sceneItems.push_front(&_item4);
1088 		BF_GLOBALS._sceneItems.push_front(&_item3);
1089 		BF_GLOBALS._sceneItems.push_front(&_item2);
1090 		BF_GLOBALS._sceneItems.push_front(&_item1);
1091 
1092 		_item1._flag = 1;
1093 		_item2._flag = 2;
1094 		_item3._flag = 3;
1095 		_item4._flag = 4;
1096 		_item5._flag = 5;
1097 		_item6._flag = 6;
1098 
1099 		_digit2.postInit();
1100 		_digit2.setVisage(560);
1101 		_digit2.setStrip(3);
1102 		_digit2.setPosition(Common::Point(151, 94));
1103 		_digit2.fixPriority(252);
1104 
1105 		_digit1.postInit();
1106 		_digit1.setVisage(560);
1107 		_digit1.setStrip(3);
1108 		_digit1.setPosition(Common::Point(167, 94));
1109 		_digit1.fixPriority(252);
1110 
1111 		_digit0.postInit();
1112 		_digit0.setVisage(560);
1113 		_digit0.setStrip(3);
1114 		_digit0.setPosition(Common::Point(183, 94));
1115 		_digit0.fixPriority(252);
1116 
1117 		int amount = (BF_GLOBALS._safeCombination != 0) ? BF_GLOBALS._safeCombination : 1000;
1118 
1119 		// Get digit 0 portion
1120 		int remainder = amount % 10;
1121 		amount /= 10;
1122 		_digit0.setFrame(!remainder ? 10 : remainder);
1123 
1124 		// Get digit 1 portion
1125 		remainder = amount % 10;
1126 		amount /= 10;
1127 		_digit1.setFrame(!remainder ? 10 : remainder);
1128 
1129 		// Get digit 2 portion
1130 		remainder = amount % 10;
1131 		_digit2.setFrame(!remainder ? 10 : remainder);
1132 	}
1133 }
1134 
remove()1135 void Scene560::SafeInset::remove() {
1136 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
1137 
1138 	_item1.remove();
1139 	_item2.remove();
1140 	_item3.remove();
1141 	_item4.remove();
1142 	_item5.remove();
1143 	_item6.remove();
1144 	_digit2.remove();
1145 	_digit1.remove();
1146 	_digit0.remove();
1147 
1148 	scene->_nickel.remove();
1149 
1150 	if (BF_GLOBALS._events.getCursor() == CURSOR_USE) {
1151 		GfxSurface cursor = _cursorVisage.getFrame(2);
1152 		BF_GLOBALS._events.setCursor(cursor);
1153 	}
1154 
1155 	FocusObject::remove();
1156 }
1157 
signal()1158 void Scene560::SafeInset::signal() {
1159 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
1160 
1161 	// Recalculate the new total
1162 	int total = 0;
1163 	if (_digit2._frame < 10)
1164 		total = _digit2._frame * 100;
1165 	if (_digit1._frame < 10)
1166 		total += _digit1._frame * 10;
1167 	if (_digit0._frame < 10)
1168 		total += _digit0._frame;
1169 
1170 	BF_GLOBALS._safeCombination = !total ? 1000 : total;
1171 
1172 	// Check if the combination is correct
1173 	if (total == 172) {
1174 		BF_GLOBALS._sceneObjects->draw();
1175 
1176 		if (!BF_GLOBALS.getFlag(fGotPointsForBank)) {
1177 			T2_GLOBALS._uiElements.addScore(50);
1178 			BF_GLOBALS.setFlag(fGotPointsForBank);
1179 		}
1180 
1181 		setFrame(2);
1182 		GfxSurface cursor = _cursorVisage.getFrame(2);
1183 		BF_GLOBALS._events.setCursor(cursor);
1184 
1185 		_item1.remove();
1186 		_item2.remove();
1187 		_item3.remove();
1188 		_item4.remove();
1189 		_item5.remove();
1190 		_item6.remove();
1191 		_digit2.remove();
1192 		_digit1.remove();
1193 		_digit0.remove();
1194 
1195 		if (BF_INVENTORY.getObjectScene(INV_NICKEL) == 560) {
1196 			// Nickel is still in the safe, show it
1197 			scene->_nickel.postInit();
1198 			scene->_nickel.setVisage(560);
1199 			scene->_nickel.setStrip(2);
1200 			scene->_nickel.setFrame(3);
1201 			scene->_nickel.fixPriority(252);
1202 			scene->_nickel.setPosition(Common::Point(181, 140));
1203 			scene->_nickel.setDetails(560, 47, 48, -1, 1, (SceneItem *)NULL);
1204 			BF_GLOBALS._sceneItems.remove(&scene->_nickel);
1205 			BF_GLOBALS._sceneItems.push_front(&scene->_nickel);
1206 		}
1207 	}
1208 }
process(Event & event)1209 void Scene560::SafeInset::process(Event &event) {
1210 	if (_bounds.contains(event.mousePos)) {
1211 		CursorType cursorId = BF_GLOBALS._events.getCursor();
1212 		if (cursorId == CURSOR_USE) {
1213 			// Instead of standard cursor, use special hand cursor
1214 			GfxSurface cursor = _cursorVisage.getFrame(6);
1215 			BF_GLOBALS._events.setCursor(cursor);
1216 		} else {
1217 			// Set cursor again just in case Exit cursor was showing
1218 			BF_GLOBALS._events.setCursor(cursorId);
1219 		}
1220 
1221 		if ((event.eventType == EVENT_BUTTON_DOWN) && (BF_GLOBALS._events.getCursor() == CURSOR_WALK) &&
1222 				(event.btnState == BTNSHIFT_RIGHT)) {
1223 			BF_GLOBALS._events.setCursor(CURSOR_USE);
1224 			event.handled = true;
1225 		}
1226 	} else {
1227 		GfxSurface cursor = _cursorVisage.getFrame(7);
1228 		BF_GLOBALS._events.setCursor(cursor);
1229 
1230 		if ((event.mousePos.y < UI_INTERFACE_Y) && (event.eventType == EVENT_BUTTON_DOWN)) {
1231 			// Leave the safe view
1232 			event.handled = true;
1233 			remove();
1234 		}
1235 	}
1236 }
1237 
startAction(CursorType action,Event & event)1238 bool Scene560::SafeInset::Item::startAction(CursorType action, Event &event) {
1239 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
1240 
1241 	switch (action) {
1242 	case CURSOR_USE:
1243 		switch (_flag) {
1244 		case 1: {
1245 			int newFrame = scene->_safeInset._digit2._frame + 1;
1246 			if (newFrame == 11)
1247 				newFrame = 1;
1248 
1249 			scene->_safeInset._digit2.setFrame(newFrame);
1250 			break;
1251 		}
1252 		case 2: {
1253 			int newFrame = scene->_safeInset._digit1._frame + 1;
1254 			if (newFrame == 11)
1255 				newFrame = 1;
1256 
1257 			scene->_safeInset._digit1.setFrame(newFrame);
1258 			break;
1259 		}
1260 		case 3: {
1261 			int newFrame = scene->_safeInset._digit0._frame + 1;
1262 			if (newFrame == 11)
1263 				newFrame = 1;
1264 
1265 			scene->_safeInset._digit0.setFrame(newFrame);
1266 			break;
1267 		}
1268 		case 4: {
1269 			int newFrame = scene->_safeInset._digit2._frame - 1;
1270 			if (newFrame == 0)
1271 				newFrame = 10;
1272 
1273 			scene->_safeInset._digit2.setFrame(newFrame);
1274 			break;
1275 		}
1276 		case 5: {
1277 			int newFrame = scene->_safeInset._digit1._frame - 1;
1278 			if (newFrame == 0)
1279 				newFrame = 10;
1280 
1281 			scene->_safeInset._digit1.setFrame(newFrame);
1282 			break;
1283 		}
1284 		case 6: {
1285 			int newFrame = scene->_safeInset._digit0._frame - 1;
1286 			if (newFrame == 0)
1287 				newFrame = 10;
1288 
1289 			scene->_safeInset._digit0.setFrame(newFrame);
1290 			break;
1291 		}
1292 		default:
1293 			break;
1294 		}
1295 
1296 		scene->_safeInset.signal();
1297 		scene->_sound1.play(75);
1298 		return true;
1299 	default:
1300 		return NamedHotspotExt::startAction(action, event);
1301 	}
1302 }
1303 
startAction(CursorType action,Event & event)1304 bool Scene560::Nickel::startAction(CursorType action, Event &event) {
1305 	if (action == CURSOR_USE) {
1306 		BF_INVENTORY.setObjectScene(INV_NICKEL, 1);
1307 		T2_GLOBALS._uiElements.addScore(10);
1308 		remove();
1309 		return true;
1310 	} else {
1311 		return NamedObject::startAction(action, event);
1312 	}
1313 }
1314 
postInit(SceneObjectList * OwnerList)1315 void Scene560::BoxInset::postInit(SceneObjectList *OwnerList) {
1316 	FocusObject::postInit();
1317 	_item1.setDetails(Rect(110, 48, 189, 102), 560, 43, 44, -1, 1, NULL);
1318 	BF_GLOBALS._sceneItems.remove(&_item1);
1319 	BF_GLOBALS._sceneItems.push_front(&_item1);
1320 }
1321 
remove()1322 void Scene560::BoxInset::remove() {
1323 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
1324 
1325 	if (scene->_sceneMode != 3)
1326 		scene->_sceneMode = 0;
1327 
1328 	_item1.remove();
1329 	FocusObject::remove();
1330 }
1331 
startAction(CursorType action,Event & event)1332 bool Scene560::BoxInset::Item1::startAction(CursorType action, Event &event) {
1333 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
1334 
1335 	if (action == CURSOR_USE) {
1336 		if (!BF_GLOBALS.getFlag(fGotPointsForBox)) {
1337 			T2_GLOBALS._uiElements.addScore(10);
1338 			BF_GLOBALS.setFlag(fGotPointsForBox);
1339 		}
1340 
1341 		scene->_safeInset.postInit();
1342 		scene->_safeInset.setVisage(560);
1343 		scene->_safeInset.setStrip(2);
1344 		scene->_safeInset.setPosition(Common::Point(160, 141));
1345 		scene->_safeInset.fixPriority(251);
1346 		scene->_safeInset.setDetails(560, 45, 46, -1);
1347 
1348 		scene->_sceneMode = 3;
1349 		scene->_boxInset.remove();
1350 
1351 		GfxSurface cursor = surfaceFromRes(1, 5, 6);
1352 		BF_GLOBALS._events.setCursor(cursor);
1353 		return true;
1354 	} else {
1355 		return NamedHotspot::startAction(action, event);
1356 	}
1357 }
1358 
1359 /*--------------------------------------------------------------------------*/
1360 
startAction(CursorType action,Event & event)1361 bool Scene560::Computer::startAction(CursorType action, Event &event) {
1362 	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene;
1363 
1364 	switch (action) {
1365 	case CURSOR_USE:
1366 		if (BF_GLOBALS._bookmark < bTalkedToGrannyAboutSkipsCard) {
1367 			SceneItem::display2(666, 24);
1368 		} else {
1369 			scene->setAction(&scene->_action3);
1370 		}
1371 		return true;
1372 	default:
1373 		return NamedHotspot::startAction(action, event);
1374 	}
1375 }
1376 
1377 /*--------------------------------------------------------------------------*/
1378 
Scene560()1379 Scene560::Scene560(): SceneExt() {
1380 	_field380 = _field11EA = false;
1381 }
1382 
postInit(SceneObjectList * OwnerList)1383 void Scene560::postInit(SceneObjectList *OwnerList) {
1384 	SceneExt::postInit();
1385 	loadScene(560);
1386 	setZoomPercents(100, 60, 168, 90);
1387 	_stripManager.addSpeaker(&_gameTextSpeaker);
1388 
1389 	_picture1.setDetails(Rect(121, 16, 139, 35), 560, -1, -1, -1, 1, NULL);
1390 	_picture2.setDetails(Rect(139, 16, 157, 35), 560, -1, -1, -1, 1, NULL);
1391 	_picture3.setDetails(Rect(121, 35, 139, 54), 560, -1, -1, -1, 1, NULL);
1392 	_picture4.setDetails(Rect(139, 35, 157, 54), 560, -1, -1, -1, 1, NULL);
1393 	_picture1._flag = 3;
1394 	_picture2._flag = 4;
1395 	_picture3._flag = 2;
1396 	_picture4._flag = 1;
1397 
1398 	if (BF_GLOBALS._dayNumber == 0)
1399 		BF_GLOBALS._dayNumber = 3;
1400 
1401 	if (BF_GLOBALS._bookmark >= bTalkedToGrannyAboutSkipsCard) {
1402 		_box.postInit();
1403 		_box.setVisage(560);
1404 		_box.setStrip(4);
1405 		_box.setFrame(1);
1406 		_box.setPosition(Common::Point(295, 37));
1407 		_box.setDetails(560, 41, 42, -1, 1, (SceneItem *)NULL);
1408 	}
1409 
1410 	_deskChair.postInit();
1411 	_deskChair.setVisage(561);
1412 	_deskChair.setStrip(3);
1413 	_deskChair.setPosition(Common::Point(81, 149));
1414 	_deskChair.fixPriority(151);
1415 	_deskChair.changeZoom(81);
1416 
1417 	if (BF_GLOBALS._sceneManager._previousScene == 570) {
1418 		// Returning from using computer
1419 		BF_GLOBALS._events.setCursor(CURSOR_USE);
1420 
1421 		_deskChair.hide();
1422 
1423 		BF_GLOBALS._player.postInit();
1424 		BF_GLOBALS._player.setVisage(561);
1425 		BF_GLOBALS._player.setStrip(2);
1426 		BF_GLOBALS._player.setFrame(BF_GLOBALS._player.getFrameCount());
1427 		BF_GLOBALS._player._moveDiff.x = 11;
1428 		BF_GLOBALS._player.setPosition(Common::Point(96, 138));
1429 		BF_GLOBALS._player.changeZoom(81);
1430 
1431 		_deskChair.setFrame(BF_GLOBALS._player._frame);
1432 		_deskChair.setStrip(BF_GLOBALS._player._strip);
1433 		_deskChair.setPosition(BF_GLOBALS._player._position);
1434 
1435 		_field11EA = false;
1436 		_field380 = true;
1437 	} else {
1438 		// Entering study through doorway
1439 		_field11EA = false;
1440 		_field380 = false;
1441 
1442 		BF_GLOBALS._player.postInit();
1443 		BF_GLOBALS._player.setVisage(563);
1444 		BF_GLOBALS._player.animate(ANIM_MODE_1, NULL);
1445 		BF_GLOBALS._player.setObjectWrapper(new SceneObjectWrapper());
1446 		BF_GLOBALS._player.setPosition(Common::Point(79, 110));
1447 		BF_GLOBALS._player._moveDiff.x = 11;
1448 		BF_GLOBALS._player.changeZoom(-1);
1449 		BF_GLOBALS._player.disableControl();
1450 
1451 		_sceneMode = 10;
1452 		ADD_MOVER(BF_GLOBALS._player, 85, 115);
1453 	}
1454 
1455 	_computer.setDetails(Rect(16, 77, 58, 107), 560, 2, -1, -1, 1, NULL);
1456 	_deskChair.setDetails(560, 3, -1, -1, 1, (SceneItem *)NULL);
1457 	_chair.setDetails(Rect(163, 64, 196, 102), 560, 13, 25, 36, 1, NULL);
1458 	_lamp.setDetails(Rect(197, 43, 214, 56), 560, 7, 19, 30, 1, NULL);
1459 	_item4.setDetails(Rect(121, 18, 156, 54), 560, 8, 20, 31, 1, NULL);
1460 	_trophy.setDetails(Rect(259, 52, 275, 63), 560, 10, 22, 33, 1, NULL);
1461 	_waterColors.setDetails(Rect(214, 48, 239, 64), 560, 12, 24, 35, 1, NULL);
1462 	_fileCabinets.setDetails(Rect(0, 47, 49, 100), 560, 14, 26, 37, 1, NULL);
1463 	_certificate.setDetails(Rect(280, 51, 292, 62), 560, 11, 23, 34, 1, NULL);
1464 	_bookcase.setDetails(Rect(176, 0, 319, 103), 560, 9, 21, 32, 1, NULL);
1465 	_desk.setDetails(1, 560, 6, 10, 29, 1);
1466 	_item12.setDetails(Rect(62, 16, 96, 101), 560, 51, 52, 53, 1, NULL);
1467 	_carpet.setDetails(Rect(0, 103, 319, 167), 560, 5, 16, 28, 1, NULL);
1468 	_office.setDetails(Rect(0, 0, 320, 168), 560, 4, -1, -1, 1, NULL);
1469 
1470 	BF_GLOBALS._player.enableControl();
1471 }
1472 
signal()1473 void Scene560::signal() {
1474 	switch (_sceneMode) {
1475 	case 1:
1476 		_object6.hide();
1477 		_object6.remove();
1478 		BF_GLOBALS._player.enableControl();
1479 		break;
1480 	case 5:
1481 	case 6:
1482 	case 7:
1483 	case 8:
1484 		BF_GLOBALS._player._strip = 4;
1485 		BF_GLOBALS._player._frame = 1;
1486 		BF_GLOBALS._player.disableControl();
1487 
1488 		_object6.postInit();
1489 		_object6.setVisage(560);
1490 		_object6.setStrip(1);
1491 		_object6.setFrame(_sceneMode - 4);
1492 		_object6.setPosition(Common::Point(160, 141));
1493 		_object6.fixPriority(250);
1494 		_stripManager.start(_sceneMode + 5595, this);
1495 		_sceneMode = 1;
1496 		break;
1497 	case 9:
1498 		// Clicked on the Baseball Cards Box
1499 		_object6._strip = 4;
1500 		_object6._frame = 1;
1501 
1502 		if (BF_GLOBALS._safeCombination == 172) {
1503 			if (_sceneMode != 3) {
1504 				_safeInset.postInit();
1505 				_safeInset.setVisage(560);
1506 				_safeInset.setStrip(2);
1507 				_safeInset.setPosition(Common::Point(160, 141));
1508 				_safeInset.fixPriority(251);
1509 				_safeInset.setDetails(560, 45, 46, -1);
1510 
1511 				_sceneMode = 3;
1512 			}
1513 		} else if ((_sceneMode != 3) && (_sceneMode != 4)) {
1514 			if (!BF_GLOBALS.getFlag(fGotPointsForPunch)) {
1515 				T2_GLOBALS._uiElements.addScore(10);
1516 				BF_GLOBALS.setFlag(fGotPointsForPunch);
1517 			}
1518 
1519 			_boxInset.postInit();
1520 			_boxInset.setVisage(560);
1521 			_boxInset.setStrip(2);
1522 			_boxInset.setFrame(4);
1523 			_boxInset.setPosition(Common::Point(160, 141));
1524 			_boxInset.fixPriority(251);
1525 			_boxInset.setDetails(560, 43, 44, -1);
1526 
1527 			_sceneMode = 4;
1528 		}
1529 		break;
1530 	case 10:
1531 		_field11EA = false;
1532 		BF_GLOBALS._player.enableControl();
1533 		break;
1534 	case 11:
1535 		BF_GLOBALS._sceneManager.changeScene(270);
1536 		break;
1537 	}
1538 }
1539 
process(Event & event)1540 void Scene560::process(Event &event) {
1541 	if ((event.eventType == EVENT_BUTTON_DOWN) && (BF_GLOBALS._events.getCursor() == CURSOR_WALK) &&
1542 			(_field380) && !_action) {
1543 		_destPosition = event.mousePos;
1544 		BF_GLOBALS._player.disableControl();
1545 		setAction(&_action2);
1546 
1547 		event.handled = true;
1548 	}
1549 
1550 	SceneExt::process(event);
1551 }
1552 
dispatch()1553 void Scene560::dispatch() {
1554 	if (!_field11EA && (BF_GLOBALS._player._position.y < 105)) {
1555 		_field11EA = true;
1556 		BF_GLOBALS._player.disableControl();
1557 		BF_GLOBALS._sceneManager.changeScene(270);
1558 	}
1559 
1560 	SceneExt::dispatch();
1561 }
1562 
1563 /*--------------------------------------------------------------------------
1564  * Scene 570 - Computer
1565  *
1566  *--------------------------------------------------------------------------*/
1567 
PasswordEntry()1568 Scene570::PasswordEntry::PasswordEntry(): EventHandler() {
1569 	_passwordStr = SCENE570_PASSWORD;
1570 }
1571 
synchronize(Serializer & s)1572 void Scene570::PasswordEntry::synchronize(Serializer &s) {
1573 	EventHandler::synchronize(s);
1574 	s.syncString(_entryBuffer);
1575 }
1576 
postInit(SceneObjectList * OwnerList)1577 void Scene570::PasswordEntry::postInit(SceneObjectList *OwnerList) {
1578 	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;
1579 
1580 	scene->_sceneMode = 10;
1581 	scene->_object3.setStrip(6);
1582 	scene->_object3.setFrame(1);
1583 	scene->_object3.fixPriority(3);
1584 
1585 	_passwordText._color1 = 22;
1586 	_passwordText._color2 = 9;
1587 	_passwordText._color3 = 9;
1588 	_passwordText._width = 128;
1589 	_passwordText._fontNumber = 9000;
1590 	_passwordText.setPosition(Common::Point(165, 40));
1591 	_passwordText.fixPriority(255);
1592 	_passwordText.setup(_passwordStr);
1593 
1594 	_entryText._color1 = 22;
1595 	_entryText._color2 = 9;
1596 	_entryText._color3 = 9;
1597 	_entryText._width = 128;
1598 	_entryText._fontNumber = 9000;
1599 	_entryText.setPosition(Common::Point(220, 40));
1600 	_entryText.fixPriority(255);
1601 	_entryText.setup(_entryBuffer);
1602 }
1603 
process(Event & event)1604 void Scene570::PasswordEntry::process(Event &event) {
1605 	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;
1606 	bool entryChanged = false;
1607 
1608 	switch (event.eventType) {
1609 	case EVENT_KEYPRESS: {
1610 		int key = toupper(event.kbd.ascii);
1611 		scene->_sound1.play(72);
1612 
1613 		if ((event.kbd.keycode == Common::KEYCODE_BACKSPACE) || (event.kbd.keycode == Common::KEYCODE_DELETE)) {
1614 			// Delete a key from the entry
1615 			if (_entryBuffer.size() > 0)
1616 				_entryBuffer.deleteLastChar();
1617 			entryChanged = true;
1618 		} else if (event.kbd.keycode == Common::KEYCODE_RETURN) {
1619 			// Finished entering password
1620 			_passwordText.remove();
1621 			_entryText.remove();
1622 
1623 			checkPassword();
1624 			remove();
1625 		} else if ((key >= 32) && (key <= 126)) {
1626 			// Valid character pressed
1627 			if (_entryBuffer.size() < 10)
1628 				_entryBuffer += (char)key;
1629 			event.handled = true;
1630 			entryChanged = true;
1631 		}
1632 		break;
1633 	}
1634 	case EVENT_BUTTON_DOWN:
1635 		event.handled = true;
1636 		break;
1637 	default:
1638 		break;
1639 	}
1640 
1641 	if (entryChanged) {
1642 		_entryText._color1 = 22;
1643 		_entryText._color2 = 9;
1644 		_entryText._color3 = 9;
1645 		_entryText._width = 128;
1646 		_entryText._fontNumber = 9000;
1647 		_entryText.setPosition(Common::Point(213, 40));
1648 		_entryText.fixPriority(255);
1649 		_entryText.setup(_entryBuffer);
1650 
1651 		// Pad entered text with spaces to make up the allowed width and then display
1652 		Common::String msg = _entryBuffer;
1653 		while (msg.size() < 10)
1654 			msg += " ";
1655 		_entryText.setup(msg);
1656 	}
1657 }
1658 
checkPassword()1659 void Scene570::PasswordEntry::checkPassword() {
1660 	// Check if the password is correctly entered as 'JACKIE' or, as a nod to the
1661 	// reimplementation in ScummVM, as the project name.
1662 	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;
1663 
1664 	if (!_entryBuffer.compareTo("JACKIE") || !_entryBuffer.compareTo("SCUMMVM")) {
1665 		// Password was correct
1666 		T2_GLOBALS._uiElements.addScore(30);
1667 		BF_GLOBALS._player.disableControl();
1668 		scene->_sound1.play(73);
1669 
1670 		T2_GLOBALS._uiElements.hide();
1671 		T2_GLOBALS._uiElements._active = false;
1672 		scene->_sceneMode = 5701;
1673 		scene->setAction(&scene->_sequenceManager, scene, 5701, &scene->_object3, NULL);
1674 	} else {
1675 		// Password was incorrect
1676 		_entryBuffer = "";
1677 
1678 		scene->_object3.fixPriority(1);
1679 		scene->_iconManager.refreshList();
1680 		BF_GLOBALS._events.setCursor(CURSOR_USE);
1681 		scene->_sceneMode = 0;
1682 	}
1683 }
1684 
IconManager()1685 Scene570::IconManager::IconManager(): EventHandler() {
1686 	_mode = _selectedFolder = _fieldAA = _fieldAC = 0;
1687 }
1688 
remove()1689 void Scene570::IconManager::remove() {
1690 	_object1.remove();
1691 	EventHandler::remove();
1692 }
1693 
setup(int mode)1694 void Scene570::IconManager::setup(int mode) {
1695 	_mode = mode;
1696 	_selectedFolder = 0;
1697 
1698 	_object1.postInit();
1699 	_object1.setVisage(572);
1700 	_object1.fixPriority(2);
1701 	_object1.setFrame((mode == 1) ? 4 : 5);
1702 	EventHandler::postInit();
1703 }
1704 
hideList()1705 void Scene570::IconManager::hideList() {
1706 	SynchronizedList<Icon *>::iterator i;
1707 	for (i = _list.begin(); i != _list.end(); ++i) {
1708 		(*i)->_sceneText.remove();
1709 	}
1710 }
1711 
refreshList()1712 void Scene570::IconManager::refreshList() {
1713 	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;
1714 
1715 	_object1.setPosition(Common::Point(163, 19));
1716 	scene->_object3.setStrip(4);
1717 
1718 	// Clear any current icons
1719 	SynchronizedList<Icon *>::iterator i;
1720 	for (i = _list.begin(); i != _list.end(); ++i) {
1721 		Icon *item = *i;
1722 
1723 		item->setVisage(572);
1724 		item->setStrip(1);
1725 		item->fixPriority(2);
1726 		item->setPosition(Common::Point(330, 100));
1727 		item->_sceneText.remove();
1728 	}
1729 
1730 	// Refresh the list
1731 	int iconIndex = 0, folderIndex = 0;
1732 	for (i = _list.begin(); i != _list.end(); ++i) {
1733 		Icon *item = *i;
1734 
1735 		if (item->_iconId == 1) {
1736 			// Folder
1737 			int parentId = item->_parentFolderId;
1738 			item->setFrame((_selectedFolder == (item->_folderId - 1)) ? 1 : 8);
1739 			item->setPosition(Common::Point(168 + parentId * 11, folderIndex * 8 + 27));
1740 			item->_sceneText.setPosition(Common::Point(175 + parentId * 11, folderIndex * 8 + 21));
1741 			item->_sceneText.setup(item->_text);
1742 			++folderIndex;
1743 		} else if (item->_parentFolderId == _selectedFolder) {
1744 			item->setPosition(Common::Point(229, 27 + iconIndex * 12));
1745 
1746 			switch (item->_iconId) {
1747 			case 2:
1748 				item->setFrame(9);
1749 				break;
1750 			case 3:
1751 				item->setFrame(7);
1752 				break;
1753 			case 5:
1754 				item->setFrame(10);
1755 				break;
1756 			case 6:
1757 				item->setFrame(11);
1758 				break;
1759 			case 7:
1760 				item->setFrame(12);
1761 				break;
1762 			default:
1763 				break;
1764 			}
1765 
1766 			item->_sceneText.setPosition(Common::Point(236, iconIndex * 12 + 22));
1767 			item->_sceneText.setup(item->_text);
1768 			++iconIndex;
1769 		}
1770 	}
1771 }
1772 
addItem(Icon * item)1773 void Scene570::IconManager::addItem(Icon *item) {
1774 	_list.push_back(item);
1775 }
1776 
Icon()1777 Scene570::Icon::Icon(): NamedObject() {
1778 	_iconId = _folderId = 0;
1779 	_parentFolderId = 0;
1780 }
1781 
synchronize(Serializer & s)1782 void Scene570::Icon::synchronize(Serializer &s) {
1783 	NamedObject::synchronize(s);
1784 	s.syncAsSint16LE(_iconId);
1785 	s.syncAsSint16LE(_folderId);
1786 	s.syncAsSint16LE(_parentFolderId);
1787 	if (s.getVersion() < 11) {
1788 		int useless = 0;
1789 		s.syncAsSint16LE(useless);
1790 	}
1791 }
1792 
remove()1793 void Scene570::Icon::remove() {
1794 	_sceneText.remove();
1795 	NamedObject::remove();
1796 }
1797 
startAction(CursorType action,Event & event)1798 bool Scene570::Icon::startAction(CursorType action, Event &event) {
1799 	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;
1800 
1801 	switch (action) {
1802 	case CURSOR_LOOK:
1803 		switch (_iconId) {
1804 		case 1:
1805 			SceneItem::display2(570, 9);
1806 			break;
1807 		case 2:
1808 			SceneItem::display2(570, 10);
1809 			break;
1810 		case 3:
1811 			SceneItem::display2(570, 4);
1812 			break;
1813 		case 5:
1814 			SceneItem::display2(570, 11);
1815 			break;
1816 		case 6:
1817 			SceneItem::display2(570, 12);
1818 			break;
1819 		case 7:
1820 			SceneItem::display2(570, 13);
1821 			break;
1822 		default:
1823 			break;
1824 		}
1825 		return true;
1826 	case CURSOR_USE:
1827 		// Select the given icon
1828 		scene->_sound1.play(73);
1829 		switch (_iconId) {
1830 		case 1:
1831 			// Folder, so select it
1832 			scene->_iconManager._selectedFolder = _folderId - 1;
1833 			scene->_iconManager.refreshList();
1834 			break;
1835 		case 2:
1836 			scene->_iconManager.hideList();
1837 			scene->_sceneMode = 5702;
1838 			scene->setAction(&scene->_sequenceManager, scene, 5702, &scene->_object3, NULL);
1839 			break;
1840 		case 3:
1841 			scene->_iconManager.hideList();
1842 			scene->_passwordEntry.postInit();
1843 			break;
1844 		case 5:
1845 			SceneItem::display2(570, 5);
1846 			break;
1847 		case 6:
1848 			scene->_iconManager.hideList();
1849 			switch (_folderId) {
1850 			case 8:
1851 				T2_GLOBALS._uiElements.hide();
1852 				T2_GLOBALS._uiElements._active = false;
1853 				scene->_sceneMode = 5705;
1854 				scene->setAction(&scene->_sequenceManager, scene, 5705, &scene->_object3, NULL);
1855 				break;
1856 			case 10:
1857 				T2_GLOBALS._uiElements.hide();
1858 				T2_GLOBALS._uiElements._active = false;
1859 				scene->_sceneMode = 5706;
1860 				scene->setAction(&scene->_sequenceManager, scene, 5706, &scene->_object3, NULL);
1861 				break;
1862 			case 12:
1863 				T2_GLOBALS._uiElements.hide();
1864 				T2_GLOBALS._uiElements._active = false;
1865 				scene->_sceneMode = 5707;
1866 				scene->setAction(&scene->_sequenceManager, scene, 5707, &scene->_object3, NULL);
1867 				break;
1868 			default:
1869 				break;
1870 			}
1871 			break;
1872 		case 7:
1873 			scene->_iconManager.hideList();
1874 			T2_GLOBALS._uiElements.hide();
1875 			T2_GLOBALS._uiElements._active = false;
1876 			scene->_sceneMode = 5704;
1877 			scene->setAction(&scene->_sequenceManager, scene, 5704, &scene->_object3, NULL);
1878 			break;
1879 		}
1880 		return true;
1881 	case CURSOR_TALK:
1882 		SceneItem::display2(570, 15);
1883 		return true;
1884 	case CURSOR_PRINTER:
1885 		switch (_iconId) {
1886 		case 1:
1887 			// Folder - "You can't print that"
1888 			SceneItem::display2(570, 8);
1889 			break;
1890 		case 7:
1891 			scene->_sound1.play(74);
1892 			if (BF_INVENTORY.getObjectScene(INV_PRINT_OUT) == 570) {
1893 				SceneItem::display2(570, 6);
1894 				T2_GLOBALS._uiElements.addScore(30);
1895 				BF_INVENTORY.setObjectScene(INV_PRINT_OUT, 1);
1896 			} else {
1897 				SceneItem::display2(570, 7);
1898 			}
1899 			break;
1900 		default:
1901 			// You don't want to print that
1902 			SceneItem::display2(570, 18);
1903 			break;
1904 		}
1905 		return true;
1906 	default:
1907 		return NamedObject::startAction(action, event);
1908 	}
1909 }
1910 
setDetails(int iconId,int folderId,int parentFolderId,const Common::String & msg)1911 void Scene570::Icon::setDetails(int iconId, int folderId, int parentFolderId, const Common::String &msg) {
1912 	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;
1913 	NamedObject::postInit();
1914 
1915 	_iconId = iconId;
1916 	_folderId = folderId;
1917 	_parentFolderId = parentFolderId;
1918 	_text = msg;
1919 
1920 	_sceneText._color1 = 22;
1921 	_sceneText._color2 = 9;
1922 	_sceneText._color3 = 9;
1923 	_sceneText._width = 128;
1924 	_sceneText._fontNumber = 9000;
1925 	_sceneText.fixPriority(2);
1926 
1927 	BF_GLOBALS._sceneItems.push_front(this);
1928 	scene->_iconManager.addItem(this);
1929 }
1930 
1931 /*--------------------------------------------------------------------------*/
1932 
startAction(CursorType action,Event & event)1933 bool Scene570::PowerSwitch::startAction(CursorType action, Event &event) {
1934 	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;
1935 
1936 	switch (action) {
1937 	case CURSOR_USE:
1938 		if (scene->_object4._flag == 1) {
1939 			setFrame(1);
1940 			scene->_object3.remove();
1941 		} else {
1942 			if (!BF_GLOBALS.getFlag(fGotPointsForCoin)) {
1943 				T2_GLOBALS._uiElements.addScore(10);
1944 				BF_GLOBALS.setFlag(fGotPointsForCoin);
1945 			}
1946 
1947 			scene->_sound1.play(70);
1948 			scene->_object4._flag = 1;
1949 			setFrame(2);
1950 
1951 			scene->_object3.postInit();
1952 			scene->_object3.fixPriority(1);
1953 			scene->_object3.setDetails(570, 16, 15, 17);
1954 			BF_GLOBALS._sceneItems.remove(&scene->_object3);
1955 			BF_GLOBALS._sceneItems.push_front(&scene->_object3);
1956 
1957 			BF_GLOBALS._player.disableControl();
1958 			scene->_sceneMode = 5700;
1959 			setAction(&scene->_sequenceManager, scene, 5700, &scene->_object3, NULL);
1960 		}
1961 		return true;
1962 	default:
1963 		return NamedObject::startAction(action, event);
1964 	}
1965 }
1966 
startAction(CursorType action,Event & event)1967 bool Scene570::PrinterIcon::startAction(CursorType action, Event &event) {
1968 	if (action == CURSOR_USE) {
1969 		BF_GLOBALS._events.setCursor(CURSOR_PRINTER);
1970 		return true;
1971 	} else {
1972 		return NamedObject::startAction(action, event);
1973 	}
1974 }
1975 
remove()1976 void Scene570::Object3::remove() {
1977 	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;
1978 	scene->_object4._flag = 0;
1979 
1980 	scene->_printerIcon.remove();
1981 	scene->_iconManager.remove();
1982 	scene->_folder1.remove();
1983 	scene->_folder2.remove();
1984 	scene->_folder3.remove();
1985 	scene->_folder4.remove();
1986 	scene->_icon1.remove();
1987 	scene->_icon2.remove();
1988 	scene->_icon3.remove();
1989 	scene->_icon4.remove();
1990 	scene->_icon5.remove();
1991 	scene->_icon6.remove();
1992 	scene->_icon7.remove();
1993 	scene->_icon8.remove();
1994 	scene->_icon9.remove();
1995 
1996 	FocusObject::remove();
1997 	BF_GLOBALS._sceneManager.changeScene(560);
1998 }
1999 
2000 /*--------------------------------------------------------------------------*/
2001 
startAction(CursorType action,Event & event)2002 bool Scene570::FloppyDrive::startAction(CursorType action, Event &event) {
2003 	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;
2004 
2005 	switch (action) {
2006 	case CURSOR_USE:
2007 		if (BF_INVENTORY.getObjectScene(INV_D_FLOPPY) == 571) {
2008 			BF_INVENTORY.setObjectScene(INV_D_FLOPPY, 1);
2009 			scene->_iconManager.refreshList();
2010 			SceneItem::display2(570, 2);
2011 		} else {
2012 			SceneItem::display2(570, 3);
2013 		}
2014 		return true;
2015 	case INV_D_FLOPPY:
2016 		BF_INVENTORY.setObjectScene(INV_D_FLOPPY, 571);
2017 		scene->_iconManager.refreshList();
2018 		return true;
2019 	default:
2020 		return NamedHotspot::startAction(action, event);
2021 	}
2022 }
2023 
2024 /*--------------------------------------------------------------------------*/
2025 
postInit(SceneObjectList * OwnerList)2026 void Scene570::postInit(SceneObjectList *OwnerList) {
2027 	SceneExt::postInit();
2028 	loadScene(570);
2029 
2030 	_stripManager.addSpeaker(&_gameTextSpeaker);
2031 	if (BF_GLOBALS._dayNumber == 0)
2032 		BF_GLOBALS._dayNumber = 1;
2033 
2034 	_object4._flag = 0;
2035 	BF_GLOBALS._player.postInit();
2036 	BF_GLOBALS._player.enableControl();
2037 	BF_GLOBALS._player.hide();
2038 
2039 	_powerSwitch.postInit();
2040 	_powerSwitch.setVisage(570);
2041 	_powerSwitch.setStrip(4);
2042 	_powerSwitch.setFrame(1);
2043 	_powerSwitch.setPosition(Common::Point(163, 131));
2044 	_powerSwitch.setDetails(570, 1, 15, -1, 1, (SceneItem *)NULL);
2045 
2046 	_floppyDrive.setDetails(Rect(258, 111, 303, 120), 570, 0, 15, -1, 1, NULL);
2047 	_item11.setDetails(0, 570, 15, 15, 15, 1);
2048 	_monitor.setDetails(1, 570, 19, 20, 21, 1);
2049 	_item3.setDetails(2, 570, 22, 23, 24, 1);
2050 	_case.setDetails(3, 570, 25, 26, 27, 1);
2051 	_keyboard.setDetails(4, 570, 28, 29, 30, 1);
2052 	_desk.setDetails(5, 570, 31, 32, 33, 1);
2053 	_printer.setDetails(7, 570, 37, 38, 39, 1);
2054 	_window.setDetails(8, 570, 40, 41, 42, 1);
2055 	_plant.setDetails(9, 570, 43, 44, 45, 1);
2056 
2057 	if ((BF_GLOBALS._dayNumber == 1) && (BF_INVENTORY.getObjectScene(INV_CRATE1) == 1)) {
2058 		_object4.postInit();
2059 		_object4.setVisage(574);
2060 		_object4.setPosition(Common::Point(90, 84));
2061 	}
2062 }
2063 
signal()2064 void Scene570::signal() {
2065 	switch (_sceneMode) {
2066 	case 5700:
2067 		_object3.setStrip(4);
2068 		_object3.setFrame(1);
2069 
2070 		_printerIcon.postInit();
2071 		_printerIcon.setVisage(572);
2072 		_printerIcon.setFrame(3);
2073 		_printerIcon.setPosition(Common::Point(172, 71));
2074 		_printerIcon.fixPriority(2);
2075 		_printerIcon.setDetails(570, 14, 15, -1, 2, (SceneItem *)NULL);
2076 
2077 		_iconManager.setup(2);
2078 		_folder1.setDetails(1, 1, 0, SCENE570_C_DRIVE);
2079 		_folder2.setDetails(1, 2, 1, SCENE570_RING);
2080 		_folder3.setDetails(1, 3, 1, SCENE570_PROTO);
2081 		_folder4.setDetails(1, 4, 1, SCENE570_WACKY);
2082 
2083 		if (!BF_GLOBALS.getFlag(fDecryptedBluePrints))
2084 			_icon1.setDetails(3, 5, 0, SCENE570_COBB);
2085 		_icon2.setDetails(2, 7, 0, SCENE570_LETTER);
2086 		if (BF_GLOBALS.getFlag(fDecryptedBluePrints))
2087 			_icon3.setDetails(7, 6, 0, SCENE570_COBB);
2088 
2089 		_icon4.setDetails(6, 8, 1, SCENE570_RINGEXE);
2090 		_icon5.setDetails(5, 9, 1, SCENE570_RINGDATA);
2091 		_icon6.setDetails(6, 10, 2, SCENE570_PROTOEXE);
2092 		_icon7.setDetails(5, 11, 2, SCENE570_PROTODATA);
2093 		_icon8.setDetails(6, 12, 3, SCENE570_WACKYEXE);
2094 		_icon9.setDetails(5, 13, 3, SCENE570_WACKYDATA);
2095 
2096 		_iconManager.refreshList();
2097 		BF_GLOBALS._player.enableControl();
2098 		break;
2099 	case 5701:
2100 		BF_GLOBALS.setFlag(fDecryptedBluePrints);
2101 		_iconManager._list.remove(&_icon1);
2102 		_icon1.remove();
2103 
2104 		_object3.setVisage(572);
2105 		_object3.setStrip(4);
2106 		_object3.setFrame(1);
2107 		_object3.fixPriority(1);
2108 
2109 		_icon3.setDetails(7, 6, 0, SCENE570_COBB);
2110 		_iconManager.refreshList();
2111 		T2_GLOBALS._uiElements._active = true;
2112 		T2_GLOBALS._uiElements.show();
2113 		BF_GLOBALS._player.enableControl();
2114 		break;
2115 	case 5704:
2116 	case 5705:
2117 	case 5706:
2118 	case 5707:
2119 		T2_GLOBALS._uiElements._active = true;
2120 		T2_GLOBALS._uiElements.show();
2121 		_object3.setPosition(Common::Point(220, 75));
2122 		_object3.setVisage(572);
2123 		_object3.setStrip(4);
2124 		_object3.setFrame(1);
2125 		// fall through
2126 	case 5702:
2127 	case 5703:
2128 		_object3.fixPriority(1);
2129 		_iconManager.refreshList();
2130 		BF_GLOBALS._player.enableControl();
2131 		break;
2132 	default:
2133 		break;
2134 	}
2135 }
2136 
process(Event & event)2137 void Scene570::process(Event &event) {
2138 	SceneExt::process(event);
2139 
2140 	if (!event.handled && (_sceneMode == 10))
2141 		// Password entry active, so pass events to it
2142 		_passwordEntry.process(event);
2143 }
2144 
2145 /*--------------------------------------------------------------------------
2146  * Scene 580 - Child Protective Services Parking Lot
2147  *
2148  *--------------------------------------------------------------------------*/
2149 
startAction(CursorType action,Event & event)2150 bool Scene580::Vechile::startAction(CursorType action, Event &event) {
2151 	Scene580 *scene = (Scene580 *)BF_GLOBALS._sceneManager._scene;
2152 
2153 	if (action == CURSOR_USE) {
2154 		BF_GLOBALS._player.disableControl();
2155 		scene->_sceneMode = 1;
2156 		scene->setAction(&scene->_sequenceManager, scene, 5800, &BF_GLOBALS._player, NULL);
2157 		return true;
2158 	} else {
2159 		return NamedObject::startAction(action, event);
2160 	}
2161 }
2162 
startAction(CursorType action,Event & event)2163 bool Scene580::Door::startAction(CursorType action, Event &event) {
2164 	Scene580 *scene = (Scene580 *)BF_GLOBALS._sceneManager._scene;
2165 
2166 	if (action == CURSOR_USE) {
2167 		BF_GLOBALS._player.disableControl();
2168 		scene->_sceneMode = 5802;
2169 		scene->setAction(&scene->_sequenceManager, scene, 5802, &BF_GLOBALS._player, this, NULL);
2170 		return true;
2171 	} else {
2172 		return NamedObject::startAction(action, event);
2173 	}
2174 }
2175 
startAction(CursorType action,Event & event)2176 bool Scene580::Lyle::startAction(CursorType action, Event &event) {
2177 	if (action == CURSOR_LOOK) {
2178 		SceneItem::display2(580, 7);
2179 		return true;
2180 	} else {
2181 		return NamedObject::startAction(action, event);
2182 	}
2183 }
2184 
2185 /*--------------------------------------------------------------------------*/
2186 
postInit(SceneObjectList * OwnerList)2187 void Scene580::postInit(SceneObjectList *OwnerList) {
2188 	SceneExt::postInit();
2189 	loadScene(580);
2190 	setZoomPercents(45, 95, 55, 100);
2191 	BF_GLOBALS._sound1.changeSound(33);
2192 
2193 	if (BF_GLOBALS._dayNumber == 0)
2194 		BF_GLOBALS._dayNumber = 1;
2195 
2196 	BF_GLOBALS._player.postInit();
2197 	BF_GLOBALS._player.setObjectWrapper(new SceneObjectWrapper());
2198 	BF_GLOBALS._player.animate(ANIM_MODE_1, NULL);
2199 	BF_GLOBALS._player._moveDiff = Common::Point(2, 1);
2200 
2201 	_door.postInit();
2202 	_door.setVisage(580);
2203 	_door.setStrip(4);
2204 	_door.setPosition(Common::Point(168, 41));
2205 	_door.hide();
2206 	_door.setDetails(580, 5, -1, -1, 1, (SceneItem *)NULL);
2207 
2208 	_vechile.postInit();
2209 	_vechile.setVisage(580);
2210 	_vechile.fixPriority(65);
2211 
2212 	if (BF_GLOBALS.getFlag(fWithLyle)) {
2213 		_lyle.postInit();
2214 		_lyle.setVisage(835);
2215 		_lyle.setObjectWrapper(new SceneObjectWrapper());
2216 		_lyle.animate(ANIM_MODE_1, NULL);
2217 		_lyle._moveDiff = Common::Point(2, 1);
2218 		_lyle.setPosition(Common::Point(149, 70));
2219 		BF_GLOBALS._sceneItems.push_back(&_lyle);
2220 
2221 		_vechile.changeZoom(90);
2222 		_vechile.setStrip(3);
2223 		_vechile.setPosition(Common::Point(165, 76));
2224 		_vechile.setDetails(580, 2, 3, -1, 1, (SceneItem *)NULL);
2225 
2226 		BF_GLOBALS._player.setVisage(303);
2227 
2228 		BF_GLOBALS._walkRegions.disableRegion(8);
2229 		BF_GLOBALS._walkRegions.disableRegion(9);
2230 		BF_GLOBALS._walkRegions.disableRegion(10);
2231 		BF_GLOBALS._walkRegions.disableRegion(11);
2232 	} else {
2233 		_vechile.setPosition(Common::Point(159, 72));
2234 
2235 		if (BF_GLOBALS.getFlag(onDuty)) {
2236 			_vechile.setStrip(1);
2237 			_vechile.setFrame(2);
2238 			_vechile.setDetails(300, 11, 13, -1, 1, (SceneItem *)NULL);
2239 
2240 			BF_GLOBALS._player.setVisage(304);
2241 		} else {
2242 			_vechile.setStrip(2);
2243 			_vechile.setFrame(3);
2244 			_vechile.setDetails(580, 0, 1, -1, 1, (SceneItem *)NULL);
2245 
2246 			BF_GLOBALS._player.setVisage(303);
2247 		}
2248 	}
2249 
2250 	BF_GLOBALS._player.updateAngle(_vechile._position);
2251 
2252 	if (BF_GLOBALS._sceneManager._previousScene == 590) {
2253 		// Leaving Services
2254 		BF_GLOBALS._player.disableControl();
2255 		_sceneMode = 0;
2256 		setAction(&_sequenceManager, this, 5801, &BF_GLOBALS._player, NULL);
2257 	} else {
2258 		// Arriving at parking lot
2259 		BF_GLOBALS._player.setPosition(Common::Point(177, 58));
2260 		signal();
2261 	}
2262 
2263 	_item1.setDetails(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 580, 6, -1, -1, 1, NULL);
2264 }
2265 
signal()2266 void Scene580::signal() {
2267 	switch (_sceneMode) {
2268 	case 1:
2269 		BF_GLOBALS._sceneManager.changeScene(60);
2270 		break;
2271 	case 5802:
2272 		BF_GLOBALS._sound1.fadeOut2(NULL);
2273 		BF_GLOBALS._sceneManager.changeScene(590);
2274 		break;
2275 	default:
2276 		BF_GLOBALS._player.enableControl();
2277 		break;
2278 	}
2279 }
2280 
process(Event & event)2281 void Scene580::process(Event &event) {
2282 	if ((event.eventType == EVENT_BUTTON_DOWN) && (BF_GLOBALS._events.getCursor() == INV_COLT45) &&
2283 			BF_GLOBALS._player.contains(event.mousePos)) {
2284 		BF_GLOBALS._player.disableControl();
2285 		SceneItem::display2(350, 26);
2286 
2287 		_sceneMode = 0;
2288 		signal();
2289 		event.handled = true;
2290 	}
2291 }
2292 
2293 /*--------------------------------------------------------------------------
2294  * Scene 590 - Child Protective Services
2295  *
2296  *--------------------------------------------------------------------------*/
2297 
startAction(CursorType action,Event & event)2298 bool Scene590::Laura::startAction(CursorType action, Event &event) {
2299 	Scene590 *scene = (Scene590 *)BF_GLOBALS._sceneManager._scene;
2300 
2301 	switch (action) {
2302 	case CURSOR_TALK:
2303 		if (!scene->_field17DC)
2304 			scene->_stripNumber = 5905;
2305 		else if (!scene->_field17DE) {
2306 			if (scene->_field17E2) {
2307 				scene->_stripNumber = 5907;
2308 			} else {
2309 				scene->_field17E2 = 1;
2310 				scene->_stripNumber = 5906;
2311 			}
2312 		}
2313 
2314 		scene->setAction(&scene->_action1);
2315 		return true;
2316 	default:
2317 		return NamedObject::startAction(action, event);
2318 	}
2319 }
2320 
startAction(CursorType action,Event & event)2321 bool Scene590::Skip::startAction(CursorType action, Event &event) {
2322 	Scene590 *scene = (Scene590 *)BF_GLOBALS._sceneManager._scene;
2323 
2324 	switch (action) {
2325 	case CURSOR_TALK:
2326 		if (BF_INVENTORY.getObjectScene(INV_BASEBALL_CARD) == 1) {
2327 			scene->_stripNumber = !scene->_field17DC ? 5903 : 5902;
2328 		} else {
2329 			scene->_stripNumber = !scene->_field17DC ? 5901 : 5902;
2330 		}
2331 
2332 		scene->setAction(&scene->_action1);
2333 		scene->_field17DC = 1;
2334 		return true;
2335 	case INV_BASEBALL_CARD:
2336 		scene->_field17DE = 1;
2337 		T2_GLOBALS._uiElements.addScore(10);
2338 		BF_INVENTORY.setObjectScene(INV_BASEBALL_CARD, 2);
2339 		BF_GLOBALS._player.disableControl();
2340 
2341 		scene->_stripNumber = !scene->_field17DC ? 5900 : 5904;
2342 		scene->_field17DC = 1;
2343 		scene->setAction(&scene->_action2);
2344 		return true;
2345 	default:
2346 		return NamedObject::startAction(action, event);
2347 	}
2348 }
2349 
2350 /*--------------------------------------------------------------------------*/
2351 
startAction(CursorType action,Event & event)2352 bool Scene590::Exit::startAction(CursorType action, Event &event) {
2353 	ADD_PLAYER_MOVER(BF_GLOBALS._player._position.x - 100, BF_GLOBALS._player._position.y + 75);
2354 	return true;
2355 }
2356 
2357 /*--------------------------------------------------------------------------*/
2358 
signal()2359 void Scene590::Action1::signal() {
2360 	Scene590 *scene = (Scene590 *)BF_GLOBALS._sceneManager._scene;
2361 
2362 	switch (_actionIndex++) {
2363 	case 0:
2364 		BF_GLOBALS._player.disableControl();
2365 		BF_GLOBALS._player.animate(ANIM_MODE_1, NULL);
2366 		ADD_PLAYER_MOVER(220, 132);
2367 		break;
2368 	case 1:
2369 		scene->_stripManager.start(scene->_stripNumber, this);
2370 		break;
2371 	case 2:
2372 		BF_GLOBALS._player.enableControl();
2373 		remove();
2374 		break;
2375 	default:
2376 		break;
2377 	}
2378 }
2379 
signal()2380 void Scene590::Action2::signal() {
2381 	Scene590 *scene = (Scene590 *)BF_GLOBALS._sceneManager._scene;
2382 
2383 	switch (_actionIndex++) {
2384 	case 0: {
2385 		BF_GLOBALS._player.animate(ANIM_MODE_1, NULL);
2386 		ADD_PLAYER_MOVER_THIS(BF_GLOBALS._player, 220, 132);
2387 		break;
2388 	}
2389 	case 1:
2390 		ADD_PLAYER_MOVER_THIS(BF_GLOBALS._player, 220, 132);
2391 		break;
2392 	case 2:
2393 		BF_GLOBALS._player.setVisage(381);
2394 		BF_GLOBALS._player.setStrip(2);
2395 		BF_GLOBALS._player.setFrame(1);
2396 		BF_GLOBALS._player.setPosition(Common::Point(257, 130));
2397 		BF_GLOBALS._player.animate(ANIM_MODE_4, 3, 1, this);
2398 
2399 		scene->_skip.setStrip(2);
2400 		scene->_skip.animate(ANIM_MODE_5, NULL);
2401 		break;
2402 	case 3:
2403 		scene->_skip.animate(ANIM_MODE_6, NULL);
2404 		BF_GLOBALS._player.animate(ANIM_MODE_5, this);
2405 		break;
2406 	case 4:
2407 		scene->_skip.setStrip(1);
2408 		scene->_skip.animate(ANIM_MODE_1, NULL);
2409 
2410 		BF_GLOBALS._player.setVisage(368);
2411 		BF_GLOBALS._player.setStrip(7);
2412 		BF_GLOBALS._player.setPosition(Common::Point(238, 131));
2413 		BF_GLOBALS._player.animate(ANIM_MODE_1, NULL);
2414 		scene->_stripManager.start(scene->_stripNumber, this);
2415 		break;
2416 	case 5:
2417 		scene->_sceneMode = 3;
2418 		scene->signal();
2419 		break;
2420 	}
2421 }
2422 
2423 /*--------------------------------------------------------------------------*/
2424 
Scene590()2425 Scene590::Scene590(): PalettedScene() {
2426 	_field17DC = _field17DE = _stripNumber = _field17E2 = 0;
2427 }
2428 
synchronize(Serializer & s)2429 void Scene590::synchronize(Serializer &s) {
2430 	PalettedScene::synchronize(s);
2431 	s.syncAsSint16LE(_field17DC);
2432 	s.syncAsSint16LE(_field17DE);
2433 	s.syncAsSint16LE(_stripNumber);
2434 	s.syncAsSint16LE(_field17E2);
2435 }
2436 
postInit(SceneObjectList * OwnerList)2437 void Scene590::postInit(SceneObjectList *OwnerList) {
2438 	PalettedScene::postInit();
2439 	loadScene(590);
2440 
2441 	BF_GLOBALS._sound1.fadeOut2(NULL);
2442 	_sound1.play(18);
2443 	_sound1.fade(100, 5, 10, false, NULL);
2444 
2445 	if (BF_GLOBALS._dayNumber == 0) {
2446 		BF_GLOBALS._dayNumber = 1;
2447 		BF_GLOBALS._bookmark = bEndOfWorkDayOne;
2448 		BF_INVENTORY.setObjectScene(INV_BASEBALL_CARD, 1);
2449 	}
2450 
2451 	_exit.setDetails(Rect(0, 157, 182, 167), 590, -1, -1, -1, 1, NULL);
2452 
2453 	BF_GLOBALS._player.postInit();
2454 	BF_GLOBALS._player.setObjectWrapper(new SceneObjectWrapper());
2455 	BF_GLOBALS._player.animate(ANIM_MODE_1, NULL);
2456 	BF_GLOBALS._player.setPosition(Common::Point(0, 190));
2457 
2458 	_stripManager.addSpeaker(&_skipSpeaker);
2459 	_stripManager.addSpeaker(&_lauraSpeaker);
2460 	_stripManager.addSpeaker(&_jakeJacketSpeaker);
2461 
2462 	if (BF_GLOBALS.getFlag(onDuty)) {
2463 		BF_GLOBALS._player.setVisage(361);
2464 		BF_GLOBALS._player._moveDiff = Common::Point(6, 2);
2465 	} else {
2466 		BF_GLOBALS._player.setVisage(368);
2467 		BF_GLOBALS._player._moveDiff = Common::Point(6, 2);
2468 
2469 		if ((BF_GLOBALS._bookmark >= bEndOfWorkDayOne) && (BF_GLOBALS._bookmark < bLyleStoppedBy)) {
2470 			_skip.postInit();
2471 			_skip.setVisage(693);
2472 			_skip.setPosition(Common::Point(271, 117));
2473 			_skip.setDetails(590, 26, -1, 27, 1, (SceneItem *)NULL);
2474 
2475 			_laura.postInit();
2476 			_laura.setVisage(692);
2477 			_laura.setPosition(Common::Point(248, 115));
2478 			_laura.setDetails(590, 24, -1, 25, 1, (SceneItem *)NULL);
2479 		}
2480 	}
2481 
2482 	_item2.setDetails(1, 590, 0, -1, 12, 1);
2483 	_item3.setDetails(3, 590, 2, -1, 14, 1);
2484 	_item4.setDetails(20, 590, 3, -1, 15, 1);
2485 	_item5.setDetails(22, 590, 4, -1, 16, 1);
2486 	_item6.setDetails(7, 590, 6, -1, 17, 1);
2487 	_item7.setDetails(7, 590, 6, -1, 18, 1);
2488 	_item8.setDetails(9, 590, 7, -1, 19, 1);
2489 	_item9.setDetails(11, 590, 8, -1, 20, 1);
2490 	_item10.setDetails(13, 590, 9, -1, 21, 1);
2491 	_item11.setDetails(15, 590, 10, -1, 22, 1);
2492 	_item12.setDetails(17, 590, 11, -1, 23, 1);
2493 
2494 	BF_GLOBALS._player.disableControl();
2495 	_sceneMode = 0;
2496 	setAction(&_sequenceManager, this, 5900, &BF_GLOBALS._player, NULL);
2497 }
2498 
signal()2499 void Scene590::signal() {
2500 	static uint32 black = 0;
2501 
2502 	switch (_sceneMode) {
2503 	case 1:
2504 		_sound1.fadeOut2(NULL);
2505 		BF_GLOBALS._sceneManager.changeScene(271);
2506 		break;
2507 	case 2:
2508 		_sound1.fadeOut2(NULL);
2509 		BF_GLOBALS._sceneManager.changeScene(580);
2510 		break;
2511 	case 3:
2512 		BF_GLOBALS._player.animate(ANIM_MODE_1, NULL);
2513 		ADD_PLAYER_MOVER_NULL(BF_GLOBALS._player, 0, 170);
2514 
2515 		_skip.animate(ANIM_MODE_1, NULL);
2516 		ADD_MOVER_NULL(_skip, 0, 170);
2517 
2518 		_laura.animate(ANIM_MODE_1, NULL);
2519 		ADD_MOVER_NULL(_laura, 0, 170);
2520 
2521 		_sceneMode = 1;
2522 		addFader((byte *)&black, 2, this);
2523 		break;
2524 	default:
2525 		BF_GLOBALS._player.enableControl();
2526 		break;
2527 	}
2528 }
2529 
process(Event & event)2530 void Scene590::process(Event &event) {
2531 	SceneExt::process(event);
2532 
2533 	if (BF_GLOBALS._player._enabled && !_focusObject && (event.mousePos.y < (UI_INTERFACE_Y - 1))) {
2534 		// Check if the cursor is on an exit
2535 		if (_exit.contains(event.mousePos)) {
2536 			GfxSurface surface = _cursorVisage.getFrame(EXITFRAME_SW);
2537 			BF_GLOBALS._events.setCursor(surface);
2538 		} else {
2539 			// In case an exit cursor was being shown, restore the previously selected cursor
2540 			CursorType cursorId = BF_GLOBALS._events.getCursor();
2541 			BF_GLOBALS._events.setCursor(cursorId);
2542 		}
2543 	}
2544 }
2545 
dispatch()2546 void Scene590::dispatch() {
2547 	if (!_action && (BF_GLOBALS._player._position.x < 182) && (BF_GLOBALS._player._position.y > 158)) {
2548 		BF_GLOBALS._player.disableControl();
2549 		_sceneMode = 2;
2550 		setAction(&_sequenceManager, this, 5901, &BF_GLOBALS._player, NULL);
2551 	}
2552 }
2553 
2554 } // End of namespace BlueForce
2555 
2556 } // End of namespace TsAGE
2557