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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
|
/* 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 "neverhood/modules/module3000.h"
#include "neverhood/modules/module3000_sprites.h"
namespace Neverhood {
// Scene3009
enum {
kCTSNull = 0,
kCTSBreakWall = 1,
kCTSWall = 2,
kCTSEmptyness = 3,
kCTSFireRobotNoTarget = 4,
kCTSFireRobotIsTarget = 5,
kCTSFireNoRobot = 6,
kCTSRaiseCannon = 7,
kCTSRightRobotNoTarget = 8,
kCTSRightRobotIsTarget = 9,
kCTSRightNoRobot = 10,
kCTSLeftRobotNoTarget = 11,
kCTSLeftRobotIsTarget = 12,
kCTSLeftNoRobot = 13,
kCTSLowerCannon = 14,
kCTSCount = 14
};
static const uint32 kSsScene3009SymbolEdgesFileHashes[] = {
0x618827A0,
0xB1A92322
};
static const uint32 kSsScene3009TargetLineFileHashes[] = {
0x4011018C,
0x15086623
};
static const NPoint kAsScene3009SymbolPoints[] = {
{289, 338},
{285, 375},
{284, 419},
{456, 372},
{498, 372},
{541, 372}
};
static const uint32 kAsScene3009SymbolFileHashes[] = {
0x24542582,
0x1CD61D96
};
static const uint32 kSsScene3009SymbolArrowFileHashes1[] = {
0x24016060,
0x21216221,
0x486160A0,
0x42216422,
0x90A16120,
0x84216824,
0x08017029,
0x08217029,
0x10014032,
0x10214032,
0x20012004,
0x20212004
};
static const uint32 kSsScene3009SymbolArrowFileHashes2[] = {
0x40092024,
0x01636002,
0x8071E028,
0x02A56064,
0x00806031,
0x052960A8,
0x0A116130,
0x0A316130,
0x14216200,
0x14016200,
0x28416460,
0x28616460
};
SsScene3009FireCannonButton::SsScene3009FireCannonButton(NeverhoodEngine *vm, Scene3009 *parentScene)
: StaticSprite(vm, 1400), _parentScene(parentScene), _isClicked(false) {
loadSprite(0x120B24B0, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 400);
setVisible(false);
SetUpdateHandler(&SsScene3009FireCannonButton::update);
SetMessageHandler(&SsScene3009FireCannonButton::handleMessage);
loadSound(0, 0x3901B44F);
}
void SsScene3009FireCannonButton::update() {
updatePosition();
if (_isClicked && !isSoundPlaying(0)) {
sendMessage(_parentScene, 0x2000, 0);
setVisible(false);
}
}
uint32 SsScene3009FireCannonButton::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
switch (messageNum) {
case 0x1011:
if (!_isClicked && !_parentScene->isTurning()) {
_isClicked = true;
setVisible(true);
playSound(0);
}
messageResult = 1;
break;
default:
break;
}
return messageResult;
}
SsScene3009SymbolEdges::SsScene3009SymbolEdges(NeverhoodEngine *vm, int index)
: StaticSprite(vm, 1400), _blinkCountdown(0) {
loadSprite(kSsScene3009SymbolEdgesFileHashes[index], kSLFDefDrawOffset | kSLFDefPosition, 600);
if (getGlobalVar(V_ROBOT_HIT))
hide();
else
startBlinking();
SetUpdateHandler(&SsScene3009SymbolEdges::update);
}
void SsScene3009SymbolEdges::update() {
if (_blinkCountdown != 0 && (--_blinkCountdown == 0)) {
if (_blinkToggle) {
setVisible(true);
} else {
setVisible(false);
}
updatePosition();
_blinkCountdown = 3;
_blinkToggle = !_blinkToggle;
}
}
void SsScene3009SymbolEdges::show() {
setVisible(true);
updatePosition();
_blinkCountdown = 0;
}
void SsScene3009SymbolEdges::hide() {
setVisible(false);
updatePosition();
_blinkCountdown = 0;
}
void SsScene3009SymbolEdges::startBlinking() {
setVisible(true);
updatePosition();
_blinkCountdown = 3;
_blinkToggle = true;
}
SsScene3009TargetLine::SsScene3009TargetLine(NeverhoodEngine *vm, int index)
: StaticSprite(vm, 1400) {
loadSprite(kSsScene3009TargetLineFileHashes[index], kSLFDefDrawOffset | kSLFDefPosition, 600);
setVisible(false);
}
void SsScene3009TargetLine::show() {
setVisible(true);
updatePosition();
}
SsScene3009SymbolArrow::SsScene3009SymbolArrow(NeverhoodEngine *vm, Sprite *asSymbol, int index)
: StaticSprite(vm, 1400), _asSymbol(asSymbol), _index(index), _enabled(true), _countdown(0) {
_incrDecr = _index % 2;
createSurface(1200, 33, 31);
loadSprite(kSsScene3009SymbolArrowFileHashes2[_index], kSLFDefPosition);
_drawOffset.set(0, 0, 33, 31);
_collisionBoundsOffset = _drawOffset;
updateBounds();
_needRefresh = true;
SetUpdateHandler(&SsScene3009SymbolArrow::update);
SetMessageHandler(&SsScene3009SymbolArrow::handleMessage);
loadSound(0, 0x2C852206);
}
void SsScene3009SymbolArrow::hide() {
_enabled = false;
setVisible(false);
}
void SsScene3009SymbolArrow::update() {
updatePosition();
if (_countdown != 0 && (--_countdown == 0)) {
loadSprite(kSsScene3009SymbolArrowFileHashes2[_index], kSLFDefDrawOffset);
}
}
uint32 SsScene3009SymbolArrow::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
switch (messageNum) {
case 0x1011:
if (_enabled && _countdown == 0) {
_countdown = 2;
loadSprite(kSsScene3009SymbolArrowFileHashes1[_index], kSLFDefDrawOffset);
playSound(0);
sendMessage(_asSymbol, NM_KLAYMEN_CLIMB_LADDER, _incrDecr);
}
messageResult = 1;
break;
default:
break;
}
return messageResult;
}
AsScene3009VerticalIndicator::AsScene3009VerticalIndicator(NeverhoodEngine *vm, Scene3009 *parentScene, int index)
: AnimatedSprite(vm, 1000), _parentScene(parentScene), _enabled(false) {
_x = 300;
_y = getGlobalVar(V_CANNON_RAISED) ? 52 : 266;
createSurface1(0xC2463913, 1200);
_needRefresh = true;
updatePosition();
setVisible(false);
SetUpdateHandler(&AnimatedSprite::update);
SetMessageHandler(&AsScene3009VerticalIndicator::handleMessage);
}
void AsScene3009VerticalIndicator::show() {
startAnimation(0xC2463913, 0, -1);
setVisible(true);
updatePosition();
_enabled = true;
}
uint32 AsScene3009VerticalIndicator::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
switch (messageNum) {
case 0x1011:
if (_enabled) {
sendMessage(_parentScene, NM_POSITION_CHANGE, 0);
}
messageResult = 1;
break;
default:
break;
}
return messageResult;
}
AsScene3009HorizontalIndicator::AsScene3009HorizontalIndicator(NeverhoodEngine *vm, Scene3009 *parentScene, uint32 cannonTargetStatus)
: AnimatedSprite(vm, 1000), _parentScene(parentScene), _enabled(false) {
_x = getGlobalVar(V_CANNON_TURNED) ? 533 : 92;
_y = 150;
createSurface1(0xC0C12954, 1200);
_needRefresh = true;
updatePosition();
setVisible(false);
SetUpdateHandler(&AnimatedSprite::update);
SetMessageHandler(&AsScene3009HorizontalIndicator::handleMessage);
if (cannonTargetStatus == kCTSRightRobotNoTarget || cannonTargetStatus == kCTSRightRobotIsTarget || cannonTargetStatus == kCTSRightNoRobot) {
SetSpriteUpdate(&AsScene3009HorizontalIndicator::suMoveRight);
_x = 280;
}
}
uint32 AsScene3009HorizontalIndicator::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
switch (messageNum) {
case 0x1011:
if (_enabled) {
sendMessage(_parentScene, 0x2004, 0);
}
messageResult = 1;
break;
default:
break;
}
return messageResult;
}
void AsScene3009HorizontalIndicator::suMoveLeft() {
_x -= 6;
if (_x < 92) {
SetSpriteUpdate(NULL);
_x = 92;
}
}
void AsScene3009HorizontalIndicator::suMoveRight() {
_x += 6;
if (_x > 533) {
SetSpriteUpdate(NULL);
_x = 533;
}
}
void AsScene3009HorizontalIndicator::show() {
startAnimation(0xC0C12954, 0, -1);
setVisible(true);
updatePosition();
_enabled = true;
}
void AsScene3009HorizontalIndicator::stMoveLeft() {
_x = 533;
SetSpriteUpdate(&AsScene3009HorizontalIndicator::suMoveLeft);
}
void AsScene3009HorizontalIndicator::stMoveRight() {
_x = 330;
SetSpriteUpdate(&AsScene3009HorizontalIndicator::suMoveRight);
}
AsScene3009Symbol::AsScene3009Symbol(NeverhoodEngine *vm, Scene3009 *parentScene, int symbolPosition)
: AnimatedSprite(vm, 1100), _parentScene(parentScene), _symbolPosition(symbolPosition) {
_symbolIndex = getSubVar(VA_CURR_CANNON_SYMBOLS, _symbolPosition);
_x = kAsScene3009SymbolPoints[_symbolPosition].x;
_y = kAsScene3009SymbolPoints[_symbolPosition].y;
createSurface1(kAsScene3009SymbolFileHashes[_symbolPosition / 3], 1200);
startAnimation(kAsScene3009SymbolFileHashes[_symbolPosition / 3], _symbolIndex, -1);
_newStickFrameIndex = _symbolIndex;
_needRefresh = true;
updatePosition();
SetUpdateHandler(&AnimatedSprite::update);
SetMessageHandler(&AsScene3009Symbol::handleMessage);
_ssArrowPrev = _parentScene->insertSprite<SsScene3009SymbolArrow>(this, _symbolPosition * 2 + 0);
_parentScene->addCollisionSprite(_ssArrowPrev);
_ssArrowNext = _parentScene->insertSprite<SsScene3009SymbolArrow>(this, _symbolPosition * 2 + 1);
_parentScene->addCollisionSprite(_ssArrowNext);
}
uint32 AsScene3009Symbol::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
switch (messageNum) {
case NM_KLAYMEN_CLIMB_LADDER:
if (param.asInteger()) {
if (_symbolIndex == 11)
_symbolIndex = 0;
else
_symbolIndex++;
} else {
if (_symbolIndex == 0)
_symbolIndex = 11;
else
_symbolIndex--;
}
startAnimation(kAsScene3009SymbolFileHashes[_symbolPosition / 3], _symbolIndex, -1);
_newStickFrameIndex = _symbolIndex;
setSubVar(VA_CURR_CANNON_SYMBOLS, _symbolPosition, _symbolIndex);
if (_symbolPosition / 3 == 0) {
sendMessage(_parentScene, 0x2001, 0);
} else {
sendMessage(_parentScene, 0x2003, 0);
}
messageResult = 1;
break;
default:
break;
}
return messageResult;
}
void AsScene3009Symbol::hide() {
_ssArrowPrev->hide();
_ssArrowNext->hide();
}
// Scene3010
static const uint32 kScene3010ButtonNameHashes[] = {
0x304008D2,
0x40119852,
0x01180951
};
static const uint32 kScene3010DeadBoltButtonFileHashes1[] = {
0x301024C2,
0x20280580,
0x30200452
};
static const uint32 kScene3010DeadBoltButtonFileHashes2[] = {
0x50C025A8,
0x1020A0A0,
0x5000A7E8
};
static const NPoint kAsScene3010DeadBoltPoints[] = {
{550, 307},
{564, 415},
{560, 514}
};
static const uint32 kAsScene3010DeadBoltFileHashes2[] = {
0x181A0042,
0x580A08F2,
0x18420076
};
static const uint32 kAsScene3010DeadBoltFileHashes1[] = {
0x300E105A,
0x804E0052,
0x040E485A
};
SsScene3010DeadBoltButton::SsScene3010DeadBoltButton(NeverhoodEngine *vm, Scene *parentScene, int buttonIndex, int initCountdown, bool initDisabled)
: StaticSprite(vm, 900), _parentScene(parentScene), _buttonLocked(false), _countdown1(0), _countdown2(0), _buttonIndex(buttonIndex) {
_buttonEnabled = getSubVar(VA_LOCKS_DISABLED, kScene3010ButtonNameHashes[_buttonIndex]) != 0;
createSurface(400, 88, 95);
setSprite(kScene3010DeadBoltButtonFileHashes2[_buttonIndex]);
if (initDisabled)
disableButton();
else if (_buttonEnabled)
_countdown1 = initCountdown * 12 + 1;
loadSound(0, 0xF4217243);
loadSound(1, 0x44049000);
loadSound(2, 0x6408107E);
SetUpdateHandler(&SsScene3010DeadBoltButton::update);
SetMessageHandler(&SsScene3010DeadBoltButton::handleMessage);
}
void SsScene3010DeadBoltButton::update() {
if (_countdown1 != 0 && (--_countdown1 == 0)) {
playSound(0);
setVisible(false);
setSprite(kScene3010DeadBoltButtonFileHashes1[_buttonIndex]);
}
if (_countdown2 != 0 && (--_countdown2 == 0)) {
setVisible(true);
setSprite(kScene3010DeadBoltButtonFileHashes2[_buttonIndex]);
}
}
uint32 SsScene3010DeadBoltButton::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
switch (messageNum) {
case 0x1011:
if (!_buttonLocked && _countdown1 == 0) {
if (_buttonEnabled) {
playSound(1);
playSound(2);
setVisible(true);
_buttonLocked = true;
sendMessage(_parentScene, 0x2000, _buttonIndex);
} else {
sendMessage(_parentScene, NM_POSITION_CHANGE, _buttonIndex);
}
_needRefresh = true;
updatePosition();
}
messageResult = 1;
break;
default:
break;
}
return messageResult;
}
void SsScene3010DeadBoltButton::disableButton() {
_buttonLocked = true;
setSprite(kScene3010DeadBoltButtonFileHashes1[_buttonIndex]);
setVisible(true);
}
void SsScene3010DeadBoltButton::setSprite(uint32 fileHash) {
loadSprite(fileHash, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset);
}
void SsScene3010DeadBoltButton::setCountdown(int count) {
_countdown2 = count * 18 + 1;
}
AsScene3010DeadBolt::AsScene3010DeadBolt(NeverhoodEngine *vm, Scene *parentScene, int boltIndex, bool initUnlocked)
: AnimatedSprite(vm, 1100), _parentScene(parentScene), _boltIndex(boltIndex), _soundToggle(true),
_unlocked(false), _locked(false), _countdown(0) {
_x = kAsScene3010DeadBoltPoints[_boltIndex].x;
_y = kAsScene3010DeadBoltPoints[_boltIndex].y;
if (getSubVar(VA_LOCKS_DISABLED, kScene3010ButtonNameHashes[_boltIndex])) {
createSurface1(kAsScene3010DeadBoltFileHashes1[_boltIndex], 1200);
startAnimation(kAsScene3010DeadBoltFileHashes1[_boltIndex], 0, -1);
loadSound(0, 0x46005BC4);
} else {
createSurface1(kAsScene3010DeadBoltFileHashes2[_boltIndex], 1200);
startAnimation(kAsScene3010DeadBoltFileHashes2[_boltIndex], 0, -1);
loadSound(0, 0x420073DC);
loadSound(1, 0x420073DC);
}
setVisible(false);
stIdle();
if (initUnlocked)
unlock(true);
_needRefresh = true;
AnimatedSprite::updatePosition();
}
void AsScene3010DeadBolt::update() {
updateAnim();
updatePosition();
if (_countdown != 0 && (--_countdown == 0)) {
stDisabled();
}
}
uint32 AsScene3010DeadBolt::hmAnimation(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
switch (messageNum) {
case NM_ANIMATION_STOP:
gotoNextState();
break;
default:
break;
}
return messageResult;
}
void AsScene3010DeadBolt::stIdle() {
stopAnimation();
SetUpdateHandler(&AsScene3010DeadBolt::update);
SetMessageHandler(&Sprite::handleMessage);
_locked = false;
}
void AsScene3010DeadBolt::unlock(bool skipAnim) {
if (!_unlocked) {
setVisible(true);
if (skipAnim) {
startAnimation(kAsScene3010DeadBoltFileHashes1[_boltIndex], -1, 0);
_newStickFrameIndex = STICK_LAST_FRAME;
} else {
startAnimation(kAsScene3010DeadBoltFileHashes1[_boltIndex], 0, -1);
SetMessageHandler(&AsScene3010DeadBolt::hmAnimation);
FinalizeState(&AsScene3010DeadBolt::stIdleMessage);
NextState(&AsScene3010DeadBolt::stIdle);
playSound(0);
}
_unlocked = true;
loadSound(2, 0x4010C345);
}
}
void AsScene3010DeadBolt::stIdleMessage() {
stopAnimation();
SetMessageHandler(&Sprite::handleMessage);
sendMessage(_parentScene, 0x2001, _boltIndex);
}
void AsScene3010DeadBolt::lock() {
if (!_locked) {
_locked = true;
setVisible(true);
startAnimation(kAsScene3010DeadBoltFileHashes2[_boltIndex], 0, -1);
SetMessageHandler(&AsScene3010DeadBolt::hmAnimation);
FinalizeState(&AsScene3010DeadBolt::stDisabledMessage);
NextState(&AsScene3010DeadBolt::stIdle);
if (_soundToggle) {
playSound(0);
} else {
playSound(1);
}
_soundToggle = !_soundToggle;
}
}
void AsScene3010DeadBolt::setCountdown(int count) {
_countdown = count * 18 + 1;
}
void AsScene3010DeadBolt::stDisabled() {
setVisible(true);
startAnimation(kAsScene3010DeadBoltFileHashes1[_boltIndex], 0, -1);
SetMessageHandler(&AsScene3010DeadBolt::hmAnimation);
FinalizeState(&AsScene3010DeadBolt::stDisabledMessage);
NextState(&AsScene3010DeadBolt::stIdle);
_playBackwards = true;
playSound(2);
}
void AsScene3010DeadBolt::stDisabledMessage() {
setVisible(false);
sendMessage(_parentScene, 0x2003, _boltIndex);
}
// Scene3011
static const uint32 kAsScene3011SymbolFileHashes[] = {
0x00C88050,
0x01488050,
0x02488050,
0x04488050,
0x08488050,
0x10488050,
0x20488050,
0x40488050,
0x80488050,
0x00488051,
0x00488052,
0x00488054,
0x008B0000,
0x008D0000,
0x00810000,
0x00990000,
0x00A90000,
0x00C90000,
0x00090000,
0x01890000,
0x02890000,
0x04890000,
0x08890000,
0x10890000
};
SsScene3011Button::SsScene3011Button(NeverhoodEngine *vm, Scene *parentScene, bool flag)
: StaticSprite(vm, 1400), _parentScene(parentScene), _countdown(0) {
loadSprite(flag ? 0x11282020 : 0x994D0433, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 400);
setVisible(false);
loadSound(0, 0x44061000);
SetUpdateHandler(&SsScene3011Button::update);
SetMessageHandler(&SsScene3011Button::handleMessage);
}
void SsScene3011Button::update() {
updatePosition();
if (_countdown != 0 && (--_countdown == 0)) {
setVisible(false);
}
}
uint32 SsScene3011Button::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = 0;
StaticSprite::handleMessage(messageNum, param, sender);
switch (messageNum) {
case 0x1011:
if (_countdown == 0) {
setVisible(true);
_countdown = 4;
sendMessage(_parentScene, 0x2000, 0);
playSound(0);
}
messageResult = 1;
break;
default:
break;
}
return messageResult;
}
AsScene3011Symbol::AsScene3011Symbol(NeverhoodEngine *vm, int symbolIndex, bool largeSymbol)
: AnimatedSprite(vm, 1000), _symbolIndex(symbolIndex), _largeSymbol(largeSymbol), _isNoisy(false) {
if (_largeSymbol) {
_x = 310;
_y = 200;
createSurface1(kAsScene3011SymbolFileHashes[_symbolIndex], 1200);
loadSound(0, 0x6052C60F);
loadSound(1, 0x6890433B);
} else {
_symbolIndex = 12;
_x = symbolIndex * 39 + 96;
_y = 225;
createSurface(1200, 41, 48);
loadSound(0, 0x64428609);
loadSound(1, 0x7080023B);
}
setVisible(false);
_needRefresh = true;
SetUpdateHandler(&AnimatedSprite::update);
}
void AsScene3011Symbol::show(bool isNoisy) {
_isNoisy = isNoisy;
startAnimation(kAsScene3011SymbolFileHashes[_symbolIndex], 0, -1);
setVisible(true);
if (_isNoisy) {
playSound(1);
} else {
playSound(0);
}
}
void AsScene3011Symbol::hide() {
stopAnimation();
setVisible(false);
}
void AsScene3011Symbol::stopSymbolSound() {
if (_isNoisy) {
stopSound(1);
} else {
stopSound(0);
}
}
void AsScene3011Symbol::change(int symbolIndex, bool isNoisy) {
_symbolIndex = symbolIndex;
_isNoisy = isNoisy;
startAnimation(kAsScene3011SymbolFileHashes[_symbolIndex], 0, -1);
setVisible(true);
if (_isNoisy) {
playSound(1);
} else {
playSound(0);
}
}
} // End of namespace Neverhood
|