コード例 #1
0
void SelectPathWidgetBase::OpenClicked()
{
	DAVA::FilePath presentPath(text().toStdString());
	DAVA::FilePath dialogString(openDialogDefaultPath);
	if(presentPath.GetDirectory().Exists())//check if file text box clean
	{
		dialogString = presentPath.GetDirectory();
	}
	this->blockSignals(true);
	DAVA::String retString = QtFileDialog::getOpenFileName(this, openFileDialogTitle.c_str(), QString(dialogString.GetAbsolutePathname().c_str()), fileFormatFilter.c_str()).toStdString();
	this->blockSignals(false);

    if(retString.empty())
    {
        return;
    }
    
    DAVA::String projectPath = ProjectManager::Instance()->CurProjectPath().GetAbsolutePathname();

    if(checkForProjectPath && DAVA::String::npos == retString.find(projectPath))
    {
        QMessageBox::warning(NULL, "Wrong file selected", QString(DAVA::Format("Path %s doesn't belong to project.", retString.c_str()).c_str() ), QMessageBox::Ok);
        return;
    }
    
	HandlePathSelected(retString);
}
コード例 #2
0
void ConvertDaeToSce(const DAVA::String & pathToFile)
{
    FCollada::Initialize();
    
    DAVA::ColladaDocument colladaDocument;
    if (!colladaDocument.Open(pathToFile.c_str()))
    {
        printf("*** ERROR: Failed to read %s\n", pathToFile.c_str());
        return;
    }
    
    /*
     int paramCount = CommandLineParser::Instance()->GetParamCount();
     for (int k = PARAM_SOURCE_FILEPATH + 1; k < paramCount; ++k)
     {
     colladaDocument.ExportAnimations(CommandLineParser::Instance()->GetParam(k).c_str());
     }
     */
    DAVA::String fileDirectory, filePath;
    DAVA::FileSystem::SplitPath(pathToFile, fileDirectory, filePath);
    filePath = DAVA::FileSystem::ReplaceExtension(filePath, ".sce");
    
    colladaDocument.SaveScene(fileDirectory, filePath);
    colladaDocument.Close();
    
    FCollada::Release();
}
コード例 #3
0
void QtMainWindow::ProjectOpened(const QString &path)
{
	DAVA::String frameworkTitle = DAVA::Core::Instance()->GetOptions()->GetString("title");
	QString strVer = QString(frameworkTitle.c_str());

	if(!strVer.isEmpty())
	{
		strVer += " | ";
	}

	this->setWindowTitle(strVer + QString("Project - ") + path);
	UpdateLibraryFileTypes();
	UpdateParticleSprites();
}
コード例 #4
0
void TextureBrowser::updateInfoConverted()
{
	if(NULL != curTexture && NULL != curDescriptor)
	{
		char tmp[1024];

		const char *formatStr = "";

		int datasize = 0;
		int filesize = 0;

		switch(curTextureView)
		{
		case ViewPVR:
			if(curDescriptor->pvrCompression.format != DAVA::FORMAT_INVALID)
			{
				DAVA::String compressedTexturePath = DAVA::TextureDescriptor::GetPathnameForFormat(curTexture->GetPathname(), DAVA::PVR_FILE);

				formatStr = DAVA::Texture::GetPixelFormatString(curDescriptor->pvrCompression.format);
				filesize = QFileInfo(compressedTexturePath.c_str()).size();
				datasize = DAVA::LibPVRHelper::GetDataLength(compressedTexturePath);
			}
			break;
		case ViewDXT:
			if(curDescriptor->dxtCompression.format != DAVA::FORMAT_INVALID)
			{
				DAVA::String compressedTexturePath = DAVA::TextureDescriptor::GetPathnameForFormat(curTexture->GetPathname(), DAVA::DXT_FILE);

				formatStr = DAVA::Texture::GetPixelFormatString(curDescriptor->dxtCompression.format);
				filesize = QFileInfo(compressedTexturePath.c_str()).size();

				// TODO: more accurate dxt data size calculation
				//datasize = (curTexture->width * curTexture->height * DAVA::Texture::GetPixelFormatSizeInBits(curDescriptor->dxtCompression.format)) >> 3;
				datasize = LibDxtHelper::GetDataSize(compressedTexturePath.c_str());
			}
			break;
		}

		sprintf(tmp, "Format\t: %s\nSize\t: %dx%d\nData size\t: %s\nFile size\t: %s", formatStr, curTexture->width, curTexture->height,
			SizeInBytesToString(datasize).c_str(),
			SizeInBytesToString(filesize).c_str());

		ui->labelConvertedFormat->setText(tmp);
	}
	else
	{
		ui->labelConvertedFormat->setText("");
	}
}
コード例 #5
0
DAVA::String GetOpenFileName(const DAVA::String &title, const DAVA::String &pathname, const DAVA::String &filter)
{
    QString filePath = QFileDialog::getOpenFileName(NULL, QString(title.c_str()), QString(pathname.c_str()),
                                                    QString(filter.c_str()));
    
    QtMainWindowHandler::Instance()->RestoreDefaultFocus();

    String openedPathname = PathnameToDAVAStyle(filePath);
    if(!openedPathname.empty() && !SceneValidator::Instance()->IsPathCorrectForProject(openedPathname))
    {
        //Need to Show Error
		ShowErrorDialog(String(Format("File(%s) was selected from incorect project.", openedPathname.c_str())));
        openedPathname = String("");
    }
    
    return openedPathname;
}
コード例 #6
0
void ShowErrorDialog(const DAVA::String &errorMessage)
{
	bool forceMode =    CommandLineTool::Instance()->CommandIsFound(String("-force"))
					||  CommandLineTool::Instance()->CommandIsFound(String("-forceclose"));
	if(!forceMode)
	{
		QMessageBox::critical(QtMainWindow::Instance(), "Error", errorMessage.c_str());
	}
}
コード例 #7
0
void Logger::Logv(eLogLevel ll, const char8* text, va_list li)
{
	if (ll < logLevel)return; 

	char tmp[4096];
	vsprintf(tmp, text, li);
	strcat(tmp, "\n");
	__android_log_print(LogLevelToAndtoid(ll), androidLogTag.c_str(), tmp);
}
コード例 #8
0
FontManagerDialog::FontManagerDialog(bool okButtonEnable,  const QString& graphicsFontPath, QDialog *parent) :
    QDialog(parent),
    ui(new Ui::FontManagerDialog)
{    
    ui->setupUi(this);
    // Setup ok button - it should be visible only if user want to change font of control.
    ui->okButton->setVisible(okButtonEnable);
    dialogResultFont = NULL;
	// Pack graphics fonts sprites each time sprite dialog is opened
	ResourcePacker2D *resPacker = new ResourcePacker2D();

	DAVA::String inDir = ResourcesManageHelper::GetFontSpritesDatasourceDirectory().toStdString();
	DAVA::String outDir = ResourcesManageHelper::GetFontSpritesDirectory().toStdString();
	// Do not pack resources if input/output folders are empty
	if (!inDir.empty() && !outDir.empty())
	{
		resPacker->InitFolders(inDir, outDir);
		resPacker->PackResources(GPU_PNG);
	}

    ui->setDefaultButton->setVisible(false);
    
    // Initialize dialog
    ConnectToSignals();
    InitializeTableView();
    UpdateTableViewContents();
 	UpdateDialogInformation();

	SafeDelete(resPacker);
	
	// Setup default path for graphics font sprites
	if (!graphicsFontPath.isEmpty())
	{
		currentFontPath = ResourcesManageHelper::GetFontAbsolutePath(graphicsFontPath);
	}
}
コード例 #9
0
void SceneValidator::ValidateScene(Scene *scene, const DAVA::FilePath &scenePath, Set<String> &errorsLog)
{
    if(scene) 
    {
		DAVA::String tmp = scenePath.GetAbsolutePathname();
		size_t pos = tmp.find("/Data");
		if(pos != String::npos)
		{
			SetPathForChecking(tmp.substr(0, pos + 1));
		}

        ValidateSceneNode(scene, errorsLog);

        for (Set<Entity*>::iterator it = emptyNodesForDeletion.begin(); it != emptyNodesForDeletion.end(); ++it)
        {
            Entity * node = *it;
            if (node->GetParent())
            {
                node->GetParent()->RemoveNode(node);
            }
        }
        

		for (Set<Entity *>::iterator it = emptyNodesForDeletion.begin(); it != emptyNodesForDeletion.end(); ++it)
		{
			Entity *node = *it;
			SafeRelease(node);
		}

        emptyNodesForDeletion.clear();
    }
    else 
    {
        errorsLog.insert(String("Scene in NULL!"));
    }
}
コード例 #10
0
namespace DAVA 
{

static DAVA::String androidLogTag = "";    

int32 LogLevelToAndtoid(Logger::eLogLevel ll)
{
	int32 androidLL = ANDROID_LOG_DEFAULT;
	switch (ll)
	{
		case Logger::LEVEL_DEBUG:
			androidLL = ANDROID_LOG_DEBUG;
			break;

		case Logger::LEVEL_INFO:
			androidLL = ANDROID_LOG_INFO;
			break;

		case Logger::LEVEL_WARNING:
			androidLL = ANDROID_LOG_WARN;
			break;

		case Logger::LEVEL_ERROR:
			androidLL = ANDROID_LOG_ERROR;
			break;
	}

	return androidLL;
}

void Logger::PlatformLog(eLogLevel ll, const char8* text)
{
	__android_log_print(LogLevelToAndtoid(ll), androidLogTag.c_str(), text, "");
}

void Logger::PlatformLog(eLogLevel ll, const char16* text)
{
	wprintf(L"%s", text);
}

void Logger::SetTag(const char8 *logTag)
{
	androidLogTag = Format("%s", logTag);
}


}
コード例 #11
0
bool AutotestingSystemLua::RunScript(const DAVA::String &luaScript)
{
    //Logger::Debug("AutotestingSystemLua::RunScript %s", luaScript.c_str());
    if(LoadScript(luaScript))
    {
 		if (lua_pcall(luaState, 0, 1, 0))
		{
			const char* err = lua_tostring(luaState, -1);

			Logger::Error("AutotestingSystemLua::RunScript error %s", err);

			return false;
		}
		return true;
    }
	Logger::Error("AutotestingSystemLua::RunScript couldnt't load script %s", luaScript.c_str());
    return false;
}
コード例 #12
0
String PVRConverter::GetCommandLinePVR(const DAVA::String & fileToConvert, const DAVA::TextureDescriptor &descriptor)
{
	String command = Format("\"%s\"", pvrTexToolPathname.c_str());
	String format = pixelFormatToPVRFormat[descriptor.pvrCompression.format];

	if(command != "" && format != "")
	{
		String outputFile = GetPVRToolOutput(fileToConvert);

		// assemble command

		// input file
		command += Format(" -i \"%s\"", fileToConvert.c_str());

		// output format
		command += Format(" -f%s", format.c_str());

		// pvr should be always flipped-y
		command += " -yflip0";

		// mipmaps
		if(descriptor.generateMipMaps)
		{
			command += " -m";
		}

		// base mipmap level (base resize)
		if(0 != descriptor.pvrCompression.compressToWidth && descriptor.pvrCompression.compressToHeight != 0)
		{
			command += Format(" -x %d -y %d", descriptor.pvrCompression.compressToWidth, descriptor.pvrCompression.compressToHeight);
		}

		// output file
		command += Format(" -o \"%s\"", outputFile.c_str());
	}
    else
    {
        Logger::Error("[PVRConverter::GetCommandLinePVR] Can't create command line for file (%s)", fileToConvert.c_str());
        command = "";
    }

	return command;
}
コード例 #13
0
bool CubemapEditorDialog::LoadImageTo(const DAVA::String& filePath, int face, bool silent)
{
	bool result = true;
	ClickableQLabel* label = GetLabelForFace(face);
	
	QString fileName = filePath.c_str();
	
	QImage faceImage;
	faceImage.load(fileName);
	
	if(VerifyImage(faceImage, face))
	{
		QImage scaledFace = faceImage.scaled(label->width(), label->height());
		label->setPixmap(QPixmap::fromImage(scaledFace));
		label->SetFaceLoaded(true);
		label->SetRotation(0);
		
		facePath[face] = fileName;
		
		if(faceHeight != faceImage.height())
		{
			faceHeight = faceImage.height();
			faceWidth = faceImage.width();
			UpdateFaceInfo();
		}
		
		faceChanged = true;
		
		UpdateButtonState();
	}
	else
	{
		if(!silent)
		{
			QString message = QString("%1\n is not suitable as current cubemap face!").arg(fileName);
			ShowErrorDialog(message.toStdString());
		}
		
		result = false;
	}

	return result;
}
コード例 #14
0
void CubemapEditorDialog::SaveCubemap(const QString& path)
{
	FilePath filePath(path.toStdString());
	DAVA::uint8 faceMask = GetFaceMask();
		
	//copy file to the location where .tex will be put. Add suffixes to file names to distinguish faces
	String fileNameWithoutExtension = filePath.GetFilename();
	String extension = filePath.GetExtension();
	fileNameWithoutExtension.replace(fileNameWithoutExtension.find(extension), extension.size(), "");
	for(int i = 0 ; i < CubemapUtils::GetMaxFaces(); ++i)
	{
		if(!facePath[i].isNull())
		{
			FilePath faceFilePath = filePath;
			faceFilePath.ReplaceFilename(fileNameWithoutExtension +
										 CubemapUtils::GetFaceNameSuffix(CubemapUtils::MapUIToFrameworkFace(i)) + "." +
										 CubemapUtils::GetDefaultFaceExtension());

			DAVA::String targetFullPath = faceFilePath.GetAbsolutePathname().c_str();
			if(facePath[i] != targetFullPath.c_str())
			{
				if(QFile::exists(targetFullPath.c_str()))
				{
					int answer = ShowQuestion("File overwrite",
											  "File " + targetFullPath + " already exist. Do you want to overwrite it with " + facePath[i].toStdString(),
											  MB_FLAG_YES | MB_FLAG_NO, MB_FLAG_NO);
					
					if(MB_FLAG_YES == answer)
					{
						bool removeResult = QFile::remove(targetFullPath.c_str());
						
						if(!removeResult)
						{
							ShowErrorDialog("Failed to copy texture " + facePath[i].toStdString() + " to " + targetFullPath.c_str());
							return;
						}

					}
					else
					{
						continue;
					}
				}
				
				bool copyResult = QFile::copy(facePath[i], targetFullPath.c_str());
				
				if(!copyResult)
				{
					ShowErrorDialog("Failed to copy texture " + facePath[i].toStdString() + " to " + targetFullPath);
					return;
				}
			}
			
			ClickableQLabel* faceLabel = GetLabelForFace(i);
			if(faceLabel->GetRotation() != 0)
			{
				QTransform transform;
				transform.rotate(faceLabel->GetRotation());
				QImage qimg(targetFullPath.c_str());
				QImage rotatedImage = qimg.transformed(transform);
				rotatedImage.save(targetFullPath.c_str());
                faceLabel->SetRotation(0);
			}
		}
	}
	
	TextureDescriptor* descriptor = new TextureDescriptor();
    bool descriptorReady = false;
    if(filePath.Exists())
    {
        descriptorReady = descriptor->Load(filePath);
    }
    
    if(!descriptorReady)
    {
        descriptor->SetDefaultValues();
        descriptor->drawSettings.wrapModeS = descriptor->drawSettings.wrapModeT = Texture::WRAP_CLAMP_TO_EDGE;
    }
    
	descriptor->dataSettings.faceDescription = faceMask;

    descriptor->Save(filePath);
	SafeDelete(descriptor);
	
	QMessageBox::information(this, "Cubemap texture save result", "Cubemap texture was saved successfully!");
}
コード例 #15
0
void SelectPathWidgetBase::setText(const DAVA::String &filePath)
{
    SelectPathWidgetBase::setText(QString(filePath.c_str()));
}
コード例 #16
0
void Logger::PlatformLog(eLogLevel ll, const char8* text)
{
	__android_log_print(LogLevelToAndtoid(ll), androidLogTag.c_str(), text, "");
}
コード例 #17
0
namespace DAVA 
{


    static DAVA::String androidLogTag = "";    
    

int32 LogLevelToAndtoid(Logger::eLogLevel ll)
{
	int32 androidLL = ANDROID_LOG_DEFAULT;
	switch (ll)
	{
		case Logger::LEVEL_DEBUG:
			androidLL = ANDROID_LOG_DEBUG;
			break;

		case Logger::LEVEL_INFO:
			androidLL = ANDROID_LOG_INFO;
			break;

		case Logger::LEVEL_WARNING:
			androidLL = ANDROID_LOG_WARN;
			break;

		case Logger::LEVEL_ERROR:
			androidLL = ANDROID_LOG_ERROR;
			break;
	}

	return androidLL;
}

void Logger::Logv(eLogLevel ll, const char8* text, va_list li)
{
	if (ll < logLevel)return; 

	char tmp[4096];
	vsprintf(tmp, text, li);
	strcat(tmp, "\n");
	__android_log_print(LogLevelToAndtoid(ll), androidLogTag.c_str(), tmp);
}

void Logger::Logv(eLogLevel ll, const char16* text, va_list li)
{
	//TODO: VK: add code

	if (ll < logLevel)return; 

 	wchar_t tmp[4096];
	vswprintf(tmp, 4096, text, li);
 	wcscat(tmp, L"\n");

// 	char tmpChar[4096];
// 	wcstombs(tmpChar, tmp, 4096);
// 	__android_log_print(LogLevelToAndtoid(ll), LOG_TAG, tmpChar);
}

void Logger::SetTag(const char8 *logTag)
{
    androidLogTag = Format("%s", logTag);
}
    

}
コード例 #18
0
void CubeMapTextureBrowser::ReloadTextures(const DAVA::String& rootPath)
{	
	cubeListItemDelegate.ClearCache();
	ui->listTextures->clear();
	ui->listTextures->setVisible(false);
	ui->loadingWidget->setVisible(true);
	
	
	this->paintEvent(NULL);
	ui->loadingWidget->update();
	QApplication::processEvents();
	QApplication::flush();
	
	this->setUpdatesEnabled(false);

	QDir dir(rootPath.c_str());
	QStringList filesList = dir.entryList(QStringList("*.tex"));
	size_t cubemapTextures = 0;
	
	if(filesList.size() > 0)
	{
		DAVA::Vector<CubeListItemDelegate::ListItemInfo> cubemapList;
		FilePath fp = rootPath;
		for(int i = 0; i < filesList.size(); ++i)
		{
			QString str = filesList.at(i);
			fp.ReplaceFilename(str.toStdString());
			
			DAVA::TextureDescriptor* texDesc = DAVA::TextureDescriptor::CreateFromFile(fp);
			if(texDesc && texDesc->IsCubeMap())
			{
				CubeListItemDelegate::ListItemInfo itemInfo;
				itemInfo.path = fp;
				itemInfo.valid = ValidateTextureAndFillThumbnails(fp, itemInfo.icons, itemInfo.actualSize);
				
				if(itemInfo.valid)
				{
					cubemapList.push_back(itemInfo);
				}
				else
				{
					//non-valid items should be always at the beginning of the list
					cubemapList.insert(cubemapList.begin(), itemInfo);
				}
			}

			SafeDelete(texDesc);
		}
		
		cubeListItemDelegate.UpdateCache(cubemapList);
		
		for(size_t i = 0; i < cubemapList.size(); ++i)
		{
			CubeListItemDelegate::ListItemInfo& itemInfo = cubemapList[i];
			
			QListWidgetItem* listItem = new QListWidgetItem();
			listItem->setData(Qt::CheckStateRole, false);
			listItem->setData(CUBELIST_DELEGATE_ITEMFULLPATH, itemInfo.path.GetAbsolutePathname().c_str());
			listItem->setData(CUBELIST_DELEGATE_ITEMFILENAME, itemInfo.path.GetFilename().c_str());
			ui->listTextures->addItem(listItem);
		}
		
		cubemapTextures = cubemapList.size();
		ui->listTextures->setCurrentItem(ui->listTextures->item(0));
	}
	
	this->setUpdatesEnabled(true);
	
	ui->listTextures->setVisible(cubemapTextures > 0);
	ui->loadingWidget->setVisible(false);
	
	UpdateCheckedState();
}