22 #ifndef MOHAWK_LIVINGBOOKS_H 23 #define MOHAWK_LIVINGBOOKS_H 25 #include "mohawk/mohawk.h" 26 #include "mohawk/console.h" 27 #include "mohawk/livingbooks_graphics.h" 28 #include "mohawk/sound.h" 29 #include "mohawk/video.h" 31 #include "common/formats/ini-file.h" 32 #include "common/rect.h" 33 #include "common/queue.h" 34 #include "common/random.h" 36 #include "livingbooks_code.h" 39 class SeekableReadStreamEndian;
40 class MemoryReadStreamEndian;
45 #define LBKEY_MOD_CTRL 1 46 #define LBKEY_MOD_ALT 2 47 #define LBKEY_MOD_SHIFT 4 75 kLBPhaseNone = 0x7fff,
76 kLBPhaseLoad = 0xfffe,
77 kLBPhaseCreate = 0xffff
95 kLBControlHideMouse = 1,
96 kLBControlPauseItems = 2
100 kLBStaticTextItem = 0x1,
101 kLBPictureItem = 0x2,
102 kLBEditTextItem = 0x14,
103 kLBLiveTextItem = 0x15,
104 kLBAnimationItem = 0x40,
108 kLBPaletteAItem = 0x44,
109 kLBPaletteItem = 0x45,
111 kLBMiniGameItem = 666,
112 kLBXDataFileItem = 0x3e9,
113 kLBDiscDectectorItem = 0xfa1
118 kLBAnimOpNotify = 0x2,
119 kLBAnimOpSetTempo = 0x3,
121 kLBAnimOpMoveTo = 0x5,
123 kLBAnimOpSetCel = 0x7,
124 kLBAnimOpSleepUntil = 0x8,
125 kLBAnimOpDrawMode = 0x9,
126 kLBAnimOpPlaySound = 0xa,
127 kLBAnimOpWaitForSound = 0xb,
128 kLBAnimOpReleaseSound = 0xc,
129 kLBAnimOpResetSound = 0xd,
130 kLBAnimOpSetTempoDiv = 0xe,
135 kLBEventPhaseInit = 0,
136 kLBEventPhaseIntro = 1,
137 kLBEventMouseDown = 2,
141 kLBEventPhaseMain = 6,
142 kLBEventNotified = 7,
143 kLBEventDragStart = 8,
144 kLBEventDragMove = 9,
145 kLBEventDragEnd = 0xa,
146 kLBEventRolloverBegin = 0xb,
147 kLBEventRolloverMove = 0xc,
148 kLBEventRolloverEnd = 0xd,
149 kLBEventMouseUpIn = 0xe,
150 kLBEventMouseUpOut = 0xf,
151 kLBEventMouseTrackIn = 0x10,
152 kLBEventMouseTrackMove = 0x11,
153 kLBEventMouseTrackMoveIn = 0x12,
154 kLBEventMouseTrackMoveOut = 0x13,
155 kLBEventMouseTrackOut = 0x14,
156 kLBEventFocusBegin = 0x15,
157 kLBEventFocusEnd = 0x16,
160 kLBEventListLoad = 0x1b,
161 kLBEventPhaseCreate = 0xff
166 kLBLiveTextData = 0x65,
167 kLBMsgListScript = 0x66,
168 kLBNotifyScript = 0x67,
169 kLBSetPlayInfo = 0x68,
170 kLBSetRandomLoc = 0x69,
172 kLBSetDrawMode = 0x6b,
174 kLBSetOneShot = 0x6d,
175 kLBSetPlayPhase = 0x6e,
177 kLBSetKeyNotify = 0x6f,
179 kLBPaletteAData = 0x71,
180 kLBPaletteXData = 0x72,
183 kLBSetNotVisible = 0x75,
184 kLBSetVisible = 0x76,
185 kLBGlobalDisable = 0x77,
186 kLBGlobalEnable = 0x78,
187 kLBGlobalSetNotVisible = 0x79,
188 kLBGlobalSetVisible = 0x7a,
189 kLBSetAmbient = 0x7b,
190 kLBSetDragParams = 0x7c,
191 kLBSetKeyEvent = 0x7d,
192 kLBSetRolloverData = 0x7e,
194 kLBSetHitTest = 0x80,
196 kLBUnknown194 = 0x194
202 kLBOpTogglePlay = 0x2,
203 kLBOpSetNotVisible = 0x3,
204 kLBOpSetVisible = 0x4,
211 kLBOpGlobalSetNotVisible = 0xb,
212 kLBOpGlobalSetVisible = 0xc,
213 kLBOpGlobalDisable = 0xd,
214 kLBOpGlobalEnable = 0xe,
215 kLBOpSeekToEnd = 0xf,
222 kLBOpSeekToNext = 0x16,
223 kLBOpSeekToPrev = 0x17,
224 kLBOpDragBegin = 0x18,
226 kLBOpScriptDisable = 0x1a,
227 kLBOpScriptEnable = 0x1b,
228 kLBOpUnknown1C = 0x1c,
229 kLBOpSendExpression = 0x1d,
230 kLBOpJumpUnlessExpression = 0xfffb,
231 kLBOpBreakExpression = 0xfffc,
232 kLBOpJumpToExpression = 0xfffd,
233 kLBOpRunSubentries = 0xfffe,
234 kLBOpRunData = 0xffff
238 kLBNotifyGUIAction = 1,
239 kLBNotifyGoToControls = 2,
240 kLBNotifyChangePage = 3,
241 kLBNotifyGotoQuit = 4,
242 kLBNotifyIntroDone = 5,
243 kLBNotifyChangeMode = 6,
244 kLBNotifyCursorChange = 7,
245 kLBNotifyPrintPage = 0xc,
250 kTargetTypeExpression = 0x3f3f,
251 kTargetTypeCode = 0xfffe,
252 kTargetTypeName = 0xffff
275 uint16 targetingType;
315 NodeState update(
bool seeking =
false);
316 bool transparentAt(
int x,
int y);
322 void loadScript(uint16 resourceId);
342 void seek(uint16 pos);
343 void seekToTime(uint32 time);
346 void playSound(uint16 resourceId);
349 bool transparentAt(
int x,
int y);
351 void setTempo(uint16 tempo);
353 uint getNumResources() {
return _shapeResources.size(); }
354 uint16 getResource(uint num) {
return _shapeResources[num]; }
355 Common::Point getOffset(uint num) {
return _shapeOffsets[num]; }
357 uint32 getCurrentFrame() {
return _currentFrame; }
359 uint16 getParentId();
370 uint16 _currentSound;
373 uint32 _lastTime, _currentFrame;
376 void loadShape(uint16 resourceId);
389 void readData(uint16 type, uint16 size, byte *data);
392 virtual void destroySelf();
393 virtual void setEnabled(
bool enabled);
394 virtual void setGlobalEnabled(
bool enabled);
396 virtual void update();
397 virtual void draw() { }
402 virtual bool togglePlaying(
bool playing,
bool restart =
false);
403 virtual void done(
bool onlyNotify);
405 virtual void seek(uint16 pos) { }
406 virtual void seekToTime(uint32 time) { }
407 virtual void setFocused(
bool focused) { }
408 virtual void setVisible(
bool visible);
409 virtual void setGlobalVisible(
bool enabled);
410 virtual void startPhase(uint phase);
412 virtual void notify(uint16 data, uint16 from);
414 virtual void unload();
420 uint16 getId() {
return _itemId; }
423 uint16 getSoundPriority() {
return _soundMode; }
424 bool isLoaded() {
return _loaded; }
425 bool isAmbient() {
return _isAmbient; }
436 void setNextTime(uint16 min, uint16 max);
437 void setNextTime(uint16 min, uint16 max, uint32 start);
444 bool _loaded, _visible, _globalVisible, _playing, _enabled, _globalEnabled;
446 uint32 _nextTime, _startTime;
449 uint16 _phase, _timingMode, _delayMin, _delayMax;
450 uint16 _loopMode, _periodMin, _periodMax;
451 uint16 _controlMode, _soundMode;
457 virtual LBItem *createClone();
460 void runScript(uint event, uint16 data = 0, uint16 from = 0);
474 void update()
override;
475 bool togglePlaying(
bool playing,
bool restart)
override;
476 void stop()
override;
479 LBItem *createClone()
override;
495 void destroySelf()
override;
496 void setEnabled(
bool enabled)
override;
497 void setGlobalEnabled(
bool enabled)
override;
499 bool togglePlaying(
bool playing,
bool restart)
override;
501 void seek(uint16 pos)
override;
502 void setVisible(
bool visible)
override;
503 void setGlobalVisible(
bool visible)
override;
504 void startPhase(uint phase)
override;
505 void stop()
override;
506 void load()
override;
507 void unload()
override;
512 LBItem *createClone()
override;
526 bool togglePlaying(
bool playing,
bool restart)
override;
527 void update()
override;
530 LBItem *createClone()
override;
532 uint16 _fadeInPeriod, _fadeInStep, _drawStart, _drawCount;
533 uint32 _fadeInStart, _fadeInCurrent;
546 uint16 wordStart, wordCount;
547 uint16 highlightStart, highlightEnd;
548 uint16 startId, endId;
558 void update()
override;
559 void draw()
override;
561 bool togglePlaying(
bool playing,
bool restart)
override;
562 void stop()
override;
563 void notify(uint16 data, uint16 from)
override;
566 LBItem *createClone()
override;
568 void paletteUpdate(uint16 word,
bool on);
569 void drawWord(uint word, uint yPos);
571 uint16 _currentPhrase, _currentWord;
573 byte _backgroundColor[4];
574 byte _foregroundColor[4];
575 byte _highlightColor[4];
576 uint16 _paletteIndex;
589 void draw()
override;
590 void init()
override;
593 LBItem *createClone()
override;
601 void setEnabled(
bool enabled)
override;
603 void update()
override;
604 void draw()
override;
605 bool togglePlaying(
bool playing,
bool restart)
override;
606 void done(
bool onlyNotify)
override;
607 void init()
override;
608 void seek(uint16 pos)
override;
609 void seekToTime(uint32 time)
override;
610 void startPhase(uint phase)
override;
611 void stop()
override;
614 LBItem *createClone()
override;
625 void update()
override;
626 bool togglePlaying(
bool playing,
bool restart)
override;
629 LBItem *createClone()
override;
637 bool togglePlaying(
bool playing,
bool restart)
override;
640 LBItem *createClone()
override;
648 void load()
override;
649 void unload()
override;
652 LBItem *createClone()
override;
658 NotifyEvent(uint t, uint p) : type(t), param(p), newUnknown(0), newMode(0), newPage(0), newSubpage(0) { }
670 enum DelayedEventType {
671 kLBDelayedEventDestroy = 0,
672 kLBDelayedEventSetNotVisible = 1,
673 kLBDelayedEventDone = 2
679 DelayedEventType type;
687 void open(
Archive *mhk, uint16 baseId);
688 uint16 getResourceVersion();
690 void addClonedItem(
LBItem *item);
691 void itemDestroyed(
LBItem *item);
704 void loadBITL(uint16 resourceId);
720 bool _needsRedraw, _needsUpdate;
728 void addArchive(
Archive *archive);
729 void removeArchive(
Archive *archive);
730 void addItem(
LBItem *item);
733 LBItem *getItemById(uint16
id);
736 void setFocus(
LBItem *focus);
737 void setEnableForAll(
bool enable,
LBItem *except = 0);
738 void notifyAll(uint16 data, uint16 from);
741 bool playSound(
LBItem *source, uint16 resourceId);
742 void lockSound(
LBItem *owner,
bool lock);
744 bool isBigEndian()
const {
return getGameType() != GType_LIVINGBOOKSV1 || getPlatform() == Common::kPlatformMacintosh; }
745 bool isPreMohawk()
const;
747 LBMode getCurMode() {
return _curMode; }
749 bool tryLoadPageStart(LBMode mode, uint page);
750 bool loadPage(LBMode mode, uint page, uint subpage);
759 Archive *createArchive()
const;
769 bool _readOnly, _introDone;
771 uint16 _curPage, _curSubPage;
781 uint16 _lastSoundOwner, _lastSoundId;
782 uint16 _lastSoundPriority;
783 uint16 _soundLockOwner;
784 uint16 _maxSoundPriority;
786 void loadSHP(uint16 resourceId);
788 bool tryDefaultPage();
790 void handleUIMenuClick(uint controlId);
791 void handleUIPoetryMenuClick(uint controlId);
792 void handleUIQuitClick(uint controlId);
793 void handleUIOptionsClick(uint controlId);
799 uint16 _screenHeight;
800 uint16 _numLanguages;
807 uint16 _curSelectedPage;
808 bool _alreadyShowedIntro;
820 void pauseEngineIntern(
bool)
override;
Definition: livingbooks.h:545
Definition: livingbooks.h:620
Definition: livingbooks.h:551
Definition: livingbooks_code.h:212
Definition: livingbooks.h:333
Definition: livingbooks.h:308
Definition: livingbooks.h:484
Definition: livingbooks_graphics.h:31
Definition: livingbooks.h:676
Definition: resource.h:134
Definition: memstream.h:103
Definition: livingbooks.h:381
Definition: livingbooks.h:643
Definition: livingbooks.h:537
Definition: livingbooks.h:657
Definition: livingbooks.h:302
Definition: algorithm.h:29
Definition: livingbooks.h:469
Definition: livingbooks.h:49
Definition: livingbooks.h:260
Definition: livingbooks.h:489
Definition: ini-file.h:58
Definition: livingbooks.h:632
Definition: livingbooks.h:582
Definition: list_intern.h:51
Definition: livingbooks.h:682
Definition: livingbooks.h:596
Definition: detection.h:65
Definition: livingbooks.h:519
Definition: livingbooks.h:707