aboutsummaryrefslogtreecommitdiff
path: root/engines/m4
diff options
context:
space:
mode:
authorPaul Gilbert2009-11-15 08:22:57 +0000
committerPaul Gilbert2009-11-15 08:22:57 +0000
commit67442c230ca364524eb245e203e2d3cc96db7e05 (patch)
tree97eaef0fadc3938b860f0302d1e04e63ce8852d9 /engines/m4
parent6bb2b8aa9a5c1e04828a6ce1ddde72b5d4292fa9 (diff)
downloadscummvm-rg350-67442c230ca364524eb245e203e2d3cc96db7e05.tar.gz
scummvm-rg350-67442c230ca364524eb245e203e2d3cc96db7e05.tar.bz2
scummvm-rg350-67442c230ca364524eb245e203e2d3cc96db7e05.zip
Added display of the rotating inventory objects
svn-id: r45912
Diffstat (limited to 'engines/m4')
-rw-r--r--engines/m4/mads_menus.cpp3
-rw-r--r--engines/m4/scene.cpp50
-rw-r--r--engines/m4/scene.h8
3 files changed, 61 insertions, 0 deletions
diff --git a/engines/m4/mads_menus.cpp b/engines/m4/mads_menus.cpp
index 3782b58e01..de44ddca41 100644
--- a/engines/m4/mads_menus.cpp
+++ b/engines/m4/mads_menus.cpp
@@ -309,6 +309,9 @@ void RexMainMenuView::handleAction(MadsGameAction action) {
vm->_mouse->cursorOn();
vm->_viewManager->addView(vm->_scene);
vm->_scene->loadScene(101);
+
+ // **DEBUG** - set the default object
+ vm->_scene->setSelectedObject(48);
return;
case SHOW_INTRO:
diff --git a/engines/m4/scene.cpp b/engines/m4/scene.cpp
index 45659b8696..30c304161c 100644
--- a/engines/m4/scene.cpp
+++ b/engines/m4/scene.cpp
@@ -46,6 +46,7 @@ Scene::Scene(M4Engine *vm): View(vm, Common::Rect(0, 0, vm->_screen->width(), vm
_codeSurface = new M4Surface();
_madsInterfaceSurface = new M4Surface();
_sceneSprites = NULL;
+ _objectSprites = NULL;
_palData = NULL;
_interfacePal = NULL;
_inverseColorTable = NULL;
@@ -68,6 +69,8 @@ Scene::~Scene() {
if (_sceneSprites)
delete _sceneSprites;
+ if (_objectSprites)
+ delete _objectSprites;
_vm->_palette->deleteAllRanges();
@@ -441,12 +444,17 @@ void Scene::playIntro() {
}
+static const int FRAME_SPEED = 8;
+static const int INVENTORY_X = 160;
+static const int INVENTORY_Y = 159;
+
void Scene::update() {
// TODO: Needs a proper implementation
// NOTE: Don't copy the background when in M4 mode or WoodScript anims won't be shown
if (!_vm->isM4()) {
_backgroundSurface->copyTo(this);
+ // Handle display of any status text
if (_statusText[0]) {
// Text colors are inverted in Dragonsphere
if (_vm->getGameType() == GType_DragonSphere)
@@ -457,6 +465,21 @@ void Scene::update() {
_vm->_font->setFont(FONT_MAIN_MADS);
_vm->_font->writeString(this, _statusText, (width() - _vm->_font->getWidth(_statusText)) / 2, 142, 0);
}
+
+ _madsInterfaceSurface->copyTo(this, 0, this->height() - _madsInterfaceSurface->height());
+
+ if (_objectSprites) {
+ // Display object sprite. Note that the frame number isn't used directly, because it would result
+ // in too fast an animation
+ M4Sprite *spr = _objectSprites->getFrame(_objectFrameNumber / FRAME_SPEED);
+ spr->copyTo(this, INVENTORY_X, INVENTORY_Y, 0);
+
+ if (!_vm->_globals->invObjectsStill) {
+ // If objetcs are to animated, move to the next frame
+ if (++_objectFrameNumber >= (_objectSprites->getCount() * FRAME_SPEED))
+ _objectFrameNumber = 0;
+ }
+ }
}
}
@@ -667,4 +690,31 @@ void Scene::showMADSV2TextBox(char *text, int x, int y, char *faceName) {
boxSprites->getFrame(bottomRight)->copyTo(_backgroundSurface, curX, curY + 1);
}
+/*--------------------------------------------------------------------------*/
+
+void Scene::setSelectedObject(int objectNumber) {
+ VALIDATE_MADS;
+
+ // Load inventory resource
+ if (_objectSprites) {
+ _vm->_palette->deleteRange(_objectPalData);
+ delete _objectSprites;
+ }
+
+ char resName[80];
+ sprintf(resName, "*OB%.3dI.SS", objectNumber);
+
+ Common::SeekableReadStream *data = _vm->res()->get(resName);
+ _objectSprites = new SpriteAsset(_vm, data, data->size(), resName);
+ _vm->res()->toss(resName);
+
+ // Slot it into available palette space
+ _objectPalData = _objectSprites->getRgbList();
+ _vm->_palette->addRange(_objectPalData);
+ _objectSprites->translate(_objectPalData, true);
+
+ _objectFrameNumber = 0;
+ _selectedObject = objectNumber;
+}
+
} // End of namespace M4
diff --git a/engines/m4/scene.h b/engines/m4/scene.h
index 671821b438..092ae8372b 100644
--- a/engines/m4/scene.h
+++ b/engines/m4/scene.h
@@ -102,6 +102,8 @@ public:
void onRefresh(RectList *rects, M4Surface *destSurface);
bool onEvent(M4EventType eventType, int param1, int x, int y, bool &captureEvents);
+ void setSelectedObject(int objectNumber);
+
private:
int _currentScene;
M4Surface *_backgroundSurface;
@@ -116,6 +118,12 @@ private:
SpriteAsset *_walkerSprite;
char _statusText[100];
+ // Inventory related fields
+ int _selectedObject;
+ SpriteAsset *_objectSprites;
+ RGBList *_objectPalData;
+ int _objectFrameNumber;
+
void nextCommonCursor();
};