CommandInternalRemoveSceneNode::CommandInternalRemoveSceneNode(Entity* node, bool removeSimilar)
:	Command(Command::COMMAND_UNDO_REDO, CommandList::ID_COMMAND_INTERNAL_REMOVE_SCENE_NODE)
{
	commandName = "Remove Object";

	if (removeSimilar)
		commandName += "s";

	if (!node || !node->GetParent())
		return;

	if (removeSimilar)
	{
		String referenceToOwner;
		Entity* nodeParent = node->GetParent();

		KeyedArchive *customProperties = node->GetCustomProperties();
		if(customProperties && customProperties->IsKeyExists(ResourceEditor::EDITOR_REFERENCE_TO_OWNER))
		{
			referenceToOwner = customProperties->GetString(ResourceEditor::EDITOR_REFERENCE_TO_OWNER);
		}

		nodesForDeletion.reserve(nodeParent->GetChildrenCount());

		for (int32 i = 0; i < nodeParent->GetChildrenCount(); ++i)
		{
			Entity* child = nodeParent->GetChild(i);

			customProperties = child->GetCustomProperties();
			if (customProperties && customProperties->IsKeyExists(ResourceEditor::EDITOR_REFERENCE_TO_OWNER))
			{
				if (customProperties->GetString(ResourceEditor::EDITOR_REFERENCE_TO_OWNER) == referenceToOwner)
				{
					RemoveNodeRec removeNodeRec;
					removeNodeRec.node = SafeRetain(child);
					removeNodeRec.nodeParent = nodeParent;

					int32 i = GetNodeIndex(removeNodeRec);
					if (i >= 0 && i < nodeParent->GetChildrenCount() - 1)
						removeNodeRec.insertBeforeNode = nodeParent->GetChild(i + 1);

					nodesForDeletion.push_back(removeNodeRec);
				}
			}
		}
	}
	else
	{
		RemoveNodeRec removeNodeRec;
		removeNodeRec.node = SafeRetain(node);
		removeNodeRec.nodeParent = node->GetParent();

		int32 i = GetNodeIndex(removeNodeRec);
		if (i >= 0 && i < removeNodeRec.nodeParent->GetChildrenCount() - 1)
			removeNodeRec.insertBeforeNode = removeNodeRec.nodeParent->GetChild(i + 1);
		nodesForDeletion.push_back(removeNodeRec);
	}

	selectedNode = node;
}
Ejemplo n.º 2
0
// Read DB parameters from config file and set connection to it
void AutotestingSystem::SetUpConnectionToDB()
{
	KeyedArchive *option = new KeyedArchive();
	bool res = option->LoadFromYamlFile("~res:/Autotesting/dbConfig.yaml");
	if (!res)
	{
		ForceQuit("Couldn't open file ~res:/Autotesting/dbConfig.yaml");
	}

	String dbName = option->GetString("name");
	String dbAddress = option->GetString("hostname");
	String collection = option->GetString("collection");
	int32 dbPort = option->GetInt32("port");
	Logger::Debug("AutotestingSystem::SetUpConnectionToDB %s -> %s[%s:%d]", collection.c_str(), dbName.c_str(), dbAddress.c_str(), dbPort);

	if(! AutotestingDB::Instance()->ConnectToDB(collection, dbName, dbAddress, dbPort))
	{
		ForceQuit("Couldn't connect to Test DB");
	}
	else
	{
		isDB = true;
	}

	SafeRelease(option);
}
Ejemplo n.º 3
0
void EditorBodyControl::ReloadNode(Entity *node, const FilePath &pathToFile)
{//если в рут ноды сложить такие же рут ноды то на релоаде все накроет пиздой
    KeyedArchive *customProperties = node->GetCustomProperties();
    if (customProperties->GetString(ResourceEditor::EDITOR_REFERENCE_TO_OWNER, "") == pathToFile.GetAbsolutePathname())
    {
        Entity *newNode = scene->GetRootNode(pathToFile)->Clone();
        newNode->SetLocalTransform(node->GetLocalTransform());
        newNode->GetCustomProperties()->SetString(ResourceEditor::EDITOR_REFERENCE_TO_OWNER, pathToFile.GetAbsolutePathname());
        newNode->SetSolid(true);
        
        Entity *parent = node->GetParent();
        AddedNode addN;
        addN.nodeToAdd = newNode;
        addN.nodeToRemove = node;
        addN.parent = parent;

        nodesToAdd.push_back(addN);
        return;
    }
    
    int32 csz = node->GetChildrenCount();
    for (int ci = 0; ci < csz; ++ci)
    {
        Entity * child = node->GetChild(ci);
        ReloadNode(child, pathToFile);
    }
}
void SceneEditorScreenMain::SaveToFolder(const String & folder)
{
    BodyItem *iBody = FindCurrentBody();
	iBody->bodyControl->PushDebugCamera();
    
    SceneData *sceneData = SceneDataManager::Instance()->SceneGetActive();
    String filePath = sceneData->GetScenePathname();
    String dataSourcePath = EditorSettings::Instance()->GetDataSourcePath();
    String::size_type pos = filePath.find(dataSourcePath);
    if(String::npos != pos)
    {
        filePath = filePath.replace(pos, dataSourcePath.length(), "");
    }
    else
    {
        DVASSERT(0);
    }
    
	// Get project path
    KeyedArchive *keyedArchieve = EditorSettings::Instance()->GetSettings();
    String projectPath = keyedArchieve->GetString(String("ProjectPath"));
    
    if(!SceneSaver::Instance()) new SceneSaver();
    
    String inFolder = projectPath + String("DataSource/3d/");
    SceneSaver::Instance()->SetInFolder(inFolder);
    SceneSaver::Instance()->SetOutFolder(folder);
    
    Set<String> errorsLog;
    SceneSaver::Instance()->SaveScene(iBody->bodyControl->GetScene(), filePath, errorsLog);
    
	iBody->bodyControl->PopDebugCamera();
    
    ShowErrorDialog(errorsLog);
}
Ejemplo n.º 5
0
void SceneSaver::CopyCustomColorTexture(Scene *scene, const FilePath & sceneFolder, Set<String> &errorLog)
{
	Entity *land = FindLandscapeEntity(scene);
	if(!land) return;

	KeyedArchive* customProps = land->GetCustomProperties();
	if(!customProps) return;

	String pathname = customProps->GetString(ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP);
	if(pathname.empty()) return;

    FilePath projectPath = CreateProjectPathFromPath(sceneFolder);
    if(projectPath.IsEmpty())
    {
		Logger::Error("[SceneSaver::CopyCustomColorTexture] Can't copy custom colors texture (%s)", pathname.c_str());
        return;
    }

    FilePath texPathname = projectPath + pathname;
    sceneUtils.CopyFile(texPathname, errorLog);
    
    FilePath newTexPathname = sceneUtils.GetNewFilePath(texPathname);
    FilePath newProjectPathname = CreateProjectPathFromPath(sceneUtils.dataFolder);
    if(newProjectPathname.IsEmpty())
    {
		Logger::Error("[SceneSaver::CopyCustomColorTexture] Can't save custom colors texture (%s)", pathname.c_str());
        return;
    }
    
    //save new path to custom colors texture
    customProps->SetString(ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP, newTexPathname.GetRelativePathname(newProjectPathname));
}
Ejemplo n.º 6
0
void RenderObject::Load(KeyedArchive * archive, SceneFileV2 *sceneFile)
{
	if(NULL != archive)
	{
		if(archive->IsKeyExists("ro.type")) type = archive->GetUInt32("ro.type");
		if(archive->IsKeyExists("ro.flags")) flags = archive->GetUInt32("ro.flags");
		if(archive->IsKeyExists("ro.debugflags")) debugFlags = archive->GetUInt32("ro.debugflags");

		if(archive->IsKeyExists("ro.batchCount"))
		{
			KeyedArchive *batchesArch = archive->GetArchive("ro.batches");
			for(uint32 i = 0; i < archive->GetUInt32("ro.batchCount"); ++i)
			{
				KeyedArchive *batchArch = batchesArch->GetArchive(KeyedArchive::GenKeyFromIndex(i));
				if(NULL != batchArch)
				{
					RenderBatch *batch = (RenderBatch *) ObjectFactory::Instance()->New(batchArch->GetString("rb.classname"));
					if(NULL != batch)
					{
						batch->Load(batchArch, sceneFile);
						AddRenderBatch(batch);
						batch->Release();
					}
				}
			}
		}
	}

	AnimatedObject::Load(archive);
}
void SceneEditorScreenMain::ExportAs(ImageFileFormat format)
{
    String formatStr;
    switch (format) 
    {
        case DAVA::PNG_FILE:
            formatStr = String("png");
            break;
            
        case DAVA::PVR_FILE:
            formatStr = String("pvr");
            break;
            
        case DAVA::DXT_FILE:
            formatStr = String("dds");
            break;
            
        default:
			DVASSERT(0);
            return;
    }
    
    
    BodyItem *iBody = FindCurrentBody();
	iBody->bodyControl->PushDebugCamera();
    
    SceneData *sceneData = SceneDataManager::Instance()->SceneGetActive();
    String filePath = sceneData->GetScenePathname();
    String dataSourcePath = EditorSettings::Instance()->GetDataSourcePath();
    String::size_type pos = filePath.find(dataSourcePath);
    if(String::npos != pos)
    {
        filePath = filePath.replace(pos, dataSourcePath.length(), "");
    }
    else 
    {
        DVASSERT(0);
    }
    
    // Get project path
    KeyedArchive *keyedArchieve = EditorSettings::Instance()->GetSettings();
    String projectPath = keyedArchieve->GetString(String("ProjectPath"));
    
    if(!SceneExporter::Instance()) new SceneExporter();
    
    String inFolder = projectPath + String("DataSource/3d/");
    SceneExporter::Instance()->SetInFolder(inFolder);
    SceneExporter::Instance()->SetOutFolder(projectPath + String("Data/3d/"));
    
    SceneExporter::Instance()->SetExportingFormat(formatStr);
    
    //TODO: how to be with removed nodes?
    Set<String> errorsLog;
    SceneExporter::Instance()->ExportScene(iBody->bodyControl->GetScene(), filePath, errorsLog);
    
	iBody->bodyControl->PopDebugCamera();
    
    ShowErrorDialog(errorsLog);
}
void QSceneGraphTreeView::ShowSceneGraphMenu(const QModelIndex &index, const QPoint &point)
{
    if(!index.isValid())
    {
        return;
    }
    
    QMenu menu;
    
	// For "custom" Particles Editor nodes the "generic" ones aren't needed".
    if (sceneGraphModel->GetParticlesEditorSceneModelHelper().NeedDisplaySceneEditorPopupMenuItems(index))
    {
		SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive();
		LandscapesController *landsacpesController = activeScene->GetLandscapesController();

		SceneEditorScreenMain *screen = static_cast<SceneEditorScreenMain *>(UIScreenManager::Instance()->GetScreen(SCREEN_MAIN_OLD));
		EditorBodyControl *c = screen->FindCurrentBody()->bodyControl;

		bool canChangeScene = !landsacpesController->EditorLandscapeIsActive() && !c->LandscapeEditorActive();
		if(!canChangeScene)
			return;



		AddActionToMenu(&menu, QString("Look at Object"), new CommandLockAtObject());
		AddActionToMenu(&menu, QString("Remove Object"), new CommandRemoveSceneNode());
	
		AddActionToMenu(&menu, QString("Debug Flags"), new CommandDebugFlags());
    
		Entity *node = static_cast<Entity *>(sceneGraphModel->ItemData(index));
		if (node)
		{
            SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive();
            if(node->GetParent() == activeScene->GetScene())
            {
                KeyedArchive *properties = node->GetCustomProperties();
                if (properties && properties->IsKeyExists(String(ResourceEditor::EDITOR_REFERENCE_TO_OWNER)))
                {
                    String filePathname = properties->GetString(String(ResourceEditor::EDITOR_REFERENCE_TO_OWNER));

                    AddActionToMenu(&menu, QString("Remove Root Nodes"), new CommandRemoveRootNodes());
				}
			}
			FilePath filePathForSaveAs(activeScene->GetScenePathname());
			AddActionToMenu(&menu, QString("Save Scene As"), new CommandSaveSpecifiedScene(node, filePathForSaveAs));
		}
	}
	
	// For "custom" Particles Editor nodes the "generic" ones aren't needed".
    // We might need more menu items/actions for Particles Editor.
    sceneGraphModel->GetParticlesEditorSceneModelHelper().AddPopupMenuItems(menu, index);

    connect(&menu, SIGNAL(triggered(QAction *)), this, SLOT(SceneGraphMenuTriggered(QAction *)));
    menu.exec(point);
}
Ejemplo n.º 9
0
// Get test parameters from id.tx
void AutotestingSystem::FetchParametersFromIdTxt()
{
	FilePath file = "~res:/Autotesting/id.yaml";
	Logger::Debug("AutotestingSystem::FetchParametersFromIdTxt %s", file.GetAbsolutePathname().c_str());
	KeyedArchive *option = new KeyedArchive();
	bool res = option->LoadFromYamlFile(file);
	if (!res)
	{
		ForceQuit("Couldn't open file " + file.GetAbsolutePathname());
	}

	buildId = option->GetString("buildId");
	buildDate = option->GetString("date");
	branch = option->GetString("branch");
	framework = option->GetString("framework");
	branchRev = option->GetString("branchRev");
	frameworkRev = option->GetString("frameworkRev");

	SafeRelease(option);
}
Ejemplo n.º 10
0
FilePath CustomColorsSystem::GetCurrentSaveFileName()
{
	String currentSaveName;

	KeyedArchive* customProps = drawSystem->GetLandscapeCustomProperties();
	if (customProps && customProps->IsKeyExists(ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP))
	{
		currentSaveName = customProps->GetString(ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP);
	}

	return GetAbsolutePathFromProjectPath(currentSaveName);
}
Ejemplo n.º 11
0
void SceneSaver::CopyReferencedObject( Entity *node, Set<String> &errorLog )
{
	KeyedArchive *customProperties = node->GetCustomProperties();
	if(customProperties && customProperties->IsKeyExists(ResourceEditor::EDITOR_REFERENCE_TO_OWNER))
	{
		String path = customProperties->GetString(ResourceEditor::EDITOR_REFERENCE_TO_OWNER);
		sceneUtils.CopyFile(path, errorLog);
	}
	for (int i = 0; i < node->GetChildrenCount(); i++)
	{
		CopyReferencedObject(node->GetChild(i), errorLog);
	}
}
Ejemplo n.º 12
0
void SceneSaver::CopyReferencedObject( Entity *node, Set<String> &errorLog )
{
	KeyedArchive *customProperties = node->GetCustomProperties();
	if(customProperties && customProperties->IsKeyExists("editor.referenceToOwner"))
	{
		String path = customProperties->GetString("editor.referenceToOwner");
		sceneUtils.CopyFile(path, errorLog);
	}
	for (int i = 0; i < node->GetChildrenCount(); i++)
	{
		CopyReferencedObject(node->GetChild(i), errorLog);
	}

}
FilePath LandscapeEditorCustomColors::GetCurrentSaveFileName()
{
	if(NULL != workingLandscapeEntity)
	{
		KeyedArchive* customProps = workingLandscapeEntity->GetCustomProperties();
		if(customProps->IsKeyExists(ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP))
		{
			String currentSaveName = customProps->GetString(ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP);

			FilePath projectPath = EditorSettings::Instance()->GetProjectPath();
			return projectPath + currentSaveName;
		}
	}

	return FilePath();
}
Ejemplo n.º 14
0
DAVA::Vector<String> RecentFilesManager::GetRecentFiles()
{
	DAVA::Vector<String> retVector;
	VariantType recentFilesVariant = SettingsManager::GetValue(Settings::Internal_RecentFiles);
	if(recentFilesVariant.GetType() == DAVA::VariantType::TYPE_KEYED_ARCHIVE)
	{
		KeyedArchive* archiveRecentFiles = recentFilesVariant.AsKeyedArchive();
		DAVA::uint32 size = archiveRecentFiles->Count();
		retVector.resize(size);
		for (DAVA::uint32 i = 0; i < size; ++i)
		{
			retVector[i] = archiveRecentFiles->GetString(Format("%d", i));
		}
		
	}
	return retVector;
}
Ejemplo n.º 15
0
void SceneValidator::ValidateCustomColorsTexture(Entity *landscapeEntity, Set<String> &errorsLog)
{
	KeyedArchive* customProps = landscapeEntity->GetCustomProperties();
	if(customProps->IsKeyExists(ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP))
	{
		String currentSaveName = customProps->GetString(ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP);
		FilePath path = "/" + currentSaveName;
		if(!path.IsEqualToExtension(".png"))
		{
			errorsLog.insert("Custom colors texture has to have .png extension.");
		}
        
        String::size_type foundPos = currentSaveName.find("DataSource/3d/");
        if(String::npos == foundPos)
        {
			errorsLog.insert("Custom colors texture has to begin from DataSource/3d/.");
        }
	}
}
Ejemplo n.º 16
0
Command2* CustomColorsSystem::CreateSaveFileNameCommand(const String& filePath)
{
	KeyedArchive* customProps = drawSystem->GetLandscapeCustomProperties();
	bool keyExists = customProps->IsKeyExists(ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP);

	Command2* command = NULL;
	if (keyExists)
	{
		String curPath = customProps->GetString(ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP);
		if (curPath != filePath)
		{
			command = new KeyeadArchiveSetValueCommand(customProps, ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP,
													   VariantType(filePath));
		}
	}
	else
	{
		command = new KeyedArchiveAddValueCommand(customProps, ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP,
												  VariantType(filePath));
	}

	return command;
}
Ejemplo n.º 17
0
	bool CoreWin32Platform::CreateWin32Window(HINSTANCE hInstance)
	{	
		this->hInstance = hInstance;

		//single instance check
		TCHAR fileName[MAX_PATH];
		GetModuleFileName(NULL, fileName, MAX_PATH);
		fileName[MAX_PATH-1] = 0; //string can be not null-terminated on winXP
		for(int32 i = 0; i < MAX_PATH; ++i)
		{
			if(fileName[i] == L'\\') //symbol \ is not allowed in CreateMutex mutex name
			{
				fileName[i] = ' ';
			}
		}
		hMutex = CreateMutex(NULL, FALSE, fileName);
		if(ERROR_ALREADY_EXISTS == GetLastError())
		{
			return false;
		}

		windowedMode = DisplayMode(800, 600, 16, 0);
		fullscreenMode = DisplayMode(800, 600, 16, 0);
		currentMode = windowedMode;
		isFullscreen = false;

		// create the window, only if we do not use the null device
		LPCWSTR className = L"DavaFrameworkWindowsDevice";

		// Register Class

		WNDCLASSEX wcex;
		wcex.cbSize = sizeof(WNDCLASSEX); 
		wcex.style			= CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW;
		wcex.lpfnWndProc	= (WNDPROC)WndProc;
		wcex.cbClsExtra		= 0;
		wcex.cbWndExtra		= 0;
		wcex.hInstance		= hInstance;
		wcex.hIcon			= 0;
		wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
		wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
		wcex.lpszMenuName	= 0;
		wcex.lpszClassName	= className;
		wcex.hIconSm		= 0;

		RegisterClassEx(&wcex);

		// calculate client size

		RECT clientSize;
		clientSize.top = 0;
		clientSize.left = 0;
		clientSize.right = currentMode.width;
		clientSize.bottom = currentMode.height;

		ULONG style = WINDOWED_STYLE | WS_CLIPCHILDREN;

		// Create the rendering window
		if (isFullscreen)
		{
			style  = WS_VISIBLE | WS_POPUP;
		} // End if Fullscreen


		AdjustWindowRect(&clientSize, style, FALSE);

		int32 realWidth = clientSize.right - clientSize.left;
		int32 realHeight = clientSize.bottom - clientSize.top;

		int32 windowLeft = -10000;//(GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2;
		int32 windowTop = -10000;//(GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2;

		if (isFullscreen)
		{
			windowLeft = 0;
			windowTop = 0;
		}

		// create window
		hWindow = CreateWindow( className, L"", style, windowLeft, windowTop, 
			realWidth, realHeight,	NULL, NULL, hInstance, NULL);

		ShowWindow(hWindow, SW_SHOW);
		UpdateWindow(hWindow);

		// fix ugly ATI driver bugs. Thanks to ariaci (Taken from Irrlight).
		MoveWindow(hWindow, windowLeft, windowTop, realWidth, realHeight, TRUE);
	
#if defined(__DAVAENGINE_DIRECTX9__)
		RenderManager::Create(Core::RENDERER_DIRECTX9);
#elif defined(__DAVAENGINE_OPENGL__)
		RenderManager::Create(Core::RENDERER_OPENGL);
#endif
		RenderManager::Instance()->Create(hInstance, hWindow);

		FrameworkDidLaunched();
		KeyedArchive * options = Core::GetOptions();

		//fullscreenMode = GetCurrentDisplayMode();
		fullscreenMode = GetCurrentDisplayMode();//FindBestMode(fullscreenMode);
		if (options)
		{
			windowedMode.width = options->GetInt32("width");
			windowedMode.height = options->GetInt32("height");
			windowedMode.bpp = options->GetInt32("bpp");
			
			// get values from config in case if they are available
			fullscreenMode.width = options->GetInt32("fullscreen.width", fullscreenMode.width);
			fullscreenMode.height = options->GetInt32("fullscreen.height", fullscreenMode.height);
			fullscreenMode.bpp = windowedMode.bpp;

			fullscreenMode = FindBestMode(fullscreenMode);

			isFullscreen = (0 != options->GetInt32("fullscreen"));	
			String title = options->GetString("title", "[set application title using core options property 'title']");
			WideString titleW = StringToWString(title);
			SetWindowText(hWindow, titleW.c_str());
		}

		Logger::FrameworkDebug("[PlatformWin32] best display fullscreen mode matched: %d x %d x %d refreshRate: %d", fullscreenMode.width, fullscreenMode.height, fullscreenMode.bpp, fullscreenMode.refreshRate);

		currentMode = windowedMode;
		if (isFullscreen)
		{
			currentMode = fullscreenMode;
		}

		clientSize.top = 0;
		clientSize.left = 0;
		clientSize.right = currentMode.width;
		clientSize.bottom = currentMode.height;

		AdjustWindowRect(&clientSize, style, FALSE);

		realWidth = clientSize.right - clientSize.left;
		realHeight = clientSize.bottom - clientSize.top;

		windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2;
		windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2;
		MoveWindow(hWindow, windowLeft, windowTop, realWidth, realHeight, TRUE);
	
        RAWINPUTDEVICE Rid;

        Rid.usUsagePage = 0x01; 
        Rid.usUsage = 0x02; 
        Rid.dwFlags = 0;
        Rid.hwndTarget = 0;

        RegisterRawInputDevices(&Rid, 1, sizeof(Rid));

		RenderManager::Instance()->ChangeDisplayMode(currentMode, isFullscreen);
		RenderManager::Instance()->Init(currentMode.width, currentMode.height);
		UIControlSystem::Instance()->SetInputScreenAreaSize(currentMode.width, currentMode.height);
		Core::Instance()->SetPhysicalScreenSize(currentMode.width, currentMode.height);

		return true;
	}
Ejemplo n.º 18
0
void SceneEditorScreenMain::ExportAs(ResourceEditor::eExportFormat format)
{
    String formatStr;
    switch (format) 
    {
        case ResourceEditor::FORMAT_PNG:
            formatStr = String("png");
            break;
            
        case ResourceEditor::FORMAT_PVR:
            formatStr = String("pvr");
            break;
            
        case ResourceEditor::FORMAT_DXT:
            DVASSERT(0);
            return;
            
        default:
			DVASSERT(0);
            return;
    }
    
    
    BodyItem *iBody = FindCurrentBody();
	iBody->bodyControl->PushDebugCamera();
    
    String filePath = iBody->bodyControl->GetFilePath();
    
    String dataSourcePath = EditorSettings::Instance()->GetDataSourcePath();
    String::size_type pos = filePath.find(dataSourcePath);
    if(String::npos != pos)
    {
        filePath = filePath.replace(pos, dataSourcePath.length(), "");
    }
    else 
    {
        DVASSERT(0);
    }
    
    // Get project path
    KeyedArchive *keyedArchieve = EditorSettings::Instance()->GetSettings();
    String projectPath = keyedArchieve->GetString(String("ProjectPath"));
    
    if(!SceneExporter::Instance()) new SceneExporter();
    
    String inFolder = projectPath + String("DataSource/3d/");
    SceneExporter::Instance()->SetInFolder(inFolder);
    SceneExporter::Instance()->SetOutFolder(projectPath + String("Data/3d/"));
    
    SceneExporter::Instance()->SetExportingFormat(formatStr);
    
    //TODO: how to be with removed nodes?
    Set<String> errorsLog;
    SceneExporter::Instance()->ExportScene(iBody->bodyControl->GetScene(), filePath, errorsLog);
    
	iBody->bodyControl->PopDebugCamera();
    libraryControl->RefreshTree();
    
    if(0 < errorsLog.size())
    {
        ErrorNotifier::Instance()->ShowError(errorsLog);
    }
}
Ejemplo n.º 19
0
void MainScreen::LoadResources()
{
    Vector2 screenSize(GetScreenWidth(), GetScreenHeight());
    
    cellH = GetScreenHeight() / 25;
    buttonW = GetScreenWidth() / 10;
    
    
    float32 infoAreaWidth = screenSize.x - 960.0f;

    Vector2 previewSize(screenSize.x - infoAreaWidth, screenSize.y - cellH);
    //Vector2 previewScale(previewSize.x/screenSize.x, previewSize.y/screenSize.y);
    
    preview = new PreviewControl(Rect(0.0f, cellH, previewSize.x, previewSize.y));
    //preview->SetScaledRect(Rect(0.0f, cellH, previewSize.x*0.9f, previewSize.y*0.9f));
    //preview->SetDebugDraw(true);
    
    AddControl(preview);
    
    FTFont* font = FTFont::Create("~res:/Fonts/MyriadPro-Regular.otf");
    font->SetSize(20.0f);
    font->SetColor(0.8f, 0.8f, 0.8f, 1.0f);
    
    chooseProject = new UIButton(Rect(0.0f, 0.0f, buttonW, cellH));
    chooseProject->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL);
    chooseProject->GetStateBackground(UIControl::STATE_NORMAL)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f));
    chooseProject->SetStateDrawType(UIControl::STATE_PRESSED_INSIDE, UIControlBackground::DRAW_FILL);
    chooseProject->GetStateBackground(UIControl::STATE_PRESSED_INSIDE)->SetColor(Color(0.5, 0.5, 0.5, 0.5));
    chooseProject->SetStateFont(UIControl::STATE_NORMAL, font);
    chooseProject->SetStateText(UIControl::STATE_NORMAL, LocalizedString("Project"));
	chooseProject->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MainScreen::OnButtonPressed));
    AddControl(chooseProject);
    
	loadUI = new UIButton(Rect(2*buttonW, 0, buttonW, cellH));
    loadUI->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL);
    loadUI->GetStateBackground(UIControl::STATE_NORMAL)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f));
    loadUI->SetStateDrawType(UIControl::STATE_PRESSED_INSIDE, UIControlBackground::DRAW_FILL);
    loadUI->GetStateBackground(UIControl::STATE_PRESSED_INSIDE)->SetColor(Color(0.5f, 0.5f, 0.5f, 0.5f));
    loadUI->SetStateFont(UIControl::STATE_NORMAL, font);
    loadUI->SetStateText(UIControl::STATE_NORMAL, LocalizedString("Load"));
	loadUI->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MainScreen::OnButtonPressed));
    AddControl(loadUI);
    loadUI->SetVisible(false);
    
    saveUI = new UIButton(Rect(buttonW*3, 0, buttonW, cellH));
    saveUI->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL);
    saveUI->GetStateBackground(UIControl::STATE_NORMAL)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f));
    saveUI->SetStateDrawType(UIControl::STATE_PRESSED_INSIDE, UIControlBackground::DRAW_FILL);
    saveUI->GetStateBackground(UIControl::STATE_PRESSED_INSIDE)->SetColor(Color(0.5f, 0.5f, 0.5f, 0.5f));
    saveUI->SetStateFont(UIControl::STATE_NORMAL, font);
    saveUI->SetStateText(UIControl::STATE_NORMAL, LocalizedString("Save"));
	saveUI->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MainScreen::OnButtonPressed));
    //TODO: add saveUI when uiviewer becomes editor
    //AddControl(saveUI);
    
    selectHoverModeButton = new UIButton(Rect(buttonW*4, 0, 2*buttonW, cellH));
    
    selectHoverModeButton->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL);
    selectHoverModeButton->GetStateBackground(UIControl::STATE_NORMAL)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f));
    selectHoverModeButton->SetStateFont(UIControl::STATE_NORMAL, font);
    selectHoverModeButton->SetStateText(UIControl::STATE_NORMAL, LocalizedString("selection.mode.click"));
    
    selectHoverModeButton->SetStateDrawType(UIControl::STATE_PRESSED_INSIDE, UIControlBackground::DRAW_FILL);
    selectHoverModeButton->GetStateBackground(UIControl::STATE_PRESSED_INSIDE)->SetColor(Color(0.5f, 0.5f, 0.5f, 0.5f));
    
    selectHoverModeButton->SetStateDrawType(UIControl::STATE_SELECTED, UIControlBackground::DRAW_FILL);
    selectHoverModeButton->GetStateBackground(UIControl::STATE_SELECTED)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f));
    selectHoverModeButton->SetStateFont(UIControl::STATE_SELECTED, font);
    selectHoverModeButton->SetStateText(UIControl::STATE_SELECTED, LocalizedString("selection.mode.hover"));
    
	selectHoverModeButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MainScreen::OnButtonPressed));
    AddControl(selectHoverModeButton);
    selectHoverModeButton->SetVisible(false);
    
    for (int32 i = 0; i < InfoControl::INFO_TYPES_COUNT; ++i) 
    {
        keyTexts[i] = new UIStaticText(Rect(screenSize.x - infoAreaWidth, cellH*(2*i+1), infoAreaWidth, cellH));
        keyTexts[i]->SetFont(font);
        keyTexts[i]->SetText(keyNames[i]);
        AddControl(keyTexts[i]);
        
        valueTexts[i] = new UIStaticText(Rect(screenSize.x - infoAreaWidth, cellH*(2*i+2), infoAreaWidth, cellH));
        valueTexts[i]->SetFont(font);
        AddControl(valueTexts[i]);
    }
    
    additionalInfoList = new UIList(Rect(screenSize.x - infoAreaWidth, cellH*(2*InfoControl::INFO_TYPES_COUNT+2), infoAreaWidth, screenSize.y - cellH*(2*InfoControl::INFO_TYPES_COUNT+2) ), UIList::ORIENTATION_VERTICAL);
    additionalInfoList->SetDelegate(this);
    AddControl(additionalInfoList);
    
    fsDlg = new UIFileSystemDialog("~res:/Fonts/MyriadPro-Regular.otf");
    fsDlg->SetDelegate(this);
    Vector<String> filter;
    filter.push_back(".yaml");
    filter.push_back(".YAML");
    fsDlg->SetExtensionFilter(filter);
    fsDlg->SetTitle(LocalizedString("Dlg.Load"));
    fsDlg->SetCurrentDir(FileSystem::Instance()->SystemPathForFrameworkPath("~res:/")); 

    fsDlgProject = new UIFileSystemDialog("~res:/Fonts/MyriadPro-Regular.otf"); //default = GetCurrentWorkingDirectory 
    fsDlgProject->SetDelegate(this);
    fsDlgProject->SetOperationType(UIFileSystemDialog::OPERATION_CHOOSE_DIR);
    fsDlgProject->SetTitle(LocalizedString("Dlg.ChoosePrj"));
    
    KeyedArchive* archive = new KeyedArchive();
	if(archive->Load("~doc:/uiviewer.archive"))
    {
        if(archive->IsKeyExists("projectPath"))
        {
            projectPath = archive->GetString("projectPath");
            //TODO: different path formats on different OS
            OnLoadProject();
            fsDlgProject->SetCurrentDir(projectPath);
        }
    }
    SafeRelease(archive);

    
    SafeRelease(font);
}