aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/livingbooks.h
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mohawk/livingbooks.h')
-rw-r--r--engines/mohawk/livingbooks.h67
1 files changed, 49 insertions, 18 deletions
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 3eff039385..cd3b206d57 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -237,6 +237,7 @@ enum {
};
class MohawkEngine_LivingBooks;
+class LBPage;
class LBGraphics;
class LBAnimation;
@@ -357,7 +358,7 @@ class LBItem {
friend class LBCode;
public:
- LBItem(MohawkEngine_LivingBooks *vm, Common::Rect rect);
+ LBItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect);
virtual ~LBItem();
void readFrom(Common::SeekableSubReadStreamEndian *stream);
@@ -385,11 +386,14 @@ public:
virtual void notify(uint16 data, uint16 from); // 0x1A
uint16 getId() { return _itemId; }
+ const Common::String &getName() { return _desc; }
+ const Common::Rect &getRect() { return _rect; }
uint16 getSoundPriority() { return _soundMode; }
bool isAmbient() { return _isAmbient; }
protected:
MohawkEngine_LivingBooks *_vm;
+ LBPage *_page;
void setNextTime(uint16 min, uint16 max);
void setNextTime(uint16 min, uint16 max, uint32 start);
@@ -425,7 +429,7 @@ protected:
class LBSoundItem : public LBItem {
public:
- LBSoundItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBSoundItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
~LBSoundItem();
void update();
@@ -443,7 +447,7 @@ struct GroupEntry {
class LBGroupItem : public LBItem {
public:
- LBGroupItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBGroupItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
@@ -467,7 +471,7 @@ protected:
class LBPaletteItem : public LBItem {
public:
- LBPaletteItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBPaletteItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
~LBPaletteItem();
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
@@ -494,7 +498,7 @@ struct LiveTextPhrase {
class LBLiveTextItem : public LBItem {
public:
- LBLiveTextItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBLiveTextItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
@@ -523,7 +527,7 @@ protected:
class LBPictureItem : public LBItem {
public:
- LBPictureItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBPictureItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
@@ -534,7 +538,7 @@ public:
class LBAnimationItem : public LBItem {
public:
- LBAnimationItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBAnimationItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
~LBAnimationItem();
void setEnabled(bool enabled);
@@ -555,7 +559,7 @@ protected:
class LBMovieItem : public LBItem {
public:
- LBMovieItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBMovieItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
~LBMovieItem();
void update();
@@ -564,14 +568,14 @@ public:
class LBMiniGameItem : public LBItem {
public:
- LBMiniGameItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBMiniGameItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
~LBMiniGameItem();
bool togglePlaying(bool playing, bool restart);
};
struct NotifyEvent {
- NotifyEvent(uint t, uint p) : type(t), param(p) { }
+ NotifyEvent(uint t, uint p) : type(t), param(p), newUnknown(0), newMode(0), newPage(0), newSubpage(0) { }
uint type;
uint param;
@@ -594,6 +598,30 @@ struct DelayedEvent {
DelayedEventType type;
};
+class LBPage {
+public:
+ LBPage(MohawkEngine_LivingBooks *vm);
+ ~LBPage();
+
+ void open(MohawkArchive *mhk, uint16 baseId);
+ uint16 getResourceVersion();
+
+ void itemDestroyed(LBItem *item);
+
+ LBCode *_code;
+
+protected:
+ MohawkEngine_LivingBooks *_vm;
+
+ MohawkArchive *_mhk;
+ Common::Array<LBItem *> _items;
+
+ uint16 _baseId;
+ bool _cascade;
+
+ void loadBITL(uint16 resourceId);
+};
+
class MohawkEngine_LivingBooks : public MohawkEngine {
protected:
Common::Error run();
@@ -614,7 +642,13 @@ public:
Common::Rect readRect(Common::SeekableSubReadStreamEndian *stream);
GUI::Debugger *getDebugger() { return _console; }
+ void addArchive(MohawkArchive *archive);
+ void removeArchive(MohawkArchive *Archive);
+ void addItem(LBItem *item);
+ void removeItems(const Common::Array<LBItem *> &items);
+
LBItem *getItemById(uint16 id);
+ LBItem *getItemByName(Common::String name);
void setFocus(LBItem *focus);
void setEnableForAll(bool enable, LBItem *except = 0);
@@ -633,11 +667,13 @@ public:
void prevPage();
void nextPage();
- LBCode *_code;
-
// TODO: make private
Common::HashMap<Common::String, LBValue> _variables;
+ // helper functions, also used by LBProxyItem
+ Common::String getFileNameFromConfig(const Common::String &section, const Common::String &key, Common::String &leftover);
+ MohawkArchive *createMohawkArchive() const;
+
private:
LivingBooksConsole *_console;
Common::ConfigFile _bookInfoFile;
@@ -651,6 +687,7 @@ private:
LBMode _curMode;
uint16 _curPage, _curSubPage;
uint16 _phase;
+ LBPage *_page;
Common::Array<LBItem *> _items;
Common::Queue<DelayedEvent> _eventQueue;
LBItem *_focus;
@@ -663,8 +700,6 @@ private:
uint16 _soundLockOwner;
uint16 _maxSoundPriority;
- uint16 getResourceVersion();
- void loadBITL(uint16 resourceId);
void loadSHP(uint16 resourceId);
bool tryDefaultPage();
@@ -698,10 +733,6 @@ private:
Common::String getStringFromConfig(const Common::String &section, const Common::String &key);
Common::String getStringFromConfig(const Common::String &section, const Common::String &key, Common::String &leftover);
int getIntFromConfig(const Common::String &section, const Common::String &key);
- Common::String getFileNameFromConfig(const Common::String &section, const Common::String &key, Common::String &leftover);
-
- // Platform/Version functions
- MohawkArchive *createMohawkArchive() const;
};
} // End of namespace Mohawk