123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- #include "TexturList.h"
- #include "Textur.h"
- #include "Text.h"
- using namespace Framework;
- int TexturList::id = 0;
- Critical TexturList::cs;
- TexturList::TexturList()
- {
- textures = new RCArray< Textur >();
- names = new RCArray< Text >();
- ref = 1;
- }
- TexturList::~TexturList()
- {
- textures->release();
- names->release();
- }
- __declspec( dllexport ) void TexturList::leeren()
- {
- cs.lock();
- textures->leeren();
- names->leeren();
- cs.unlock();
- }
- bool TexturList::addTextur( Textur *t, const char *name )
- {
- cs.lock();
- for( auto i = names->getIterator(); i; i++ )
- {
- if( i->istGleich( name ) )
- {
- t->release();
- cs.unlock();
- return 0;
- }
- }
- t->id = id++;
- textures->add( t );
- names->add( new Text( name ) );
- cs.unlock();
- return 1;
- }
- void TexturList::removeTextur( const char *name )
- {
- cs.lock();
- int index = 0;
- for( auto i = names->getIterator(); i; i++ )
- {
- if( i->istGleich( name ) )
- {
- names->remove( index );
- textures->remove( index );
- cs.unlock();
- return;
- }
- index++;
- }
- cs.unlock();
- }
- bool TexturList::hatTextur( const char *name ) const
- {
- cs.lock();
- for( auto i = names->getIterator(); i; i++ )
- {
- if( i->istGleich( name ) )
- {
- cs.unlock();
- return 1;
- }
- }
- cs.unlock();
- return 0;
- }
- Textur *TexturList::getTextur( const char *name ) const
- {
- cs.lock();
- int index = 0;
- for( auto i = names->getIterator(); i; i++ )
- {
- if( i->istGleich( name ) )
- {
- cs.unlock();
- return textures->get( index );
- }
- index++;
- }
- cs.unlock();
- return 0;
- }
- Textur *TexturList::getTextur( int id ) const
- {
- cs.lock();
- for( auto i = textures->getIterator(); i; i++ )
- {
- if( i->getId() == id )
- {
- cs.unlock();
- return i->getThis();
- }
- }
- cs.unlock();
- return 0;
- }
- Textur *TexturList::zTextur( const char *name ) const
- {
- cs.lock();
- int index = 0;
- for( auto i = names->getIterator(); i; i++ )
- {
- if( i->istGleich( name ) )
- {
- cs.unlock();
- return textures->z( index );
- }
- index++;
- }
- cs.unlock();
- return 0;
- }
- Textur *TexturList::zTextur( int id ) const
- {
- cs.lock();
- for( auto i = textures->getIterator(); i; i++ )
- {
- if( i->getId() == id )
- {
- cs.unlock();
- return i;
- }
- }
- cs.unlock();
- return 0;
- }
- TexturList *TexturList::getThis()
- {
- ref++;
- return this;
- }
- TexturList *TexturList::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
- void TexturList::init()
- {
- id = 0;
- }
- void TexturList::destroy()
- {
- }
|