Esempio n. 1
0
void FileSystemActor::onLaunch()
{
	assert(!filePath.isNull());

	if (!_onLaunchHandler.empty())
		_onLaunchHandler(this);

	// override for widgets
	Widget * w = widgetManager->getActiveWidgetForFile(getFullPath());
	if (w && w->isWidgetOverrideActor(this))
	{
		w->launchWidgetOverride(this);
		return;
	}
	
	// Do a quick pass to determine what needs to be created or not
	bool isWatchingHighlighted = cam->isWatchedActorHighlighted(this);
	bool zoomIntoImage = isFileSystemType(Image) && !isWatchingHighlighted && texMgr->isTextureState(thumbnailID, TextureLoaded);
	bool launchImage = (isFileSystemType(Image) && isWatchingHighlighted) && !texMgr->isTextureState(thumbnailID, TextureLoaded);
	bool createTemporaryActor = !zoomIntoImage && !launchImage;
	bool createRandomAnimPath = createTemporaryActor;

	Actor * obj = NULL;
	if (createTemporaryActor)
	{
		obj = new Actor();
		Vec3 startPosition;

		// Set up the state of the Actor
		obj->pushActorType(Temporary);
		obj->setDims(getDims());
		obj->setGravity(false);
		obj->setCollisions(false);
		obj->setAlphaAnim(getAlpha(), 0.2f, 40);
		obj->setGlobalPose(getGlobalPose());
		obj->setObjectToMimic(this);
	}

	// Special case for launching a pileized actor
	Vec3 startPosition;
	if (isPileized())
	{
		startPosition = pileizedPile->getGlobalPosition();
	}else{
		startPosition = getGlobalPosition();
	}

	// create random animation path from the icon up to the camera eye
	if (createRandomAnimPath)
	{
		// Set an animation that moves the icon into the camera
 		CreateRandomAnimPath(obj, startPosition, cam->getEye(), 40);

		// Delete the object after the random animation is over.
		animManager->removeAnimation(obj);
		animManager->addAnimation(AnimationEntry(obj, (FinishedCallBack) DeleteActorAfterAnim));
	}

	// handle the launch override if there is one
	if (!getLaunchOverride().isEmpty())
	{
		fsManager->launchFileAsync(getLaunchOverride());
		return;
	}

	// Execute this Icon
	if (!isFileSystemType(Virtual))
	{
		// If this is a folder, then try and browse to it
		if (scnManager->isShellExtension && isFileSystemType(Folder))
		{			
			// try and send a custom message to the proxy window to move to the child
			incrementNumTimesLaunched();
			animManager->finishAnimation(this);
			SaveSceneToFile();
			winOS->ShellExtBrowseToChild(filePath);
			return;
		}
		// This is an image, so zoom to it if we are not already watching it
		else if (zoomIntoImage && isFileSystemType(Image) && texMgr->isTextureState(thumbnailID, TextureLoaded))
		{
			Key_EnableSlideShow();
			this->putToSleep();

			// record this zoom interaction
			statsManager->getStats().bt.interaction.actors.highlightedImage++;
			return;
		}

		// Execute it as normal
		// QString lnkTarget, lnkArgs, lnkWorkingDir;
		bool fileLaunched = false;
		/*
		if (isFileSystemType(Link))
		{
			fsManager->getShortcutTarget(getFullPath(), &lnkTarget, &lnkArgs, &lnkWorkingDir);
			fileLaunched = fsManager->launchFileAsync(lnkTarget, lnkArgs, lnkWorkingDir);
		}
		else
		*/
		fileLaunched = fsManager->launchFileAsync(filePath);

		if (fileLaunched)
		{
			// otherwise, just increment this file launch count and execute it
			// it is decided that images do not auto-grow (was a design decision)
			if (!launchImage)
			{
				incrementNumTimesLaunched();
			}

			// record this launch
			statsManager->getStats().bt.interaction.actors.launchedFile++;
		}
	}
	else
	{
		incrementNumTimesLaunched();
		fsManager->launchFile(filePath);
	}
}
Esempio n. 2
0
void SceneEditorScreenMain::OnFileSelected(UIFileSystemDialog *forDialog, const String &pathToFile)
{
    switch (fileSystemDialogOpMode) 
    {
        case DIALOG_OPERATION_MENU_OPEN:
        {
            EditorSettings::Instance()->AddLastOpenedFile(pathToFile);
            OpenFileAtScene(pathToFile);
//        //опен всегда загружает только уровень, но не отдельные части сцены
//            bodies[0]->bodyControl->OpenScene(pathToFile, true);
//            bodies[0]->bodyControl->SetFilePath(pathToFile);
            break;
        }
            
        case DIALOG_OPERATION_MENU_SAVE:
        {
            EditorSettings::Instance()->AddLastOpenedFile(pathToFile);
            SaveSceneToFile(pathToFile);

//            BodyItem *iBody = FindCurrentBody();
//            iBody->bodyControl->SetFilePath(pathToFile);
//			
//			iBody->bodyControl->PushDebugCamera();
//
//            Scene * scene = iBody->bodyControl->GetScene();
//
//            uint64 startTime = SystemTimer::Instance()->AbsoluteMS();
//            SceneFileV2 * file = new SceneFileV2();
//            file->EnableDebugLog(false);
//            file->SaveScene(pathToFile, scene);
//            SafeRelease(file);
//            uint64 endTime = SystemTimer::Instance()->AbsoluteMS();
//            Logger::Info("[SAVE SCENE TIME] %d ms", (endTime - startTime));
//
//			iBody->bodyControl->PopDebugCamera();			
            break;
        }
            
        case DIALOG_OPERATION_MENU_PROJECT:
        {
            KeyedArchive *keyedArchieve = EditorSettings::Instance()->GetSettings();
            String projectPath = pathToFile;
            if('/' != projectPath[projectPath.length() - 1])
            {
                projectPath += '/';
            }
            keyedArchieve->SetString("ProjectPath", projectPath);
            keyedArchieve->SetString("3dDataSourcePath", projectPath + "DataSource/3d/");
            EditorSettings::Instance()->Save();
            
            SceneValidator::Instance()->SetPathForChecking(EditorSettings::Instance()->GetProjetcPath());
            libraryControl->SetPath(EditorSettings::Instance()->GetDataSourcePath());
            break;
        }

        default:
            break;
    }

    fileSystemDialogOpMode = DIALOG_OPERATION_NONE;
}