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;
50 #define LBKEY_MOD_CTRL 1 51 #define LBKEY_MOD_ALT 2 52 #define LBKEY_MOD_SHIFT 4 80 kLBPhaseNone = 0x7fff,
81 kLBPhaseLoad = 0xfffe,
82 kLBPhaseCreate = 0xffff
100 kLBControlHideMouse = 1,
101 kLBControlPauseItems = 2
105 kLBStaticTextItem = 0x1,
106 kLBPictureItem = 0x2,
107 kLBEditTextItem = 0x14,
108 kLBLiveTextItem = 0x15,
109 kLBAnimationItem = 0x40,
113 kLBPaletteAItem = 0x44,
114 kLBPaletteItem = 0x45,
116 kLBMiniGameItem = 666,
117 kLBXDataFileItem = 0x3e9,
118 kLBDiscDectectorItem = 0xfa1
123 kLBAnimOpNotify = 0x2,
124 kLBAnimOpSetTempo = 0x3,
126 kLBAnimOpMoveTo = 0x5,
128 kLBAnimOpSetCel = 0x7,
129 kLBAnimOpSleepUntil = 0x8,
130 kLBAnimOpDrawMode = 0x9,
131 kLBAnimOpPlaySound = 0xa,
132 kLBAnimOpWaitForSound = 0xb,
133 kLBAnimOpReleaseSound = 0xc,
134 kLBAnimOpResetSound = 0xd,
135 kLBAnimOpSetTempoDiv = 0xe,
140 kLBEventPhaseInit = 0,
141 kLBEventPhaseIntro = 1,
142 kLBEventMouseDown = 2,
146 kLBEventPhaseMain = 6,
147 kLBEventNotified = 7,
148 kLBEventDragStart = 8,
149 kLBEventDragMove = 9,
150 kLBEventDragEnd = 0xa,
151 kLBEventRolloverBegin = 0xb,
152 kLBEventRolloverMove = 0xc,
153 kLBEventRolloverEnd = 0xd,
154 kLBEventMouseUpIn = 0xe,
155 kLBEventMouseUpOut = 0xf,
156 kLBEventMouseTrackIn = 0x10,
157 kLBEventMouseTrackMove = 0x11,
158 kLBEventMouseTrackMoveIn = 0x12,
159 kLBEventMouseTrackMoveOut = 0x13,
160 kLBEventMouseTrackOut = 0x14,
161 kLBEventFocusBegin = 0x15,
162 kLBEventFocusEnd = 0x16,
165 kLBEventListLoad = 0x1b,
166 kLBEventPhaseCreate = 0xff
171 kLBLiveTextData = 0x65,
172 kLBMsgListScript = 0x66,
173 kLBNotifyScript = 0x67,
174 kLBSetPlayInfo = 0x68,
175 kLBSetRandomLoc = 0x69,
177 kLBSetDrawMode = 0x6b,
179 kLBSetOneShot = 0x6d,
180 kLBSetPlayPhase = 0x6e,
182 kLBSetKeyNotify = 0x6f,
184 kLBPaletteAData = 0x71,
185 kLBPaletteXData = 0x72,
188 kLBSetNotVisible = 0x75,
189 kLBSetVisible = 0x76,
190 kLBGlobalDisable = 0x77,
191 kLBGlobalEnable = 0x78,
192 kLBGlobalSetNotVisible = 0x79,
193 kLBGlobalSetVisible = 0x7a,
194 kLBSetAmbient = 0x7b,
195 kLBSetDragParams = 0x7c,
196 kLBSetKeyEvent = 0x7d,
197 kLBSetRolloverData = 0x7e,
199 kLBSetHitTest = 0x80,
201 kLBUnknown194 = 0x194
207 kLBOpTogglePlay = 0x2,
208 kLBOpSetNotVisible = 0x3,
209 kLBOpSetVisible = 0x4,
216 kLBOpGlobalSetNotVisible = 0xb,
217 kLBOpGlobalSetVisible = 0xc,
218 kLBOpGlobalDisable = 0xd,
219 kLBOpGlobalEnable = 0xe,
220 kLBOpSeekToEnd = 0xf,
227 kLBOpSeekToNext = 0x16,
228 kLBOpSeekToPrev = 0x17,
229 kLBOpDragBegin = 0x18,
231 kLBOpScriptDisable = 0x1a,
232 kLBOpScriptEnable = 0x1b,
233 kLBOpUnknown1C = 0x1c,
234 kLBOpSendExpression = 0x1d,
235 kLBOpJumpUnlessExpression = 0xfffb,
236 kLBOpBreakExpression = 0xfffc,
237 kLBOpJumpToExpression = 0xfffd,
238 kLBOpRunSubentries = 0xfffe,
239 kLBOpRunData = 0xffff
243 kLBNotifyGUIAction = 1,
244 kLBNotifyGoToControls = 2,
245 kLBNotifyChangePage = 3,
246 kLBNotifyGotoQuit = 4,
247 kLBNotifyIntroDone = 5,
248 kLBNotifyChangeMode = 6,
249 kLBNotifyCursorChange = 7,
250 kLBNotifyPrintPage = 0xc,
255 kTargetTypeExpression = 0x3f3f,
256 kTargetTypeCode = 0xfffe,
257 kTargetTypeName = 0xffff
280 uint16 targetingType;
320 NodeState update(
bool seeking =
false);
321 bool transparentAt(
int x,
int y);
327 void loadScript(uint16 resourceId);
347 void seek(uint16 pos);
348 void seekToTime(uint32 time);
351 void playSound(uint16 resourceId);
354 bool transparentAt(
int x,
int y);
356 void setTempo(uint16 tempo);
358 uint getNumResources() {
return _shapeResources.size(); }
359 uint16 getResource(uint num) {
return _shapeResources[num]; }
360 Common::Point getOffset(uint num) {
return _shapeOffsets[num]; }
362 uint32 getCurrentFrame() {
return _currentFrame; }
364 uint16 getParentId();
375 uint16 _currentSound;
378 uint32 _lastTime, _currentFrame;
381 void loadShape(uint16 resourceId);
394 void readData(uint16 type, uint16 size, byte *data);
397 virtual void destroySelf();
398 virtual void setEnabled(
bool enabled);
399 virtual void setGlobalEnabled(
bool enabled);
401 virtual void update();
402 virtual void draw() { }
407 virtual bool togglePlaying(
bool playing,
bool restart =
false);
408 virtual void done(
bool onlyNotify);
410 virtual void seek(uint16 pos) { }
411 virtual void seekToTime(uint32 time) { }
412 virtual void setFocused(
bool focused) { }
413 virtual void setVisible(
bool visible);
414 virtual void setGlobalVisible(
bool enabled);
415 virtual void startPhase(uint phase);
417 virtual void notify(uint16 data, uint16 from);
419 virtual void unload();
425 uint16 getId() {
return _itemId; }
428 uint16 getSoundPriority() {
return _soundMode; }
429 bool isLoaded() {
return _loaded; }
430 bool isAmbient() {
return _isAmbient; }
441 void setNextTime(uint16 min, uint16 max);
442 void setNextTime(uint16 min, uint16 max, uint32 start);
449 bool _loaded, _visible, _globalVisible, _playing, _enabled, _globalEnabled;
451 uint32 _nextTime, _startTime;
454 uint16 _phase, _timingMode, _delayMin, _delayMax;
455 uint16 _loopMode, _periodMin, _periodMax;
456 uint16 _controlMode, _soundMode;
462 virtual LBItem *createClone();
465 void runScript(uint event, uint16 data = 0, uint16 from = 0);
479 void update()
override;
480 bool togglePlaying(
bool playing,
bool restart)
override;
481 void stop()
override;
484 LBItem *createClone()
override;
500 void destroySelf()
override;
501 void setEnabled(
bool enabled)
override;
502 void setGlobalEnabled(
bool enabled)
override;
504 bool togglePlaying(
bool playing,
bool restart)
override;
506 void seek(uint16 pos)
override;
507 void setVisible(
bool visible)
override;
508 void setGlobalVisible(
bool visible)
override;
509 void startPhase(uint phase)
override;
510 void stop()
override;
511 void load()
override;
512 void unload()
override;
517 LBItem *createClone()
override;
531 bool togglePlaying(
bool playing,
bool restart)
override;
532 void update()
override;
535 LBItem *createClone()
override;
537 uint16 _fadeInPeriod, _fadeInStep, _drawStart, _drawCount;
538 uint32 _fadeInStart, _fadeInCurrent;
551 uint16 wordStart, wordCount;
552 uint16 highlightStart, highlightEnd;
553 uint16 startId, endId;
563 void update()
override;
564 void draw()
override;
566 bool togglePlaying(
bool playing,
bool restart)
override;
567 void stop()
override;
568 void notify(uint16 data, uint16 from)
override;
571 LBItem *createClone()
override;
573 void paletteUpdate(uint16 word,
bool on);
574 void drawWord(uint word, uint yPos);
576 uint16 _currentPhrase, _currentWord;
578 byte _backgroundColor[4];
579 byte _foregroundColor[4];
580 byte _highlightColor[4];
581 uint16 _paletteIndex;
594 void draw()
override;
595 void init()
override;
598 LBItem *createClone()
override;
606 void setEnabled(
bool enabled)
override;
608 void update()
override;
609 void draw()
override;
610 bool togglePlaying(
bool playing,
bool restart)
override;
611 void done(
bool onlyNotify)
override;
612 void init()
override;
613 void seek(uint16 pos)
override;
614 void seekToTime(uint32 time)
override;
615 void startPhase(uint phase)
override;
616 void stop()
override;
619 LBItem *createClone()
override;
630 void update()
override;
631 bool togglePlaying(
bool playing,
bool restart)
override;
634 LBItem *createClone()
override;
642 bool togglePlaying(
bool playing,
bool restart)
override;
645 LBItem *createClone()
override;
653 void load()
override;
654 void unload()
override;
657 LBItem *createClone()
override;
663 NotifyEvent(uint t, uint p) : type(t), param(p), newUnknown(0), newMode(0), newPage(0), newSubpage(0) { }
675 enum DelayedEventType {
676 kLBDelayedEventDestroy = 0,
677 kLBDelayedEventSetNotVisible = 1,
678 kLBDelayedEventDone = 2
684 DelayedEventType type;
692 void open(
Archive *mhk, uint16 baseId);
693 uint16 getResourceVersion();
695 void addClonedItem(
LBItem *item);
696 void itemDestroyed(
LBItem *item);
709 void loadBITL(uint16 resourceId);
725 bool _needsRedraw, _needsUpdate;
733 void addArchive(
Archive *archive);
734 void removeArchive(
Archive *archive);
735 void addItem(
LBItem *item);
738 LBItem *getItemById(uint16
id);
741 void setFocus(
LBItem *focus);
742 void setEnableForAll(
bool enable,
LBItem *except = 0);
743 void notifyAll(uint16 data, uint16 from);
746 bool playSound(
LBItem *source, uint16 resourceId);
747 void lockSound(
LBItem *owner,
bool lock);
749 bool isBigEndian()
const {
return getGameType() != GType_LIVINGBOOKSV1 || getPlatform() == Common::kPlatformMacintosh; }
750 bool isPreMohawk()
const;
752 LBMode getCurMode() {
return _curMode; }
754 bool tryLoadPageStart(LBMode mode, uint page);
755 bool loadPage(LBMode mode, uint page, uint subpage);
764 Archive *createArchive()
const;
774 bool _readOnly, _introDone;
776 uint16 _curPage, _curSubPage;
786 uint16 _lastSoundOwner, _lastSoundId;
787 uint16 _lastSoundPriority;
788 uint16 _soundLockOwner;
789 uint16 _maxSoundPriority;
791 void loadSHP(uint16 resourceId);
793 bool tryDefaultPage();
795 void handleUIMenuClick(uint controlId);
796 void handleUIPoetryMenuClick(uint controlId);
797 void handleUIQuitClick(uint controlId);
798 void handleUIOptionsClick(uint controlId);
804 uint16 _screenHeight;
805 uint16 _numLanguages;
812 uint16 _curSelectedPage;
813 bool _alreadyShowedIntro;
825 void pauseEngineIntern(
bool)
override;
Definition: livingbooks.h:550
Definition: livingbooks.h:625
Definition: livingbooks.h:556
Definition: livingbooks_code.h:212
Definition: livingbooks.h:338
Definition: livingbooks.h:313
Definition: livingbooks.h:489
Definition: livingbooks_graphics.h:31
Definition: livingbooks.h:681
Definition: resource.h:134
Definition: memstream.h:103
Definition: livingbooks.h:386
Definition: livingbooks.h:648
Definition: livingbooks.h:542
Definition: livingbooks.h:662
Definition: livingbooks.h:307
Definition: algorithm.h:29
Definition: livingbooks.h:474
Definition: livingbooks.h:54
Definition: livingbooks.h:265
Definition: livingbooks.h:494
Definition: ini-file.h:58
Definition: livingbooks.h:637
Definition: livingbooks.h:587
Definition: list_intern.h:54
Definition: livingbooks.h:687
Definition: livingbooks.h:601
Definition: detection.h:65
Definition: livingbooks.h:524
Definition: livingbooks.h:712