123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- #include "TexturList.h"
- #include "Text.h"
- #include "Textur.h"
- using namespace Framework;
- int TexturList::id = 0;
- Critical TexturList::cs;
- TexturList::TexturList()
- : ReferenceCounter()
- {
- textures = new RCArray<Textur>();
- names = new RCArray<Text>();
- }
- 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)
- {
- 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)
- {
- 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)
- {
- 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)
- {
- 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)
- {
- if (i->getId() == id)
- {
- cs.unlock();
- return dynamic_cast<Textur*>(i->getThis());
- }
- }
- cs.unlock();
- return 0;
- }
- Textur* TexturList::zTextur(const char* name) const
- {
- cs.lock();
- int index = 0;
- for (auto i : *names)
- {
- 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)
- {
- if (i->getId() == id)
- {
- cs.unlock();
- return i;
- }
- }
- cs.unlock();
- return 0;
- }
- void TexturList::init()
- {
- id = 0;
- }
- void TexturList::destroy() {}
|