diff --git a/engines/grim/actor.cpp b/engines/grim/actor.cpp index 2942cffa210..1aa40206fe1 100644 --- a/engines/grim/actor.cpp +++ b/engines/grim/actor.cpp @@ -74,7 +74,10 @@ Actor::Actor(const Common::String &actorName) : _visible(true), _lipSync(NULL), _turning(false), _walking(false), _walkedLast(false), _walkedCur(false), _lastTurnDir(0), _currTurnDir(0), - _sayLineText(0), _talkDelay(0), _attachedActor(NULL), _attachedJoint("") { + _sayLineText(0), _talkDelay(0), + _attachedActor(NULL), _attachedJoint(""), + _global_alpha(1.f), _alphaMode(AlphaOff) { + _inOverworld = false; _lookingMode = false; _constrain = false; _talkSoundName = ""; @@ -112,6 +115,9 @@ Actor::Actor() { _attachedActor = NULL; _attachedJoint = ""; + _alphaMode = AlphaOff; + _global_alpha = 1.f; + for (int i = 0; i < MAX_SHADOWS; i++) { _shadowArray[i].active = false; _shadowArray[i].dontNegate = false; diff --git a/engines/grim/actor.h b/engines/grim/actor.h index e9e34c1fe43..b036146543b 100644 --- a/engines/grim/actor.h +++ b/engines/grim/actor.h @@ -71,6 +71,12 @@ public: CollisionSphere = 2 }; + enum AlphaMode { + AlphaOff = -1, + AlphaReplace = 2, + AlphaModulate = 3 // Seems to be unused + }; + /** * Initializes an actor with the given name. * @@ -467,6 +473,9 @@ public: void setInOverworld(bool inOverworld) { _inOverworld = inOverworld; } bool isInOverworld() { return _inOverworld; } + void setGlobalAlpha(float alpha) { _global_alpha = alpha; } + void setAlphaMode(AlphaMode mode) { _alphaMode = mode; } + private: void costumeMarkerCallback(int marker); void collisionHandlerCallback(Actor *other) const; @@ -600,6 +609,8 @@ private: int _talkDelay; Actor *_attachedActor; Common::String _attachedJoint; + AlphaMode _alphaMode; + float _global_alpha; bool _inOverworld; diff --git a/engines/grim/emi/lua_v2_actor.cpp b/engines/grim/emi/lua_v2_actor.cpp index 6a73a0d92c2..03375e8781b 100644 --- a/engines/grim/emi/lua_v2_actor.cpp +++ b/engines/grim/emi/lua_v2_actor.cpp @@ -56,8 +56,8 @@ void Lua_V2::SetActorLocalAlpha() { void Lua_V2::SetActorGlobalAlpha() { lua_Object actorObj = lua_getparam(1); -// lua_Object alphaModeObj = lua_getparam(2); -// lua_Object valueObj = lua_getparam(3); + lua_Object alphaObj = lua_getparam(2); +// lua_Object meshObj = lua_getparam(3); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; @@ -66,19 +66,17 @@ void Lua_V2::SetActorGlobalAlpha() { if (!actor) return; - warning("Lua_V2::SetActorGlobalAlpha: actor: %s", actor->getName().c_str()); - - /* Only when actor has primitives - if (!actor->primities) + if (!lua_isnumber(alphaObj)) return; - if (lua_isnumber(alphaModeObj) { - int alphaMode = (int)lua_getnumber(alphaModeObj); - if (!lua_isnil(valueObj) && lua_isstring(valueObj)) { - // TODO: missing part - } - // TODO + + float alpha = lua_getnumber(alphaObj); + if (alpha == Actor::AlphaOff || + alpha == Actor::AlphaReplace || + alpha == Actor::AlphaModulate) { + actor->setAlphaMode((Actor::AlphaMode) (int) alpha); + } else { + actor->setGlobalAlpha(alpha); } - */ } void Lua_V2::PutActorInOverworld() {