Ejemplo n.º 1
0
void FileSystemActor::refreshThumbnail()
{
	if (winOS->IsFileInUse(getFullPath()))
		return;

	if (isThumbnailized())
	{
		Widget * w = widgetManager->getActiveWidgetForFile(getFullPath());
		if (w)
			loadThumbnailTexture(GLTextureObject(Load|Reload, _alternateThumbnailId, filePath, HiResImage, NormalPriority));
		else
			loadThumbnailTexture(GLTextureObject(Load|Compress, _alternateThumbnailId, getTargetPath(), getMinThumbnailDetail(), NormalPriority));
	}
	else
		loadThumbnailTexture(GLTextureObject(Load|Reload, textureID, getTargetPath(), FileIcon, NormalPriority));
}
Ejemplo n.º 2
0
void FileSystemActor::setTextureOverride( QString path )
{
	// set the override file path
	_overrideTexturePath = path;	
	if (!path.isEmpty())
	{
		loadThumbnailTexture(GLTextureObject(Load|Compress|Reload, _alternateThumbnailId, _overrideTexturePath, HiResImage, NormalPriority));

		if (!isThumbnailized())
			setTextureID(_alternateThumbnailId);
	}
}
bool ButtonWithImage::init(const std::string &normalImage, const std::string &selectedImage, const std::string &disabledImage, const std::string &thumbnailImage, cocos2d::ui::Widget::TextureResType texType){
    //super init
    
    if(!Button::init(normalImage,selectedImage,disabledImage,texType)){
        return false;
    }
    
    //load thumbnail texture (orignally from plist)
    loadThumbnailTexture(thumbnailImage, texType);
    //loadFocusTexture();
    
    return true;
    
}
Ejemplo n.º 4
0
// Sets whether this actor should be thumbnailed at all, and if loadThumbnail
// is true, queues the thumbnail operation on the texture loader.
// If no thumbnail exists, it will use the default filesystem icon.
void FileSystemActor::enableThumbnail(bool enableThumbnail/*=true*/, bool loadThumbnail/*=true*/)
{
	useThumbnail = enableThumbnail;

	// Load this Thumbnail because it wasn't loaded before
	if (useThumbnail)
	{
		GLTextureDetail detail = SampledImage;
		// NOTE: workaround for keeping training images in hires
		// also use hi-res if user wants to skip thumbs db usage
		bool isTrainingImage = getFullPath().startsWith(native(winOS->GetTrainingDirectory()), Qt::CaseInsensitive);
		if (!GLOBAL(settings).useThumbsDb || isTrainingImage)
			detail = HiResImage;

		if (loadThumbnail)
			loadThumbnailTexture(GLTextureObject(Load|Reload, _alternateThumbnailId, getTargetPath(), detail, NormalPriority, true, isFileSystemType(Image)));
	}
}
Ejemplo n.º 5
0
void FileSystemActor::setFilePath(QString fullPath, bool skipTextureResolution /*=false*/)
{	
	if (_isAnimatedTexture)
		_animatedTextureSource.setPath(fullPath);

	// Save the Path (or Virtual Folder Name)
	filePath = fullPath;
	winOS->GetShortPathName(fullPath, shortPath);
	if (skipTextureResolution)
		return;

	// resolve the texture to load for this file if there is one
	QString ext = fsManager->getFileExtension(fullPath);
	QString texId;
	GLTextureDetail detail = FileIcon;
	GLTextureLoadPriority priority = NormalPriority;

	bool isVista = winOS->IsWindowsVersionGreaterThanOrEqualTo(WindowsVista);
	bool overrideSystemTextures = GLOBAL(settings).useThemeIconOverrides;
	int virtualIconId = winOS->GetIconTypeFromFileName(fullPath);
	if (virtualIconId > -1)
	{
		// mark this is a virtual icon
		pushFileSystemType(Virtual);
		pushFileSystemType(Folder);

		// check if we are overloading any virtual icons (only My Computer for now)
		if (overrideSystemTextures && 
			(virtualIconId == MyComputer) &&
			texMgr->hasTexture("override.virtual.mycomputer"))
		{
			texId = QT_NT("override.virtual.mycomputer");
			detail = HiResImage;
		}
		else
		{
			// otherwise, we will just load the icon later
			texId = fullPath;

			// NOTE: we force load these icons here because we do not do so if the 
			// texture id is set below
			loadThumbnailTexture(GLTextureObject(Load, texId, texId, FileIcon, priority, false));
		}
	}
	else
	{
		// not a virtual icon, just a random icon then
		unsigned int fileAttributes = fsManager->getFileAttributes(fullPath);

		// delete this object if it doesn't exist (and it's not a photo frame or volume)
		if (!fileAttributes &&
			!(isFileSystemType(PhotoFrame) || isFileSystemType(LogicalVolume)))
		{
			animManager->addAnimation(AnimationEntry(this, (FinishedCallBack) DeleteActorAfterAnim));
			setAlpha(0.0f);
			return;
		}

		// make sure there's no lingering animations
		animManager->removeAnimation(this);
		setAlpha(1.0f);

		// XXX: check if we are using animated textures
		// _isAnimatedTexture = (fileExtension == ".gif");

		// check if this is a shortcut
		// NOTE: if it is a valid shortcut, the file attributes and extension
		//		 now refer to the target and not the shortcut itself
		if (fileAttributes && ext == ".lnk")
		{
			// resolve the shortcut target
			fsManager->getShortcutTarget(fullPath, &lnkFullPath);
			if (fsManager->isValidFileName(lnkFullPath))
			{
				pushFileSystemType(Link);
				popFileSystemType(DeadLink);

				fileAttributes = fsManager->getFileAttributes(lnkFullPath);
				ext = fsManager->getFileExtension(lnkFullPath);
			}
			else
			{
				pushFileSystemType(DeadLink);
			}
		}


		// check if it is a folder
		if (fileAttributes & Directory)
		{
			pushFileSystemType(Folder);

			// XXX: only override shortcuts, and not folders?
			/*
			if (!overrideSystemTextures || !enableFileTypeIconsForShortcuts)
			{
				texId = winOS->GetSystemIconInfo(getFullPath());
			}
			else 
			*/
			if (overrideSystemTextures)
			{
				texId = QT_NT("override.ext.folder");
				detail = HiResImage;
			}		
		}
		else
		{
			// normal file
			pushFileSystemType(File);
			hasExtension(true); //only files have extension, so the nameable extension hide only applies here

			// resolve some information about the file
			if (ext.size() > 0)
			{
				if (ext == ".exe")
					pushFileSystemType(Executable);
				else
				{
					// XXX: check if it's a document
					// pushFileSystemType(Document);

					if (overrideSystemTextures)
					{
						QString potentialOverrideTex = QString(QT_NT("override.ext")) + ext;
						if (texMgr->hasTexture(potentialOverrideTex))
						{
							texId = potentialOverrideTex;
							detail = HiResImage;
						}
					}
				}

				// load the thumbnail if this is an image
				// NOTE: we append the period because if the extension is empty
				// the search is always true
				if (GLOBAL(supportedExtensions).contains(ext + "."))
				{
					if (!isThumbnailized())
						enableThumbnail(true, !winOS->IsFileInUse(fullPath));
					pushFileSystemType(Image);
					pushFileSystemType(Thumbnail);
					hideText(true);
				}
			}
		}
	}

	// at this point, resolve the file icon texture id if there was no override
	if (texId.isEmpty())
	{
		texId = winOS->GetSystemIconInfo(fullPath);

		// mark the texture for loading
		loadThumbnailTexture(GLTextureObject(Load, texId, texId, detail, priority,false));
	}
	setTextureID(texId);

	// we also want to try and load thumbnails for normal files if they exist
	// (as long as it's not a widget file)
	Widget * w = widgetManager->getActiveWidgetForFile(fullPath);
	if (!isThumbnailized() && (detail == FileIcon) && !w)
	{
		FileSystemActorType typesToIgnore = FileSystemActorType(Executable | Virtual);
		// on vista, just queue the thumbnail for loading
		if (isVista && !isFileSystemType(typesToIgnore))
		{
			QString ext = fsManager->getFileExtension(getTargetPath());
			loadThumbnailTexture(GLTextureObject(Load|Reload, _alternateThumbnailId, getTargetPath(), SampledImage, IdlePriority));
		}
		// on windows xp, check if the thumbs db has a record first
		else if (winOS->IsWindowsVersion(WindowsXP))
		{
			if (texMgr->hasWinThumbnail(getTargetPath()))
			{
				loadThumbnailTexture(GLTextureObject(Load|Reload, _alternateThumbnailId, getTargetPath(), SampledImage, IdlePriority));
			}
		}
	}

	// XXX: (disabled) set the initial dimensions and weight of this file based on it's size
	// setDimsFromFileSize(this);

	// set the text
	if(!isFileSystemType(PhotoFrame)) {
		if (w && w->isWidgetOverrideActor(this))
		{
			setText(w->getWidgetOverrideLabel(this));
			Vec3 actorDims = getDims();
			float aspect = (actorDims.x / actorDims.y);
			Vec3 dims(GLOBAL(settings).xDist, GLOBAL(settings).zDist / aspect, GLOBAL(settings).yDist);
			float scale = w->getWidgetOverrideScale(this);
			if (scale > 0.0f)
			{
				dims *= scale;
				setSizeAnim(getDims(), dims, 25);
			}
		}
		else
			setText(getFileName(isFileSystemType(Link) || isFileSystemType(DeadLink)));
	}
	setRespectIconExtensionVisibility(!isFileSystemType(Folder));


	// New name was set, invalidate text
	textManager->invalidate();
	rndrManager->invalidateRenderer();
}