Skip to content

Commit

Permalink
ZVISION: Refactore AnimationControl to AnimationNode + changes for co…
Browse files Browse the repository at this point in the history
…rrect use it from actions.
  • Loading branch information
Marisa-Chan committed Nov 15, 2013
1 parent e3b9f84 commit 30ee8ed
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 221 deletions.
58 changes: 43 additions & 15 deletions engines/zvision/actions.cpp
Expand Up @@ -274,17 +274,29 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, const Common::St
char fileName[25];

// The two %*u are always 0 and dont seem to have a use
sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %u %u)", &_key, fileName, &_mask, &_framerate);
sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %d %d)", &_key, fileName, &_mask, &_framerate);

if (_mask > 0) {
byte r, g, b;
Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(_mask, r, g, b);
_mask = _engine->_pixelFormat.RGBToColor(r, g, b);
}

_fileName = Common::String(fileName);
}

bool ActionPreloadAnimation::execute() {
// TODO: We ignore the mask and framerate atm. Mask refers to a key color used for binary alpha. We assume the framerate is the default framerate embedded in the videos
ActionPreloadAnimation::~ActionPreloadAnimation() {
_engine->getScriptManager()->deleteSideFx(_key);
}

// TODO: Check if the Control already exists
bool ActionPreloadAnimation::execute() {
AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key);

// Create the control, but disable it until PlayPreload is called
if (!nod) {
nod = new AnimationNode(_engine, _key, _fileName, _mask, _framerate, false);
_engine->getScriptManager()->addSideFX(nod);
} else
nod->stop();
return true;
}

Expand All @@ -299,14 +311,34 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String &

// The two %*u are always 0 and dont seem to have a use
sscanf(line.c_str(),
"%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %u %*u %*u %u %u)",
"%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %d %*u %*u %d %d)",
&_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loopCount, &_mask, &_framerate);

if (_mask > 0) {
byte r, g, b;
Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(_mask, r, g, b);
_mask = _engine->_pixelFormat.RGBToColor(r, g, b);
}

_fileName = Common::String(fileName);
}

ActionPlayAnimation::~ActionPlayAnimation() {
_engine->getScriptManager()->deleteSideFx(_key);
}

bool ActionPlayAnimation::execute() {
// TODO: Implement
AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key);

if (!nod) {
nod = new AnimationNode(_engine, _key, _fileName, _mask, _framerate);
_engine->getScriptManager()->addSideFX(nod);
} else
nod->stop();

if (nod)
nod->addPlayNode(_key, _x, _y, _width, _height, _start, _end, _loopCount);

return true;
}

Expand All @@ -323,14 +355,10 @@ ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, const Co
}

bool ActionPlayPreloadAnimation::execute() {
// Find the control
AnimationControl *control = (AnimationControl *)_engine->getScriptManager()->getControl(_controlKey);

// Set the needed values within the control
control->setAnimationKey(_animationKey);
control->setLoopCount(_loopCount);
control->setXPos(_x1);
control->setYPost(_y1);
AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_animationKey);

if (nod)
nod->addPlayNode(_controlKey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount);

return true;
}
Expand Down
12 changes: 7 additions & 5 deletions engines/zvision/actions.h
Expand Up @@ -240,6 +240,7 @@ class ActionMusic : public ResultAction {
class ActionPlayAnimation : public ResultAction {
public:
ActionPlayAnimation(ZVision *engine, const Common::String &line);
~ActionPlayAnimation();
bool execute();

private:
Expand All @@ -251,9 +252,9 @@ class ActionPlayAnimation : public ResultAction {
uint32 _height;
uint32 _start;
uint32 _end;
uint _mask;
uint _framerate;
uint _loopCount;
int32 _mask;
int32 _framerate;
int32 _loopCount;
};

class ActionPlayPreloadAnimation : public ResultAction {
Expand All @@ -276,13 +277,14 @@ class ActionPlayPreloadAnimation : public ResultAction {
class ActionPreloadAnimation : public ResultAction {
public:
ActionPreloadAnimation(ZVision *engine, const Common::String &line);
~ActionPreloadAnimation();
bool execute();

private:
uint32 _key;
Common::String _fileName;
uint _mask;
uint _framerate;
int32 _mask;
int32 _framerate;
};

class ActionQuit : public ResultAction {
Expand Down

0 comments on commit 30ee8ed

Please sign in to comment.