Ejemplo n.º 1
0
void copySysOSX(const char* projName)
{
#ifdef _DEBUG
	const char * appName = "MaratisPlayerDebug";
#else
	const char * appName = "MaratisPlayer";
#endif

	MWindow * window = MWindow::getInstance();
	MEngine* engine = MEngine::getInstance();
	MSystemContext* system = engine->getSystemContext();

	char filename[256];
	getLocalFilename(filename, system->getWorkingDirectory(), projName);

	if(char* ext = strstr(filename, ".mproj"))
	{
		MProject proj;
		if(proj.loadXML(projName))
		{
			strcpy(ext, ".app");

			char path[256];
			char srcName[256];
			char destName[256];
			char appPath[256];
			char level[256];

			getLocalFilename(level, system->getWorkingDirectory(), proj.startLevel.c_str());
			getGlobalFilename(appPath, getPubDir(), filename);

			sprintf(path, "../../../%s.app", appName);
			getGlobalFilename(srcName, window->getCurrentDirectory(), path);
			copyDirectory(srcName, appPath);

			strcpy(ext, "");
			sprintf(srcName, "%s/Contents/MacOS/%s", appPath, appName);

			strcpy(ext, ".mproj");
			embedProject(srcName, srcName, filename, level, proj.renderer.c_str());
			chmod(srcName, 0777);

			// we need to put all data in app/Contents/Resources/
			sprintf(destName, "%s/Contents/Resources", appPath);
			createDirectory(destName);
			s_dataDir = destName;
		}
	}
}
Ejemplo n.º 2
0
const char* getPubDir()
{
	MEngine* engine = MEngine::getInstance();
	MSystemContext* system = engine->getSystemContext();

	char dir[256];
	getGlobalFilename(dir, system->getWorkingDirectory(), "published");
	s_pubDir = dir;

	return s_pubDir.c_str();
}
Ejemplo n.º 3
0
bool MEmbedFile::IsFile(const char* name)
{
    M_PROFILE_SCOPE(MEmbedFile::IsFile);
    MEngine* engine = MEngine::getInstance();
    MSystemContext* system = engine->getSystemContext();
    
    char localFilename[256];
    getLocalFilename(localFilename, system->getWorkingDirectory(), name);
    
    return strcmp(localFilename, m_Filename) == 0;
}
Ejemplo n.º 4
0
void copySysLinux(const char* projName)
{
#ifdef _DEBUG
	const char * appName = "MaratisPlayerDebug";
#else
	const char * appName = "MaratisPlayer";
#endif

	MEngine* engine = MEngine::getInstance();
	MSystemContext* system = engine->getSystemContext();

	char filename[256];
	getLocalFilename(filename, system->getWorkingDirectory(), projName);

	if(char* ext = strstr(filename, ".mproj"))
	{
		*ext = 0;

		MProject proj;
		if(proj.loadXML(projName))
		{
			char destName[256];
			getGlobalFilename(destName, getPubDir(), filename);

			char level[256];
			getLocalFilename(level, system->getWorkingDirectory(), proj.startLevel.c_str());

			strcpy(ext, ".mproj");
			embedProject(appName, destName, filename, level, proj.renderer.c_str());
			chmod(destName, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);

			// find all dynamic libraries
			copyDirFiles(".", getPubDir(), ".so");
		}
	}
}
Ejemplo n.º 5
0
void copySysWindows(const char* projName)
{
#ifdef _DEBUG
	const char * appName = "MaratisPlayerDebug.exe";
#else
	const char * appName = "MaratisPlayer.exe";
#endif

	MEngine* engine = MEngine::getInstance();
	MSystemContext* system = engine->getSystemContext();

	char filename[256];
	getLocalFilename(filename, system->getWorkingDirectory(), projName);

	if(char* ext = strstr(filename, ".mproj"))
	{
		MProject proj;
		if(proj.loadXML(projName))
		{
			strcpy(ext, ".exe");
			char destName[256];
			getGlobalFilename(destName, getPubDir(), filename);

			char level[256];
			getLocalFilename(level, system->getWorkingDirectory(), proj.startLevel.c_str());

			// we need the project "filename" to still be a .mproj for MaratisPlayer to behave
			// correctly
			strcpy(ext, ".mproj");
			embedProject(appName, destName, filename, level, proj.renderer.c_str());

			// find all dynamic libraries
			copyDirFiles(".", getPubDir(), ".dll");
		}
	}
}
Ejemplo n.º 6
0
/*--------------------------------------------------------------------------------
 * MPackageFileOpenHook::open
 * File open callback
 *-------------------------------------------------------------------------------*/
MFile* MPackageFileOpenHook::open(const char* path, const char* mode)
{
	MEngine* engine = MEngine::getInstance();
	MSystemContext * system = engine->getSystemContext();
	
	char localFilename[256];
	getLocalFilename(localFilename, system->getWorkingDirectory(), path);
	
	
	if(strstr(mode, "w") != 0)
		return MStdFile::getNew(path, mode);
	
	// look within the package for a file with the requested name
	if(MPackageEnt ent = engine->getPackageManager()->findEntity(localFilename))
		return MPackageFile::getNew(ent);
	
	// give up, just look for a new file using stdio
	return MStdFile::getNew(path, mode);
}
Ejemplo n.º 7
0
MPackage openProjectPackage(const char* projName)
{
	MEngine* engine = MEngine::getInstance();
	MSystemContext* system = engine->getSystemContext();

	char projFile[256];
	getLocalFilename(projFile, system->getWorkingDirectory(), projName);
	char* ext = strstr(projFile, ".mproj");
	if(ext == 0)
	{
		return 0;
	}

	sprintf(ext, ".npk");
	char packFile[256];

	getGlobalFilename(packFile, getDataDir(), projFile);

	MPackageManager* packageManager = engine->getPackageManager();
	MPackage package = packageManager->openPackage(packFile);

	return package;
}
Ejemplo n.º 8
0
	void	execute(const char* projName)
	{
		MEngine* engine = MEngine::getInstance();
		MSystemContext* system = engine->getSystemContext();

		char filename[256];
		char destFilename[256];

#ifdef WIN32
		const char* pluginName = "Game.dll";
#elif __APPLE__
		const char* pluginName = "Game.dylib";
#elif linux
		const char* pluginName = "Game.so";
#endif

		getGlobalFilename(filename, system->getWorkingDirectory(), pluginName);
		getGlobalFilename(destFilename, getDataDir(), pluginName);

		if(isFileExist(filename))
		{
			copyFile(filename, destFilename);
		}
	}
Ejemplo n.º 9
0
	void execute(const char* projName)
	{
		MEngine* engine = MEngine::getInstance();
		MSystemContext* system = engine->getSystemContext();
		MPackageManager* packageManager = engine->getPackageManager();

		char directory[256], localFilename[256];
		getGlobalFilename(directory, system->getWorkingDirectory(), "meshs");
		vector<string> files;
		readDirectory(directory, &files, 1, 1);

		MLevel* currentLevel = engine->getLevel();
		MLevel* tempLevel = new MLevel();
		engine->setLevel(tempLevel);

		MMesh* mesh = MMesh::getNew();
		MArmatureAnim* armAnim = MArmatureAnim::getNew();
		MTexturesAnim* texAnim = MTexturesAnim::getNew();
		MMaterialsAnim* matAnim = MMaterialsAnim::getNew();

		// open package and scan meshes
		MPackage package = openProjectPackage(projName);
		for(int i = 0; i < files.size(); ++i)
		{
			bool binarized = false;
			
			if(strstr(files[i].c_str(), "._bin") != 0)
				continue;
			
			// export bin
			if(strstr(files[i].c_str(), ".mesh") != 0)
			{
				if(engine->getMeshLoader()->loadData(files[i].c_str(), mesh))
					binarized = exportMeshBin((files[i] + "._bin").c_str(), mesh);
			}
			else if (strstr(files[i].c_str(), ".maa") != 0)
			{
				if(engine->getArmatureAnimLoader()->loadData(files[i].c_str(), armAnim))
					binarized = exportArmatureAnimBin((files[i] + "._bin").c_str(), armAnim);
			}
			else if (strstr(files[i].c_str(), ".mma") != 0)
			{
				if(engine->getMaterialsAnimLoader()->loadData(files[i].c_str(), matAnim))
					binarized = exportMaterialsAnimBin((files[i] + "._bin").c_str(), matAnim);
			}
			else if (strstr(files[i].c_str(), ".mta") != 0)
			{
				if(engine->getTexturesAnimLoader()->loadData(files[i].c_str(), texAnim))
					binarized = exportTexturesAnimBin((files[i] + "._bin").c_str(), texAnim);
			}
			else
			{
				// try to export unknow format
				if(engine->getMeshLoader()->loadData(files[i].c_str(), mesh))
				{
					binarized = exportMeshBin((files[i] + "._bin").c_str(), mesh);
					
					// try to export animation
					MArmatureAnimRef * maaRef = mesh->getArmatureAnimRef();
					if(maaRef)
					{
						exportArmatureAnimBin((files[i] + ".maa._bin").c_str(), maaRef->getArmatureAnim());
						getLocalFilename(localFilename, system->getWorkingDirectory(), (files[i] + ".maa").c_str());
						packageManager->addFileToPackage((files[i] + ".maa._bin").c_str(), package, localFilename);
					}
				}
			}

			tempLevel->clear();

			// pack file
			getLocalFilename(localFilename, system->getWorkingDirectory(), files[i].c_str());
			
			if(binarized)
				packageManager->addFileToPackage((files[i] + "._bin").c_str(), package, localFilename); // pack bin file
			else
				packageManager->addFileToPackage(files[i].c_str(), package, localFilename); // pack original file
		}
		packageManager->closePackage(package);

		
		// clear mesh
		mesh->destroy();
		armAnim->destroy();
		texAnim->destroy();
		matAnim->destroy();

		// remove bin
		for(int i = 0; i < files.size(); ++i)
		{
			remove((files[i] + "._bin").c_str());
			remove((files[i] + ".maa._bin").c_str());
		}

		// restore level
		engine->setLevel(currentLevel);
		SAFE_DELETE(tempLevel);
	}