void SceneHelper::CollectTextures(const DAVA::NMaterial *material, DAVA::TexturesMap &textures, TexturesEnumerateMode mode) { DAVA::uint32 texCount = material->GetTextureCount(); for(DAVA::uint32 t = 0; t < texCount; ++t) { DAVA::FilePath texturePath = material->GetTexturePath(material->GetTextureName(t)); if(!texturePath.IsEmpty() && SceneValidator::Instance()->IsPathCorrectForProject(texturePath)&&!NMaterial::IsRuntimeTexture(material->GetTextureName(t))) { if(mode == EXCLUDE_NULL) { DAVA::Texture *texture = material->GetTexture(t); if(texture && !texture->isRenderTarget) { const DAVA::FilePath & path = texture->texDescriptor->pathname; if(path != texturePath) { DAVA::Logger::Error("texture path: \"%s\"\n material (%s) path: \"%s\"\n", path.GetAbsolutePathname().c_str(), material->GetMaterialName().c_str(), texturePath.GetAbsolutePathname().c_str()); DVASSERT(path == texturePath); } textures[FILEPATH_MAP_KEY(path)] = texture; } } else if(mode == INCLUDE_NULL) { textures[FILEPATH_MAP_KEY(texturePath)] = material->GetTexture(t); } else { DVASSERT(0 && "Unknown enumeration mode"); } } } }
void QtMainWindow::OpenLastProject() { if(CommandLineManager::Instance() && !CommandLineManager::Instance()->IsCommandLineModeEnabled()) { DAVA::FilePath projectPath = EditorSettings::Instance()->GetProjectPath(); if(projectPath.IsEmpty()) { projectPath = FilePath(ProjectManager::Instance()->ProjectOpenDialog().toStdString()); } if(projectPath.IsEmpty()) { QtLayer::Instance()->Quit(); } else { ProjectManager::Instance()->ProjectOpen(QString(projectPath.GetAbsolutePathname().c_str())); } } }
void SceneHelper::CollectDescriptors(DAVA::Set<DAVA::FilePath> &descriptors, const DAVA::FilePath &pathname) { if(pathname.GetType() == FilePath::PATH_EMPTY) return; DVASSERT(pathname.IsEqualToExtension(TextureDescriptor::GetDescriptorExtension())); if(!pathname.IsEmpty() && SceneValidator::Instance()->IsPathCorrectForProject(pathname)) { descriptors.insert(pathname); } }
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; } }
void CustomColorsSystem::SaveTexture(const DAVA::FilePath &filePath) { if(filePath.IsEmpty()) return; Sprite* customColorsSprite = drawSystem->GetCustomColorsProxy()->GetSprite(); Texture* customColorsTexture = customColorsSprite->GetTexture(); Image* image = customColorsTexture->CreateImageFromMemory(RenderState::RENDERSTATE_2D_BLEND); ImageSystem::Instance()->Save(filePath, image); SafeRelease(image); StoreSaveFileName(filePath); drawSystem->GetCustomColorsProxy()->ResetChanges(); }
bool CustomColorsSystem::LoadTexture( const DAVA::FilePath &filePath, bool createUndo /* = true */ ) { if(filePath.IsEmpty()) return false; Vector<Image*> images; ImageSystem::Instance()->Load(filePath, images); if(images.empty()) return false; Image* image = images.front(); if(image) { Texture* texture = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(), image->GetWidth(), image->GetHeight(), false); Sprite* sprite = Sprite::CreateFromTexture(texture, 0, 0, texture->GetWidth(), texture->GetHeight()); if (createUndo) { StoreOriginalState(); } RenderManager::Instance()->SetRenderTarget(drawSystem->GetCustomColorsProxy()->GetSprite()); Sprite::DrawState drawState; sprite->Draw(&drawState); RenderManager::Instance()->RestoreRenderTarget(); AddRectToAccumulator(Rect(Vector2(0.f, 0.f), Vector2(texture->GetWidth(), texture->GetHeight()))); SafeRelease(sprite); SafeRelease(texture); for_each(images.begin(), images.end(), SafeRelease<Image>); if (createUndo) { ((SceneEditor2*)GetScene())->BeginBatch("Load custom colors texture"); StoreSaveFileName(filePath); CreateUndoPoint(); ((SceneEditor2*)GetScene())->EndBatch(); } } return true; }