示例#1
0
void ResourceManager::unloadAllResources(const std::string &fileName)
{
	CL_ResourceManager resourceManager = loadResourceFile(fileName);
	std::vector<CL_String> names = resourceManager.get_resource_names();
	for (std::vector<CL_String>::const_iterator it = names.begin(); it != names.end(); ++it)
		unloadResource(*it);
	mResourceFiles.erase(fileName);
}
示例#2
0
void ResourceManager::unloadAll( void )
{
	for( uint32_t i = 0; i < _resources.size(); ++i )
	{
		string_hash resourceId = *_resources.get_key( i );
		unloadResource( resourceId );
	}
}
示例#3
0
void AssetBrowser::selectResource(Lumix::Resource* resource)
{
	if (m_selected_resource) m_history.push(m_selected_resource->getPath());
	if (m_history.size() > 20) m_history.erase(0);


	m_wanted_resource = "";
	unloadResource();
	m_selected_resource = resource;
	ASSERT(m_selected_resource->getRefCount() > 0);
}
// リソースをすべて解放する 
void ResourceManager::release()
{
    auto it = m_hash.begin();
    while (it != m_hash.end())
    {
        // リソースのアンロード
        unloadResource(it->second);
        ++it;
    }
    // ハッシュマップのクリア
    m_hash.clear();
}
示例#5
0
AssetBrowser::~AssetBrowser()
{
	unloadResource();

	for (auto* plugin : m_plugins)
	{
		LUMIX_DELETE(m_editor.getAllocator(), plugin);
	}
	m_plugins.clear();

	FileSystemWatcher::destroy(m_watchers[0]);
	FileSystemWatcher::destroy(m_watchers[1]);
}
示例#6
0
void LoadingScene::loadResource()
{
    unloadResource();
    
    
    AnimationLoader::loadData();
  
    CCScene* scene = TestScene::scene();
    CCDirector::sharedDirector()->popToRootScene();
    CCDirector::sharedDirector()->pushScene(scene);
       for(int i=0; i<DataCollector::getInstance()->getMatchData()->resourcePackList.size(); i++)
    {
        ResourceLoader::loadResourcePack(DataCollector::getInstance()->getMatchData()->resourcePackList[i]);
    }
    ((TestScene*)scene->getChildByTag(1))->loadResource();
    ((TestScene*)scene->getChildByTag(1))->initScene();

}
示例#7
0
void AssetBrowser::selectResource(Lumix::Resource* resource, bool record_history)
{
	if (record_history)
	{
		while (m_history_index < m_history.size() - 1)
		{
			m_history.pop();
		}
		m_history_index++;
		m_history.push(resource->getPath());

		if (m_history.size() > 20)
		{
			--m_history_index;
			m_history.erase(0);
		}
	}

	m_wanted_resource = "";
	unloadResource();
	m_selected_resource = resource;
	ASSERT(m_selected_resource->getRefCount() > 0);
}
示例#8
0
文件: Plugin.cpp 项目: cgart/nrEngine
	//----------------------------------------------------------------------------------
	Plugin::~Plugin()
	{
		unloadResource();
	}
示例#9
0
/**
 * Loads a resource into memory, a raw resource is loaded in
 * with above routine, then further decoded here.
 */
int AgiLoader_v2::loadResource(int t, int n) {
	int ec = errOK;
	uint8 *data = NULL;

	debugC(3, kDebugLevelResources, "(t = %d, n = %d)", t, n);
	if (n > MAX_DIRS)
		return errBadResource;

	switch (t) {
	case rLOGIC:
		if (~_vm->_game.dirLogic[n].flags & RES_LOADED) {
			debugC(3, kDebugLevelResources, "loading logic resource %d", n);
			unloadResource(rLOGIC, n);

			// load raw resource into data
			data = loadVolRes(&_vm->_game.dirLogic[n]);

			_vm->_game.logics[n].data = data;
			ec = data ? _vm->decodeLogic(n) : errBadResource;

			_vm->_game.logics[n].sIP = 2;
		}

		// if logic was cached, we get here
		// reset code pointers incase it was cached

		_vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
		break;
	case rPICTURE:
		// if picture is currently NOT loaded *OR* cacheing is off,
		// unload the resource (caching == off) and reload it

		debugC(3, kDebugLevelResources, "loading picture resource %d", n);
		if (_vm->_game.dirPic[n].flags & RES_LOADED)
			break;

		// if loaded but not cached, unload it
		// if cached but not loaded, etc
		unloadResource(rPICTURE, n);
		data = loadVolRes(&_vm->_game.dirPic[n]);

		if (data != NULL) {
			_vm->_game.pictures[n].rdata = data;
			_vm->_game.dirPic[n].flags |= RES_LOADED;
		} else {
			ec = errBadResource;
		}
		break;
	case rSOUND:
		debugC(3, kDebugLevelResources, "loading sound resource %d", n);
		if (_vm->_game.dirSound[n].flags & RES_LOADED)
			break;

		data = loadVolRes(&_vm->_game.dirSound[n]);

		if (data != NULL) {
			// Freeing of the raw resource from memory is delegated to the createFromRawResource-function
			_vm->_game.sounds[n] = AgiSound::createFromRawResource(data, _vm->_game.dirSound[n].len, n, *_vm->_sound, _vm->_soundemu);
			_vm->_game.dirSound[n].flags |= RES_LOADED;
		} else {
			ec = errBadResource;
		}
		break;
	case rVIEW:
		// Load a VIEW resource into memory...
		// Since VIEWS alter the view table ALL the time
		// can we cache the view? or must we reload it all
		// the time?
		if (_vm->_game.dirView[n].flags & RES_LOADED)
			break;

		debugC(3, kDebugLevelResources, "loading view resource %d", n);
		unloadResource(rVIEW, n);
		data = loadVolRes(&_vm->_game.dirView[n]);
		if (data) {
			_vm->_game.views[n].rdata = data;
			_vm->_game.dirView[n].flags |= RES_LOADED;
			ec = _vm->decodeView(n);
		} else {
			ec = errBadResource;
		}
		break;
	default:
		ec = errBadResource;
		break;
	}

	return ec;
}