aboutsummaryrefslogtreecommitdiff
path: root/engines/mutationofjb
diff options
context:
space:
mode:
authorĽubomír Remák2019-01-12 05:33:49 +0100
committerĽubomír Remák2019-01-12 05:33:49 +0100
commitb4fed90145e7aa22601de9f32b5a4b0501266d1a (patch)
tree608e339329980a6227772bd0e91cd3311dd1aa24 /engines/mutationofjb
parenta97a14cc8918c7b60d94ec07ca4b214f3a7a2c93 (diff)
downloadscummvm-rg350-b4fed90145e7aa22601de9f32b5a4b0501266d1a.tar.gz
scummvm-rg350-b4fed90145e7aa22601de9f32b5a4b0501266d1a.tar.bz2
scummvm-rg350-b4fed90145e7aa22601de9f32b5a4b0501266d1a.zip
MUTATIONOFJB: Fix SETANIM and add support for pickupable statics.
Diffstat (limited to 'engines/mutationofjb')
-rw-r--r--engines/mutationofjb/commands/setobjectframecommand.cpp5
-rw-r--r--engines/mutationofjb/gamescreen.cpp2
-rw-r--r--engines/mutationofjb/room.cpp26
-rw-r--r--engines/mutationofjb/room.h19
4 files changed, 43 insertions, 9 deletions
diff --git a/engines/mutationofjb/commands/setobjectframecommand.cpp b/engines/mutationofjb/commands/setobjectframecommand.cpp
index 54d9059af7..8fcff2be26 100644
--- a/engines/mutationofjb/commands/setobjectframecommand.cpp
+++ b/engines/mutationofjb/commands/setobjectframecommand.cpp
@@ -29,7 +29,7 @@
/** @file
* "SETANIM " <objectId> " " <frame>
*
- * Sets the frame for the specified object and redraws it.
+ * Draws the frame for the specified object without changing the object's current frame.
* If the object is active, it is deactivated.
*/
@@ -51,7 +51,8 @@ Command::ExecuteResult SetObjectFrameCommand::execute(ScriptExecutionContext &sc
Object *const object = scriptExecCtx.getGameData().getCurrentScene()->getObject(_objectId);
object->_active = 0;
- scriptExecCtx.getGame().getRoom().drawObject(_objectId);
+ // The object's current frame is not changed, so use frame override instead.
+ scriptExecCtx.getGame().getRoom().drawObject(_objectId, _frame);
return Finished;
}
diff --git a/engines/mutationofjb/gamescreen.cpp b/engines/mutationofjb/gamescreen.cpp
index 024d7b6308..b8d6743570 100644
--- a/engines/mutationofjb/gamescreen.cpp
+++ b/engines/mutationofjb/gamescreen.cpp
@@ -28,6 +28,7 @@
#include "mutationofjb/gamedata.h"
#include "mutationofjb/mutationofjb.h"
#include "mutationofjb/inventory.h"
+#include "mutationofjb/room.h"
#include "mutationofjb/util.h"
#include "mutationofjb/widgets/conversationwidget.h"
#include "mutationofjb/widgets/gamewidget.h"
@@ -405,6 +406,7 @@ void GameScreen::onGameStaticClicked(GameWidget *, Static *stat) {
_game.getGameData().getInventory().addItem(inventoryName);
stat->_active = 0;
+ _game.getRoom().drawStatic(stat);
}
}
}
diff --git a/engines/mutationofjb/room.cpp b/engines/mutationofjb/room.cpp
index e478a1cb8c..1d49fb3c80 100644
--- a/engines/mutationofjb/room.cpp
+++ b/engines/mutationofjb/room.cpp
@@ -148,11 +148,11 @@ void Room::drawObjectAnimation(uint8 objectId, int animOffset) {
blit_if(_surfaces[animFrame], _background, Common::Point(object->_x, object->_y), ThresholdBlitOperation());
}
-void Room::drawObject(uint8 objectId) {
+void Room::drawObject(uint8 objectId, uint8 overrideFrame) {
Scene *const currentScene = _game->getGameData().getCurrentScene();
Object *const object = currentScene->getObject(objectId);
- drawObjectAnimation(objectId, object->_currentFrame - _objectsStart[objectId - 1] - 1);
+ drawObjectAnimation(objectId, (overrideFrame ? overrideFrame : object->_currentFrame) - _objectsStart[objectId - 1] - 1);
}
void Room::drawBitmap(uint8 bitmapId) {
@@ -171,6 +171,16 @@ void Room::drawBitmap(uint8 bitmapId) {
drawFrames(bitmap->_roomFrame - 1, bitmap->_roomFrame - 1, bitmapArea, 0xC0);
}
+void Room::drawStatic(Static *const stat) {
+ if (!stat || !stat->allowsImplicitPickup()) {
+ return;
+ }
+
+ const uint8 frame = stat->_active ? 1 : 2; // Hardcoded values. Active is taken from frame 1 and inactive from frame 2.
+ const Common::Rect staticArea(stat->_x, stat->_y, stat->_x + stat->_width, stat->_y + stat->_height);
+ drawFrames(frame, frame, staticArea, 0xC0); // Hardcoded threshold.
+}
+
void Room::drawFrames(uint8 fromFrame, uint8 toFrame, const Common::Rect &area, uint8 threshold) {
GameData &gameData = _game->getGameData();
@@ -195,15 +205,19 @@ void Room::drawFrames(uint8 fromFrame, uint8 toFrame, const Common::Rect &area,
AnimationDecoder decoder(fileName, _background);
decoder.setPartialMode(fromFrame, toFrame, area, threshold);
decoder.decode(nullptr);
- if (!area.isEmpty())
- _screen->getSubArea(area); // Add dirty rect.
- else
- _screen->makeAllDirty();
}
}
void Room::initialDraw() {
Scene *const currentScene = _game->getGameData().getCurrentScene();
+
+ for (uint8 i = 0; i < currentScene->getNoStatics(); ++i) {
+ Static *const stat = currentScene->getStatic(i + 1);
+ if (stat->_active && stat->allowsImplicitPickup()) {
+ drawStatic(stat);
+ }
+ }
+
for (uint8 i = 0; i < currentScene->getNoObjects(); ++i) {
Object *const obj = currentScene->getObject(i + 1);
if (obj->_active) {
diff --git a/engines/mutationofjb/room.h b/engines/mutationofjb/room.h
index 705e285d4a..1c76344303 100644
--- a/engines/mutationofjb/room.h
+++ b/engines/mutationofjb/room.h
@@ -36,6 +36,7 @@ namespace MutationOfJB {
class EncryptedFile;
class Game;
+class Static;
class Room {
public:
@@ -45,8 +46,24 @@ public:
Room(Game *game, Graphics::Screen *screen);
bool load(uint8 roomNumber, bool roomB);
void drawObjectAnimation(uint8 objectId, int animOffset);
- void drawObject(uint8 objectId);
+
+ /**
+ * Draws an object.
+ * By default, object's current frame is used, but that can be overridden.
+ *
+ * @param objectId ID of object to draw.
+ * @param overrideFrame Optional frame override.
+ */
+ void drawObject(uint8 objectId, uint8 overrideFrame = 0);
void drawBitmap(uint8 bitmapId);
+
+ /**
+ * Draws a static.
+ * Only statics that allow implicit pickup are drawable.
+ *
+ * @param stat Static.
+ */
+ void drawStatic(Static *stat);
void drawFrames(uint8 fromFrame, uint8 toFrame, const Common::Rect &area = Common::Rect(), uint8 threshold = 0xFF);
void initialDraw();
void redraw(bool useBackgroundBuffer = true);