Beispiel #1
0
Datei: vfs.cpp Projekt: m64/PEG
	VFSSource* VFS::createSource(const std::string& path) const {
		if ( m_usedfiles.count(path) ) {
			FL_WARN(_log, LMsg(path) << " is already used as VFS source");
			return 0;
		}

		type_providers::const_iterator end = m_providers.end();
		for (type_providers::const_iterator i = m_providers.begin(); i != end; ++i) {
			const VFSSourceProvider* provider = *i;
			if (!provider->isReadable(path))
				continue;

			try {
				VFSSource* source = provider->createSource(path);
				m_usedfiles.insert(path);
				return source;
			} catch (const Exception& ex) {
				FL_WARN(_log, LMsg(provider->getName()) << " thought it could load " << path << " but didn't succeed (" << ex.getMessage() << ")");
				continue;
			} catch (...) {
				FL_WARN(_log, LMsg(provider->getName()) << " thought it could load " << path << " but didn't succeed (unkown exception)");
				continue;
			}
		}

		FL_WARN(_log, LMsg("no provider for ") << path << " found");
		return 0;
	}
Beispiel #2
0
	void InstanceTree::removeInstance(Instance* instance) {
		InstanceTreeNode * node = m_reverse[instance];
		if( !node ) {
			FL_WARN(_log, "InstanceTree::removeInstance() - Instance not part of tree.");
			return;
		}
		m_reverse.erase(instance);
		InstanceList& list = node->data();
		for(InstanceList::iterator i = list.begin(); i != list.end(); ++i) {
			if((*i) == instance) {
				list.erase(i);
				return;
			}
		}
		FL_WARN(_log, "InstanceTree::removeInstance() - Instance part of tree but not found in the expected tree node.");
	}
Beispiel #3
0
	void VFS::addNewSource(const std::string& path) {
		VFSSource* source = createSource(path);
		if (source) {
			addSource(source);
		} else {
			FL_WARN(_log, LMsg("Failed to add new VFS source: ") << path);
		}
	}
Beispiel #4
0
	SoundClipPtr SoundClipManager::create(const std::string& name, IResourceLoader* loader){
		if (exists(name)) {
			FL_WARN(_log, LMsg("SoundClipManager::create(std::string, IResourceLoader* loader) - ") << "Resource name " << name << " was previously created.  Returning original SoundClip...");
			return get(name);
		}

		SoundClip* ptr = new SoundClip(name, loader);
		return add(ptr);
	}
Beispiel #5
0
	ImagePtr ImageManager::create(const std::string& name, IResourceLoader* loader){
		if (exists(name)) {
			FL_WARN(_log, LMsg("ImageManager::create(std::string, IResourceLoader* loader) - ") << "Resource name " << name << " was previously created.  Returning original Image...");
			return getPtr(name);
		}

		Image* ptr = RenderBackend::instance()->createImage(name, loader);
		return add(ptr);
	}
Beispiel #6
0
	IPather* Model::getPather(const std::string& pathername) {
		std::vector<IPather*>::const_iterator it = m_pathers.begin();
		for(; it != m_pathers.end(); ++it) {
			if ((*it)->getName() == pathername) {
				return *it;
			}
		}
		FL_WARN(_log, "No pather of requested type \"" + pathername + "\" found.");
		return NULL;
	}
Beispiel #7
0
	void QuadTreeRenderer::render(Camera* cam, Layer* layer, RenderList& instances) {
		CellGrid* cg = layer->getCellGrid();
		if (!cg) {
			FL_WARN(_log, "No cellgrid assigned to layer, cannot draw grid");
			return;
		}
		InstanceTree * itree = layer->getInstanceTree();
		RenderVisitor VIPguess(m_renderbackend, layer,cam);
		itree->applyVisitor(VIPguess);
	}
Beispiel #8
0
	ImagePtr ImageManager::getPtr(ResourceHandle handle) {
		ImageHandleMapConstIterator it = m_imgHandleMap.find(handle);
		if (it != m_imgHandleMap.end()) {
			return it->second;
		}

		FL_WARN(_log, LMsg("ImageManager::getPtr(ResourceHandle) - ") << "Resource handle " << handle << " is undefined.");

		return ImagePtr();
	}
Beispiel #9
0
	VFSSource* VFS::getSourceForFile(const std::string& file) const {
		type_sources::const_iterator i = std::find_if(m_sources.begin(), m_sources.end(),
										 boost::bind2nd(boost::mem_fun(&VFSSource::fileExists), file));
		if (i == m_sources.end()) {
			FL_WARN(_log, LMsg("no source for ") << file << " found");
			return 0;
		}

		return *i;
	}
Beispiel #10
0
	ResourceHandle SoundClipManager::getResourceHandle(const std::string& name) {
		SoundClipNameMapIterator nit = m_sclipNameMap.find(name);
		if (nit != m_sclipNameMap.end()) {
			return nit->second->getHandle();
		}

		FL_WARN(_log, LMsg("SoundClipManager::getResourceHandle(std::string) - ") << "Resource " << name << " is undefined.");

		return 0;
	}
Beispiel #11
0
	ImagePtr ImageManager::getPtr(const std::string& name) {
		ImageNameMapIterator nit = m_imgNameMap.find(name);

		if (nit != m_imgNameMap.end()) {
			return nit->second;
		}

		FL_WARN(_log, LMsg("ImageManager::getPtr(std::string) - ") << "Resource " << name << " is undefined.");

		return ImagePtr();
	}
Beispiel #12
0
	void InstanceTree::addInstance(Instance* instance) {
		ModelCoordinate coords = instance->getLocationRef().getLayerCoordinates();
		InstanceTreeNode * node = m_tree.find_container(coords.x,coords.y,0,0);
		InstanceList& list = node->data();
		list.push_back(instance);
		if( m_reverse.find(instance) != m_reverse.end() ) {
			FL_WARN(_log, "InstanceTree::addInstance() - Duplicate Instance.  Ignoring.");
			return;
		}
		m_reverse[instance] = node;
	}
Beispiel #13
0
	void SoundClipManager::free(ResourceHandle handle) {
		SoundClipHandleMapConstIterator it = m_sclipHandleMap.find(handle);
		if (it != m_sclipHandleMap.end()) {
			if ( it->second->getState() == IResource::RES_LOADED) {
				it->second->free();
			}
			return;
		}

		FL_WARN(_log, LMsg("SoundClipManager::free(ResourceHandle) - ") << "Resource handle " << handle << " not found.");
	}
 void Instance::removeDeleteListener(InstanceDeleteListener *listener) {
         std::vector<InstanceDeleteListener*>::iterator itor;
         itor = std::find(m_deletelisteners.begin(),
                          m_deletelisteners.end(),
                          listener);
         if(itor != m_deletelisteners.end()) {
                 m_deletelisteners.erase(itor);
         } else {
                 FL_WARN(_log, "Cannot remove unknown listener");
         }
 }
Beispiel #15
0
	void EngineSettings::setLightingModel(uint32_t lighting) {
		if (lighting <= 2) {
			m_lighting = lighting;
			return;
		}

		FL_WARN(_log, LMsg("EngineSettings::setLightingModel() - ")
			<< lighting << " is not a valid lighting model." <<
			".  Setting the lighting model to the default value of 0 (off)");

		m_lighting = 0;
	}
Beispiel #16
0
	void EngineSettings::setInitialVolume(float volume) {
		if (volume > getMaxVolume() || volume < 0) {
			FL_WARN(_log, LMsg("EngineSettings::setInitialVolume() - ")
				<< " Tried to set initial volume to an unsupporded value of " << volume <<
				".  Setting volume to the default value of 5 (minumum is 0, maximum is 10)");

			m_initialvolume = 5.0;
			return;
		}

		m_initialvolume = volume;
	}
Beispiel #17
0
	void SoundClipManager::free(const std::string& name) {
		SoundClipNameMapIterator nit = m_sclipNameMap.find(name);

		if (nit != m_sclipNameMap.end()) {
			if ( nit->second->getState() == IResource::RES_LOADED) {
				nit->second->free();
			}
			return;
		}

		FL_WARN(_log, LMsg("SoundClipManager::free(std::string) - ") << "Resource name " << name << " not found.");
	}
Beispiel #18
0
	CellGrid* Model::getCellGrid(const std::string& gridtype) {
		std::vector<CellGrid*>::const_iterator it = m_adopted_grids.begin();
		for(; it != m_adopted_grids.end(); ++it) {
			if ((*it)->getType() == gridtype) {
				CellGrid* newcg = (*it)->clone();
				m_created_grids.push_back(newcg);
				return newcg;
			}
		}
		FL_WARN(_log, "No cellgrid of requested type \"" + gridtype + "\" found.");
		return NULL;
	}
Beispiel #19
0
	void ImageManager::reload(const std::string& name) {
		ImageNameMapIterator nit = m_imgNameMap.find(name);

		if (nit != m_imgNameMap.end()) {
			if ( nit->second->getState() == IResource::RES_LOADED) {
				nit->second->free();
			}
			nit->second->load();
			return;
		}

		FL_WARN(_log, LMsg("ImageManager::reload(std::string) - ") << "Resource name " << name << " not found.");
	}
Beispiel #20
0
	void EngineSettings::setRenderBackend(const std::string& renderbackend) {
		std::vector<std::string> pv = getPossibleRenderBackends();
		std::vector<std::string>::iterator i = std::find(pv.begin(), pv.end(), renderbackend);
		if (i != pv.end()) {
			m_renderbackend = renderbackend;
			return;
		}
		FL_WARN(_log, LMsg("EngineSettings::setRenderBackend() - ")
			<< renderbackend << " is not a valid render backend " <<
			".  Setting the render backend to the default value of \"SDL\".");

		m_renderbackend = "SDL";
	}
Beispiel #21
0
	void EngineSettings::setBitsPerPixel(uint8_t bitsperpixel) {
		std::vector<uint8_t> pv = getPossibleBitsPerPixel();
		std::vector<uint8_t>::iterator i = std::find(pv.begin(), pv.end(), bitsperpixel);
		if (i != pv.end()) {
			m_bitsperpixel = bitsperpixel;
			return;
		}

		FL_WARN(_log, LMsg("EngineSettings::setBitsPerPixel() - ")
			<< " Tried to set screen bpp to an unsupporded value of " << bitsperpixel <<
			".  Setting bpp to use the default value of 0 (the current screen bpp)");

		m_bitsperpixel = 0;  //default value
	}
Beispiel #22
0
	SoundClipPtr SoundClipManager::get(ResourceHandle handle) {
		SoundClipHandleMapConstIterator it = m_sclipHandleMap.find(handle);
		if (it != m_sclipHandleMap.end()) {
			if (it->second->getState() != IResource::RES_LOADED){
				//resource is not loaded so load it
				it->second->load();
			}
			return it->second;
		}

		FL_WARN(_log, LMsg("SoundClipManager::get(ResourceHandle) - ") << "Resource handle " << handle << " is undefined.");

		return SoundClipPtr();
	}
	void Instance::removeChangeListener(InstanceChangeListener* listener) {
		if (!m_activity) {
			return;
		}
		std::vector<InstanceChangeListener*>::iterator i = m_activity->m_changelisteners.begin();
		while (i != m_activity->m_changelisteners.end()) {
			if ((*i) == listener) {
				*i = NULL;
				return;
			}
			++i;
		}
		FL_WARN(_log, "Cannot remove unknown listener");
	}
Beispiel #24
0
	void ImageManager::reload(ResourceHandle handle) {
		ImageHandleMapIterator it = m_imgHandleMap.find(handle);

		if ( it != m_imgHandleMap.end()) {
			if ( it->second->getState() == IResource::RES_LOADED) {
				it->second->free();
			}
			it->second->load();
			return;
		}

		FL_WARN(_log, LMsg("ImageManager::reload(ResourceHandle) - ") << "Resource handle " << handle << " not found.");

	}
Beispiel #25
0
	void TwoButton::draw(Graphics *graphics) {
		Image* img = m_upImage;
		int32_t xoffset = 0;
		int32_t yoffset = 0;

		if (isPressed()) {
			if( m_downImage ) {
				img = m_downImage;
				xoffset = x_downoffset;
				yoffset = y_downoffset;
			}
		} else if(mHasMouse) {
			if( m_hoverImage ) {
				img = m_hoverImage;
			}
		}

		if (img) {
			graphics->drawImage(img, xoffset, yoffset);
		}

		graphics->setColor(getForegroundColor());
		int32_t textX;
		int32_t textY = getHeight() / 2 - getFont()->getHeight() / 2;
		switch (getAlignment())
		{
			case Graphics::LEFT:
				textX = 4;
				break;
			case Graphics::CENTER:
				textX = getWidth() / 2;
				break;
			case Graphics::RIGHT:
				textX = getWidth() - 4;
				break;
			default:
				textX = 4;
				FL_WARN(_log, FIFE::LMsg("TwoButton::draw() - ") << "Unknown alignment: "
				              << getAlignment() << ".  Using the default of Graphics::LEFT");
		}

		graphics->setFont(getFont());
		if (mCaption.size() > 0) {
			if (isPressed())
				graphics->drawText(getCaption(), textX + 1,
						textY + 1, getAlignment());
			else
				graphics->drawText(getCaption(), textX, textY, getAlignment());
		}
	}
Beispiel #26
0
	void HybridGuiManager::removeGuiManager(IGUIManager* guiManager) {
		std::vector<IGUIManager*>::iterator currManager(m_guiManagers.begin());
		std::vector<IGUIManager*>::iterator endManager(m_guiManagers.end());
		
		for(; currManager != endManager;) {
			if((*currManager) == guiManager) {
				m_guiManagers.erase(currManager);
				return;
			}
			
			++currManager;
		}
		
		FL_WARN(_log, LMsg() << "Tyring to remove a non-existing gui manager from a hybrid gui manager.");
	}
Beispiel #27
0
	void ImageManager::remove(ImagePtr& resource) {
		ImageHandleMapIterator it = m_imgHandleMap.find(resource->getHandle());
		ImageNameMapIterator nit = m_imgNameMap.find(resource->getName());

		if (it != m_imgHandleMap.end()) {
			m_imgHandleMap.erase(it);

			if (nit != m_imgNameMap.end()) {
				m_imgNameMap.erase(nit);
				return;
			}
			assert(false); //should never get here
		}

		FL_WARN(_log, LMsg("ImageManager::remove(ResourcePtr&) - ") << "Resource " << resource->getName() << " was not found.");
	}
Beispiel #28
0
	void SoundClipManager::remove(SoundClipPtr& resource) {
		SoundClipHandleMapIterator it = m_sclipHandleMap.find(resource->getHandle());
		SoundClipNameMapIterator nit = m_sclipNameMap.find(resource->getName());

		if (it != m_sclipHandleMap.end()) {
			m_sclipHandleMap.erase(it);

			if (nit != m_sclipNameMap.end()) {
				m_sclipNameMap.erase(nit);
				return;
			}
			assert(false); //should never get here
		}

		FL_WARN(_log, LMsg("SoundClipManager::remove(ResourcePtr&) - ") << "Resource " << resource->getName() << " was not found.");
	}
Beispiel #29
0
Datei: vfs.cpp Projekt: m64/PEG
	std::string VFS::lower(const std::string& str) const {
		std::string result;
		result.resize(str.size());
		bool found_uppercase = false;
		for(unsigned i=0; i != str.size(); ++i)
		{
			result[i] = tolower(str[i]);
			found_uppercase |= result[i] != str[i];
		}
		if( found_uppercase )
		{
			FL_WARN(_log, LMsg("Case mismatch: given '") << str
				<< "', FIFE will use '" << result
				<< "' - Please only use lower case filenames to avoid problems with different file systems.");
		}
		return result;
	}
Beispiel #30
0
	SoundClipPtr SoundClipManager::add(SoundClip* res) {
		assert(res);
		assert(!(exists(res->getHandle()) || exists(res->getName())));

		SoundClipPtr resptr(res);

		std::pair<SoundClipHandleMapIterator, bool> returnValue;
		returnValue = m_sclipHandleMap.insert ( SoundClipHandleMapPair(res->getHandle(), resptr));

		if (returnValue.second) {
			m_sclipNameMap.insert ( SoundClipNameMapPair(returnValue.first->second->getName(), returnValue.first->second) );
		}
		else {
			FL_WARN(_log, LMsg("SoundClipManager::add(IResource*) - ") << "Resource " << res->getName() << " already exists.... ignoring.");
		}

		return returnValue.first->second;
	}