KSGSAnimation2DData.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #include "KSGSAnimation2DData.h"
  2. #include "KSGSTyp.h"
  3. #include "../Error/Error.h"
  4. #include "../Main/KSGScriptObj.h"
  5. #include <DateiSystem.h>
  6. #include <InitDatei.h>
  7. #include "KSGSBild.h"
  8. #include "KSGSInt.h"
  9. #include "KSGSBool.h"
  10. using namespace KSGScript;
  11. // Inhalt der KSGSAnimation2DDataKlasse Klasse aus KSGSAnimation2DData.h
  12. // Konstruktor
  13. KSGSAnimation2DDataKlasse::KSGSAnimation2DDataKlasse( KSGScriptProcessor *zObj, Animation2DData *std )
  14. : KSGSKlasseInstanz( KSGS_ANIMATION2DDATA, 0, 0, zObj )
  15. {
  16. val = std;
  17. }
  18. // Destruktor
  19. KSGSAnimation2DDataKlasse::~KSGSAnimation2DDataKlasse()
  20. {
  21. val->release();
  22. }
  23. // nicht constant
  24. KSGSVariable *KSGSAnimation2DDataKlasse::startFunktion( int id, bool access, RCArray< KSGSVariable > *parameter )
  25. {
  26. KSGSVariable *ret = 0;
  27. switch( id )
  28. {
  29. case 0: // void ladeAnimation( Text )
  30. if( 1 )
  31. {
  32. if( parameter->getEintragAnzahl() < 1 )
  33. error( 20, {}, obj );
  34. Text *pf = parameter->z( 0 ) ? parameter->z( 0 )->getText() : 0;
  35. Text *tmp = obj->convertPfad( *pf );
  36. pf->release();
  37. pf = tmp;
  38. if( pf )
  39. {
  40. if( pf->hat( ".ltdb" ) && pf->positionVon( ".ltdb", pf->anzahlVon( ".ltdb" ) - 1 ) == pf->getLength() - 5 )
  41. {
  42. LTDBDatei *dat = new LTDBDatei();
  43. dat->setDatei( pf );
  44. dat->leseDaten( 0 );
  45. val->ladeAnimation( dat );
  46. }
  47. else
  48. {
  49. InitDatei *dat = new InitDatei( pf );
  50. dat->laden();
  51. val->ladeAnimation( dat );
  52. }
  53. }
  54. }
  55. break;
  56. case 1: // void setFPS( int )
  57. if( parameter->getEintragAnzahl() < 1 )
  58. error( 20, {}, obj );
  59. val->setFPS( parameter->z( 0 ) ? parameter->z( 0 )->getInt() : 0 );
  60. break;
  61. case 2: // void setWiederhohlend( bool )
  62. if( parameter->getEintragAnzahl() < 1 )
  63. error( 20, {}, obj );
  64. val->setWiederhohlend( parameter->z( 0 ) ? parameter->z( 0 )->getBool() : 0 );
  65. break;
  66. case 3: // void setTransparent( bool )
  67. if( parameter->getEintragAnzahl() < 1 )
  68. error( 20, {}, obj );
  69. val->setTransparent( parameter->z( 0 ) ? parameter->z( 0 )->getBool() : 0 );
  70. break;
  71. case 4: // void reset()
  72. val->reset();
  73. break;
  74. case 5: // Bild getBild( int )
  75. if( parameter->getEintragAnzahl() < 1 )
  76. error( 20, {}, obj );
  77. ret = new KSGSBildKlasse( obj, val->getBild( parameter->z( 0 ) ? parameter->z( 0 )->getInt() : 0 ) );
  78. break;
  79. case 6: // int getBildAnzahl()
  80. ret = new KSGSIntKlasse( obj, val->getBildAnzahl() );
  81. break;
  82. case 7: // int getFPS()
  83. ret = new KSGSIntKlasse( obj, val->getFPS() );
  84. break;
  85. case 8: // bool istWiederhohlend()
  86. ret = new KSGSBoolKlasse( obj, val->istWiederhohlend() );
  87. break;
  88. case 9: // bool istTransparent()
  89. ret = new KSGSBoolKlasse( obj, val->istTransparent() );
  90. break;
  91. default: // unbekannt
  92. error( 19, {}, obj );
  93. break;
  94. }
  95. parameter->release();
  96. return ret;
  97. }
  98. KSGSVariable *KSGSAnimation2DDataKlasse::doOperator( int id, KSGSVariable *rechts )
  99. {
  100. if( !rechts )
  101. {
  102. error( 3, {}, obj );
  103. return 0;
  104. }
  105. KSGSVariable *ret = 0;
  106. switch( id )
  107. {
  108. case KSGS_O_SET:
  109. if( 1 )
  110. {
  111. val->release();
  112. val = rechts->getAnimation2DData();
  113. ret = (KSGSVariable *)getThis();
  114. }
  115. break;
  116. }
  117. if( !ret )
  118. error( 21, {}, obj );
  119. if( rechts )
  120. rechts->release();
  121. return ret;
  122. }
  123. // constant
  124. Animation2DData *KSGSAnimation2DDataKlasse::getVal() const
  125. {
  126. return (Animation2DData *)val->getThis();
  127. }
  128. Animation2DData *KSGSAnimation2DDataKlasse::zVal() const
  129. {
  130. return val;
  131. }