123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- #include "KSGSAnimation2DData.h"
- #include "KSGSTyp.h"
- #include "../Error/Error.h"
- #include "../Main/KSGScriptObj.h"
- #include <DateiSystem.h>
- #include <InitDatei.h>
- #include "KSGSBild.h"
- #include "KSGSInt.h"
- #include "KSGSBool.h"
- using namespace KSGScript;
- // Inhalt der KSGSAnimation2DDataKlasse Klasse aus KSGSAnimation2DData.h
- // Konstruktor
- KSGSAnimation2DDataKlasse::KSGSAnimation2DDataKlasse( KSGScriptObj *zObj, Animation2DData *std )
- : KSGSKlasseInstanz( KSGS_ANIMATION2DDATA, 0, 0, zObj )
- {
- val = std;
- }
- // Destruktor
- KSGSAnimation2DDataKlasse::~KSGSAnimation2DDataKlasse()
- {
- val->release();
- }
- // nicht constant
- KSGSVariable *KSGSAnimation2DDataKlasse::startFunktion( int id, bool access, RCArray< KSGSVariable > *parameter )
- {
- KSGSVariable *ret = 0;
- switch( id )
- {
- case 0: // void ladeAnimation( Text )
- if( 1 )
- {
- if( parameter->getEintragAnzahl() < 1 )
- error( 20, {}, obj );
- Text *pf = parameter->z( 0 ) ? parameter->z( 0 )->getText() : 0;
- Text *tmp = obj->convertPfad( *pf );
- pf->release();
- pf = tmp;
- if( pf )
- {
- if( pf->hat( ".ltdb" ) && pf->positionVon( ".ltdb", pf->anzahlVon( ".ltdb" ) - 1 ) == pf->getLength() - 5 )
- {
- LTDBDatei *dat = new LTDBDatei();
- dat->setDatei( pf );
- dat->leseDaten( 0 );
- val->ladeAnimation( dat );
- }
- else
- {
- InitDatei *dat = new InitDatei( pf );
- dat->laden();
- val->ladeAnimation( dat );
- }
- }
- }
- break;
- case 1: // void setFPS( int )
- if( parameter->getEintragAnzahl() < 1 )
- error( 20, {}, obj );
- val->setFPS( parameter->z( 0 ) ? parameter->z( 0 )->getInt() : 0 );
- break;
- case 2: // void setWiederhohlend( bool )
- if( parameter->getEintragAnzahl() < 1 )
- error( 20, {}, obj );
- val->setWiederhohlend( parameter->z( 0 ) ? parameter->z( 0 )->getBool() : 0 );
- break;
- case 3: // void setTransparent( bool )
- if( parameter->getEintragAnzahl() < 1 )
- error( 20, {}, obj );
- val->setTransparent( parameter->z( 0 ) ? parameter->z( 0 )->getBool() : 0 );
- break;
- case 4: // void reset()
- val->reset();
- break;
- case 5: // Bild getBild( int )
- if( parameter->getEintragAnzahl() < 1 )
- error( 20, {}, obj );
- ret = new KSGSBildKlasse( obj, val->getBild( parameter->z( 0 ) ? parameter->z( 0 )->getInt() : 0 ) );
- break;
- case 6: // int getBildAnzahl()
- ret = new KSGSIntKlasse( obj, val->getBildAnzahl() );
- break;
- case 7: // int getFPS()
- ret = new KSGSIntKlasse( obj, val->getFPS() );
- break;
- case 8: // bool istWiederhohlend()
- ret = new KSGSBoolKlasse( obj, val->istWiederhohlend() );
- break;
- case 9: // bool istTransparent()
- ret = new KSGSBoolKlasse( obj, val->istTransparent() );
- break;
- default: // unbekannt
- error( 19, {}, obj );
- break;
- }
- parameter->release();
- return ret;
- }
- KSGSVariable *KSGSAnimation2DDataKlasse::doOperator( int id, KSGSVariable *rechts )
- {
- if( !rechts )
- {
- error( 3, {}, obj );
- return 0;
- }
- KSGSVariable *ret = 0;
- switch( id )
- {
- case KSGS_O_SET:
- if( 1 )
- {
- val->release();
- val = rechts->getAnimation2DData();
- ret = getThis();
- }
- break;
- }
- if( !ret )
- error( 21, {}, obj );
- if( rechts )
- rechts->release();
- return ret;
- }
- // constant
- Animation2DData *KSGSAnimation2DDataKlasse::getVal() const
- {
- return val->getThis();
- }
- Animation2DData *KSGSAnimation2DDataKlasse::zVal() const
- {
- return val;
- }
- // Reference Counting
- KSGSVariable *KSGSAnimation2DDataKlasse::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
|