123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880 |
- #include "precomp.h"
- #include <api/script/scriptmgr.h>
- #include <api/script/script.h>
- #include <api/skin/widgets/animlayer.h>
- #include <tataki/canvas/canvas.h>
- const wchar_t animLayerXuiObjectStr[] = L"AnimatedLayer"; // This is the xml tag
- char animLayerXuiSvcName[] = "Animated Layer xui object"; // this is the name of the xuiservice
- AnimLayerScriptController _animlayerController;
- AnimLayerScriptController *animlayerController = &_animlayerController;
- // -- Functions table -------------------------------------
- function_descriptor_struct AnimLayerScriptController::exportedFunction[] = {
- {L"setSpeed", 1, (void*)AnimatedLayer::script_vcpu_setSpeed },
- {L"gotoFrame", 1, (void*)AnimatedLayer::script_vcpu_gotoFrame },
- {L"setStartFrame", 1, (void*)AnimatedLayer::script_vcpu_setStartFrame },
- {L"setEndFrame", 1, (void*)AnimatedLayer::script_vcpu_setEndFrame },
- {L"setAutoReplay", 1, (void*)AnimatedLayer::script_vcpu_setAutoReplay },
- {L"play", 0, (void*)AnimatedLayer::script_vcpu_play },
- {L"togglePause", 0, (void*)AnimatedLayer::script_vcpu_pause },
- {L"stop", 0, (void*)AnimatedLayer::script_vcpu_stop },
- {L"pause", 0, (void*)AnimatedLayer::script_vcpu_pause },
- {L"isPlaying", 0, (void*)AnimatedLayer::script_vcpu_isPlaying },
- {L"isPaused", 0, (void*)AnimatedLayer::script_vcpu_isPaused },
- {L"isStopped", 0, (void*)AnimatedLayer::script_vcpu_isStopped },
- {L"getStartFrame", 0, (void*)AnimatedLayer::script_vcpu_getStartFrame },
- {L"getEndFrame", 0, (void*)AnimatedLayer::script_vcpu_getEndFrame },
- {L"getLength", 0, (void*)AnimatedLayer::script_vcpu_getLength },
- {L"getDirection", 0, (void*)AnimatedLayer::script_vcpu_getDirection },
- {L"getAutoReplay", 0, (void*)AnimatedLayer::script_vcpu_getAutoReplay },
- {L"getCurFrame", 0, (void*)AnimatedLayer::script_vcpu_getCurFrame },
- {L"onPlay", 0, (void*)AnimatedLayer::script_vcpu_onPlay },
- {L"onPause", 0, (void*)AnimatedLayer::script_vcpu_onPause },
- {L"onResume", 0, (void*)AnimatedLayer::script_vcpu_onResume },
- {L"onStop", 0, (void*)AnimatedLayer::script_vcpu_onStop },
- {L"onFrame", 1, (void*)AnimatedLayer::script_vcpu_onFrame },
- {L"setRealtime", 1, (void*)AnimatedLayer::script_vcpu_setRealtime },
- };
- // --------------------------------------------------------
- const wchar_t *AnimLayerScriptController::getClassName()
- {
- return L"AnimatedLayer";
- }
- const wchar_t *AnimLayerScriptController::getAncestorClassName()
- {
- return L"Layer";
- }
- ScriptObject *AnimLayerScriptController::instantiate()
- {
- AnimatedLayer *a = new AnimatedLayer;
- ASSERT(a != NULL);
- return a->getScriptObject();
- }
- void AnimLayerScriptController::destroy(ScriptObject *o)
- {
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- ASSERT(a != NULL);
- delete a;
- }
- void *AnimLayerScriptController::encapsulate(ScriptObject *o)
- {
- return NULL; // no encapsulation for animatedlayer yet
- }
- void AnimLayerScriptController::deencapsulate(void *o)
- {}
- int AnimLayerScriptController::getNumFunctions()
- {
- return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
- }
- const function_descriptor_struct *AnimLayerScriptController::getExportedFunctions()
- {
- return exportedFunction;
- }
- GUID AnimLayerScriptController::getClassGuid()
- {
- return animLayerGuid;
- }
- XMLParamPair AnimatedLayer::params[] =
- {
- {ANIMLAYER_AUTOPLAY, L"AUTOPLAY"},
- {ANIMLAYER_AUTOREPLAY, L"AUTOREPLAY"},
- {ANIMLAYER_DEBUG, L"DEBUG"},
- {ANIMLAYER_ELEMENTFRAMES, L"ELEMENTFRAMES"},
- {ANIMLAYER_END, L"END"},
- {ANIMLAYER_FRAMEHEIGHT, L"FRAMEHEIGHT"},
- {ANIMLAYER_FRAMEWIDTH, L"FRAMEWIDTH"},
- {ANIMLAYER_REALTIME, L"REALTIME"},
- {ANIMLAYER_SPEED, L"SPEED"},
- {ANIMLAYER_START, L"START"},
- };
- AnimatedLayer::AnimatedLayer()
- {
- getScriptObject()->vcpu_setInterface(animLayerGuid, (void *)static_cast<AnimatedLayer *>(this));
- getScriptObject()->vcpu_setClassName(L"AnimatedLayer");
- getScriptObject()->vcpu_setController(animlayerController);
- autoplay = 0;
- startframe = -1;
- endframe = -1;
- curframe = 0;
- autoreplay = 1;
- speed = 200;
- timerset = 0;
- status = ANIM_STOPPED;
- realtime = 0;
- debug = 0;
- style = ANIM_UNKNOWN;
- oldstyle = ANIM_UNKNOWN;
- frameHeight = AUTOWH;
- frameWidth = AUTOWH;
- multiple_elements_frames = 0;
- xuihandle = newXuiHandle();
- CreateXMLParameters(xuihandle);
- }
- void AnimatedLayer::CreateXMLParameters(int master_handle)
- {
- //ANIMLAYER_PARENT::CreateXMLParameters(master_handle);
- int numParams = sizeof(params) / sizeof(params[0]);
- hintNumberOfParams(xuihandle, numParams);
- for (int i = 0;i < numParams;i++)
- addParam(xuihandle, params[i], XUI_ATTRIBUTE_IMPLIED);
- }
- AnimatedLayer::~AnimatedLayer()
- {
- bitmap_elements.deleteAll();
- regionlist.deleteAll();
- }
- int AnimatedLayer::onInit()
- {
- ANIMLAYER_PARENT::onInit();
- int w, h;
- getGuiObject()->guiobject_getGuiPosition(NULL, NULL, &w, &h, NULL, NULL, NULL, NULL);
- if (frameWidth == AUTOWH && w != AUTOWH) setWidth(w, 1);
- if (frameHeight == AUTOWH && h != AUTOWH) setHeight(h, 1);
- if (style == 0)
- {
- SkinBitmap *bm = getBitmap();
- if (bm)
- {
- if (bm->getWidth() != w) style = ANIM_HORZ;
- else if (bm->getHeight() != h) style = ANIM_VERT;
- }
- }
- if (getRegionOp())
- makeRegion();
- reloadMultipleElements();
- if (autoplay)
- {
- if (startframe == -1)
- setStartFrame(0);
- if (endframe == -1)
- setEndFrame(getLength() - 1);
- play();
- }
- return 1;
- }
- int AnimatedLayer::setXuiParam(int _xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *strvalue)
- {
- if (xuihandle == _xuihandle)
- {
- switch (xmlattributeid)
- {
- case ANIMLAYER_AUTOREPLAY: setAutoReplay(WTOI(strvalue)); return 1;
- case ANIMLAYER_AUTOPLAY: setAutoPlay(WTOI(strvalue)); return 1;
- case ANIMLAYER_SPEED: setSpeed(WTOI(strvalue)); return 1;
- case ANIMLAYER_FRAMEHEIGHT: setHeight(WTOI(strvalue)); return 1;
- case ANIMLAYER_FRAMEWIDTH: setWidth(WTOI(strvalue)); return 1;
- case ANIMLAYER_REALTIME: setRealtime(WTOI(strvalue)); return 1;
- case ANIMLAYER_ELEMENTFRAMES: setElementFrames(WTOI(strvalue)); return 1;
- case ANIMLAYER_START: setStartFrame(WTOI(strvalue)); return 1;
- case ANIMLAYER_END: setEndFrame(WTOI(strvalue)); return 1;
- case ANIMLAYER_DEBUG: debug = WTOI(strvalue); return 1;
- }
- }
- return ANIMLAYER_PARENT::setXuiParam(_xuihandle, xmlattributeid, xmlattributename, strvalue);
- }
- void AnimatedLayer::_invalidate()
- {
- if (realtime)
- {
- if (isVisible() && !isMinimized()) cascadeRepaint();
- }
- else
- invalidate();
- }
- void AnimatedLayer::setElementFrames(int n)
- {
- if (multiple_elements_frames == n) return ;
- multiple_elements_frames = n;
- if (n > 0)
- {
- if (style != ANIM_MULTI)
- oldstyle = style;
- style = ANIM_MULTI;
- }
- else
- {
- style = oldstyle;
- oldstyle = ANIM_UNKNOWN;
- }
- invalidateRegionCache();
- }
- void AnimatedLayer::setHeight(int h, int selfset)
- {
- ASSERTPR(selfset || style == ANIM_UNKNOWN, "can't set frameHeight if frameWidth has already been set");
- frameHeight = h;
- if (!selfset) style = ANIM_VERT;
- }
- int AnimatedLayer::getHeight()
- {
- if (style == ANIM_MULTI)
- {
- SkinBitmap *bm0 = getElementBitmap(0);
- if (bm0 == NULL) return AUTOWH;
- return bm0->getHeight();
- }
- if (style == ANIM_HORZ)
- return ANIMLAYER_PARENT::getHeight();
- return frameHeight;
- }
- void AnimatedLayer::setWidth(int w, int selfset)
- {
- ASSERTPR(selfset || style == ANIM_UNKNOWN, "can't set frameWidth if frameHeight has already been set");
- frameWidth = w;
- if (!selfset) style = ANIM_HORZ;
- }
- int AnimatedLayer::getWidth()
- {
- if (style == ANIM_MULTI)
- {
- SkinBitmap *bm0 = getElementBitmap(0);
- if (bm0 == NULL) return AUTOWH;
- return bm0->getWidth();
- }
- if (style == ANIM_VERT)
- return ANIMLAYER_PARENT::getWidth();
- return frameWidth;
- }
- void AnimatedLayer::setRealtime(int r)
- {
- realtime = r;
- }
- int AnimatedLayer::getLength()
- {
- if (style == ANIM_VERT && frameHeight < 0) return 0;
- if (style == ANIM_HORZ && frameWidth < 0) return 0;
- ASSERT(getBitmap() != NULL);
- if (style == ANIM_VERT)
- return ANIMLAYER_PARENT::getHeight() / frameHeight;
- else if (style == ANIM_HORZ)
- return ANIMLAYER_PARENT::getWidth() / frameWidth;
- else if (style == ANIM_MULTI)
- return multiple_elements_frames;
- return 0;
- }
- void AnimatedLayer::timerCallback(int id)
- {
- switch (id)
- {
- case TIMER_ANIM:
- {
- int oldframe = curframe;
- for (int i = 0;i < timerclient_getSkipped() + 1;i++)
- {
- if (curframe == getEndFrame())
- {
- if (!autoreplay)
- {
- stop();
- break;
- }
- else
- curframe = getStartFrame();
- }
- else
- {
- curframe += getDirection();
- if (curframe != oldframe)
- script_onFrame(curframe);
- }
- }
- if (curframe != oldframe)
- _invalidate();
- break;
- }
- default:
- ANIMLAYER_PARENT::timerCallback(id);
- break;
- }
- }
- int AnimatedLayer::getSourceOffsetY()
- {
- if (style == ANIM_MULTI) return 0;
- if (style == ANIM_HORZ) return 0;
- if (curframe > getLength() - 1) return 0;
- return curframe * getHeight();
- }
- int AnimatedLayer::getSourceOffsetX()
- {
- if (style == ANIM_MULTI) return 0;
- if (style == ANIM_VERT) return 0;
- if (curframe > getLength() - 1) return 0;
- return curframe * getWidth();
- }
- void AnimatedLayer::setSpeed(int s)
- {
- speed = s;
- if (status == ANIM_PLAYING)
- {
- stopTimer();
- startTimer();
- }
- }
- void AnimatedLayer::stopTimer()
- {
- if (timerset)
- {
- killTimer(TIMER_ANIM);
- timerset = 0;
- }
- }
- void AnimatedLayer::startTimer()
- {
- if (!timerset)
- {
- setTimer(TIMER_ANIM, speed);
- timerset = 1;
- }
- }
- void AnimatedLayer::play()
- {
- gotoFrame(startframe);
- startTimer();
- status = ANIM_PLAYING;
- script_onPlay();
- }
- void AnimatedLayer::stop()
- {
- stopTimer();
- status = ANIM_STOPPED;
- script_onStop();
- }
- void AnimatedLayer::pause()
- {
- if (status == ANIM_PAUSED)
- {
- startTimer();
- status = ANIM_PLAYING;
- script_onResume();
- }
- else
- if (status == ANIM_PLAYING)
- {
- stopTimer();
- status = ANIM_PAUSED;
- script_onPause();
- }
- }
- int AnimatedLayer::getCurFrame()
- {
- return curframe;
- }
- void AnimatedLayer::setStartFrame(int s)
- {
- if (s < 0) return ;
- startframe = s;
- }
- void AnimatedLayer::setEndFrame(int e)
- {
- if (e < 0) return ;
- endframe = e;
- }
- void AnimatedLayer::setAutoReplay(int r)
- {
- autoreplay = r;
- }
- void AnimatedLayer::setAutoPlay(int r)
- {
- autoplay = r;
- // no need to trigger an event here, we can't be in a script if we
- // need to autoplay at xml loading
- }
- int AnimatedLayer::getStartFrame()
- {
- return startframe == -1 ? 0 : startframe;
- }
- int AnimatedLayer::getEndFrame()
- {
- return endframe == -1 ? getLength() - 1 : endframe;
- }
- int AnimatedLayer::getSpeed()
- {
- return speed;
- }
- int AnimatedLayer::isPlaying()
- {
- return status == ANIM_PLAYING;
- }
- int AnimatedLayer::isStopped()
- {
- return status == ANIM_STOPPED;
- }
- int AnimatedLayer::isPaused()
- {
- return status == ANIM_PAUSED;
- }
- int AnimatedLayer::getAutoReplay()
- {
- return autoreplay;
- }
- int AnimatedLayer::getDirection()
- {
- return getStartFrame() < getEndFrame() ? 1 : -1;
- }
- void AnimatedLayer::gotoFrame(int n)
- {
- if (n != curframe)
- {
- curframe = n;
- _invalidate();
- script_onFrame(n);
- }
- }
- api_region *AnimatedLayer::getBitmapRegion()
- {
- if (curframe > getLength() - 1) return NULL;
- return regionlist.enumItem(getCurFrame());
- }
- void AnimatedLayer::makeRegion()
- {
- if (!isInited()) return ;
- regionlist.deleteAll();
- for (int i = 0;i < getLength();i++)
- {
- RegionI *rg;
- if (style == ANIM_VERT)
- {
- RECT g = {0, i * getHeight(), getWidth(), i * getHeight() + getHeight()};
- rg = new RegionI(getBitmap(), &g, 0, -i * getHeight(), FALSE);
- }
- else if (style == ANIM_HORZ)
- {
- RECT g = {i * getWidth(), 0, i * getWidth() + getWidth(), getHeight()};
- rg = new RegionI(getBitmap(), &g, -i * getWidth(), 0, FALSE);
- }
- else if (style == ANIM_MULTI)
- {
- RECT g = {0, 0, getWidth(), getHeight()};
- rg = new RegionI(getElementBitmap(i), &g, 0, 0, FALSE);
- }
- else
- return;
- regionlist.addItem(rg);
- }
- }
- void AnimatedLayer::deleteRegion()
- {
- regionlist.deleteAll();
- }
- SkinBitmap *AnimatedLayer::getBitmap()
- {
- if (style != ANIM_MULTI)
- return layer_getBitmap();
- return getElementBitmap(getCurFrame());
- }
- SkinBitmap *AnimatedLayer::getElementBitmap(int n)
- {
- return bitmap_elements.enumItem(n);
- }
- void AnimatedLayer::reloadMultipleElements()
- {
- bitmap_elements.deleteAll();
- if (style != ANIM_MULTI) return ;
- // basically blah$$$$.png becomes blah0000.png, blah0001.png etc
- for (int i = 0;i < multiple_elements_frames;i++)
- {
- StringW elementname(layer_getBitmapName());
- elementname.replaceNumericField(i);
- bitmap_elements.addItem(new SkinBitmap(elementname));
- }
- }
- void AnimatedLayer::setBitmap(const wchar_t *name)
- {
- ANIMLAYER_PARENT::setBitmap(name);
- reloadMultipleElements();
- }
- // Script virtuals
- int AnimatedLayer::script_getStartFrame()
- {
- return getStartFrame();
- }
- int AnimatedLayer::script_getEndFrame()
- {
- return getEndFrame();
- }
- int AnimatedLayer::script_getSpeed()
- {
- return getSpeed();
- }
- int AnimatedLayer::script_getCurFrame()
- {
- return getCurFrame();
- }
- int AnimatedLayer::script_getDirection()
- {
- return getDirection();
- }
- int AnimatedLayer::script_getAutoReplay()
- {
- return getAutoReplay();
- }
- int AnimatedLayer::script_getLength()
- {
- return getLength();
- }
- int AnimatedLayer::script_isPlaying()
- {
- return isPlaying();
- }
- int AnimatedLayer::script_isStopped()
- {
- return isStopped();
- }
- int AnimatedLayer::script_isPaused()
- {
- return isPaused();
- }
- void AnimatedLayer::script_play()
- {
- play();
- }
- void AnimatedLayer::script_pause()
- {
- pause();
- }
- void AnimatedLayer::script_stop()
- {
- stop();
- }
- void AnimatedLayer::script_setStartFrame(int s)
- {
- setStartFrame(s);
- }
- void AnimatedLayer::script_setEndFrame(int e)
- {
- setEndFrame(e);
- }
- void AnimatedLayer::script_setRealtime(int r)
- {
- setRealtime(r);
- }
- void AnimatedLayer::script_setAutoReplay(int r)
- {
- setAutoReplay(r);
- }
- /*
- void AnimatedLayer::script_gotoFrame(int n) {
- gotoFrame(n);
- }*/
- void AnimatedLayer::script_setSpeed(int n)
- {
- setSpeed(n);
- }
- void AnimatedLayer::script_onPause()
- {
- script_vcpu_onPause(SCRIPT_CALL, getScriptObject());
- }
- void AnimatedLayer::script_onResume()
- {
- script_vcpu_onResume(SCRIPT_CALL, getScriptObject());
- }
- void AnimatedLayer::script_onStop()
- {
- script_vcpu_onStop(SCRIPT_CALL, getScriptObject());
- }
- void AnimatedLayer::script_onPlay()
- {
- script_vcpu_onPlay(SCRIPT_CALL, getScriptObject());
- }
- void AnimatedLayer::script_onFrame(int n)
- {
- if (getRegionOp()) { invalidateRegionCache(); getParent()->invalidateWindowRegion(); }
- scriptVar _n = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_n, n);
- script_vcpu_onFrame(SCRIPT_CALL, getScriptObject(), _n);
- }
- // end virtuals
- // VCPU
- scriptVar AnimatedLayer::script_vcpu_gotoFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar f)
- {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&f));
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) a-> /*script_*/gotoFrame(SOM::makeInt(&f));
- RETURN_SCRIPT_VOID;
- }
- scriptVar AnimatedLayer::script_vcpu_getLength(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) return MAKE_SCRIPT_INT(a->script_getLength());
- RETURN_SCRIPT_ZERO;
- }
- scriptVar AnimatedLayer::script_vcpu_setStartFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s)
- {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&s));
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) a->script_setStartFrame(SOM::makeInt(&s));
- RETURN_SCRIPT_VOID;
- }
- scriptVar AnimatedLayer::script_vcpu_setEndFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar e)
- {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&e));
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) a->script_setEndFrame(SOM::makeInt(&e));
- RETURN_SCRIPT_VOID;
- }
- scriptVar AnimatedLayer::script_vcpu_setAutoReplay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar rp)
- {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&rp));
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) a->script_setAutoReplay(SOM::makeBoolean(&rp));
- RETURN_SCRIPT_VOID;
- }
- scriptVar AnimatedLayer::script_vcpu_play(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) a->script_play();
- RETURN_SCRIPT_VOID;
- }
- scriptVar AnimatedLayer::script_vcpu_pause(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) a->script_pause();
- RETURN_SCRIPT_VOID;
- }
- scriptVar AnimatedLayer::script_vcpu_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) a->script_stop();
- RETURN_SCRIPT_VOID;
- }
- scriptVar AnimatedLayer::script_vcpu_onPlay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, animlayerController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
- scriptVar AnimatedLayer::script_vcpu_onStop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, animlayerController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
- scriptVar AnimatedLayer::script_vcpu_onPause(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, animlayerController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
- scriptVar AnimatedLayer::script_vcpu_onResume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, animlayerController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
- scriptVar AnimatedLayer::script_vcpu_onFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar f)
- {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS1(o, animlayerController, f);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT1(o, f);
- }
- scriptVar AnimatedLayer::script_vcpu_getAutoReplay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) return MAKE_SCRIPT_INT(a->script_getAutoReplay());
- RETURN_SCRIPT_ZERO;
- }
- scriptVar AnimatedLayer::script_vcpu_getDirection(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) return MAKE_SCRIPT_INT(a->script_getDirection());
- RETURN_SCRIPT_ZERO;
- }
- scriptVar AnimatedLayer::script_vcpu_getStartFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) return MAKE_SCRIPT_INT(a->script_getStartFrame());
- RETURN_SCRIPT_ZERO;
- }
- scriptVar AnimatedLayer::script_vcpu_getEndFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) return MAKE_SCRIPT_INT(a->script_getEndFrame());
- RETURN_SCRIPT_ZERO;
- }
- scriptVar AnimatedLayer::script_vcpu_isPlaying(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) return MAKE_SCRIPT_BOOLEAN(a->script_isPlaying());
- RETURN_SCRIPT_ZERO;
- }
- scriptVar AnimatedLayer::script_vcpu_isPaused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) return MAKE_SCRIPT_BOOLEAN(a->script_isPaused());
- RETURN_SCRIPT_ZERO;
- }
- scriptVar AnimatedLayer::script_vcpu_isStopped(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) return MAKE_SCRIPT_BOOLEAN(a->script_isStopped());
- RETURN_SCRIPT_ZERO;
- }
- scriptVar AnimatedLayer::script_vcpu_getSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) return MAKE_SCRIPT_INT(a->script_getSpeed());
- RETURN_SCRIPT_ZERO;
- }
- scriptVar AnimatedLayer::script_vcpu_getCurFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) return MAKE_SCRIPT_INT(a->script_getCurFrame());
- RETURN_SCRIPT_ZERO;
- }
- scriptVar AnimatedLayer::script_vcpu_setSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s)
- {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&s));
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) a->script_setSpeed(SOM::makeInt(&s));
- RETURN_SCRIPT_VOID;
- }
- scriptVar AnimatedLayer::script_vcpu_setRealtime(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r)
- {
- SCRIPT_FUNCTION_INIT;
- AnimatedLayer *a = static_cast<AnimatedLayer *>(o->vcpu_getInterface(animLayerGuid));
- if (a) a->script_setRealtime(SOM::makeInt(&r));
- RETURN_SCRIPT_VOID;
- }
- int AnimatedLayer::onPaint(Canvas *canvas)
- {
- int r = ANIMLAYER_PARENT::onPaint(canvas);
- if (debug && canvas != NULL)
- {
- Wasabi::FontInfo fontInfo;
- fontInfo.pointSize = 14;
- canvas->textOut(0, 0, StringPrintfW(L"%d", curframe), &fontInfo);
- }
- return r;
- }
|