2009-12-29 23:18:24 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOHAWK_LIVINGBOOKS_H
|
|
|
|
#define MOHAWK_LIVINGBOOKS_H
|
|
|
|
|
|
|
|
#include "mohawk/mohawk.h"
|
|
|
|
#include "mohawk/console.h"
|
|
|
|
#include "mohawk/graphics.h"
|
2011-04-01 12:43:22 +00:00
|
|
|
#include "mohawk/sound.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
#include "common/config-file.h"
|
2010-11-19 17:03:07 +00:00
|
|
|
#include "common/substream.h"
|
2010-11-28 22:55:15 +00:00
|
|
|
#include "common/rect.h"
|
|
|
|
#include "common/queue.h"
|
|
|
|
#include "common/random.h"
|
|
|
|
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/mixer.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2011-01-12 19:11:27 +00:00
|
|
|
#include "livingbooks_code.h"
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
namespace Mohawk {
|
|
|
|
|
2011-03-30 22:17:33 +00:00
|
|
|
#define LBKEY_MOD_CTRL 1
|
|
|
|
#define LBKEY_MOD_ALT 2
|
|
|
|
#define LBKEY_MOD_SHIFT 4
|
|
|
|
|
|
|
|
struct LBKey {
|
|
|
|
byte code;
|
|
|
|
byte modifiers;
|
|
|
|
byte char_;
|
|
|
|
byte repeats;
|
|
|
|
};
|
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
enum NodeState {
|
|
|
|
kLBNodeDone = 0,
|
|
|
|
kLBNodeRunning = 1,
|
|
|
|
kLBNodeWaiting = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
enum LBMode {
|
|
|
|
kLBIntroMode = 1,
|
|
|
|
kLBControlMode = 2,
|
|
|
|
kLBCreditsMode = 3,
|
|
|
|
kLBPreviewMode = 4,
|
|
|
|
kLBReadMode = 5,
|
|
|
|
kLBPlayMode = 6
|
|
|
|
};
|
|
|
|
|
2010-12-12 23:59:46 +00:00
|
|
|
// automatic modes used in _timingMode
|
|
|
|
enum {
|
|
|
|
kLBAutoNone = 0,
|
|
|
|
kLBAutoIntro = 1,
|
|
|
|
kLBAutoUserIdle = 2,
|
|
|
|
kLBAutoMain = 3,
|
|
|
|
kLBAutoSync = 4,
|
|
|
|
kLBAutoInit = 5,
|
|
|
|
kLBAutoCreate = 6,
|
|
|
|
kLBAutoLoad = 7
|
|
|
|
};
|
|
|
|
|
2010-12-13 00:03:15 +00:00
|
|
|
// control modes used in _controlMode
|
|
|
|
enum {
|
|
|
|
kLBControlNone = 0,
|
|
|
|
kLBControlHideMouse = 1,
|
|
|
|
kLBControlPauseItems = 2
|
|
|
|
};
|
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
enum {
|
|
|
|
kLBStaticTextItem = 0x1,
|
|
|
|
kLBPictureItem = 0x2,
|
|
|
|
kLBEditTextItem = 0x14,
|
|
|
|
kLBLiveTextItem = 0x15,
|
|
|
|
kLBAnimationItem = 0x40,
|
|
|
|
kLBSoundItem = 0x41,
|
|
|
|
kLBGroupItem = 0x42,
|
2010-12-09 21:25:05 +00:00
|
|
|
kLBMovieItem = 0x43,
|
|
|
|
kLBPaletteAItem = 0x44, // unused?
|
|
|
|
kLBPaletteItem = 0x45,
|
|
|
|
kLBProxyItem = 0x46,
|
2011-03-26 15:08:07 +00:00
|
|
|
kLBMiniGameItem = 666, // EVIL!!!!
|
2011-01-12 19:11:27 +00:00
|
|
|
kLBXDataFileItem = 0x3e9,
|
|
|
|
kLBDiscDectectorItem = 0xfa1
|
2010-11-28 22:55:15 +00:00
|
|
|
};
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
enum {
|
2010-11-28 22:55:15 +00:00
|
|
|
// no 0x1?
|
|
|
|
kLBAnimOpNotify = 0x2,
|
|
|
|
kLBAnimOpSetTempo = 0x3,
|
|
|
|
// no 0x4?
|
|
|
|
kLBAnimOpMoveTo = 0x5,
|
|
|
|
kLBAnimOpWait = 0x6,
|
|
|
|
kLBAnimOpSetCel = 0x7,
|
|
|
|
kLBAnimOpSleepUntil = 0x8,
|
|
|
|
kLBAnimOpDrawMode = 0x9,
|
|
|
|
kLBAnimOpPlaySound = 0xa,
|
|
|
|
kLBAnimOpWaitForSound = 0xb,
|
|
|
|
kLBAnimOpReleaseSound = 0xc,
|
|
|
|
kLBAnimOpResetSound = 0xd,
|
2011-01-30 22:42:37 +00:00
|
|
|
kLBAnimOpSetTempoDiv = 0xe,
|
2010-12-02 21:24:55 +00:00
|
|
|
kLBAnimOpDelay = 0xf
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
enum {
|
2010-12-07 22:58:45 +00:00
|
|
|
kLBEventPhaseInit = 0,
|
|
|
|
kLBEventPhaseIntro = 1,
|
|
|
|
kLBEventMouseDown = 2,
|
|
|
|
kLBEventStarted = 3,
|
|
|
|
kLBEventDone = 4,
|
|
|
|
kLBEventMouseUp = 5,
|
|
|
|
kLBEventPhaseMain = 6,
|
|
|
|
kLBEventNotified = 7,
|
|
|
|
kLBEventDragMove = 9,
|
|
|
|
kLBEventRolloverBegin = 0xb,
|
|
|
|
kLBEventRolloverMove = 0xc,
|
|
|
|
kLBEventRolloverEnd = 0xd,
|
|
|
|
kLBEventMouseUpIn = 0xe,
|
|
|
|
kLBEventMouseUpOut = 0xf,
|
|
|
|
kLBEventMouseTrackIn = 0x10,
|
|
|
|
kLBEventMouseTrackMove = 0x11,
|
|
|
|
kLBEventMouseTrackMoveIn = 0x12,
|
|
|
|
kLBEventMouseTrackMoveOut = 0x13,
|
|
|
|
kLBEventMouseTrackOut = 0x14,
|
|
|
|
kLBEventFocusBegin = 0x15,
|
|
|
|
kLBEventFocusEnd = 0x16,
|
|
|
|
kLBEventInit = 0x17,
|
|
|
|
kLBEventLoad = 0x1a,
|
|
|
|
kLBEventListLoad = 0x1b,
|
|
|
|
kLBEventPhaseCreate = 0xff
|
2010-11-28 22:55:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kLBGroupData = 0x64,
|
|
|
|
kLBLiveTextData = 0x65,
|
|
|
|
kLBMsgListScript = 0x66,
|
|
|
|
kLBNotifyScript = 0x67,
|
|
|
|
kLBSetPlayInfo = 0x68,
|
2010-12-01 18:22:05 +00:00
|
|
|
kLBSetRandomLoc = 0x69, // unused?
|
|
|
|
kLBSetDrag = 0x6a, // unused?
|
|
|
|
kLBSetDrawMode = 0x6b,
|
|
|
|
kLBSetFont = 0x6c, // unused?
|
|
|
|
kLBSetOneShot = 0x6d, // unused?
|
2010-11-29 21:41:21 +00:00
|
|
|
kLBSetPlayPhase = 0x6e,
|
2010-12-01 18:22:05 +00:00
|
|
|
// from here, 2.x+
|
2011-03-30 22:17:33 +00:00
|
|
|
kLBSetKeyNotify = 0x6f,
|
2010-12-01 18:22:05 +00:00
|
|
|
kLBCommand = 0x70,
|
|
|
|
kLBPaletteAData = 0x71, // unused?
|
|
|
|
kLBPaletteXData = 0x72,
|
|
|
|
kLBDisable = 0x73, // unused?
|
|
|
|
kLBEnable = 0x74, // unused?
|
|
|
|
kLBSetNotVisible = 0x75,
|
|
|
|
kLBSetVisible = 0x76, // unused?
|
2010-12-12 23:00:46 +00:00
|
|
|
kLBGlobalDisable = 0x77,
|
2010-12-01 18:22:05 +00:00
|
|
|
kLBGlobalEnable = 0x78, // unused?
|
|
|
|
kLBGlobalSetNotVisible = 0x79,
|
|
|
|
kLBGlobalSetVisible = 0x7a, // unused?
|
|
|
|
kLBSetAmbient = 0x7b,
|
|
|
|
kLBUnknown7C = 0x7c, // unused?
|
2011-03-30 22:17:33 +00:00
|
|
|
kLBSetKeyEvent = 0x7d,
|
2011-01-12 19:11:27 +00:00
|
|
|
kLBUnknown7E = 0x7e, // unused? (rect flag)
|
2010-12-01 18:22:05 +00:00
|
|
|
kLBSetParent = 0x7f, // unused?
|
2011-03-30 22:17:33 +00:00
|
|
|
kLBSetHitTest = 0x80,
|
2011-01-12 19:11:27 +00:00
|
|
|
// from here, rugrats
|
|
|
|
kLBUnknown194 = 0x194
|
2010-11-28 22:55:15 +00:00
|
|
|
};
|
|
|
|
|
2010-12-08 15:45:40 +00:00
|
|
|
enum {
|
|
|
|
kLBOpNone = 0x0,
|
|
|
|
kLBOpXShow = 0x1,
|
|
|
|
kLBOpTogglePlay = 0x2,
|
|
|
|
kLBOpSetNotVisible = 0x3,
|
|
|
|
kLBOpSetVisible = 0x4,
|
|
|
|
kLBOpDestroy = 0x5,
|
|
|
|
kLBOpRewind = 0x6,
|
|
|
|
kLBOpStop = 0x7,
|
|
|
|
kLBOpDisable = 0x8,
|
|
|
|
kLBOpEnable = 0x9,
|
|
|
|
// (no 0xa)
|
|
|
|
kLBOpGlobalSetNotVisible = 0xb,
|
|
|
|
kLBOpGlobalSetVisible = 0xc,
|
|
|
|
kLBOpGlobalDisable = 0xd,
|
|
|
|
kLBOpGlobalEnable = 0xe,
|
|
|
|
kLBOpSeekToEnd = 0xf,
|
|
|
|
// (no 0x10)
|
|
|
|
kLBOpMute = 0x11,
|
|
|
|
kLBOpUnmute = 0x12,
|
|
|
|
kLBOpLoad = 0x13,
|
|
|
|
kLBOpPreload = 0x14,
|
|
|
|
kLBOpUnload = 0x15,
|
|
|
|
kLBOpSeekToNext = 0x16,
|
|
|
|
kLBOpSeekToPrev = 0x17,
|
|
|
|
kLBOpDragBegin = 0x18,
|
|
|
|
kLBOpDragEnd = 0x19,
|
|
|
|
kLBOpScriptDisable = 0x1a,
|
|
|
|
kLBOpScriptEnable = 0x1b,
|
|
|
|
kLBOpUnknown1C = 0x1c,
|
|
|
|
kLBOpSendExpression = 0x1d,
|
2011-04-06 22:33:11 +00:00
|
|
|
kLBOpJumpUnlessExpression = 0xfffb,
|
|
|
|
kLBOpBreakExpression = 0xfffc,
|
|
|
|
kLBOpJumpToExpression = 0xfffd,
|
2010-12-13 20:19:34 +00:00
|
|
|
kLBOpRunSubentries = 0xfffe,
|
2010-12-08 15:45:40 +00:00
|
|
|
kLBOpRunCommand = 0xffff
|
|
|
|
};
|
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
enum {
|
|
|
|
kLBNotifyGUIAction = 1,
|
|
|
|
kLBNotifyGoToControls = 2,
|
|
|
|
kLBNotifyChangePage = 3,
|
2010-12-08 15:45:22 +00:00
|
|
|
kLBNotifyGotoQuit = 4,
|
2010-11-28 22:55:15 +00:00
|
|
|
kLBNotifyIntroDone = 5,
|
2010-12-05 22:10:50 +00:00
|
|
|
kLBNotifyChangeMode = 6,
|
2010-12-08 15:45:22 +00:00
|
|
|
kLBNotifyCursorChange = 7,
|
|
|
|
kLBNotifyPrintPage = 0xc,
|
|
|
|
kLBNotifyQuit = 0xd
|
2010-11-28 22:55:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class MohawkEngine_LivingBooks;
|
2011-04-09 19:01:27 +00:00
|
|
|
class LBPage;
|
2009-12-29 23:18:24 +00:00
|
|
|
class LBGraphics;
|
2010-11-28 22:55:15 +00:00
|
|
|
class LBAnimation;
|
|
|
|
|
|
|
|
struct LBScriptEntry {
|
|
|
|
LBScriptEntry();
|
|
|
|
~LBScriptEntry();
|
|
|
|
|
2011-02-01 22:00:37 +00:00
|
|
|
uint16 state;
|
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
uint16 type;
|
2010-12-07 22:58:45 +00:00
|
|
|
uint16 event;
|
2010-11-28 22:55:15 +00:00
|
|
|
uint16 opcode;
|
|
|
|
uint16 param;
|
2010-12-05 22:10:50 +00:00
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
uint16 argc;
|
|
|
|
uint16 *argvParam;
|
|
|
|
uint16 *argvTarget;
|
2010-12-05 16:19:52 +00:00
|
|
|
|
2010-12-05 22:10:50 +00:00
|
|
|
// kLBNotifyChangeMode
|
|
|
|
uint16 newUnknown;
|
|
|
|
uint16 newMode;
|
|
|
|
uint16 newPage;
|
|
|
|
uint16 newSubpage;
|
|
|
|
|
2010-12-07 22:58:45 +00:00
|
|
|
// kLBEventNotified
|
2010-12-05 22:10:50 +00:00
|
|
|
uint16 matchFrom;
|
|
|
|
uint16 matchNotify;
|
|
|
|
|
2010-12-11 23:48:29 +00:00
|
|
|
// kLBOpSendExpression
|
|
|
|
uint32 offset;
|
2011-04-06 22:33:11 +00:00
|
|
|
// kLBOpJumpUnlessExpression
|
|
|
|
uint16 target;
|
2010-12-11 23:48:29 +00:00
|
|
|
|
2010-12-05 16:19:52 +00:00
|
|
|
Common::String command;
|
|
|
|
Common::Array<Common::String> conditions;
|
2010-12-13 20:19:34 +00:00
|
|
|
Common::Array<LBScriptEntry *> subentries;
|
2010-11-28 22:55:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct LBAnimScriptEntry {
|
|
|
|
byte opcode;
|
|
|
|
byte size;
|
|
|
|
byte *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LBAnimationNode {
|
|
|
|
public:
|
|
|
|
LBAnimationNode(MohawkEngine_LivingBooks *vm, LBAnimation *parent, uint16 scriptResourceId);
|
|
|
|
~LBAnimationNode();
|
|
|
|
|
|
|
|
void draw(const Common::Rect &_bounds);
|
|
|
|
void reset();
|
|
|
|
NodeState update(bool seeking = false);
|
|
|
|
bool transparentAt(int x, int y);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
MohawkEngine_LivingBooks *_vm;
|
|
|
|
LBAnimation *_parent;
|
|
|
|
|
|
|
|
void loadScript(uint16 resourceId);
|
|
|
|
uint _currentEntry;
|
|
|
|
Common::Array<LBAnimScriptEntry> _scriptEntries;
|
|
|
|
|
|
|
|
uint _currentCel;
|
|
|
|
int16 _xPos, _yPos;
|
2010-12-02 21:24:55 +00:00
|
|
|
uint32 _delay;
|
2010-11-28 22:55:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class LBAnimationItem;
|
|
|
|
|
|
|
|
class LBAnimation {
|
|
|
|
public:
|
|
|
|
LBAnimation(MohawkEngine_LivingBooks *vm, LBAnimationItem *parent, uint16 resourceId);
|
|
|
|
~LBAnimation();
|
|
|
|
|
|
|
|
void draw();
|
2010-11-30 14:40:51 +00:00
|
|
|
bool update();
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
void start();
|
|
|
|
void seek(uint16 pos);
|
|
|
|
void stop();
|
|
|
|
|
2011-01-31 18:03:27 +00:00
|
|
|
void playSound(uint16 resourceId);
|
2011-04-01 12:43:22 +00:00
|
|
|
bool soundPlaying(uint16 resourceId, const Common::String &cue);
|
2011-01-31 18:03:27 +00:00
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
bool transparentAt(int x, int y);
|
|
|
|
|
|
|
|
void setTempo(uint16 tempo);
|
|
|
|
|
|
|
|
uint getNumResources() { return _shapeResources.size(); }
|
|
|
|
uint16 getResource(uint num) { return _shapeResources[num]; }
|
|
|
|
Common::Point getOffset(uint num) { return _shapeOffsets[num]; }
|
|
|
|
|
|
|
|
uint32 getCurrentFrame() { return _currentFrame; }
|
|
|
|
|
|
|
|
uint16 getParentId();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
MohawkEngine_LivingBooks *_vm;
|
|
|
|
LBAnimationItem *_parent;
|
|
|
|
|
|
|
|
Common::Rect _bounds, _clip;
|
|
|
|
Common::Array<LBAnimationNode *> _nodes;
|
|
|
|
|
|
|
|
uint16 _tempo;
|
2011-04-01 12:43:22 +00:00
|
|
|
|
2011-01-31 18:03:27 +00:00
|
|
|
uint16 _currentSound;
|
2011-04-01 12:43:22 +00:00
|
|
|
CueList _cueList;
|
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
uint32 _lastTime, _currentFrame;
|
2010-11-30 14:40:51 +00:00
|
|
|
bool _running;
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
void loadShape(uint16 resourceId);
|
|
|
|
Common::Array<uint16> _shapeResources;
|
|
|
|
Common::Array<Common::Point> _shapeOffsets;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LBItem {
|
2011-01-12 19:11:27 +00:00
|
|
|
friend class LBCode;
|
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
public:
|
2011-04-09 19:01:27 +00:00
|
|
|
LBItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect);
|
2010-11-28 22:55:15 +00:00
|
|
|
virtual ~LBItem();
|
|
|
|
|
|
|
|
void readFrom(Common::SeekableSubReadStreamEndian *stream);
|
|
|
|
virtual void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
|
|
|
|
|
|
|
|
virtual void destroySelf(); // 0x2
|
|
|
|
virtual void setEnabled(bool enabled); // 0x3
|
2010-12-04 23:48:31 +00:00
|
|
|
virtual void setGlobalEnabled(bool enabled);
|
2010-11-28 22:55:15 +00:00
|
|
|
virtual bool contains(Common::Point point); // 0x7
|
|
|
|
virtual void update(); // 0x8
|
|
|
|
virtual void draw() { } // 0x9
|
|
|
|
virtual void handleKeyChar(Common::Point pos) { } // 0xA
|
|
|
|
virtual void handleMouseDown(Common::Point pos); // 0xB
|
|
|
|
virtual void handleMouseMove(Common::Point pos); // 0xC
|
|
|
|
virtual void handleMouseUp(Common::Point pos); // 0xD
|
2010-11-30 14:41:27 +00:00
|
|
|
virtual bool togglePlaying(bool playing, bool restart = false); // 0xF
|
2010-11-28 22:55:15 +00:00
|
|
|
virtual void done(bool onlyNotify); // 0x10
|
|
|
|
virtual void init() { } // 0x11
|
|
|
|
virtual void seek(uint16 pos) { } // 0x13
|
|
|
|
virtual void setFocused(bool focused) { } // 0x14
|
|
|
|
virtual void setVisible(bool visible); // 0x17
|
2010-12-04 23:48:31 +00:00
|
|
|
virtual void setGlobalVisible(bool enabled);
|
2010-11-28 22:55:15 +00:00
|
|
|
virtual void startPhase(uint phase); // 0x18
|
|
|
|
virtual void stop(); // 0x19
|
|
|
|
virtual void notify(uint16 data, uint16 from); // 0x1A
|
|
|
|
|
|
|
|
uint16 getId() { return _itemId; }
|
2011-04-07 21:02:28 +00:00
|
|
|
const Common::String &getName() { return _desc; }
|
2011-04-07 21:05:22 +00:00
|
|
|
const Common::Rect &getRect() { return _rect; }
|
2011-03-29 14:28:24 +00:00
|
|
|
uint16 getSoundPriority() { return _soundMode; }
|
2011-03-29 19:19:46 +00:00
|
|
|
bool isAmbient() { return _isAmbient; }
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
MohawkEngine_LivingBooks *_vm;
|
2011-04-09 19:01:27 +00:00
|
|
|
LBPage *_page;
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
void setNextTime(uint16 min, uint16 max);
|
|
|
|
void setNextTime(uint16 min, uint16 max, uint32 start);
|
|
|
|
|
|
|
|
Common::Rect _rect;
|
|
|
|
Common::String _desc;
|
|
|
|
uint16 _resourceId;
|
|
|
|
uint16 _itemId;
|
|
|
|
|
2010-12-04 23:48:31 +00:00
|
|
|
bool _visible, _globalVisible, _playing, _enabled, _neverEnabled, _globalEnabled;
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
uint32 _nextTime, _startTime;
|
|
|
|
uint16 _loops;
|
|
|
|
|
|
|
|
uint16 _phase, _timingMode, _delayMin, _delayMax;
|
2010-12-06 13:49:56 +00:00
|
|
|
uint16 _loopMode, _periodMin, _periodMax;
|
|
|
|
uint16 _controlMode, _soundMode;
|
2010-11-28 22:55:15 +00:00
|
|
|
Common::Point _relocPoint;
|
|
|
|
|
2010-12-01 18:22:05 +00:00
|
|
|
bool _isAmbient;
|
2011-03-30 23:16:47 +00:00
|
|
|
bool _doHitTest;
|
2010-12-01 18:22:05 +00:00
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
Common::Array<LBScriptEntry *> _scriptEntries;
|
2010-12-13 20:19:34 +00:00
|
|
|
void runScript(uint event, uint16 data = 0, uint16 from = 0);
|
2011-04-06 22:33:11 +00:00
|
|
|
int runScriptEntry(LBScriptEntry *entry);
|
2010-12-05 16:19:35 +00:00
|
|
|
|
|
|
|
LBValue parseValue(const Common::String &command, uint &pos);
|
|
|
|
void runCommand(const Common::String &command);
|
|
|
|
bool checkCondition(const Common::String &condition);
|
2010-12-12 19:01:46 +00:00
|
|
|
|
|
|
|
LBScriptEntry *parseScriptEntry(uint16 type, uint16 &size, Common::SeekableSubReadStreamEndian *stream, bool isSubentry = false);
|
2010-11-28 22:55:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class LBSoundItem : public LBItem {
|
|
|
|
public:
|
2011-04-09 19:01:27 +00:00
|
|
|
LBSoundItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
|
2010-11-28 22:55:15 +00:00
|
|
|
~LBSoundItem();
|
|
|
|
|
2010-11-30 15:35:22 +00:00
|
|
|
void update();
|
2010-11-30 14:41:27 +00:00
|
|
|
bool togglePlaying(bool playing, bool restart);
|
2010-11-28 22:55:15 +00:00
|
|
|
void stop();
|
2010-11-30 15:35:22 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool _running;
|
2010-11-28 22:55:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct GroupEntry {
|
|
|
|
uint entryId;
|
|
|
|
uint entryType;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LBGroupItem : public LBItem {
|
|
|
|
public:
|
2011-04-09 19:01:27 +00:00
|
|
|
LBGroupItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
|
|
|
|
|
2011-03-29 13:09:15 +00:00
|
|
|
void destroySelf();
|
2010-11-28 22:55:15 +00:00
|
|
|
void setEnabled(bool enabled);
|
2010-12-04 23:48:31 +00:00
|
|
|
void setGlobalEnabled(bool enabled);
|
2010-11-28 22:55:15 +00:00
|
|
|
bool contains(Common::Point point);
|
2010-11-30 14:41:27 +00:00
|
|
|
bool togglePlaying(bool playing, bool restart);
|
2010-11-28 22:55:15 +00:00
|
|
|
// 0x12
|
|
|
|
void seek(uint16 pos);
|
|
|
|
void setVisible(bool visible);
|
2010-12-04 23:48:31 +00:00
|
|
|
void setGlobalVisible(bool visible);
|
2010-11-28 22:55:15 +00:00
|
|
|
void startPhase(uint phase);
|
|
|
|
void stop();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool _starting;
|
|
|
|
|
|
|
|
Common::Array<GroupEntry> _groupEntries;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LBPaletteItem : public LBItem {
|
|
|
|
public:
|
2011-04-09 19:01:27 +00:00
|
|
|
LBPaletteItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
|
2010-12-09 21:25:21 +00:00
|
|
|
~LBPaletteItem();
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
|
|
|
|
|
2010-12-05 22:11:07 +00:00
|
|
|
bool togglePlaying(bool playing, bool restart);
|
|
|
|
void update();
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
protected:
|
2010-12-05 22:11:07 +00:00
|
|
|
uint16 _fadeInPeriod, _fadeInStep, _drawStart, _drawCount;
|
|
|
|
uint32 _fadeInStart, _fadeInCurrent;
|
2010-12-09 21:25:21 +00:00
|
|
|
byte *_palette;
|
2010-11-28 22:55:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct LiveTextWord {
|
|
|
|
Common::Rect bounds;
|
|
|
|
uint16 soundId;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LiveTextPhrase {
|
|
|
|
uint16 wordStart, wordCount;
|
|
|
|
uint16 highlightStart, highlightEnd;
|
|
|
|
uint16 startId, endId;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LBLiveTextItem : public LBItem {
|
|
|
|
public:
|
2011-04-09 19:01:27 +00:00
|
|
|
LBLiveTextItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
|
|
|
|
|
2010-11-29 21:42:00 +00:00
|
|
|
bool contains(Common::Point point);
|
|
|
|
void update();
|
2010-12-01 18:21:49 +00:00
|
|
|
void draw();
|
2010-11-29 21:42:00 +00:00
|
|
|
void handleMouseDown(Common::Point pos);
|
2010-11-30 14:41:27 +00:00
|
|
|
bool togglePlaying(bool playing, bool restart);
|
2010-11-29 21:42:00 +00:00
|
|
|
void stop();
|
2010-11-28 22:55:15 +00:00
|
|
|
void notify(uint16 data, uint16 from);
|
|
|
|
|
|
|
|
protected:
|
2010-11-30 14:41:09 +00:00
|
|
|
void paletteUpdate(uint16 word, bool on);
|
2010-12-01 18:21:49 +00:00
|
|
|
void drawWord(uint word, uint yPos);
|
2010-11-30 14:41:09 +00:00
|
|
|
|
2010-12-01 18:21:49 +00:00
|
|
|
uint16 _currentPhrase, _currentWord;
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
byte _backgroundColor[4];
|
|
|
|
byte _foregroundColor[4];
|
|
|
|
byte _highlightColor[4];
|
|
|
|
uint16 _paletteIndex;
|
|
|
|
|
|
|
|
Common::Array<LiveTextWord> _words;
|
|
|
|
Common::Array<LiveTextPhrase> _phrases;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LBPictureItem : public LBItem {
|
|
|
|
public:
|
2011-04-09 19:01:27 +00:00
|
|
|
LBPictureItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
|
|
|
|
|
|
|
|
bool contains(Common::Point point);
|
|
|
|
void draw();
|
|
|
|
void init();
|
|
|
|
};
|
|
|
|
|
|
|
|
class LBAnimationItem : public LBItem {
|
|
|
|
public:
|
2011-04-09 19:01:27 +00:00
|
|
|
LBAnimationItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
|
2010-11-28 22:55:15 +00:00
|
|
|
~LBAnimationItem();
|
|
|
|
|
|
|
|
void setEnabled(bool enabled);
|
|
|
|
bool contains(Common::Point point);
|
|
|
|
void update();
|
|
|
|
void draw();
|
2010-11-30 14:41:27 +00:00
|
|
|
bool togglePlaying(bool playing, bool restart);
|
2010-11-28 22:55:15 +00:00
|
|
|
void done(bool onlyNotify);
|
|
|
|
void init();
|
|
|
|
void seek(uint16 pos);
|
|
|
|
void startPhase(uint phase);
|
|
|
|
void stop();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
LBAnimation *_anim;
|
|
|
|
bool _running;
|
|
|
|
};
|
|
|
|
|
2010-12-09 21:25:05 +00:00
|
|
|
class LBMovieItem : public LBItem {
|
|
|
|
public:
|
2011-04-09 19:01:27 +00:00
|
|
|
LBMovieItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
|
2010-12-09 21:25:05 +00:00
|
|
|
~LBMovieItem();
|
|
|
|
|
|
|
|
void update();
|
|
|
|
bool togglePlaying(bool playing, bool restart);
|
|
|
|
};
|
|
|
|
|
2011-03-26 15:08:07 +00:00
|
|
|
class LBMiniGameItem : public LBItem {
|
|
|
|
public:
|
2011-04-09 19:01:27 +00:00
|
|
|
LBMiniGameItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
|
2011-03-26 15:08:07 +00:00
|
|
|
~LBMiniGameItem();
|
|
|
|
|
|
|
|
bool togglePlaying(bool playing, bool restart);
|
|
|
|
};
|
|
|
|
|
2011-05-13 21:02:06 +00:00
|
|
|
class LBProxyItem : public LBItem {
|
|
|
|
public:
|
|
|
|
LBProxyItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
|
|
|
|
~LBProxyItem();
|
|
|
|
|
|
|
|
void init();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
class LBPage *_page;
|
|
|
|
};
|
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
struct NotifyEvent {
|
2011-04-11 22:21:46 +00:00
|
|
|
NotifyEvent(uint t, uint p) : type(t), param(p), newUnknown(0), newMode(0), newPage(0), newSubpage(0) { }
|
2010-11-28 22:55:15 +00:00
|
|
|
uint type;
|
|
|
|
uint param;
|
2010-12-05 22:58:13 +00:00
|
|
|
|
|
|
|
// kLBNotifyChangeMode
|
|
|
|
uint16 newUnknown;
|
|
|
|
uint16 newMode;
|
|
|
|
uint16 newPage;
|
|
|
|
uint16 newSubpage;
|
2010-11-28 22:55:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum DelayedEventType {
|
2010-12-07 22:58:45 +00:00
|
|
|
kLBDelayedEventDestroy = 0,
|
|
|
|
kLBDelayedEventSetNotVisible = 1,
|
|
|
|
kLBDelayedEventDone = 2
|
2010-11-28 22:55:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DelayedEvent {
|
|
|
|
DelayedEvent(LBItem *i, DelayedEventType t) : item(i), type(t) { }
|
|
|
|
LBItem *item;
|
|
|
|
DelayedEventType type;
|
|
|
|
};
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2011-04-09 19:01:27 +00:00
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
class MohawkEngine_LivingBooks : public MohawkEngine {
|
|
|
|
protected:
|
|
|
|
Common::Error run();
|
|
|
|
|
|
|
|
public:
|
|
|
|
MohawkEngine_LivingBooks(OSystem *syst, const MohawkGameDescription *gamedesc);
|
|
|
|
virtual ~MohawkEngine_LivingBooks();
|
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
Common::RandomSource *_rnd;
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
LBGraphics *_gfx;
|
2010-11-28 22:55:15 +00:00
|
|
|
bool _needsRedraw, _needsUpdate;
|
|
|
|
|
|
|
|
void addNotifyEvent(NotifyEvent event);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
Common::SeekableSubReadStreamEndian *wrapStreamEndian(uint32 tag, uint16 id);
|
2010-12-16 16:53:26 +00:00
|
|
|
Common::String readString(Common::SeekableSubReadStreamEndian *stream);
|
2010-11-28 22:55:15 +00:00
|
|
|
Common::Rect readRect(Common::SeekableSubReadStreamEndian *stream);
|
2009-12-29 23:18:24 +00:00
|
|
|
GUI::Debugger *getDebugger() { return _console; }
|
|
|
|
|
2011-04-09 19:01:27 +00:00
|
|
|
void addArchive(MohawkArchive *archive);
|
|
|
|
void removeArchive(MohawkArchive *Archive);
|
|
|
|
void addItem(LBItem *item);
|
|
|
|
void removeItems(const Common::Array<LBItem *> &items);
|
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
LBItem *getItemById(uint16 id);
|
2011-04-07 21:02:28 +00:00
|
|
|
LBItem *getItemByName(Common::String name);
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
void setFocus(LBItem *focus);
|
|
|
|
void setEnableForAll(bool enable, LBItem *except = 0);
|
|
|
|
void notifyAll(uint16 data, uint16 from);
|
|
|
|
void queueDelayedEvent(DelayedEvent event);
|
|
|
|
|
2011-03-29 14:28:24 +00:00
|
|
|
bool playSound(LBItem *source, uint16 resourceId);
|
|
|
|
void lockSound(LBItem *owner, bool lock);
|
|
|
|
|
2010-11-29 12:51:53 +00:00
|
|
|
bool isBigEndian() const { return getGameType() != GType_LIVINGBOOKSV1 || getPlatform() == Common::kPlatformMacintosh; }
|
2011-02-13 21:11:22 +00:00
|
|
|
bool isPreMohawk() const;
|
2010-11-28 22:55:15 +00:00
|
|
|
|
2010-11-30 21:05:45 +00:00
|
|
|
LBMode getCurMode() { return _curMode; }
|
|
|
|
|
|
|
|
bool tryLoadPageStart(LBMode mode, uint page);
|
|
|
|
void prevPage();
|
|
|
|
void nextPage();
|
|
|
|
|
2010-12-05 16:19:35 +00:00
|
|
|
// TODO: make private
|
|
|
|
Common::HashMap<Common::String, LBValue> _variables;
|
|
|
|
|
2011-04-09 19:01:27 +00:00
|
|
|
// helper functions, also used by LBProxyItem
|
|
|
|
Common::String getFileNameFromConfig(const Common::String §ion, const Common::String &key, Common::String &leftover);
|
|
|
|
MohawkArchive *createMohawkArchive() const;
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
private:
|
|
|
|
LivingBooksConsole *_console;
|
|
|
|
Common::ConfigFile _bookInfoFile;
|
|
|
|
|
2009-12-30 23:02:14 +00:00
|
|
|
Common::String getBookInfoFileName() const;
|
2010-11-23 22:32:39 +00:00
|
|
|
void loadBookInfo(const Common::String &filename);
|
2010-11-28 22:55:15 +00:00
|
|
|
|
|
|
|
Common::String stringForMode(LBMode mode);
|
|
|
|
|
|
|
|
bool _readOnly, _introDone;
|
|
|
|
LBMode _curMode;
|
|
|
|
uint16 _curPage, _curSubPage;
|
|
|
|
uint16 _phase;
|
2011-04-09 19:01:27 +00:00
|
|
|
LBPage *_page;
|
2010-11-28 22:55:15 +00:00
|
|
|
Common::Array<LBItem *> _items;
|
|
|
|
Common::Queue<DelayedEvent> _eventQueue;
|
|
|
|
LBItem *_focus;
|
|
|
|
void destroyPage();
|
|
|
|
bool loadPage(LBMode mode, uint page, uint subpage);
|
|
|
|
void updatePage();
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2011-03-29 14:28:24 +00:00
|
|
|
uint16 _lastSoundOwner, _lastSoundId;
|
|
|
|
uint16 _lastSoundPriority;
|
|
|
|
uint16 _soundLockOwner;
|
|
|
|
uint16 _maxSoundPriority;
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
void loadSHP(uint16 resourceId);
|
2010-11-28 22:55:15 +00:00
|
|
|
|
2010-11-30 21:05:45 +00:00
|
|
|
bool tryDefaultPage();
|
2010-11-28 22:55:15 +00:00
|
|
|
|
2010-12-04 23:47:43 +00:00
|
|
|
void handleUIMenuClick(uint controlId);
|
|
|
|
void handleUIPoetryMenuClick(uint controlId);
|
|
|
|
void handleUIQuitClick(uint controlId);
|
|
|
|
void handleUIOptionsClick(uint controlId);
|
|
|
|
|
2010-11-28 22:55:15 +00:00
|
|
|
Common::Queue<NotifyEvent> _notifyEvents;
|
|
|
|
void handleNotify(NotifyEvent &event);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
uint16 _screenWidth;
|
|
|
|
uint16 _screenHeight;
|
|
|
|
uint16 _numLanguages;
|
|
|
|
uint16 _numPages;
|
|
|
|
Common::String _title;
|
|
|
|
Common::String _copyright;
|
2010-11-28 22:55:15 +00:00
|
|
|
bool _poetryMode;
|
|
|
|
|
|
|
|
uint16 _curLanguage;
|
2010-11-29 23:19:59 +00:00
|
|
|
uint16 _curSelectedPage;
|
2010-11-28 22:55:15 +00:00
|
|
|
bool _alreadyShowedIntro;
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
// String Manipulation Functions
|
2011-03-30 19:06:12 +00:00
|
|
|
Common::String removeQuotesFromString(const Common::String &string, Common::String &leftover);
|
2010-11-23 22:32:39 +00:00
|
|
|
Common::String convertMacFileName(const Common::String &string);
|
|
|
|
Common::String convertWinFileName(const Common::String &string);
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
// Configuration File Functions
|
2010-11-23 22:32:39 +00:00
|
|
|
Common::String getStringFromConfig(const Common::String §ion, const Common::String &key);
|
2011-03-30 19:06:12 +00:00
|
|
|
Common::String getStringFromConfig(const Common::String §ion, const Common::String &key, Common::String &leftover);
|
2010-11-23 22:32:39 +00:00
|
|
|
int getIntFromConfig(const Common::String §ion, const Common::String &key);
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Mohawk
|
|
|
|
|
|
|
|
#endif
|