Пример #1
0
std::set<Package> PackagesManager::getLocalPackages() const
{
    std::set<Package> localPackages;

    //Each packages paths
    for(const auto& packagesPath : m_packagesPaths)
    {
        if(fs::exists(packagesPath))
        {
            //List all packages
            for(fs::directory_entry& packageEntry : fs::directory_iterator(packagesPath))
            {
                fs::path packagePath = packageEntry.path();
                if(fs::is_directory(packagePath))
                {
                    //This is a folder, so it is be a package.
                    std::string packageName = fs::relative(packagePath, packagesPath).string();
                    try
                    {
                        localPackages.insert(getLocalPackage(packageName)); //Note: getLocalPackage will throw if the package is being currently downloaded.
                    }
                    catch(...) {} //Ignore if the package is invalid or downloading !
                }
            }
        }
        else
        {
            std::cout << "[Packages/Warning] \"" << packagesPath.string() << "\" doesn't exists!" << std::endl;
        }
    }

    return localPackages;
}
Пример #2
0
void ImageValueEditor::sliceImage(const Image& image) {
	if (!image.Ok()) return;
	// mask
	GeneratedImage::Options options((int)style().width, (int)style().height, &viewer.getStylePackage(), &viewer.getLocalPackage());
	AlphaMask mask;
	style().mask.getNoCache(options,mask);
	// slice
	ImageSliceWindow s(wxGetTopLevelParent(&editor()), image, style().getSize(), mask);
	// clicked ok?
	if (s.ShowModal() == wxID_OK) {
		// store the image into the set
		LocalFileName new_image_file = getLocalPackage().newFileName(field().name,_("")); // a new unique name in the package
		Image img = s.getImage();
		img.SaveFile(getLocalPackage().nameOut(new_image_file), wxBITMAP_TYPE_PNG); // always use PNG images, see #69. Disk space is cheap anyway.
		addAction(value_action(valueP(), script_local_image_file(new_image_file)));
	}
}
Пример #3
0
bool ImageValueEditor::doCopy() {
	// load/generate image
	GeneratedImage::Options opts;
	opts.package         = &getStylePackage();
	opts.local_package   = &getLocalPackage();
	Image image = value().value->toImage()->generate(opts);
	if (!image.Ok()) return false;
	// set data
	if (!wxTheClipboard->Open()) return false;
	bool ok = wxTheClipboard->SetData(new wxBitmapDataObject(image));
	wxTheClipboard->Close();
	return ok;
}