Esempio n. 1
0
bool FontResource::parserCallback_font(ParserNode *node) {
	// Get the attributes of the font
	Common::String bitmapFilename = node->values["bitmap"];

	if (!parseIntegerKey(node->values["lineheight"], 1, &_lineHeight)) {
		warning("Illegal or missing lineheight attribute in <font> tag in \"%s\". Assuming default (\"%d\").",
		                 getFileName().c_str(), DEFAULT_LINEHEIGHT);
		_lineHeight = DEFAULT_LINEHEIGHT;
	}

	if (!parseIntegerKey(node->values["gap"], 1, &_gapWidth)) {
		warning("Illegal or missing gap attribute in <font> tag in \"%s\". Assuming default (\"%d\").",
		                 getFileName().c_str(), DEFAULT_GAPWIDTH);
		_gapWidth = DEFAULT_GAPWIDTH;
	}
	
	// Get a reference to the package manager
	assert(_pKernel);
	PackageManager *pPackage = _pKernel->getPackage();
	assert(pPackage);

	// Get the full path and filename for the bitmap resource
	_bitmapFileName = pPackage->getAbsolutePath(bitmapFilename);
	if (_bitmapFileName == "") {
		error("Image file \"%s\" was specified in <font> tag of \"%s\" but could not be found.",
		               _bitmapFileName.c_str(), getFileName().c_str());
	}

	// Pre-cache the resource
	if (!_pKernel->getResourceManager()->precacheResource(_bitmapFileName)) {
		error("Could not precache \"%s\".", _bitmapFileName.c_str());
	}

	return true;
}
Esempio n. 2
0
Resource::Resource(const Common::String &fileName, RESOURCE_TYPES type) :
	_type(type),
	_refCount(0) {
	PackageManager *pPM = Kernel::getInstance()->getPackage();
	assert(pPM);

	_fileName = pPM->getAbsolutePath(fileName);
}
Esempio n. 3
0
bool LuaScriptEngine::executeFile(const Common::String &fileName) {
#ifdef DEBUG
	int __startStackDepth = lua_gettop(_state);
#endif
	debug(2, "LuaScriptEngine::executeFile(%s)", fileName.c_str());

	// Get a pointer to the package manager
	PackageManager *pPackage = Kernel::getInstance()->getPackage();
	assert(pPackage);

	// File read
	uint fileSize;
	byte *fileData = pPackage->getFile(fileName, &fileSize);
	if (!fileData) {
		error("Couldn't read \"%s\".", fileName.c_str());
#ifdef DEBUG
		assert(__startStackDepth == lua_gettop(_state));
#endif
		return false;
	}

	// Run the file content
	if (!executeBuffer(fileData, fileSize, "@" + pPackage->getAbsolutePath(fileName))) {
		// Release file buffer
		delete[] fileData;
#ifdef DEBUG
		assert(__startStackDepth == lua_gettop(_state));
#endif
		return false;
	}

	// Release file buffer
	delete[] fileData;

#ifdef DEBUG
	assert(__startStackDepth == lua_gettop(_state));
#endif

	return true;
}