bool AutotestingSystemLua::LoadScriptFromFile(const FilePath &luaFilePath)
{
	Logger::Debug("AutotestingSystemLua::LoadScriptFromFile: %s", luaFilePath.GetAbsolutePathname().c_str());
	File * file = File::Create(luaFilePath, File::OPEN | File::READ );
	if (file)
	{
		char *data = new char[file->GetSize()];
		file->Read(data, file->GetSize());
		uint32 fileSize = file->GetSize();
		file->Release();
		file = NULL;

		bool result = luaL_loadbuffer(luaState, data, fileSize, luaFilePath.GetAbsolutePathname().c_str()) == LUA_OK;
		delete [] data;
		if (result)
		{
			return true;
		}
		else
		{
			Logger::Error("AutotestingSystemLua::LoadScriptFromFile: couldn't load buffer %s", luaFilePath.GetAbsolutePathname().c_str());
			//lua_pushnil(L);
			return false;
		}

	} else {
		Logger::Error("AutotestingSystemLua::LoadScriptFromFile: couldn't open %s",luaFilePath.GetAbsolutePathname().c_str());
		//lua_pushnil(L);
		return false;
	}

}
Esempio n. 2
0
void Scene::AddRootNode(Entity *node, const FilePath &rootNodePath)
{
    ProxyNode * proxyNode = new ProxyNode();
    proxyNode->SetNode(node);
    
    rootNodes[rootNodePath.GetAbsolutePathname()] = proxyNode;
    proxyNode->SetName(rootNodePath.GetAbsolutePathname());
}
Esempio n. 3
0
void SceneSaver::CopyTexture(const FilePath &texturePathname, Set<String> &errorLog)
{
    FilePath descriptorPathname = TextureDescriptor::GetDescriptorPathname(texturePathname);
	
	TextureDescriptor* desc = TextureDescriptor::CreateFromFile(descriptorPathname);
	if(desc->IsCubeMap())
	{
		sceneUtils.CopyFile(descriptorPathname, errorLog);
		
		Vector<String> faceNames;
		Texture::GenerateCubeFaceNames(descriptorPathname.GetAbsolutePathname().c_str(), faceNames);
		for(Vector<String>::iterator it = faceNames.begin();
			it != faceNames.end();
			++it)
		{
			sceneUtils.CopyFile(*it, errorLog);
		}
	}
	else
	{
		FilePath pngPathname = GPUFamilyDescriptor::CreatePathnameForGPU(texturePathname, GPU_UNKNOWN, FORMAT_RGBA8888);

		sceneUtils.CopyFile(descriptorPathname, errorLog);
		sceneUtils.CopyFile(pngPathname, errorLog);
	}
	
	SafeRelease(desc);
}
Esempio n. 4
0
void TextureDescriptor::Save(const FilePath &filePathname) const
{
    File *file = File::Create(filePathname, File::WRITE | File::OPEN | File::CREATE);
    if(!file)
    {
        Logger::Error("[TextureDescriptor::Save] Can't open file: %s", filePathname.GetAbsolutePathname().c_str());
        return;
    }

    int32 signature = NOTCOMPRESSED_FILE;
    file->Write(&signature, sizeof(signature));

    int8 version = CURRENT_VERSION;
    file->Write(&version, sizeof(version));

    WriteGeneralSettings(file);

    //Compression
    for(int32 i = 0; i < GPU_FAMILY_COUNT; ++i)
    {
        WriteCompression(file, compression[i]);
    }

    SafeRelease(file);
}
Esempio n. 5
0
void SpritePackerHelper::Pack()
{
	void *pool = DAVA::QtLayer::Instance()->CreateAutoreleasePool();
	FilePath projectPath = EditorSettings::Instance()->GetProjectPath();
	FilePath inputDir = projectPath + "DataSource/Gfx/Particles/";
	FilePath outputDir = projectPath + "Data/Gfx/Particles/";

	if(!FileSystem::Instance()->IsDirectory(inputDir))
	{
		Logger::Error("[SpritePackerHelper::Pack] inputDir is not directory (%s)", inputDir.GetAbsolutePathname().c_str());
		return;
	}

	ResourcePacker2D * resourcePacker = new ResourcePacker2D();
	
	bool isChanged = resourcePacker->IsMD5ChangedDir(projectPath+"DataSource/Gfx/",inputDir,"particles.md5",true);
	
	SafeDelete(resourcePacker);
	if(!isChanged)
	{
		return;
	}
	
	SpritesPacker packer;
	packer.SetInputDir(inputDir);
	packer.SetOutputDir(outputDir);
	packer.PackTextures();
	DAVA::QtLayer::Instance()->ReleaseAutoreleasePool(pool);
}
Esempio n. 6
0
void FilePath::Initialize(const String &_pathname)
{
	String pathname = NormalizePathname(_pathname);
    pathType = GetPathType(pathname);

	if (pathType == PATH_EMPTY)
	{
		absolutePathname = String();
	}
    else if(pathType == PATH_IN_RESOURCES || pathType == PATH_IN_MEMORY)
    {
        absolutePathname = pathname;
    }
    else if(pathType == PATH_IN_DOCUMENTS)
    {
        absolutePathname = GetSystemPathname(pathname, pathType);
    }
    else if(IsAbsolutePathname(pathname))
    {
        absolutePathname = pathname;
    }
    else
    {
        Logger::FrameworkDebug("[FilePath::Initialize] FilePath was initialized from relative path name (%s)", _pathname.c_str());
        
#if defined(__DAVAENGINE_ANDROID__)
        absolutePathname = pathname;
#else //#if defined(__DAVAENGINE_ANDROID__)
        FilePath path = FileSystem::Instance()->GetCurrentWorkingDirectory() + pathname;
        absolutePathname = path.GetAbsolutePathname();
#endif //#if defined(__DAVAENGINE_ANDROID__)
    }
}
Esempio n. 7
0
void TextureHelper::CollectTexture(Map<String, Texture *> &textures, const FilePath &name, Texture *tex)
{
	if (!name.IsEmpty())
	{
		textures[name.GetAbsolutePathname()] = tex;
	}
}
void LandscapeEditorCustomColors::SaveTextureAction(const FilePath &pathToFile)
{
	if(pathToFile.IsEmpty())
		return;

    if(colorSprite)
    {
        Image *img = colorSprite->GetTexture()->CreateImageFromMemory();
        if(img)
        {
            StoreSaveFileName(pathToFile.GetAbsolutePathname());
            ImageLoader::Save(img, pathToFile.GetAbsolutePathname());
            SafeRelease(img);
            
            unsavedChanges = false;
        }
	}
}
Esempio n. 9
0
void Scene::ReleaseRootNode(const FilePath &rootNodePath)
{
	Map<String, ProxyNode*>::iterator it;
	it = rootNodes.find(rootNodePath.GetAbsolutePathname());
	if (it != rootNodes.end())
	{
        it->second->Release();
        rootNodes.erase(it);
	}
}
Esempio n. 10
0
bool TextureDescriptor::Load(const FilePath &filePathname)
{
    File *file = File::Create(filePathname, File::READ | File::OPEN);
    if(!file)
    {
        Logger::Error("[TextureDescriptor::Load] Can't open file: %s", filePathname.GetAbsolutePathname().c_str());
        return false;
    }

    pathname = filePathname;

    int32 signature;
    file->Read(&signature, sizeof(signature));

    int8 version = 0;
    file->Read(&version, sizeof(version));
    if(version != CURRENT_VERSION)
    {
        ConvertToCurrentVersion(version, signature, file);
        SafeRelease(file);
        return true;
    }

    isCompressedFile = (COMPRESSED_FILE == signature);
    if(isCompressedFile)
    {
        LoadCompressed(file);
    }
    else if(NOTCOMPRESSED_FILE == signature)
    {
        LoadNotCompressed(file);
    }
    else
    {
        Logger::Error("[TextureDescriptor::Load] Wrong descriptor file: %s", filePathname.GetAbsolutePathname().c_str());
        SafeRelease(file);
        return false;
    }

    SafeRelease(file);

    return true;
}
bool AutotestingSystemLua::RunScriptFromFile(const FilePath &luaFilePath)
{
    Logger::Debug("AutotestingSystemLua::RunScriptFromFile %s", luaFilePath.GetAbsolutePathname().c_str());
    if(LoadScriptFromFile(luaFilePath))
    {
		lua_pushstring(luaState, luaFilePath.GetBasename().c_str());
        return RunScript();
    }
    return false;
}
Esempio n. 12
0
// Get test parameters from id.tx
void AutotestingSystem::FetchParametersFromIdTxt()
{
	FilePath file = "~res:/Autotesting/id.yaml";
	Logger::Debug("AutotestingSystem::FetchParametersFromIdTxt %s", file.GetAbsolutePathname().c_str());
	KeyedArchive *option = new KeyedArchive();
	bool res = option->LoadFromYamlFile(file);
	if (!res)
	{
		ForceQuit("Couldn't open file " + file.GetAbsolutePathname());
	}

	buildId = option->GetString("buildId");
	buildDate = option->GetString("date");
	branch = option->GetString("branch");
	framework = option->GetString("framework");
	branchRev = option->GetString("branchRev");
	frameworkRev = option->GetString("frameworkRev");

	SafeRelease(option);
}
Esempio n. 13
0
FilePath SceneSaver::CreateProjectPathFromPath(const FilePath & pathname)
{
	String fullPath = pathname.GetAbsolutePathname();
	String::size_type pos = fullPath.find("/Data");
	if(pos != String::npos)
	{
        return fullPath.substr(0, pos+1);
	}
    
    return FilePath();
}
CubeMapTextureBrowser::CubeMapTextureBrowser(SceneEditor2* currentScene, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::CubeMapTextureBrowser),
	cubeListItemDelegate(QSize(FACE_IMAGE_SIZE, FACE_IMAGE_SIZE))
{
	scene = currentScene;
	
    ui->setupUi(this);
	ui->loadingWidget->setVisible(false);
	ui->listTextures->setItemDelegate(&cubeListItemDelegate);
	
	ConnectSignals();
	
	FilePath projectPath = CubemapUtils::GetDialogSavedPath("Internal/CubemapLastProjDir",
															ProjectManager::Instance()->CurProjectDataSourcePath().GetAbsolutePathname());
		
	ui->textRootPath->setText(projectPath.GetAbsolutePathname().c_str());
	ReloadTextures(projectPath.GetAbsolutePathname());
	
	UpdateCheckedState();
}
Esempio n. 15
0
bool SceneValidator::ValidateTexturePathname(const FilePath &pathForValidation, Set<String> &errorsLog)
{
	DVASSERT_MSG(!pathForChecking.IsEmpty(), "Need to set pathname for DataSource folder");

	bool pathIsCorrect = IsPathCorrectForProject(pathForValidation);
	if(pathIsCorrect)
	{
		String textureExtension = pathForValidation.GetExtension();
		String::size_type extPosition = TextureDescriptor::GetSupportedTextureExtensions().find(textureExtension);
		if(String::npos == extPosition)
		{
			errorsLog.insert(Format("Path %s has incorrect extension", pathForValidation.GetAbsolutePathname().c_str()));
			return false;
		}
	}
	else
	{
		errorsLog.insert(Format("Path %s is incorrect for project %s", pathForValidation.GetAbsolutePathname().c_str(), pathForChecking.GetAbsolutePathname().c_str()));
	}

	return pathIsCorrect;
}
CubeMapTextureBrowser::CubeMapTextureBrowser(SceneEditor2* currentScene, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::CubeMapTextureBrowser),
	cubeListItemDelegate(QSize(FACE_IMAGE_SIZE, FACE_IMAGE_SIZE))
{
	scene = currentScene;
	
    ui->setupUi(this);
	ui->loadingWidget->setVisible(false);
	ui->listTextures->setItemDelegate(&cubeListItemDelegate);
	
	ConnectSignals();
	
	FilePath projectPath = CubemapUtils::GetDialogSavedPath(ResourceEditor::CUBEMAP_LAST_PROJECT_DIR_KEY,
															EditorSettings::Instance()->GetDataSourcePath().GetAbsolutePathname(),
															EditorSettings::Instance()->GetDataSourcePath().GetAbsolutePathname());
		
	ui->textRootPath->setText(projectPath.GetAbsolutePathname().c_str());
	ReloadTextures(projectPath.GetAbsolutePathname());
	
	UpdateCheckedState();
}
Esempio n. 17
0
Vector<Image *> ImageLoader::CreateFromFile(const FilePath & pathname)
{
    File *file = File::Create(pathname, File::OPEN | File::READ);
    
    if(!file)
    {
        Logger::Error("[ImageLoader::CreateFromFile] Cannot open file %s", pathname.GetAbsolutePathname().c_str());
        return Vector<Image *>();
    }
    
    Vector<Image *>imageSet = CreateFromFile(file);
    SafeRelease(file);
	return imageSet;
};
Esempio n. 18
0
void SceneSaver::SaveScene(Scene *scene, const FilePath &fileName, Set<String> &errorLog)
{
    DVASSERT(0 == texturesForSave.size())
    
    String relativeFilename = fileName.GetRelativePathname(sceneUtils.dataSourceFolder);
    sceneUtils.workingFolder = fileName.GetDirectory().GetRelativePathname(sceneUtils.dataSourceFolder);
    
    FileSystem::Instance()->CreateDirectory(sceneUtils.dataFolder + sceneUtils.workingFolder, true);

    scene->Update(0.1f);

    FilePath oldPath = SceneValidator::Instance()->SetPathForChecking(sceneUtils.dataSourceFolder);
    SceneValidator::Instance()->ValidateScene(scene, errorLog);

    texturesForSave.clear();
    SceneDataManager::EnumerateTextures(scene, texturesForSave);

    CopyTextures(scene, errorLog);
	ReleaseTextures();

	Landscape *landscape = EditorScene::GetLandscape(scene);
    if (landscape)
    {
        sceneUtils.CopyFile(landscape->GetHeightmapPathname(), errorLog);
    }

	CopyReferencedObject(scene, errorLog);
	CopyEffects(scene, errorLog);
	CopyCustomColorTexture(scene, fileName.GetDirectory(), errorLog);

    //save scene to new place
    FilePath tempSceneName = sceneUtils.dataSourceFolder + relativeFilename;
    tempSceneName.ReplaceExtension(".saved.sc2");
    
    SceneFileV2 * outFile = new SceneFileV2();
    outFile->EnableSaveForGame(true);
    outFile->EnableDebugLog(false);
    
    outFile->SaveScene(tempSceneName, scene);
    SafeRelease(outFile);

    bool moved = FileSystem::Instance()->MoveFile(tempSceneName, sceneUtils.dataFolder + relativeFilename, true);
	if(!moved)
	{
		errorLog.insert(Format("Can't move file %s", fileName.GetAbsolutePathname().c_str()));
	}
    
    SceneValidator::Instance()->SetPathForChecking(oldPath);
}
Esempio n. 19
0
bool PngImageExt::Read(const FilePath & filename)
{
    SafeRelease(internalData);
    
    internalData = new Image();
    
    int32 retCode = LibPngWrapper::ReadPngFile(filename, internalData, FORMAT_RGBA8888);
    if(1 != retCode)
    {
        Logger::Error("[PngImageExt::Read] failed to open png file: %s", filename.GetAbsolutePathname().c_str());
        SafeRelease(internalData);
    }
    
	return (internalData != NULL);
}
Esempio n. 20
0
void SceneUtils::PrepareFolderForCopyFile(const String &filename, Set<String> &errorLog)
{
    FilePath newFolderPath = (dataFolder + filename).GetDirectory();
    
    if(!FileSystem::Instance()->IsDirectory(newFolderPath))
    {
        FileSystem::eCreateDirectoryResult retCreate = FileSystem::Instance()->CreateDirectory(newFolderPath, true);
        if(FileSystem::DIRECTORY_CANT_CREATE == retCreate)
        {
            errorLog.insert(String(Format("Can't create folder %s", newFolderPath.GetAbsolutePathname().c_str())));
        }
    }
    
    FileSystem::Instance()->DeleteFile(dataFolder + filename);
}
Esempio n. 21
0
void VisibilityToolPanel::SaveTexture()
{
	FilePath currentPath = FileSystem::Instance()->GetUserDocumentsPath();
	QString filePath = QtFileDialog::getSaveFileName(NULL,
													QString(ResourceEditor::VISIBILITY_TOOL_SAVE_CAPTION.c_str()),
													QString(currentPath.GetAbsolutePathname().c_str()),
													QString(ResourceEditor::VISIBILITY_TOOL_FILE_FILTER.c_str()));

	FilePath selectedPathname = PathnameToDAVAStyle(filePath);

	if(!selectedPathname.IsEmpty())
	{
		GetActiveScene()->visibilityToolSystem->SaveTexture(selectedPathname);
	}
}
Esempio n. 22
0
bool SceneValidator::ValidateHeightmapPathname(const FilePath &pathForValidation, Set<String> &errorsLog)
{
	DVASSERT_MSG(!pathForChecking.IsEmpty(), "Need to set pathname for DataSource folder");

	bool pathIsCorrect = IsPathCorrectForProject(pathForValidation);
	if(pathIsCorrect)
	{
		String::size_type posPng = pathForValidation.GetAbsolutePathname().find(".png");
		String::size_type posHeightmap = pathForValidation.GetAbsolutePathname().find(Heightmap::FileExtension());
        
        pathIsCorrect = ((String::npos != posPng) || (String::npos != posHeightmap));
        if(!pathIsCorrect)
        {
            errorsLog.insert(Format("Heightmap path %s is wrong", pathForValidation.GetAbsolutePathname().c_str()));
            return false;
        }
        
        Heightmap *heightmap = new Heightmap();
        if(String::npos != posPng)
        {
            Image *image = CreateTopLevelImage(pathForValidation);
            pathIsCorrect = heightmap->BuildFromImage(image);
            SafeRelease(image);
        }
        else
        {
            pathIsCorrect = heightmap->Load(pathForValidation);
        }

        
        if(!pathIsCorrect)
        {
            SafeRelease(heightmap);
            errorsLog.insert(Format("Can't load Heightmap from path %s", pathForValidation.GetAbsolutePathname().c_str()));
            return false;
        }
        
        
        pathIsCorrect = IsPowerOf2(heightmap->Size() - 1);
        if(!pathIsCorrect)
        {
            errorsLog.insert(Format("Heightmap %s has wrong size", pathForValidation.GetAbsolutePathname().c_str()));
        }
        
        SafeRelease(heightmap);
		return pathIsCorrect;
	}
	else
	{
		errorsLog.insert(Format("Path %s is incorrect for project %s", pathForValidation.GetAbsolutePathname().c_str(), pathForChecking.GetAbsolutePathname().c_str()));
	}

	return pathIsCorrect;
}
Esempio n. 23
0
void CubemapEditorDialog::LoadCubemap(const QString& path)
{
	FilePath filePath(path.toStdString());
	TextureDescriptor* texDescriptor = TextureDescriptor::CreateFromFile(filePath);
	
	if(NULL != texDescriptor &&
	   texDescriptor->IsCubeMap())
	{
		String fileNameWithoutExtension = filePath.GetFilename();
		String extension = filePath.GetExtension();
		fileNameWithoutExtension.replace(fileNameWithoutExtension.find(extension), extension.size(), "");

		bool cubemapLoadResult = true;
		for(int i = 0; i < CubemapUtils::GetMaxFaces(); ++i)
		{
			if(texDescriptor->dataSettings.faceDescription & (1 << CubemapUtils::MapUIToFrameworkFace(i)))
			{
				FilePath faceFilePath = filePath;
				faceFilePath.ReplaceFilename(fileNameWithoutExtension +
											 CubemapUtils::GetFaceNameSuffix(CubemapUtils::MapUIToFrameworkFace(i)) + "." +
											 CubemapUtils::GetDefaultFaceExtension());

				bool faceLoadResult = LoadImageTo(faceFilePath.GetAbsolutePathname(), i, true);
				cubemapLoadResult = cubemapLoadResult && faceLoadResult;
			}
		}
		
		if(!cubemapLoadResult)
		{
			ShowErrorDialog("This cubemap texture seems to be damaged.\nPlease repair it by setting image(s) to empty face(s) and save to disk.");
		}
	}
	else
	{
		if(NULL == texDescriptor)
		{
			ShowErrorDialog("Failed to load cubemap texture " + path.toStdString());
		}
		else
		{
			ShowErrorDialog("Failed to load cubemap texture " + path.toStdString() + ". Seems this is not a cubemap texture.");
		}
	}

	SafeDelete(texDescriptor);
}
void CubeMapTextureBrowser::ReloadTexturesFromUI(QString& path)
{
	if(path.at(path.size() - 1) != QChar('/') &&
	   path.at(path.size() - 1) != QChar('\\'))
	{
		path += "/";
	}
	
	ui->textRootPath->setText(path);
	
	FilePath projectPath = path.toStdString();
	EditorSettings::Instance()->GetSettings()->SetString(ResourceEditor::CUBEMAP_LAST_PROJECT_DIR_KEY,
														 projectPath.GetAbsolutePathname());
	EditorSettings::Instance()->Save();
	
	ReloadTextures(path.toStdString());
}
Esempio n. 25
0
bool SceneValidator::ValidatePathname(const FilePath &pathForValidation, const String &validatedObjectName)
{
    DVASSERT(!pathForChecking.IsEmpty());
    //Need to set path to DataSource/3d for path correction  
    //Use SetPathForChecking();
    
    String pathname = pathForValidation.GetAbsolutePathname();
    
    String::size_type fboFound = pathname.find(String("FBO"));
    String::size_type resFound = pathname.find(String("~res:"));
    if((String::npos != fboFound) || (String::npos != resFound))
    {
        return true;   
    }
    
    return IsPathCorrectForProject(pathForValidation);
}
Esempio n. 26
0
bool ImageSplitter::SplitImage(const FilePath &pathname, Set<String> &errorLog)
{
    Image *loadedImage = CreateTopLevelImage(pathname);
    if(!loadedImage)
    {
        errorLog.insert(String(Format("Can't load image %s", pathname.GetAbsolutePathname().c_str())));
        return false;
    }
    
    if(loadedImage->GetPixelFormat() != FORMAT_RGBA8888)
    {
        errorLog.insert(String(Format("Incorrect image format %s. Must be RGBA8888", Texture::GetPixelFormatString(loadedImage->GetPixelFormat()))));
        return false;
    }
    

    Image *red = Image::Create(loadedImage->width, loadedImage->height, FORMAT_A8);
    Image *green = Image::Create(loadedImage->width, loadedImage->height, FORMAT_A8);
    Image *blue = Image::Create(loadedImage->width, loadedImage->height, FORMAT_A8);
    Image *alpha = Image::Create(loadedImage->width, loadedImage->height, FORMAT_A8);

    int32 size = loadedImage->width * loadedImage->height;
    int32 pixelSize = Texture::GetPixelFormatSizeInBytes(FORMAT_RGBA8888);
    for(int32 i = 0; i < size; ++i)
    {
        int32 offset = i * pixelSize;
        red->data[i] = loadedImage->data[offset];
        green->data[i] = loadedImage->data[offset + 1];
        blue->data[i] = loadedImage->data[offset + 2];
        alpha->data[i] = loadedImage->data[offset + 3];
    }
    
    FilePath folder(pathname.GetDirectory());
    
    SaveImage(red, folder + "r.png");
    SaveImage(green, folder + "g.png");
    SaveImage(blue, folder + "b.png");
    SaveImage(alpha, folder + "a.png");


    ReleaseImages(red, green, blue, alpha);
    SafeRelease(loadedImage);
    return true;
}
Esempio n. 27
0
String FilePath::AbsoluteToRelative(const FilePath &directoryPathname, const FilePath &absolutePathname)
{
    if(absolutePathname.IsEmpty())
        return String();

    DVASSERT(directoryPathname.IsDirectoryPathname());

    Vector<String> folders;
	Vector<String> fileFolders;

	if(directoryPathname.GetType() == PATH_IN_RESOURCES &&	absolutePathname.GetType() == PATH_IN_RESOURCES)
	{
		Split(directoryPathname.absolutePathname, "/", folders);
		Split(absolutePathname.GetDirectory().absolutePathname, "/", fileFolders);
	}
	else
	{
		Split(directoryPathname.GetAbsolutePathname(), "/", folders);
		Split(absolutePathname.GetDirectory().GetAbsolutePathname(), "/", fileFolders);
	}
    
    Vector<String>::size_type equalCount = 0;
    for(; equalCount < folders.size() && equalCount < fileFolders.size(); ++equalCount)
    {
        if(folders[equalCount] != fileFolders[equalCount])
        {
            break;
        }
    }
    
    String retPath = "";
    for(Vector<String>::size_type i = equalCount; i < folders.size(); ++i)
    {
        retPath += "../";
    }
    
    for(Vector<String>::size_type i = equalCount; i < fileFolders.size(); ++i)
    {
        retPath += fileFolders[i] + "/";
    }
    
    return (retPath + absolutePathname.GetFilename());
}
void CommandSaveTextureVisibilityTool::Execute()
{
    FilePath currentPath = FileSystem::Instance()->GetUserDocumentsPath();
	QString filePath = QFileDialog::getSaveFileName(NULL,
													QString("Save texture"),
													QString(currentPath.GetAbsolutePathname().c_str()),
													QString("PNG image (*.png)"));

	FilePath selectedPathname = PathnameToDAVAStyle(filePath);

	if(!selectedPathname.IsEmpty())
	{
		SceneEditorScreenMain *screen = dynamic_cast<SceneEditorScreenMain *>(UIScreenManager::Instance()->GetScreen());
		if(screen)
		{
			screen->VisibilityToolSaveTexture(selectedPathname);
		}
	}
}
Esempio n. 29
0
bool YamlParser::Parse(const FilePath & pathName)
{
    File * yamlFile = File::Create(pathName, File::OPEN | File::READ);
    if (!yamlFile)
    {
        Logger::Error("[YamlParser::Parse] Can't create file: %s", pathName.GetAbsolutePathname().c_str());
        return false;
    }

    YamlDataHolder dataHolder;
    dataHolder.fileSize = yamlFile->GetSize();
    dataHolder.data = new uint8[dataHolder.fileSize];
    dataHolder.dataOffset = 0;
    yamlFile->Read(dataHolder.data, dataHolder.fileSize);
    SafeRelease(yamlFile);

    bool result = Parse(&dataHolder);
    SafeDeleteArray(dataHolder.data);
    return result;
}
EditorFontManager::DefaultFontPath EditorFontManager::GetDefaultFontPath()
{
	FilePath defFontPath;
	FilePath defFontSpritePath;

	if (defaultFont)
	{
		Font::eFontType fontType = defaultFont->GetFontType();		
        switch (fontType)
        {
            case Font::TYPE_FT:
            {
                FTFont *ftFont = dynamic_cast<FTFont*>(defaultFont);
				FilePath ftFontPath = ftFont->GetFontPath();
				// Don't save standart default font
				if (ftFontPath.GetAbsolutePathname().find(DEFAULT_FONT_NAME) == String::npos)
				{
					// Set font path
					defFontPath = ftFontPath;
				}
                break;
            }
            case Font::TYPE_GRAPHICAL:
            {
                GraphicsFont *gFont = dynamic_cast<GraphicsFont*>(defaultFont);
                // Try to get font sprite
                Sprite *fontSprite = gFont->GetFontSprite();
				// Save font only if sprite is available
                if (fontSprite)
                {
					// Set font definition and sprite relative path
					defFontPath = gFont->GetFontDefinitionName();
					defFontSpritePath = fontSprite->GetRelativePathname();
                }
				break;
            }
        }	
	}
	
	return DefaultFontPath(defFontPath, defFontSpritePath);
}