Ejemplo n.º 1
0
void Replay::StartRecord(const FilePath & dirName)
{
    DVASSERT(!isRecord);
    DVASSERT(!isPlayback);
    isRecord = true;
    pauseReplay = false;

    FileSystem::Instance()->DeleteDirectoryFiles(dirName, false);
    FileSystem::Instance()->CreateDirectory(dirName);

    FileList * list = new FileList("~doc:/");
    int32 listSize = list->GetCount();
    for(int32 i = 0; i < listSize; ++i)
    {
        String fileName = list->GetFilename(i);
        if(!list->IsNavigationDirectory(i) && !list->IsDirectory(i) && fileName != "LastReplay.rep")
        {
            FileSystem::Instance()->CopyFile(list->GetPathname(i), dirName + fileName);
        }
    }

    list->Release();

    FilePath filePath = dirName + "LastReplay.rep";
    file = File::Create(filePath, File::CREATE | File::WRITE);

    Random::Instance()->Seed();
}
Ejemplo n.º 2
0
void Replay::StartPlayback(const FilePath & dirName)
{
    DVASSERT(!isRecord);
    DVASSERT(!isPlayback);
    pauseReplay = false;
    isPlayback = true;

    FileSystem::Instance()->DeleteDirectoryFiles("~doc:/", false);
    FileList * list = new FileList(dirName);
    int32 listSize = list->GetCount();
    for(int32 i = 0; i < listSize; ++i)
    {
        String fileName = list->GetFilename(i);
        if(!list->IsNavigationDirectory(i) && !list->IsDirectory(i))
        {
            FilePath existingFile = dirName + fileName;
            FilePath newFile("~doc:/" + fileName);

            FileSystem::Instance()->CopyFile(existingFile, newFile);
        }
    }

    list->Release();


    skipType = false;
    file = File::Create("~doc:/LastReplay.rep", File::OPEN | File::READ);
}
Ejemplo n.º 3
0
void UIFileTree::RecursiveTreeWalk(const String & path, UITreeItemInfo * current)
{
	FileList * fileList = new FileList(path);
	
	// Find flags and setup them
	for (int fi = 0; fi < fileList->GetCount(); ++fi)
	{
		bool addElement = true;
		if (!fileList->IsDirectory(fi))
		{
			size_t extsSize = extensions.size();
			if (extsSize > 0)
			{
				addElement = false;
				String ext = FileSystem::GetExtension(fileList->GetFilename(fi));
				for (size_t ei = 0; ei < extsSize; ++ei)
					if (extensions[ei] == ext)
					{
						addElement = true;
						break;
					}
			}
		}
		if (!isFolderNavigationEnabled)
			if (fileList->IsNavigationDirectory(fi))
				addElement = false;

		if (fileList->GetFilename(fi) == ".")
			addElement = false;

		if (addElement)
		{
			UITreeItemInfo *child = new UITreeItemInfo(this);
			child->Set(current->GetLevel() + 1, fileList->GetFilename(fi), fileList->GetPathname(fi), fileList->IsDirectory(fi));
			current->AddChild(child);

//			if (fileList->IsDirectory(fi) )
//			{
//				if (!fileList->IsNavigationDirectory(fi))
//				{
//					RecursiveTreeWalk(path + String("/") + fileList->GetFilename(fi), child);
//				}
//			}
		}
	}
	SafeRelease(fileList);
}
Ejemplo n.º 4
0
FilePath HeightmapModificationCommand::SaveHeightmap(Heightmap* heightmap)
{
    FilePath documentsPath("~doc:/");

    FilePath folderPathname("~doc:/History/");
    FileSystem::Instance()->CreateDirectory(folderPathname);

    folderPathname = folderPathname + "Heightmap/";
    FileSystem::Instance()->CreateDirectory(folderPathname);

    FileList* fileList = new FileList(folderPathname);

    bool validFileName = false;
    String filename;
    String time = TimeString();
    uint32 num = 0;
    do
    {
        filename = time;
        if (num)
        {
            filename += Format(" (%d)", num);
        }
        filename += Heightmap::FileExtension();

        int32 i = 0;
        for (; i < fileList->GetCount(); ++i)
        {
            if (fileList->GetFilename(i) == filename)
            {
                ++num;
                break;
            }
        }
        if (i >= fileList->GetCount())
            validFileName = true;
    } while (!validFileName);

    FilePath saveFileName = folderPathname + filename;
    heightmap->Save(saveFileName);

    SafeRelease(fileList);

    return saveFileName;
}
void ResourcePackerScreen::RecursiveTreeWalk(const String & inputPath, const String & outputPath)
{
	uint64 packTime = SystemTimer::Instance()->AbsoluteMS();

	FileList * fileList = new FileList(inputPath);

	/* New $process folder structure */
	
	String dataSourceRelativePath = inputPath;
	StringReplace(dataSourceRelativePath, excludeDirectory, std::string(""));
	// printf("%s\n", dataSourceRelativePath.c_str());

	String processDirectoryPath = excludeDirectory + String("/") + GetProcessFolderName() + String("/") + dataSourceRelativePath;
	if (FileSystem::Instance()->CreateDirectory(processDirectoryPath, true) == FileSystem::DIRECTORY_CANT_CREATE)
	{
		//Logger::Error("Can't create directory: %s", processDirectoryPath.c_str());
	}

	if(clearProcessDirectory)
	{
		FileSystem::Instance()->DeleteDirectoryFiles(processDirectoryPath, false);
	}

	//String outputPath = outputPath;
	if (FileSystem::Instance()->CreateDirectory(outputPath) == FileSystem::DIRECTORY_CANT_CREATE)
	{
		//Logger::Error("Can't create directory: %s", outputPath.c_str());
	}
	
	CommandLineParser::Instance()->ClearFlags();
	std::list<DefinitionFile *> definitionFileList;

	// Find flags and setup them
	for (int fi = 0; fi < fileList->GetCount(); ++fi)
	{
		if (!fileList->IsDirectory(fi))
		{
			if (fileList->GetFilename(fi) == "flags.txt")
			{
				String fullname = inputPath + String("/") + fileList->GetFilename(fi);
				ProcessFlags(fullname);
				break;
			}
		}
	}
	
	bool modified = isGfxModified;
	// Process all psd / png files

	if (IsMD5ChangedDir(processDirectoryPath, inputPath, "dir.md5", false))
	{
		modified = true;
		//if (Core::Instance()->IsConsoleMode())
		//	printf("[Directory changed - rebuild: %s]\n", inputGfxDirectory.c_str());
	}

	if (modified)
	{
		FileSystem::Instance()->DeleteDirectoryFiles(outputPath, false);
		
		for (int fi = 0; fi < fileList->GetCount(); ++fi)
		{
			if (!fileList->IsDirectory(fi))
			{
				String fullname = inputPath + String("/") + fileList->GetFilename(fi);
				if (FileSystem::GetExtension(fullname) == ".psd")
				{
					DefinitionFile * defFile = ProcessPSD(processDirectoryPath, fullname, fileList->GetFilename(fi));
					definitionFileList.push_back(defFile);
				}
				else if(isLightmapsPacking && FileSystem::GetExtension(fullname) == ".png")
				{
					DefinitionFile * defFile = new DefinitionFile();
					defFile->LoadPNG(fullname, processDirectoryPath);
					definitionFileList.push_back(defFile);
				}
				else if (FileSystem::GetExtension(fullname) == ".pngdef")
				{
					DefinitionFile * defFile = new DefinitionFile();
					if (defFile->LoadPNGDef(fullname, processDirectoryPath))
					{
						definitionFileList.push_back(defFile);
					}
					else 
					{
						SafeDelete(defFile);
					}
				}
			}
		}

		// 
		if (definitionFileList.size() > 0 && modified)
		{
			TexturePacker packer;
			String outputPathWithSlash = outputPath + String("/");
				
			if(isLightmapsPacking)
			{
				packer.UseOnlySquareTextures();
				packer.SetMaxTextureSize(2048);
			}

			if (CommandLineParser::Instance()->IsFlagSet("--split"))
			{
				packer.PackToTexturesSeparate(excludeDirectory.c_str(), outputPathWithSlash.c_str(), definitionFileList);
			}
			else
			{
				packer.PackToTextures(excludeDirectory.c_str(), outputPathWithSlash.c_str(), definitionFileList);
			}
		}
	}	

	packTime = SystemTimer::Instance()->AbsoluteMS() - packTime;

	if (Core::Instance()->IsConsoleMode())
	{
		if (CommandLineParser::Instance()->IsExtendedOutput())
		{
			printf("[%d files packed with flags: %s]\n", (int)definitionFileList.size(), currentFlags.c_str());
		}
	
		String result = "[unchanged]";
		if (modified)
			result = "[REPACKED]";

		printf("[%s - %.2lf secs] - %s\n", inputPath.c_str(), (float64)packTime / 1000.0f, result.c_str());
	}

	
	for (std::list<DefinitionFile*>::iterator it = definitionFileList.begin(); it != definitionFileList.end(); ++it)
	{
		DefinitionFile * file = *it;
		SafeDelete(file);
	}
	definitionFileList.clear();
	
	for (int fi = 0; fi < fileList->GetCount(); ++fi)
	{
		if (fileList->IsDirectory(fi))
		{
			String filename = fileList->GetFilename(fi);
			if ((filename != ".") && (filename != "..") && (filename != "$process") && (filename != ".svn"))
			{
				if ((filename.size() > 0) && (filename[0] != '.'))
					RecursiveTreeWalk(inputPath + String("/") + fileList->GetFilename(fi),
									  outputPath + String("/") + fileList->GetFilename(fi));
			}
		}
	}
	
	SafeRelease(fileList);
}