Exemplo n.º 1
0
void SceneUtils::AddFile(const DAVA::FilePath &sourcePath)
{
    String workingPathname = sourcePath.GetRelativePathname(dataSourceFolder);
    FilePath destinationPath = dataFolder + workingPathname;

    if(sourcePath != destinationPath)
    {
        DVASSERT(!sourcePath.IsEmpty());
        DVASSERT(!destinationPath.IsEmpty());

        filesForCopy[sourcePath] = destinationPath;
    }
}
Exemplo n.º 2
0
FilePath TextureDescriptor::GetDescriptorPathname(const FilePath &texturePathname)
{
    DVASSERT(!texturePathname.IsEmpty());

    if(0 == CompareCaseInsensitive(texturePathname.GetExtension(), GetDescriptorExtension()))
    {
        return texturePathname;
    }

    DVASSERT(GPUFamilyDescriptor::GetGPUForPathname(texturePathname) == GPU_UNKNOWN);

    return FilePath::CreateWithNewExtension(texturePathname, GetDescriptorExtension());
}
void LandscapeEditorDrawSystem::SaveTileMaskTexture()
{
	if (!baseLandscape)
	{
		return;
	}

	if (!GetLandscapeProxy()->IsTilemaskChanged())
	{
		return;
	}

	Texture* texture = baseLandscape->GetTexture(Landscape::TEXTURE_TILE_MASK);

	if (texture)
	{
		FilePath texturePathname = baseLandscape->GetTextureName(Landscape::TEXTURE_TILE_MASK);

		if (texturePathname.IsEmpty())
		{
			return;
		}

		texturePathname.ReplaceExtension(".png");

		eBlendMode srcBlend = RenderManager::Instance()->GetSrcBlend();
		eBlendMode dstBlend = RenderManager::Instance()->GetDestBlend();
		RenderManager::Instance()->SetBlendMode(BLEND_ONE, BLEND_ZERO);
		Image *image = texture->CreateImageFromMemory();
		RenderManager::Instance()->SetBlendMode(srcBlend, dstBlend);

		if(image)
		{
			ImageLoader::Save(image, texturePathname);
			SafeRelease(image);
		}

		FilePath descriptorPathname = TextureDescriptor::GetDescriptorPathname(texturePathname);
		TextureDescriptor *descriptor = TextureDescriptor::CreateFromFile(descriptorPathname);
		if(!descriptor)
		{
			descriptor = new TextureDescriptor();
			descriptor->pathname = descriptorPathname;
			descriptor->Save();
		}

		SafeRelease(descriptor);

		GetLandscapeProxy()->ResetTilemaskChanged();
	}
}
Exemplo n.º 4
0
LandscapeEditorDrawSystem::eErrorType CustomColorsSystem::EnableLandscapeEditing()
{
	if (enabled)
	{
		return LandscapeEditorDrawSystem::LANDSCAPE_EDITOR_SYSTEM_NO_ERRORS;
	}

	LandscapeEditorDrawSystem::eErrorType canBeEnabledError = IsCanBeEnabled();
	if ( canBeEnabledError!= LandscapeEditorDrawSystem::LANDSCAPE_EDITOR_SYSTEM_NO_ERRORS)
	{
		return canBeEnabledError;
	}

	LandscapeEditorDrawSystem::eErrorType enableCustomDrawError = drawSystem->EnableCustomDraw();
	if (enableCustomDrawError != LandscapeEditorDrawSystem::LANDSCAPE_EDITOR_SYSTEM_NO_ERRORS)
	{
		return enableCustomDrawError;
	}

    selectionSystem->SetLocked(true);
    modifSystem->SetLocked(true);
    landscapeSize = drawSystem->GetTextureSize(Landscape::TEXTURE_TILE_FULL);

	FilePath filePath = GetCurrentSaveFileName();
	if (!filePath.IsEmpty())
	{
        const bool isTextureLoaded = LoadTexture(filePath, false);
        drawSystem->GetCustomColorsProxy()->ResetLoadedState(isTextureLoaded);
	}
	else
	{
		drawSystem->GetCustomColorsProxy()->UpdateSpriteFromConfig();
	}

	drawSystem->EnableCursor(landscapeSize);
	drawSystem->SetCursorTexture(cursorTexture);
	drawSystem->SetCursorSize(cursorSize);
	
	Texture* customColorsTexture = drawSystem->GetCustomColorsProxy()->GetSprite()->GetTexture();
	drawSystem->GetLandscapeProxy()->SetCustomColorsTexture(customColorsTexture);
	drawSystem->GetLandscapeProxy()->SetCustomColorsTextureEnabled(true);
	
	if (!toolImageSprite)
	{
		CreateToolImage(512, "~res:/LandscapeEditor/Tools/customcolorsbrush/circle.tex");
	}
	
	enabled = true;
	return LandscapeEditorDrawSystem::LANDSCAPE_EDITOR_SYSTEM_NO_ERRORS;
}
Exemplo n.º 5
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);
	}
}
Exemplo n.º 6
0
    UIListCell::UIListCell(const Rect &rect, const String &cellIdentifier, const FilePath &aggregatorPath)
        :	UIButton(rect)
        ,	currentIndex(-1)
        ,	identifier(cellIdentifier)
        ,	cellStore(NULL)
    {
		if (!aggregatorPath.IsEmpty())
		{
			UIAggregatorControl *aggregator = new UIAggregatorControl();
			UIYamlLoader loader;
			loader.Load(aggregator, aggregatorPath);
			
			this->AddControl(aggregator);
		}
    }
Exemplo n.º 7
0
void SpritePackerHelper::UpdateParticleSpritesAsync()
{
	FilePath projectPath = EditorSettings::Instance()->GetProjectPath();
    if(projectPath.IsEmpty())
    {
        Logger::Warning("[ParticlesEditorSpritePackerHelper::UpdateParticleSprites] Project path not set.");
        return;
    }

	if(NULL == future)
	{
		future = new QFuture<void>;
		*future = QtConcurrent::run(this, &SpritePackerHelper::Pack);
		watcher.setFuture(*future);
	}
}
Exemplo n.º 8
0
void FilePath::AddTopResourcesFolder(const FilePath & folder)
{
	DVASSERT(!folder.IsEmpty());

	for(List<FilePath>::iterator it = resourceFolders.begin(); it != resourceFolders.end(); ++it)
	{
		if(folder == *it)
		{
			DVASSERT(false);
		}
	}

	FilePath resPath = folder;
	resPath.pathType = PATH_IN_RESOURCES;
	resourceFolders.push_front(resPath);
}
Exemplo n.º 9
0
void FilePath::SetBundleName(const FilePath & newBundlePath)
{
	FilePath virtualBundlePath = newBundlePath;

	if(!virtualBundlePath.IsEmpty())
	{
		virtualBundlePath.MakeDirectoryPathname();
	}

    virtualBundlePath.pathType = PATH_IN_RESOURCES;

    if(resourceFolders.size())
        resourceFolders.pop_front();
    
    resourceFolders.push_front(virtualBundlePath);
}
Exemplo n.º 10
0
void SceneValidator::ValidateMaterial(Material *material, Set<String> &errorsLog)
{
    for(int32 iTex = 0; iTex < Material::TEXTURE_COUNT; ++iTex)
    {
        Texture *texture = material->GetTexture((Material::eTextureLevel)iTex);
        if(texture)
        {
            ValidateTexture(texture, material->GetTextureName((Material::eTextureLevel)iTex), Format("Material: %s. TextureLevel %d.", material->GetName().c_str(), iTex), errorsLog);
            
            FilePath matTexName = material->GetTextureName((Material::eTextureLevel)iTex);
            if(!matTexName.IsEmpty() && !IsTextureDescriptorPath(matTexName))
            {
                material->SetTexture((Material::eTextureLevel)iTex, TextureDescriptor::GetDescriptorPathname(matTexName));
            }
        }
    }
}
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;
        }
	}
}
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);
		}
	}
}
Exemplo n.º 13
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 LandscapeEditorCustomColors::LoadTextureAction(const FilePath &pathToFile)
{
	if(pathToFile.IsEmpty())
		return;

	Vector<Image*> images = ImageLoader::CreateFromFile(pathToFile);
	if(images.empty())
		return;

	Image* image = images.front();
	if(image)
	{
		Texture* texture = Texture::CreateFromData(image->GetPixelFormat(),
												   image->GetData(),
												   image->GetWidth(),
												   image->GetHeight(),
												   false);

		SafeRelease(colorSprite);
		colorSprite = Sprite::CreateAsRenderTarget(texSurf->GetWidth(), texSurf->GetHeight(), FORMAT_RGBA8888);
		Sprite* sprite = Sprite::CreateFromTexture(texture, 0, 0, texture->GetWidth(), texture->GetHeight());

		StoreOriginalState();

		RenderManager::Instance()->SetRenderTarget(colorSprite);
		sprite->Draw();
		RenderManager::Instance()->RestoreRenderTarget();
		PerformLandscapeDraw();

		SafeRelease(sprite);
		SafeRelease(texture);
		for_each(images.begin(), images.end(), SafeRelease<Image>);

		StoreSaveFileName(pathToFile);

		CreateUndoPoint();
	}
}
Exemplo n.º 15
0
void SceneValidator::ValidateInstanceMaterialState(InstanceMaterialState *materialState, Set<String> &errorsLog)
{
    if(materialState->GetLightmap())
    {
        ValidateTexture(materialState->GetLightmap(), materialState->GetLightmapName(), "InstanceMaterialState, lightmap", errorsLog);
    }
    
    FilePath lightmapName = materialState->GetLightmapName();
    if(!IsTextureDescriptorPath(lightmapName))
    {
        Texture *lightmap = SafeRetain(materialState->GetLightmap());
        
        if(lightmapName.IsEmpty())
        {
            materialState->SetLightmap(lightmap, FilePath());
        }
        else
        {
            materialState->SetLightmap(lightmap, TextureDescriptor::GetDescriptorPathname(lightmapName));
        }
        
        SafeRelease(lightmap);
    }
}
Exemplo n.º 16
0
void MipMapReplacer::ReplaceMipMap(Texture * texture, int32 level)
{
    if(!texture)
        return;

    if(texture->width != texture->height)
        return;

    FilePath textureFilePath = GetDummyTextureFilePath(texture);
    if(!textureFilePath.IsEmpty())
    {
        Vector<Image*> mipImg = ImageLoader::CreateFromFile(textureFilePath);
        if(mipImg.size())
        {
            uint32 mipMapSize = texture->width / (1 << level);

            int32 imgCount = mipImg.size();
            for(int i = 0; i < imgCount; i++)
            {
                Image * dummyImg = mipImg[i];
                if(dummyImg->width == mipMapSize)
                {
                    RenderManager::Instance()->LockNonMain();
                    texture->TexImage(level, dummyImg->width, dummyImg->height, dummyImg->data, dummyImg->dataSize);
                    RenderManager::Instance()->UnlockNonMain();
                }

                SafeRelease(dummyImg);
            }
        }
    }
    else
    {
        return ReplaceMipMapFromMemory(texture, level);
    }
}