animlayer.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. #ifndef _ANIMLAYER_H
  2. #define _ANIMLAYER_H
  3. #include "layer.h"
  4. // {6B64CD27-5A26-4c4b-8C59-E6A70CF6493A}
  5. static const GUID animLayerGuid =
  6. { 0x6b64cd27, 0x5a26, 0x4c4b, { 0x8c, 0x59, 0xe6, 0xa7, 0xc, 0xf6, 0x49, 0x3a } };
  7. #define ANIMLAYER_SCRIPTPARENT Layer
  8. class AnimLayerScriptController : public LayerScriptController {
  9. public:
  10. virtual const wchar_t *getClassName();
  11. virtual const wchar_t *getAncestorClassName();
  12. virtual ScriptObjectController *getAncestorController() { return layerController; }
  13. virtual int getNumFunctions();
  14. virtual const function_descriptor_struct *getExportedFunctions();
  15. virtual GUID getClassGuid();
  16. virtual ScriptObject *instantiate();
  17. virtual void destroy(ScriptObject *o);
  18. virtual void *encapsulate(ScriptObject *o);
  19. virtual void deencapsulate(void *o);
  20. private:
  21. static function_descriptor_struct exportedFunction[];
  22. };
  23. extern AnimLayerScriptController *animlayerController;
  24. #ifndef _NOSTUDIO
  25. #define TIMER_ANIM 872
  26. #define ANIM_STOPPED 0
  27. #define ANIM_PLAYING 1
  28. #define ANIM_PAUSED 2
  29. #define ANIMLAYER_PARENT Layer
  30. #define ANIM_UNKNOWN 0
  31. #define ANIM_VERT 1
  32. #define ANIM_HORZ 2
  33. #define ANIM_MULTI 3
  34. class AnimatedLayer : public ANIMLAYER_SCRIPTPARENT {
  35. public:
  36. AnimatedLayer();
  37. virtual ~AnimatedLayer();
  38. virtual int onInit();
  39. virtual int getHeight();
  40. virtual int getWidth();
  41. virtual void timerCallback(int id);
  42. virtual int getSourceOffsetY();
  43. virtual int getSourceOffsetX();
  44. virtual void setAutoPlay(int p);
  45. virtual int setXuiParam(int _xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value);
  46. virtual void setHeight(int h, int selfset=0);
  47. virtual void setWidth(int w, int selfset=0);
  48. virtual SkinBitmap *getBitmap();
  49. void play();
  50. void pause();
  51. void stop();
  52. int getLength();
  53. void setStartFrame(int s);
  54. void setEndFrame(int e);
  55. void setAutoReplay(int r);
  56. int getStartFrame();
  57. int getEndFrame();
  58. int isPlaying();
  59. int isPaused();
  60. int isStopped();
  61. int getSpeed();
  62. int getDirection();
  63. void gotoFrame(int n);
  64. void setSpeed(int s);
  65. int getAutoReplay();
  66. int getCurFrame();
  67. void setRealtime(int r);
  68. virtual api_region *getBitmapRegion();
  69. SkinBitmap *getElementBitmap(int n);
  70. virtual void makeRegion();
  71. virtual void deleteRegion();
  72. void reloadMultipleElements();
  73. virtual void setElementFrames(int n);
  74. virtual void setBitmap(const wchar_t *name);
  75. virtual int onPaint(Canvas *canvas);
  76. protected:
  77. /*static */void CreateXMLParameters(int master_handle);
  78. enum {
  79. ANIMLAYER_AUTOREPLAY=0,
  80. ANIMLAYER_AUTOPLAY,
  81. ANIMLAYER_SPEED,
  82. ANIMLAYER_FRAMEHEIGHT,
  83. ANIMLAYER_FRAMEWIDTH,
  84. ANIMLAYER_REALTIME,
  85. ANIMLAYER_ELEMENTFRAMES,
  86. ANIMLAYER_START,
  87. ANIMLAYER_END,
  88. ANIMLAYER_DEBUG,
  89. };
  90. private:
  91. int frameHeight, frameWidth;
  92. int startframe;
  93. int endframe;
  94. int status;
  95. int curframe;
  96. int autoreplay;
  97. int speed;
  98. int timerset;
  99. int realtime;
  100. int style;
  101. int autoplay;
  102. PtrList<SkinBitmap> bitmap_elements;
  103. int multiple_elements_frames;
  104. int debug;
  105. int xuihandle;
  106. void _invalidate();
  107. void stopTimer();
  108. void startTimer();
  109. PtrList<RegionI> regionlist;
  110. int oldstyle;
  111. static XMLParamPair params[];
  112. // FG>
  113. // -- SCRIPT -----------------------------------------------------
  114. public:
  115. // virtuals
  116. virtual void script_play();
  117. virtual void script_pause();
  118. virtual void script_stop();
  119. virtual int script_getLength();
  120. virtual void script_setStartFrame(int s);
  121. virtual void script_setEndFrame(int e);
  122. virtual void script_setAutoReplay(int r);
  123. virtual void script_setSpeed(int a);
  124. virtual int script_getStartFrame();
  125. virtual int script_getEndFrame();
  126. virtual int script_getSpeed();
  127. virtual int script_getDirection();
  128. virtual int script_getAutoReplay();
  129. virtual int script_isPlaying();
  130. virtual int script_isStopped();
  131. virtual int script_isPaused();
  132. //virtual void script_gotoFrame(int f);
  133. virtual void script_onFrame(int n);
  134. virtual void script_onStop();
  135. virtual void script_onPlay();
  136. virtual void script_onPause();
  137. virtual void script_onResume();
  138. virtual int script_getCurFrame();
  139. virtual void script_setRealtime(int r);
  140. static scriptVar script_vcpu_setSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s);
  141. static scriptVar script_vcpu_gotoFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar f);
  142. static scriptVar script_vcpu_setStartFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s);
  143. static scriptVar script_vcpu_setEndFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar e);
  144. static scriptVar script_vcpu_setAutoReplay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ar);
  145. static scriptVar script_vcpu_play(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  146. static scriptVar script_vcpu_pause(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  147. static scriptVar script_vcpu_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  148. static scriptVar script_vcpu_isPlaying(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  149. static scriptVar script_vcpu_isPaused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  150. static scriptVar script_vcpu_isStopped(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  151. static scriptVar script_vcpu_getStartFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  152. static scriptVar script_vcpu_getEndFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  153. static scriptVar script_vcpu_getLength(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  154. static scriptVar script_vcpu_getDirection(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  155. static scriptVar script_vcpu_getAutoReplay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  156. static scriptVar script_vcpu_getSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  157. static scriptVar script_vcpu_getCurFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  158. static scriptVar script_vcpu_setRealtime(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r);
  159. static scriptVar script_vcpu_onPlay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  160. static scriptVar script_vcpu_onStop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  161. static scriptVar script_vcpu_onPause(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  162. static scriptVar script_vcpu_onResume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  163. static scriptVar script_vcpu_onFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar f);
  164. #else
  165. class AnimatedLayer : public ANIMLAYER_SCRIPTPARENT {
  166. public:
  167. #endif
  168. // INSERT_SCRIPT_OBJECT_CONTROL
  169. };
  170. extern const wchar_t animLayerXuiObjectStr[];
  171. extern char animLayerXuiSvcName[];
  172. class AnimLayerXuiSvc : public XuiObjectSvc<AnimatedLayer, animLayerXuiObjectStr, animLayerXuiSvcName> {};
  173. #endif