aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Dupont2010-10-26 22:18:14 +0000
committerSylvain Dupont2010-10-26 22:18:14 +0000
commit66da19552ea855d825c6a68b00e3e5ea8b84d932 (patch)
tree6d3cc2502a4e0a16ca16cd8264f3c3db4ae833a8
parent83eb3b36541aa9ca2872db6fd173e628d16b094a (diff)
downloadscummvm-rg350-66da19552ea855d825c6a68b00e3e5ea8b84d932.tar.gz
scummvm-rg350-66da19552ea855d825c6a68b00e3e5ea8b84d932.tar.bz2
scummvm-rg350-66da19552ea855d825c6a68b00e3e5ea8b84d932.zip
TOON: Implement cmd_Set_Anim_Scale_Size
Used to rescale the knight animation when the knight is moved around the room in Chapter 2 svn-id: r53865
-rw-r--r--engines/toon/anim.cpp18
-rw-r--r--engines/toon/anim.h3
-rw-r--r--engines/toon/script_func.cpp8
3 files changed, 26 insertions, 3 deletions
diff --git a/engines/toon/anim.cpp b/engines/toon/anim.cpp
index be53c12dc7..c5769f5081 100644
--- a/engines/toon/anim.cpp
+++ b/engines/toon/anim.cpp
@@ -425,6 +425,7 @@ AnimationInstance::AnimationInstance(ToonEngine *vm, AnimationInstanceType type)
_playing = false;
_rangeEnd = 0;
_useMask = false;
+ _alignBottom = false;
_rangeStart = 0;
_scale = 1024;
_x = 0;
@@ -433,6 +434,7 @@ AnimationInstance::AnimationInstance(ToonEngine *vm, AnimationInstanceType type)
_layerZ = 0;
}
+
void AnimationInstance::render() {
debugC(5, kDebugAnim, "render()");
if (_visible && _animation) {
@@ -443,11 +445,22 @@ void AnimationInstance::render() {
if (frame >= _animation->_numFrames)
frame = _animation->_numFrames - 1;
+ int32 x = _x;
+ int32 y = _y;
+
+ if (_alignBottom) {
+ int32 offsetX = (_animation->_x2 - _animation->_x1) / 2 * (_scale - 1024);
+ int32 offsetY = (_animation->_y2 - _animation->_y1) * (_scale - 1024);
+
+ x -= offsetX >> 10;
+ y -= offsetY >> 10;
+ }
+
if (_useMask) {
//if (_scale == 100) { // 100% scale
// _animation->drawFrameWithMask(_vm->getMainSurface(), _currentFrame, _x, _y, _z, _vm->getMask());
//} else {
- _animation->drawFrameWithMaskAndScale(_vm->getMainSurface(), frame, _x, _y, _z, _vm->getMask(), _scale);
+ _animation->drawFrameWithMaskAndScale(_vm->getMainSurface(), frame, x, y, _z, _vm->getMask(), _scale);
//}
} else {
_animation->drawFrame(_vm->getMainSurface(), frame, _x, _y);
@@ -534,9 +547,10 @@ void AnimationInstance::setVisible(bool visible) {
_visible = visible;
}
-void AnimationInstance::setScale(int32 scale) {
+void AnimationInstance::setScale(int32 scale, bool align) {
debugC(4, kDebugAnim, "setScale(%d)", scale);
_scale = scale;
+ _alignBottom = align;
}
void AnimationInstance::setUseMask(bool useMask) {
diff --git a/engines/toon/anim.h b/engines/toon/anim.h
index 5d65959e07..01475276c5 100644
--- a/engines/toon/anim.h
+++ b/engines/toon/anim.h
@@ -102,7 +102,7 @@ public:
void forceFrame(int32 position);
void setPosition(int32 x, int32 y, int32 z, bool relative = false);
Animation *getAnimation() const { return _animation; }
- void setScale(int32 scale);
+ void setScale(int32 scale, bool align = false);
void setVisible(bool visible);
bool getVisible() const { return _visible; }
void setUseMask(bool useMask);
@@ -150,6 +150,7 @@ protected:
bool _playing;
bool _looping;
bool _visible;
+ bool _alignBottom;
ToonEngine *_vm;
};
diff --git a/engines/toon/script_func.cpp b/engines/toon/script_func.cpp
index a84683a9a2..f96b9567a9 100644
--- a/engines/toon/script_func.cpp
+++ b/engines/toon/script_func.cpp
@@ -473,6 +473,14 @@ int32 ScriptFunc::sys_Cmd_Empty_Inventory(EMCState *state) {
}
int32 ScriptFunc::sys_Cmd_Set_Anim_Scale_Size(EMCState *state) {
+ int32 animID = stackPos(0);
+ int32 scale = stackPos(1);
+
+ SceneAnimation *sceneAnim = _vm->getSceneAnimation(animID);
+ if (sceneAnim) {
+ sceneAnim->_animInstance->setUseMask(true);
+ sceneAnim->_animInstance->setScale(scale,true);
+ }
return 0;
}
int32 ScriptFunc::sys_Cmd_Delete_Item_From_Inventory(EMCState *state) {