本文整理汇总了C++中gd::Project::ExposeResources方法的典型用法代码示例。如果您正苦于以下问题:C++ Project::ExposeResources方法的具体用法?C++ Project::ExposeResources怎么用?C++ Project::ExposeResources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gd::Project
的用法示例。
在下文中一共展示了Project::ExposeResources方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddAllMissingImages
bool ProjectResourcesAdder::AddAllMissingImages(gd::Project & project)
{
gd::ImagesUsedInventorizer inventorizer;
project.ExposeResources(inventorizer);
std::set<gd::String> & allImages = inventorizer.GetAllUsedImages();
ResourcesManager & resourcesManager = project.GetResourcesManager();
for (std::set<gd::String>::const_iterator it = allImages.begin(); it != allImages.end(); ++it)
{
if (!resourcesManager.HasResource(*it))
{
std::cout << "Adding missing resource \""<<*it<<"\"to the project.";
resourcesManager.AddResource(*it, /*filename=*/*it); //Note that AddResource add a image resource by default.
}
}
return true;
}
示例2:
std::vector<std::string> ProjectResourcesAdder::GetAllUselessResources(gd::Project & project)
{
std::vector<std::string> unusedResources;
//Search for used images
gd::ImagesUsedInventorizer inventorizer;
project.ExposeResources(inventorizer);
std::set<std::string> & usedImages = inventorizer.GetAllUsedImages();
//Search all images resources not used
std::vector<std::string> resources = project.GetResourcesManager().GetAllResourcesList();
for (unsigned int i = 0;i < resources.size();i++)
{
if (project.GetResourcesManager().GetResource(resources[i]).GetKind() != "image")
continue;
if (usedImages.find(resources[i]) == usedImages.end())
unusedResources.push_back(resources[i]);
}
return unusedResources;
}
示例3: CopyAllResourcesTo
bool ProjectResourcesCopier::CopyAllResourcesTo(gd::Project & originalProject, AbstractFileSystem & fs,
gd::String destinationDirectory, bool updateOriginalProject, wxProgressDialog * optionalProgressDialog,
bool askAboutAbsoluteFilenames, bool preserveDirectoryStructure)
{
//Check if there are some resources with absolute filenames
gd::ResourcesAbsolutePathChecker absolutePathChecker(fs);
originalProject.ExposeResources(absolutePathChecker);
bool copyAlsoResourcesWithAbsolutePath = !askAboutAbsoluteFilenames;
std::cout << "Copying all ressources to " << destinationDirectory;
#if !defined(GD_NO_WX_GUI)
if ( !copyAlsoResourcesWithAbsolutePath )
{
copyAlsoResourcesWithAbsolutePath = absolutePathChecker.HasResourceWithAbsoluteFilenames() &&
wxMessageBox(_("Some resources are using absolute filenames.\nDo you want them to be copied in the new folder of the project? If you choose No, they won't be modified."),
_("Some resources are using absolute filenames."), wxYES_NO | wxICON_QUESTION) == wxYES;
}
#endif
//Get the resources to be copied
gd::ResourcesMergingHelper resourcesMergingHelper(fs);
resourcesMergingHelper.SetBaseDirectory(fs.DirNameFrom(originalProject.GetProjectFile()));
resourcesMergingHelper.PreserveDirectoriesStructure(preserveDirectoryStructure);
resourcesMergingHelper.PreserveAbsoluteFilenames(!copyAlsoResourcesWithAbsolutePath);
if ( updateOriginalProject )
{
originalProject.ExposeResources(resourcesMergingHelper);
}
else
{
std::shared_ptr<gd::Project> project(new gd::Project(originalProject));
project->ExposeResources(resourcesMergingHelper);
}
//Copy resources
map<gd::String, gd::String> & resourcesNewFilename = resourcesMergingHelper.GetAllResourcesOldAndNewFilename();
unsigned int i = 0;
for(map<gd::String, gd::String>::const_iterator it = resourcesNewFilename.begin(); it != resourcesNewFilename.end(); ++it)
{
if ( !it->first.empty() )
{
#if !defined(GD_NO_WX_GUI)
if ( optionalProgressDialog )
{
if ( !optionalProgressDialog->Update(i/static_cast<float>(resourcesNewFilename.size())*100.0f, _("Exporting ")+it->second) )
return false; //User choose to abort.
}
#endif
//Create the destination filename
gd::String destinationFile(destinationDirectory + "/" + it->second);
fs.MakeAbsolute(destinationFile, destinationDirectory);
if ( destinationFile != it->first )
{
//Be sure the directory exists
gd::String dir = fs.DirNameFrom(destinationFile);
if ( !fs.DirExists(dir) ) fs.MkDir(dir);
//We can now copy the file
if ( !fs.CopyFile(it->first, destinationFile) )
{
gd::LogWarning( _( "Unable to copy \"")+it->first+_("\" to \"")+destinationFile+_("\"."));
}
}
}
++i;
}
return true;
}