示例#1
0
bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) {
	Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename);
	if (!file) {
		BaseEngine::LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str());
		if (_gameRef->_debugDebugMode) {
			return loadFile("invalid_debug.bmp", lifeTime, cacheType);
		} else {
			return loadFile("invalid.bmp", lifeTime, cacheType);
		}
	} else {
		BaseFileManager::getEngineInstance()->closeFile(file);
		file = nullptr;
	}

	bool ret = STATUS_FAILED;

	AnsiString filePrefix = filename;
	AnsiString ext = PathUtil::getExtension(filename);
	ext.toLowercase();
	filePrefix.toLowercase();
	if (filePrefix.hasPrefix("savegame:") || (ext == "bmp") || (ext == "tga") || (ext == "png") || (ext == "jpg")) {
		BaseFrame *frame = new BaseFrame(_gameRef);
		BaseSubFrame *subframe = new BaseSubFrame(_gameRef);
		subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true);
		if (subframe->_surface == nullptr) {
			BaseEngine::LOG(0, "Error loading simple sprite '%s'", filename.c_str());
			ret = STATUS_FAILED;
			delete frame;
			delete subframe;
		} else {
			subframe->setDefaultRect();
			frame->_subframes.add(subframe);
			_frames.add(frame);
			_currentFrame = 0;
			ret = STATUS_OK;
		}
	} else {
		char *buffer = (char *)BaseFileManager::getEngineInstance()->readWholeFile(filename);
		if (buffer) {
			if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) {
				BaseEngine::LOG(0, "Error parsing SPRITE file '%s'", filename.c_str());
			} else {
				ret = STATUS_OK;
			}
			delete[] buffer;
		}
	}

	setFilename(filename.c_str());

	return ret;
}
示例#2
0
void ScEngine::addScriptTime(const char *filename, uint32 time) {
	if (!_isProfiling) {
		return;
	}

	AnsiString fileName = filename;
	fileName.toLowercase();
	_scriptTimes[fileName] += time;
}
示例#3
0
AnsiString PathUtil::normalizeFileName(const AnsiString &path) {
	AnsiString newPath = unifySeparators(path);
	newPath.toLowercase();
	return newPath;
}