Example #1
0
Kernel::Kernel() :
	_resourceManager(NULL),
	_initSuccess(false),
	_gfx(0),
	_sfx(0),
	_input(0),
	_package(0),
	_script(0),
	_fmv(0)
	{

	// Log that the kernel is beign created
	BS_LOGLN("created.");
	_instance = this;

	// Create the resource manager
	_resourceManager = new ResourceManager(this);

	// Initialise the script engine
	_script = new LuaScriptEngine(this);
	if (!_script || !_script->init()) {
		_initSuccess = false;
		return;
	}

	// Register kernel script bindings
	if (!registerScriptBindings()) {
		BS_LOG_ERRORLN("Script bindings could not be registered.");
		_initSuccess = false;
		return;
	}
	BS_LOGLN("Script bindings registered.");

	_input = new InputEngine(this);
	assert(_input);

	_gfx = new GraphicEngine(this);
	assert(_gfx);

	_sfx = new SoundEngine(this);
	assert(_sfx);

	_package = new PackageManager(this);
	assert(_package);

	_geometry = new Geometry(this);
	assert(_geometry);

#ifdef USE_THEORADEC
	_fmv = new MoviePlayer(this);
	assert(_fmv);
#endif

	_initSuccess = true;
}
Example #2
0
Kernel::~Kernel() {
	// Services are de-registered in reverse order of creation

	delete _input;
	_input = 0;

	delete _gfx;
	_gfx = 0;

	delete _sfx;
	_sfx = 0;

	delete _package;
	_package = 0;

	delete _geometry;
	_geometry = 0;

#ifdef USE_THEORADEC
	delete _fmv;
	_fmv = 0;
#endif

	delete _script;
	_script = 0;

	// Resource-Manager freigeben
	delete _resourceManager;

	BS_LOGLN("destroyed.");
}
Example #3
0
PackageManager::PackageManager(Kernel *pKernel) : Service(pKernel),
	_currentDirectory(PATH_SEPARATOR),
	_rootFolder(ConfMan.get("path")) {
	if (!registerScriptBindings())
		BS_LOG_ERRORLN("Script bindings could not be registered.");
	else
		BS_LOGLN("Script bindings registered.");
}
Example #4
0
bool PackageManager::loadDirectoryAsPackage(const Common::String &directoryName, const Common::String &mountPosition) {
	Common::FSNode directory(directoryName);
	Common::Archive *folderArchive = new Common::FSDirectory(directory, 6);
	if (!directory.exists() || (folderArchive == NULL)) {
		BS_LOG_ERRORLN("Unable to mount directory \"%s\" to \"%s\".", directoryName.c_str(), mountPosition.c_str());
		return false;
	} else {
		BS_LOGLN("Directory '%s' mounted as '%s'.", directoryName.c_str(), mountPosition.c_str());

		Common::ArchiveMemberList files;
		folderArchive->listMembers(files);
		debug(0, "Capacity %d", files.size());

		_archiveList.push_front(new ArchiveEntry(folderArchive, mountPosition));

		return true;
	}
}
Example #5
0
bool PackageManager::loadPackage(const Common::String &fileName, const Common::String &mountPosition) {
	debug(3, "loadPackage(%s, %s)", fileName.c_str(), mountPosition.c_str());

	Common::Archive *zipFile = Common::makeZipArchive(fileName);
	if (zipFile == NULL) {
		BS_LOG_ERRORLN("Unable to mount file \"%s\" to \"%s\"", fileName.c_str(), mountPosition.c_str());
		return false;
	} else {
		BS_LOGLN("Package '%s' mounted as '%s'.", fileName.c_str(), mountPosition.c_str());
		Common::ArchiveMemberList files;
		zipFile->listMembers(files);
		debug(3, "Capacity %d", files.size());

		for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it)
			debug(3, "%s", (*it)->getName().c_str());

		_archiveList.push_front(new ArchiveEntry(zipFile, mountPosition));

		return true;
	}
}