KSGSAnimation2D.cpp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #include "KSGSAnimation2D.h"
  2. #include "KSGSTyp.h"
  3. #include "../Error/Error.h"
  4. #include "../Main/KSGScriptObj.h"
  5. #include "KSGSMausEreignis.h"
  6. #include "KSGSInt.h"
  7. #include "KSGSBool.h"
  8. #include "KSGSAnimation2DData.h"
  9. #include <ToolTip.h>
  10. #include "KSGSText.h"
  11. using namespace KSGScript;
  12. // Inhalt der KSGSAnimation2DKlasse aus KSGSAnimaion2D
  13. // Konstruktor
  14. KSGSAnimation2DKlasse::KSGSAnimation2DKlasse( KSGScriptObj *zObj, Animation2D *std )
  15. : KSGSKlasseInstanz( KSGS_ANIMATION2D, 0, 0, zObj )
  16. {
  17. val = std;
  18. }
  19. // Destruktor
  20. KSGSAnimation2DKlasse::~KSGSAnimation2DKlasse()
  21. {
  22. val->release();
  23. }
  24. // nicht constant
  25. KSGSVariable *KSGSAnimation2DKlasse::startFunktion( int id, bool access, RCArray< KSGSVariable > *parameter )
  26. {
  27. KSGSVariable *ret = 0;
  28. switch( id )
  29. {
  30. case 0: // void setRahmen( bool )
  31. if( parameter->getEintragAnzahl() < 1 )
  32. error( 20, {}, obj );
  33. val->setRahmen( parameter->z( 0 ) ? parameter->z( 0 )->getBool() : 0 );
  34. break;
  35. case 1: // void setRahmenBreite( int )
  36. if( parameter->getEintragAnzahl() < 1 )
  37. error( 20, {}, obj );
  38. val->setRahmenBreite( parameter->z( 0 ) ? parameter->z( 0 )->getInt() : 0 );
  39. break;
  40. case 2: // void setRahmenFarbe( int )
  41. if( parameter->getEintragAnzahl() < 1 )
  42. error( 20, {}, obj );
  43. val->setRahmenFarbe( parameter->z( 0 ) ? parameter->z( 0 )->getInt() : 0 );
  44. break;
  45. case 3: // void setAnimationData( Animation2DData )
  46. if( parameter->getEintragAnzahl() < 1 )
  47. error( 20, {}, obj );
  48. val->setAnimationDataZ( parameter->z( 0 ) ? parameter->z( 0 )->getAnimation2DData() : 0 );
  49. break;
  50. case 4: // void setAlphaMaske( int )
  51. if( parameter->getEintragAnzahl() < 1 )
  52. error( 20, {}, obj );
  53. val->setAlphaMaske( parameter->z( 0 ) ? parameter->z( 0 )->getInt() : 0 );
  54. break;
  55. case 5: // void setAPS( int )
  56. if( parameter->getEintragAnzahl() < 1 )
  57. error( 20, {}, obj );
  58. val->setAPS( parameter->z( 0 ) ? parameter->z( 0 )->getInt() : 0 );
  59. break;
  60. case 6: // void setSichtbar( bool )
  61. if( parameter->getEintragAnzahl() < 1 )
  62. error( 20, {}, obj );
  63. val->setSichtbar( parameter->z( 0 ) ? parameter->z( 0 )->getBool() : 0 );
  64. break;
  65. case 7: // bool tick( double )
  66. if( parameter->getEintragAnzahl() < 1 )
  67. error( 20, {}, obj );
  68. ret = new KSGSBoolKlasse( obj, val->tick( parameter->z( 0 ) ? parameter->z( 0 )->getDouble() : 0 ) );
  69. break;
  70. case 8: // void render( int, int, Bild )
  71. if( 1 )
  72. {
  73. if( parameter->getEintragAnzahl() < 1 )
  74. error( 20, {}, obj );
  75. Bild *b = parameter->z( 0 ) ? parameter->z( 0 )->getBild() : 0;
  76. if( b )
  77. {
  78. val->render( *b );
  79. b->release();
  80. }
  81. }
  82. break;
  83. case 9: // Animation2DData getAnimationData()
  84. if( val->zAnimationData() )
  85. ret = new KSGSAnimation2DDataKlasse( obj, val->getAnimationData() );
  86. break;
  87. case 10: // bool istSichtbar()
  88. ret = new KSGSBoolKlasse( obj, val->istSichtbar() );
  89. break;
  90. case 11: // int getJetzt()
  91. ret = new KSGSIntKlasse( obj, val->getJetzt() );
  92. break;
  93. case 12: // int getAlphaMaske()
  94. ret = new KSGSIntKlasse( obj, val->getAlphaMaske() );
  95. break;
  96. case 13: // bool hatRahmen()
  97. ret = new KSGSBoolKlasse( obj, val->hatRahmen() );
  98. break;
  99. case 14: // int getRahmenBreite()
  100. ret = new KSGSIntKlasse( obj, val->getRahmenBreite() );
  101. break;
  102. case 15: // int getRahmenFarbe()
  103. ret = new KSGSIntKlasse( obj, val->getRahmenFarbe() );
  104. break;
  105. case 16: // void setToolTipText( Text )
  106. if( 1 )
  107. {
  108. if( parameter->getEintragAnzahl() < 1 )
  109. error( 20, {}, obj );
  110. Text *txt = parameter->z( 0 ) ? parameter->z( 0 )->getText() : 0;
  111. val->setToolTipText( txt ? *txt : 0, obj->zBildschirm() );
  112. if( txt )
  113. txt->release();
  114. }
  115. break;
  116. case 17: // void setPosition( int, int )
  117. if( parameter->getEintragAnzahl() < 2 )
  118. error( 20, {}, obj );
  119. val->setPosition( parameter->z( 0 ) ? parameter->z( 0 )->getInt() : 0,
  120. parameter->z( 1 ) ? parameter->z( 1 )->getInt() : 0 );
  121. break;
  122. case 18: // void setGröße( int, int )
  123. if( parameter->getEintragAnzahl() < 2 )
  124. error( 20, {}, obj );
  125. val->setSize( parameter->z( 0 ) ? parameter->z( 0 )->getInt() : 0,
  126. parameter->z( 1 ) ? parameter->z( 1 )->getInt() : 0 );
  127. break;
  128. case 19: // int getBreite()
  129. ret = new KSGSIntKlasse( obj, val->getBreite() );
  130. break;
  131. case 20: // int getHöhe()
  132. ret = new KSGSIntKlasse( obj, val->getHeight() );
  133. break;
  134. case 21: // int getX()
  135. ret = new KSGSIntKlasse( obj, val->getX() );
  136. break;
  137. case 22: // int getY()
  138. ret = new KSGSIntKlasse( obj, val->getY() );
  139. break;
  140. case 23: // Text getToolTipText()
  141. if( 1 )
  142. {
  143. Text *txt = val->zToolTip() ? val->zToolTip()->zText() : 0;
  144. ret = new KSGSTextKlasse( obj, txt ? *txt : "" );
  145. }
  146. break;
  147. default: // unbekannt
  148. error( 19, {}, obj );
  149. break;
  150. }
  151. parameter->release();
  152. return ret;
  153. }
  154. KSGSVariable *KSGSAnimation2DKlasse::doOperator( int id, KSGSVariable *rechts )
  155. {
  156. if( !rechts )
  157. {
  158. error( 3, {}, obj );
  159. return 0;
  160. }
  161. KSGSVariable *ret = 0;
  162. switch( id )
  163. {
  164. case KSGS_O_SET:
  165. if( 1 )
  166. {
  167. val->release();
  168. val = rechts->getAnimation2D();
  169. ret = getThis();
  170. }
  171. break;
  172. }
  173. if( !ret )
  174. error( 21, {}, obj );
  175. if( rechts )
  176. rechts->release();
  177. return ret;
  178. }
  179. // constant
  180. Animation2D *KSGSAnimation2DKlasse::getVal() const
  181. {
  182. return (Animation2D*)val->getThis();
  183. }
  184. Animation2D *KSGSAnimation2DKlasse::zVal() const
  185. {
  186. return val;
  187. }
  188. // Reference Counting
  189. KSGSVariable *KSGSAnimation2DKlasse::release()
  190. {
  191. ref--;
  192. if( !ref )
  193. delete this;
  194. return 0;
  195. }