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
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
|
/* 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 "common/config-manager.h"
#include "common/error.h"
#include "common/events.h"
#include "common/fs.h"
#include "common/memstream.h"
#include "common/savefile.h"
#include "common/textconsole.h"
#include "common/translation.h"
#include "base/plugins.h"
#include "base/version.h"
#include "gui/saveload.h"
#include "video/qt_decoder.h"
#include "pegasus/console.h"
#include "pegasus/cursor.h"
#include "pegasus/gamestate.h"
#include "pegasus/interface.h"
#include "pegasus/menu.h"
#include "pegasus/movie.h"
#include "pegasus/pegasus.h"
#include "pegasus/timers.h"
#include "pegasus/items/itemlist.h"
#include "pegasus/items/biochips/aichip.h"
#include "pegasus/items/biochips/biochipitem.h"
#include "pegasus/items/biochips/opticalchip.h"
#include "pegasus/items/biochips/pegasuschip.h"
#include "pegasus/items/biochips/retscanchip.h"
#include "pegasus/items/biochips/shieldchip.h"
#include "pegasus/items/inventory/airmask.h"
#include "pegasus/items/inventory/gascanister.h"
#include "pegasus/items/inventory/inventoryitem.h"
#include "pegasus/items/inventory/keycard.h"
#include "pegasus/neighborhood/neighborhood.h"
namespace Pegasus {
PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), InputHandler(0), _gameDescription(gamedesc),
_shellNotification(kJMPDCShellNotificationID, this), _returnHotspot(kInfoReturnSpotID) {
_continuePoint = 0;
_saveAllowed = _loadAllowed = true;
_gameMenu = 0;
_deathReason = kDeathStranded;
_neighborhood = 0;
}
PegasusEngine::~PegasusEngine() {
delete _resFork;
delete _console;
delete _cursor;
delete _continuePoint;
delete _gameMenu;
delete _gfx;
}
Common::Error PegasusEngine::run() {
_console = new PegasusConsole(this);
_gfx = new GraphicsManager(this);
_resFork = new Common::MacResManager();
_cursor = new Cursor();
if (!_resFork->open("JMP PP Resources") || !_resFork->hasResFork())
error("Could not load JMP PP Resources");
// Initialize items
createItems();
// Initialize cursors
_cursor->addCursorFrames(0x80); // Main
_cursor->addCursorFrames(900); // Mars Shuttle
if (!isDemo() && !detectOpeningClosingDirectory()) {
Common::String message = "Missing intro directory. ";
// Give Mac OS X a more specific message because we can
#ifdef MACOSX
message += "Make sure \"Opening/Closing\" is present.";
#else
message += "Be sure to rename \"Opening/Closing\" to \"Opening_Closing\".";
#endif
GUIErrorMessage(message);
warning("%s", message.c_str());
return Common::kNoGameDataFoundError;
}
// Set up input
InputHandler::setInputHandler(this);
allowInput(true);
// Set up inventories
_items.setWeightLimit(0);
_items.setOwnerID(kPlayerID);
_biochips.setWeightLimit(8);
_biochips.setOwnerID(kPlayerID);
// Start up the first notification
_shellNotification.notifyMe(this, kJMPShellNotificationFlags, kJMPShellNotificationFlags);
_shellNotification.setNotificationFlags(kGameStartingFlag, kGameStartingFlag);
_returnHotspot.setArea(Common::Rect(kNavAreaLeft, kNavAreaTop, 512 + kNavAreaLeft, 256 + kNavAreaTop));
_returnHotspot.setHotspotFlags(kInfoReturnSpotFlag);
g_allHotspots.push_back(&_returnHotspot);
while (!shouldQuit()) {
checkCallBacks();
checkNotifications();
InputHandler::pollForInput();
refreshDisplay();
}
return Common::kNoError;
}
bool PegasusEngine::detectOpeningClosingDirectory() {
// We need to detect what our Opening/Closing directory is listed as
// On the original disc, it was 'Opening/Closing' but only HFS(+) supports the slash
// Mac OS X will display this as 'Opening:Closing' and we can use that directly
// On other systems, users will need to rename to "Opening_Closing"
Common::FSNode gameDataDir(ConfMan.get("path"));
gameDataDir = gameDataDir.getChild("Images");
if (!gameDataDir.exists())
return false;
Common::FSList fsList;
if (!gameDataDir.getChildren(fsList, Common::FSNode::kListDirectoriesOnly, true))
return false;
for (uint i = 0; i < fsList.size() && _introDirectory.empty(); i++) {
Common::String name = fsList[i].getName();
if (name.equalsIgnoreCase("Opening:Closing"))
_introDirectory = name;
else if (name.equalsIgnoreCase("Opening_Closing"))
_introDirectory = name;
}
if (_introDirectory.empty())
return false;
debug(0, "Detected intro location as '%s'", _introDirectory.c_str());
_introDirectory = Common::String("Images/") + _introDirectory;
return true;
}
void PegasusEngine::createItems() {
Common::SeekableReadStream *res = _resFork->getResource(MKTAG('N', 'I', 't', 'm'), 0x80);
uint16 entryCount = res->readUint16BE();
for (uint16 i = 0; i < entryCount; i++) {
tItemID itemID = res->readUint16BE();
tNeighborhoodID neighborhoodID = res->readUint16BE();
tRoomID roomID = res->readUint16BE();
tDirectionConstant direction = res->readByte();
res->readByte(); // alignment
createItem(itemID, neighborhoodID, roomID, direction);
}
delete res;
}
void PegasusEngine::createItem(tItemID itemID, tNeighborhoodID neighborhoodID, tRoomID roomID, tDirectionConstant direction) {
switch (itemID) {
case kInterfaceBiochip:
// Unused in game, but still in the data and we need to create
// it because it's saved/loaded from save files.
new BiochipItem(itemID, neighborhoodID, roomID, direction);
break;
case kAIBiochip:
new AIChip(itemID, neighborhoodID, roomID, direction);
break;
case kPegasusBiochip:
new PegasusChip(itemID, neighborhoodID, roomID, direction);
break;
case kOpticalBiochip:
new OpticalChip(itemID, neighborhoodID, roomID, direction);
break;
case kMapBiochip:
// TODO: Implement this biochip
new BiochipItem(itemID, neighborhoodID, roomID, direction);
break;
case kRetinalScanBiochip:
new RetScanChip(itemID, neighborhoodID, roomID, direction);
break;
case kShieldBiochip:
new ShieldChip(itemID, neighborhoodID, roomID, direction);
break;
case kAirMask:
new AirMask(itemID, neighborhoodID, roomID, direction);
break;
case kKeyCard:
new KeyCard(itemID, neighborhoodID, roomID, direction);
break;
case kGasCanister:
new GasCanister(itemID, neighborhoodID, roomID, direction);
break;
default:
// Everything else is a normal inventory item
new InventoryItem(itemID, neighborhoodID, roomID, direction);
break;
}
}
void PegasusEngine::runIntro() {
bool skipped = false;
Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
if (video->loadFile(_introDirectory + "/BandaiLogo.movie")) {
while (!shouldQuit() && !video->endOfVideo() && !skipped) {
if (video->needsUpdate()) {
const Graphics::Surface *frame = video->decodeNextFrame();
_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 0, 0, frame->w, frame->h);
_system->updateScreen();
}
Input input;
InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
if (input.anyInput())
skipped = true;
_system->delayMillis(10);
}
}
delete video;
if (shouldQuit() || skipped)
return;
video = new Video::QuickTimeDecoder();
if (!video->loadFile(_introDirectory + "/Big Movie.movie"))
error("Could not load intro movie");
video->seekToTime(Audio::Timestamp(0, 10 * 600, 600));
while (!shouldQuit() && !video->endOfVideo()) {
if (video->needsUpdate()) {
const Graphics::Surface *frame = video->decodeNextFrame();
// Scale up the frame doing some simple scaling
Graphics::Surface scaledFrame;
scaledFrame.create(frame->w * 2, frame->h * 2, frame->format);
const byte *src = (const byte *)frame->pixels;
byte *dst1 = (byte *)scaledFrame.pixels;
byte *dst2 = (byte *)scaledFrame.pixels + scaledFrame.pitch;
for (int y = 0; y < frame->h; y++) {
for (int x = 0; x < frame->w; x++) {
memcpy(dst1, src, frame->format.bytesPerPixel);
dst1 += frame->format.bytesPerPixel;
memcpy(dst1, src, frame->format.bytesPerPixel);
dst1 += frame->format.bytesPerPixel;
memcpy(dst2, src, frame->format.bytesPerPixel);
dst2 += frame->format.bytesPerPixel;
memcpy(dst2, src, frame->format.bytesPerPixel);
dst2 += frame->format.bytesPerPixel;
src += frame->format.bytesPerPixel;
}
src += frame->pitch - frame->format.bytesPerPixel * frame->w;
dst1 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
dst2 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
}
_system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, 0, 0, scaledFrame.w, scaledFrame.h);
_system->updateScreen();
scaledFrame.free();
}
Input input;
InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
if (input.anyInput())
break;
_system->delayMillis(10);
}
delete video;
}
void PegasusEngine::showLoadDialog() {
GUI::SaveLoadChooser slc(_("Load game:"), _("Load"));
slc.setSaveMode(false);
Common::String gameId = ConfMan.get("gameid");
const EnginePlugin *plugin = 0;
EngineMan.findGame(gameId, &plugin);
int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
if (slot >= 0) {
warning("TODO: Load game");
}
slc.close();
}
GUI::Debugger *PegasusEngine::getDebugger() {
return _console;
}
void PegasusEngine::addIdler(Idler *idler) {
_idlers.push_back(idler);
}
void PegasusEngine::removeIdler(Idler *idler) {
_idlers.remove(idler);
}
void PegasusEngine::giveIdleTime() {
for (Common::List<Idler *>::iterator it = _idlers.begin(); it != _idlers.end(); it++)
(*it)->useIdleTime();
}
void PegasusEngine::addTimeBase(TimeBase *timeBase) {
_timeBases.push_back(timeBase);
}
void PegasusEngine::removeTimeBase(TimeBase *timeBase) {
_timeBases.remove(timeBase);
}
bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
// TODO: Dispose currently running stuff (neighborhood, etc.)
// Signature
uint32 creator = stream->readUint32BE();
if (creator != kPegasusPrimeCreator) {
warning("Bad save creator '%s'", tag2str(creator));
return false;
}
uint32 gameType = stream->readUint32BE();
int saveType;
switch (gameType) {
case kPegasusPrimeDisk1GameType:
case kPegasusPrimeDisk2GameType:
case kPegasusPrimeDisk3GameType:
case kPegasusPrimeDisk4GameType:
saveType = kNormalSave;
break;
case kPegasusPrimeContinueType:
saveType = kContinueSave;
break;
default:
// There are five other possible game types on the Pippin
// version, but hopefully we don't see any of those here
warning("Unhandled pegasus game type '%s'", tag2str(gameType));
return false;
}
uint32 version = stream->readUint32BE();
if (version != kPegasusPrimeVersion) {
warning("Where did you get this save? It's a beta (v%04x)!", version & 0x7fff);
return false;
}
// Game State
GameState.readGameState(stream);
// Energy
setLastEnergyValue(stream->readUint32BE() >> 16);
// Death reason
setEnergyDeathReason(stream->readByte());
// TODO: This is as far as we can go right now
return true;
// Items
g_allItems.readFromStream(stream);
// TODO: Player Inventory
// TODO: Player BioChips
// TODO: Disc check
// TODO: Jump to environment
// TODO: AI rules
// Make a new continue point if this isn't already one
if (saveType == kNormalSave)
makeContinuePoint();
return true;
}
bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
// Not ready yet! :P
return false;
// Signature
stream->writeUint32BE(kPegasusPrimeCreator);
if (saveType == kNormalSave) {
// TODO: Disc check
stream->writeUint32BE(kPegasusPrimeDisk1GameType);
} else { // Continue
stream->writeUint32BE(kPegasusPrimeContinueType);
}
stream->writeUint32BE(kPegasusPrimeVersion);
// Game State
GameState.writeGameState(stream);
// Energy
stream->writeUint32BE(getSavedEnergyValue() << 16);
// Death reason
stream->writeByte(getEnergyDeathReason());
// Items
g_allItems.writeToStream(stream);
// TODO: Player Inventory
// TODO: Player BioChips
// TODO: Jump to environment
// TODO: AI rules
return true;
}
void PegasusEngine::makeContinuePoint() {
delete _continuePoint;
Common::MemoryWriteStreamDynamic newPoint(DisposeAfterUse::NO);
writeToStream(&newPoint, kContinueSave);
_continuePoint = new Common::MemoryReadStream(newPoint.getData(), newPoint.size(), DisposeAfterUse::YES);
}
void PegasusEngine::loadFromContinuePoint() {
// Failure to load a continue point is fatal
if (!_continuePoint)
error("Attempting to load from non-existant continue point");
if (!loadFromStream(_continuePoint))
error("Failed loading continue point");
}
Common::Error PegasusEngine::loadGameState(int slot) {
Common::StringArray filenames = _saveFileMan->listSavefiles("pegasus-*.sav");
Common::InSaveFile *loadFile = _saveFileMan->openForLoading(filenames[slot]);
if (!loadFile)
return Common::kUnknownError;
bool valid = loadFromStream(loadFile);
delete loadFile;
return valid ? Common::kNoError : Common::kUnknownError;
}
Common::Error PegasusEngine::saveGameState(int slot, const Common::String &desc) {
Common::String output = Common::String::format("pegasus-%s.sav", desc.c_str());
Common::OutSaveFile *saveFile = _saveFileMan->openForSaving(output);
if (!saveFile)
return Common::kUnknownError;
bool valid = writeToStream(saveFile, kNormalSave);
delete saveFile;
return valid ? Common::kNoError : Common::kUnknownError;
}
void PegasusEngine::receiveNotification(Notification *notification, const tNotificationFlags flags) {
if (&_shellNotification == notification) {
switch (flags) {
case kGameStartingFlag: {
#if 0
// This is just some graphical test that I wrote; I'll
// keep it around for reference.
Movie opening(1);
opening.initFromMovieFile(_introDirectory + "/Big Movie.movie");
opening.setTime(10, 1);
opening.setStart(10, 1);
opening.startDisplaying();
opening.show();
opening.start();
opening.setFlags(kLoopTimeBase);
Input input;
InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
while (opening.isRunning() && !shouldQuit()) {
checkCallBacks();
_gfx->updateDisplay();
InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
if (input.anyInput())
break;
_system->delayMillis(10);
}
#else
if (!isDemo())
runIntro();
if (shouldQuit())
return;
useMenu(new MainMenu());
_gfx->invalRect(Common::Rect(0, 0, 640, 480));
_gfx->updateDisplay();
((MainMenu *)_gameMenu)->startMainMenuLoop();
#endif
break;
}
default:
break;
}
}
}
void PegasusEngine::checkCallBacks() {
for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
(*it)->checkCallBacks();
}
void PegasusEngine::resetIntroTimer() {
// TODO
}
void PegasusEngine::delayShell(TimeValue time, TimeScale scale) {
if (time == 0 || scale == 0)
return;
uint32 startTime = g_system->getMillis();
uint32 timeInMillis = time * 1000 / scale;
while (g_system->getMillis() < startTime + timeInMillis) {
checkCallBacks();
_gfx->updateDisplay();
}
}
void PegasusEngine::useMenu(GameMenu *newMenu) {
if (_gameMenu) {
_gameMenu->restorePreviousHandler();
delete _gameMenu;
}
_gameMenu = newMenu;
if (_gameMenu)
_gameMenu->becomeCurrentHandler();
}
bool PegasusEngine::checkGameMenu() {
tGameMenuCommand command = kMenuCmdNoCommand;
if (_gameMenu) {
command = _gameMenu->getLastCommand();
if (command != kMenuCmdNoCommand) {
_gameMenu->clearLastCommand();
doGameMenuCommand(command);
}
}
return command != kMenuCmdNoCommand;
}
void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
switch (command) {
case kMenuCmdStartAdventure:
GameState.setWalkthroughMode(false);
error("Start new game (adventure mode)");
break;
case kMenuCmdCredits:
if (isDemo()) {
showTempScreen("Images/Demo/DemoCredits.pict");
// TODO: Fade out
_gfx->updateDisplay();
// TODO: Fade in
} else {
// TODO: Stop intro timer
// TODO: Fade out
useMenu(new CreditsMenu());
_gfx->updateDisplay();
// TODO: Fade in
}
break;
case kMenuCmdQuit:
_system->quit();
break;
case kMenuCmdOverview:
// TODO: Stop intro timer
doInterfaceOverview();
resetIntroTimer();
break;
case kMenuCmdStartWalkthrough:
GameState.setWalkthroughMode(true);
error("Start new game (walkthrough mode)");
break;
case kMenuCmdRestore:
error("Load game");
break;
case kMenuCmdCreditsMainMenu:
// TODO: Fade out
useMenu(new MainMenu());
_gfx->updateDisplay();
((MainMenu *)_gameMenu)->startMainMenuLoop();
// TODO: Fade in
resetIntroTimer();
break;
case kMenuCmdNoCommand:
break;
default:
error("Unknown menu command %d", command);
}
}
void PegasusEngine::handleInput(const Input &input, const Hotspot *cursorSpot) {
if (!checkGameMenu())
; // TODO: Other input
// Handle the console here
if (input.isConsoleRequested()) {
_console->attach();
_console->onFrame();
}
// TODO: Quit request
// TODO: Save request
// TODO: Load request
}
void PegasusEngine::doInterfaceOverview() {
static const short kNumOverviewSpots = 11;
static const Common::Rect overviewSpots[kNumOverviewSpots] = {
Common::Rect(354, 318, 354 + 204, 318 + 12),
Common::Rect(211, 34, 211 + 114, 34 + 28),
Common::Rect(502, 344, 502 + 138, 344 + 120),
Common::Rect(132, 40, 132 + 79, 40 + 22),
Common::Rect(325, 40, 332 + 115, 40 + 22),
Common::Rect(70, 318, 70 + 284, 318 + 12),
Common::Rect(76, 334, 76 + 96, 334 + 96),
Common::Rect(64, 64, 64 + 512, 64 + 256),
Common::Rect(364, 334, 364 + 96, 334 + 96),
Common::Rect(172, 334, 172 + 192, 334 + 96),
Common::Rect(542, 36, 542 + 58, 36 + 20)
};
// TODO: fade out
useMenu(0);
Picture leftBackground(kNoDisplayElement);
leftBackground.initFromPICTFile("Images/Interface/OVLeft.mac");
leftBackground.setDisplayOrder(0);
leftBackground.moveElementTo(kBackground1Left, kBackground1Top);
leftBackground.startDisplaying();
leftBackground.show();
Picture topBackground(kNoDisplayElement);
topBackground.initFromPICTFile("Images/Interface/OVTop.mac");
topBackground.setDisplayOrder(0);
topBackground.moveElementTo(kBackground2Left, kBackground2Top);
topBackground.startDisplaying();
topBackground.show();
Picture rightBackground(kNoDisplayElement);
rightBackground.initFromPICTFile("Images/Interface/OVRight.mac");
rightBackground.setDisplayOrder(0);
rightBackground.moveElementTo(kBackground3Left, kBackground3Top);
rightBackground.startDisplaying();
rightBackground.show();
Picture bottomBackground(kNoDisplayElement);
bottomBackground.initFromPICTFile("Images/Interface/OVBottom.mac");
bottomBackground.setDisplayOrder(0);
bottomBackground.moveElementTo(kBackground4Left, kBackground4Top);
bottomBackground.startDisplaying();
bottomBackground.show();
Picture controllerHighlight(kNoDisplayElement);
controllerHighlight.initFromPICTFile("Images/Interface/OVcontrollerHilite.mac");
controllerHighlight.setDisplayOrder(0);
controllerHighlight.moveElementTo(kOverviewControllerLeft, kOverviewControllerTop);
controllerHighlight.startDisplaying();
Movie overviewText(kNoDisplayElement);
overviewText.initFromMovieFile("Images/Interface/Overview Mac.movie");
overviewText.setDisplayOrder(0);
overviewText.moveElementTo(kNavAreaLeft, kNavAreaTop);
overviewText.startDisplaying();
overviewText.show();
overviewText.redrawMovieWorld();
DropHighlight highlight(kNoDisplayElement);
highlight.setDisplayOrder(1);
highlight.startDisplaying();
highlight.setHighlightThickness(4);
highlight.setHighlightColor(g_system->getScreenFormat().RGBToColor(239, 239, 0));
highlight.setHighlightCornerDiameter(8);
Input input;
InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
Common::Point cursorLoc;
input.getInputLocation(cursorLoc);
uint16 i;
for (i = 0; i < kNumOverviewSpots; ++i)
if (overviewSpots[i].contains(cursorLoc))
break;
TimeValue time;
if (i == kNumOverviewSpots)
time = 5;
else if (i > 4)
time = i + 1;
else
time = i;
if (time == 2) {
highlight.hide();
controllerHighlight.show();
} else if (i != kNumOverviewSpots) {
controllerHighlight.hide();
Common::Rect r = overviewSpots[i];
r.grow(5);
highlight.setBounds(r);
highlight.show();
} else {
highlight.hide();
controllerHighlight.hide();
}
overviewText.setTime(time * 3 + 2, 15);
overviewText.redrawMovieWorld();
_cursor->setCurrentFrameIndex(3);
_cursor->show();
_gfx->updateDisplay();
// TODO: Fade in
for (;;) {
InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
if (input.anyInput() || shouldQuit()) // TODO: Check for save/load requests too
break;
input.getInputLocation(cursorLoc);
for (i = 0; i < kNumOverviewSpots; ++i)
if (overviewSpots[i].contains(cursorLoc))
break;
if (i == kNumOverviewSpots)
time = 5;
else if (i > 4)
time = i + 1;
else
time = i;
if (time == 2) {
highlight.hide();
controllerHighlight.show();
} else if (i != kNumOverviewSpots) {
controllerHighlight.hide();
Common::Rect r = overviewSpots[i];
r.grow(5);
highlight.setBounds(r);
highlight.show();
} else {
highlight.hide();
controllerHighlight.hide();
}
overviewText.setTime(time * 3 + 2, 15);
overviewText.redrawMovieWorld();
refreshDisplay();
}
if (shouldQuit())
return;
highlight.hide();
_cursor->hide();
// TODO: Fade out
useMenu(new MainMenu());
_gfx->updateDisplay();
((MainMenu *)_gameMenu)->startMainMenuLoop();
// TODO: Fade in
// TODO: Cancel save/load requests?
}
void PegasusEngine::showTempScreen(const Common::String &fileName) {
// TODO: Fade out
Picture picture(0);
picture.initFromPICTFile(fileName);
picture.setDisplayOrder(kMaxAvailableOrder);
picture.startDisplaying();
picture.show();
_gfx->updateDisplay();
// TODO: Fade in
// Wait for the next event
bool done = false;
while (!shouldQuit() && !done) {
Common::Event event;
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONUP:
case Common::EVENT_KEYDOWN:
done = true;
break;
default:
break;
}
}
_system->delayMillis(10);
}
}
void PegasusEngine::refreshDisplay() {
giveIdleTime();
_gfx->updateDisplay();
}
void PegasusEngine::resetEnergyDeathReason() {
// TODO!
_deathReason = kDeathStranded;
}
uint16 PegasusEngine::getSoundFXLevel() {
// TODO
return 0x100;
}
bool PegasusEngine::playerHasItem(const Item *item) {
return playerHasItemID(item->getObjectID());
}
bool PegasusEngine::playerHasItemID(const tItemID itemID) {
return itemInInventory(itemID) || itemInBiochips(itemID);
}
InventoryItem *PegasusEngine::getCurrentInventoryItem() {
if (g_interface)
return g_interface->getCurrentInventoryItem();
return 0;
}
bool PegasusEngine::itemInInventory(InventoryItem *item) {
return _items.itemInInventory(item);
}
bool PegasusEngine::itemInInventory(tItemID id) {
return _items.itemInInventory(id);
}
BiochipItem *PegasusEngine::getCurrentBiochip() {
if (g_interface)
g_interface->getCurrentBiochip();
return 0;
}
bool PegasusEngine::itemInBiochips(BiochipItem *item) {
return _biochips.itemInInventory(item);
}
bool PegasusEngine::itemInBiochips(tItemID id) {
return _biochips.itemInInventory(id);
}
bool PegasusEngine::playerAlive() {
return (_shellNotification.getNotificationFlags() & kPlayerDiedFlag) == 0;
}
Common::String PegasusEngine::getBriefingMovie() {
if (_neighborhood)
return _neighborhood->getBriefingMovie();
return Common::String();
}
Common::String PegasusEngine::getEnvScanMovie() {
if (_neighborhood)
return _neighborhood->getEnvScanMovie();
return Common::String();
}
uint PegasusEngine::getNumHints() {
if (_neighborhood)
return _neighborhood->getNumHints();
return 0;
}
Common::String PegasusEngine::getHintMovie(uint hintNum) {
if (_neighborhood)
return _neighborhood->getHintMovie(hintNum);
return Common::String();
}
bool PegasusEngine::canSolve() {
if (_neighborhood)
return _neighborhood->canSolve();
return false;
}
void PegasusEngine::prepareForAIHint(const Common::String &movieName) {
if (g_neighborhood)
g_neighborhood->prepareForAIHint(movieName);
}
void PegasusEngine::cleanUpAfterAIHint(const Common::String &movieName) {
if (g_neighborhood)
g_neighborhood->cleanUpAfterAIHint(movieName);
}
void PegasusEngine::jumpToNewEnvironment(const tNeighborhoodID neighborhoodID, const tRoomID roomID, const tDirectionConstant direction) {
GameState.setNextLocation(neighborhoodID, roomID, direction);
_shellNotification.setNotificationFlags(kNeedNewJumpFlag, kNeedNewJumpFlag);
}
void PegasusEngine::checkFlashlight() {
if (_neighborhood)
_neighborhood->checkFlashlight();
}
} // End of namespace Pegasus
|