当前位置: 首页>>代码示例>>C++>>正文


C++ CData::GetKey方法代码示例

本文整理汇总了C++中CData::GetKey方法的典型用法代码示例。如果您正苦于以下问题:C++ CData::GetKey方法的具体用法?C++ CData::GetKey怎么用?C++ CData::GetKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CData的用法示例。


在下文中一共展示了CData::GetKey方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Initialize

void CInstructor::Initialize()
{
    if (m_pCurrentPanel)
    {
        RootPanel()->RemoveControl(m_pCurrentPanel);
    }

    m_pCurrentPanel = NULL;

    Clear();

    FILE* fp = tfopen_asset("scripts/instructor.txt", "r");

    if (!fp)
    {
        TMsg("Couldn't load instructor script.\n");
        return;
    }

    std::shared_ptr<CData> pData(new CData());
    CDataSerializer::Read(fp, pData.get());

    for (size_t i = 0; i < pData->GetNumChildren(); i++)
    {
        CData* pChildData = pData->GetChild(i);

        if (pChildData->GetKey() == "Lesson")
            ReadLesson(pChildData);
    }
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:30,代码来源:instructor.cpp

示例2: ReadLessonOutput

void CInstructor::ReadLessonOutput(const CData* pData, CLesson* pLesson)
{
    CLessonOutput* pOutput = &pLesson->m_aOutputs.push_back();
    pOutput->m_sOutput = pData->GetValueString();

    for (size_t i = 0; i < pData->GetNumChildren(); i++)
    {
        CData* pChildData = pData->GetChild(i);

        if (pChildData->GetKey() == "Target")
            pOutput->m_sTarget = pChildData->GetValueString();
        else if (pChildData->GetKey() == "Input")
            pOutput->m_sInput = pChildData->GetValueString();
        else if (pChildData->GetKey() == "Args")
            pOutput->m_sArgs = pChildData->GetValueString();
    }
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:17,代码来源:instructor.cpp

示例3: CreateEntitiesFromData

void CLevel::CreateEntitiesFromData(const CData* pData)
{
	m_aLevelEntities.clear();
	m_iNextHandle = 0;

	for (size_t i = 0; i < pData->GetNumChildren(); i++)
	{
		CData* pChildData = pData->GetChild(i);

		if (pChildData->GetKey() != "Entity")
			continue;

		m_aLevelEntities.push_back(CLevelEntity(m_iNextHandle++, pChildData->GetValueString()));

		CLevelEntity* pEntity = &m_aLevelEntities.back();

		pEntity->m_iHandle = m_aLevelEntities.size()-1;

		for (size_t k = 0; k < pChildData->GetNumChildren(); k++)
		{
			CData* pField = pChildData->GetChild(k);

			tstring sHandle = pField->GetKey();
			tstring sValue = pField->GetValueString();

			if (sHandle == "Output")
			{
				tstring sTarget;
				tstring sInput;
				tstring sArgs;
				bool bKill = false;

				for (size_t o = 0; o < pField->GetNumChildren(); o++)
				{
					CData* pOutputData = pField->GetChild(o);

					if (pOutputData->GetKey() == "Target")
						sTarget = pOutputData->GetValueString();
					else if (pOutputData->GetKey() == "Input")
						sInput = pOutputData->GetValueString();
					else if (pOutputData->GetKey() == "Args")
						sArgs = pOutputData->GetValueString();
					else if (pOutputData->GetKey() == "Kill")
						bKill = pOutputData->GetValueBool();
				}

				CLevelEntity::CLevelEntityOutput& oOutput = pEntity->GetOutputs().push_back();
				oOutput.m_sOutput = sValue;
				oOutput.m_sTargetName = sTarget;
				oOutput.m_sInput = sInput;
				oOutput.m_sArgs = sArgs;
				oOutput.m_bKill = bKill;
			}
			else
			{
				pEntity->SetParameterValue(sHandle, sValue);
			}
		}
	}
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:60,代码来源:level.cpp

示例4: SaveData

static void SaveData(std::basic_ostream<char>& sStream, CData* pData, size_t iLevel)
{
	string sTabs;
	for (size_t i = 0; i < iLevel; i++)
		sTabs += "\t";

	for (size_t i = 0; i < pData->GetNumChildren(); i++)
	{
		CData* pChild = pData->GetChild(i);

		if (pChild->GetValueString().length())
			sStream << (sTabs + pChild->GetKey() + ": " + pChild->GetValueString() + "\n").c_str();
		else
			sStream << (sTabs + pChild->GetKey() + "\n").c_str();

		if (pChild->GetNumChildren())
		{
			sStream << (sTabs + "{\n").c_str();
			SaveData(sStream, pChild, iLevel+1);
			sStream << (sTabs + "}\n").c_str();
		}
	}
}
开发者ID:BSVino,项目名称:MathForGameDevelopers,代码行数:23,代码来源:dataserializer.cpp

示例5: BuildFromInputScript

bool CGeppetto::BuildFromInputScript(const tstring& sScript)
{
	FILE* fp = tfopen_asset(GetPath(sScript), "r");
	if (!fp)
	{
		TError("Could not read input script '" + sScript + "'\n");
		return false;
	}

	std::shared_ptr<CData> pData(new CData());
	CDataSerializer::Read(fp, pData.get());

	CData* pOutput = pData->FindChild("Output");
	if (!pOutput)
	{
		TError("Could not find Output section in input script '" + sScript + "'\n");
		return false;
	}

	CData* pGame = pData->FindChild("Game");
	if (!pGame)
	{
		TError("Could not find Game section in input script '" + sScript + "'\n");
		return false;
	}

	t.SetGameDirectory(FindAbsolutePath(GetPath(pGame->GetValueString())));

	tstring sOutputDir = ToForwardSlashes(pOutput->GetValueString());
	t.SetOutputDirectory(GetDirectory(sOutputDir));
	t.SetOutputFile(GetFilename(sOutputDir));
	t.SetScriptDirectory(GetDirectory((GetPath(sScript))));

	m_sOutput = FindAbsolutePath(t.GetGameDirectory() + T_DIR_SEP + pOutput->GetValueString());

	CData* pSceneAreas = pData->FindChild("SceneAreas");
	CData* pMesh = pData->FindChild("Mesh");
	CData* pPhysics = pData->FindChild("Physics");
	CData* pPhysicsShapes = pData->FindChild("PhysicsShapes");

	// Find all file modification times.
	time_t iScriptModificationTime = GetFileModificationTime(sScript.c_str());
	time_t iOutputModificationTime = GetFileModificationTime(m_sOutput.c_str());

	tmap<tstring, time_t> aiSceneModificationTimes;

	if (pSceneAreas)
	{
		for (size_t i = 0; i < pSceneAreas->GetNumChildren(); i++)
		{
			CData* pArea = pSceneAreas->GetChild(i);

			if (pArea->GetKey() != "Area")
				continue;

			tstring sFile = pArea->FindChildValueString("File");
			TAssert(sFile.length());
			if (!sFile.length())
				continue;

			auto it = aiSceneModificationTimes.find(sFile);
			if (it == aiSceneModificationTimes.end())
				aiSceneModificationTimes[sFile] = GetFileModificationTime(sFile.c_str());
		}
	}

	time_t iInputModificationTime = 0;
	if (pMesh)
		iInputModificationTime = GetFileModificationTime(pMesh->GetValueString().c_str());
	time_t iPhysicsModificationTime = 0;
	if (pPhysics)
		iPhysicsModificationTime = GetFileModificationTime(pPhysics->GetValueString().c_str());

	bool bRecompile = false;
	if (iScriptModificationTime > iOutputModificationTime)
		bRecompile = true;
	else if (iInputModificationTime > iOutputModificationTime)
		bRecompile = true;
	else if (iPhysicsModificationTime > iOutputModificationTime)
		bRecompile = true;
	else if (m_iBinaryModificationTime > iOutputModificationTime)
		bRecompile = true;
	else
	{
		for (auto it = aiSceneModificationTimes.begin(); it != aiSceneModificationTimes.end(); it++)
		{
			if (it->second > iOutputModificationTime)
			{
				bRecompile = true;
				break;
			}
		}
	}

	if (!bRecompile)
	{
		if (m_bForceCompile)
		{
			TMsg("Forcing rebuild even though no changes detected.\n");
		}
//.........这里部分代码省略.........
开发者ID:BSVino,项目名称:Digitanks,代码行数:101,代码来源:inputscript.cpp

示例6: LoadSceneAreas

bool CGeppetto::LoadSceneAreas(CData* pData)
{
	tmap<tstring, std::shared_ptr<CConversionScene> > asScenes;
	tmap<tstring, size_t> aiSceneIDs;

	size_t iSceneArea = 0;

	for (size_t i = 0; i < pData->GetNumChildren(); i++)
	{
		CData* pArea = pData->GetChild(i);

		if (pArea->GetKey() == "NeighborDistance")
		{
			t.SetNeighborDistance(pArea->GetValueFloat());
			continue;
		}

		if (pArea->GetKey() == "UseGlobalTransforms")
		{
			t.UseGlobalTransformations();
			continue;
		}

		if (pArea->GetKey() == "UseLocalTransforms")
		{
			t.UseLocalTransformations();
			continue;
		}

		TAssert(pArea->GetKey() == "Area");
		if (pArea->GetKey() != "Area")
			continue;

		tstring sFile = pArea->FindChildValueString("File");
		TAssert(sFile.length());
		if (!sFile.length())
			continue;

		tstring sMesh = pArea->FindChildValueString("Mesh");
		TAssert(sMesh.length());
		if (!sMesh.length())
			continue;

		tstring sPhysics = pArea->FindChildValueString("Physics");

		auto it = asScenes.find(sFile);
		if (it == asScenes.end())
		{
			TMsg("Reading model '" + GetPath(sFile) + "' ...");
			std::shared_ptr<CConversionScene> pScene(new CConversionScene());
			CModelConverter c(pScene.get());

			if (!c.ReadModel(GetPath(sFile)))
			{
				TError("Couldn't read '" + GetPath(sFile) + "'.\n");
				return false;
			}
			TMsg(" Done.\n");

			asScenes[sFile] = pScene;
		}

		iSceneArea++;

		CToyUtil ts;

		if (t.IsUsingUV())
			ts.UseUV();
		if (t.IsUsingNormals())
			ts.UseNormals();

		ts.SetGameDirectory(t.GetGameDirectory());
		ts.SetOutputDirectory(t.GetOutputDirectory());
		ts.SetOutputFile(tsprintf(t.GetOutputFile() + "_sa%d_" + pArea->GetValueString().tolower(), iSceneArea));
		ts.UseLocalTransformations(t.IsUsingLocalTransformations());

		CConversionSceneNode* pMeshNode = asScenes[sFile]->FindSceneNode(sMesh);
		CConversionSceneNode* pPhysicsNode = nullptr;
		if (sPhysics.length())
		{
			pPhysicsNode = asScenes[sFile]->FindSceneNode(sPhysics);
		
			if (!pPhysicsNode)
				TError("Couldn't find a scene node in '" + sFile + "' named '" + sMesh + "'\n");
		}

		TAssert(pMeshNode);

		TMsg("Building scene area toy ...");

		Matrix4x4 mUpLeftSwap(Vector(1, 0, 0), Vector(0, 0, 1), Vector(0, -1, 0));

		if (pMeshNode)
			LoadSceneNodeIntoToy(asScenes[sFile].get(), pMeshNode, mUpLeftSwap, &ts);
		else
			TError("Couldn't find a scene node in '" + sFile + "' named '" + sMesh + "'\n");

		if (pPhysicsNode)
			LoadSceneNodeIntoToyPhysics(asScenes[sFile].get(), pPhysicsNode, mUpLeftSwap, &ts);

//.........这里部分代码省略.........
开发者ID:BSVino,项目名称:Digitanks,代码行数:101,代码来源:inputscript.cpp

示例7: AddShader

void CShaderLibrary::AddShader(const string& sFile)
{
	TAssert(!Get()->m_bCompiled);
	if (Get()->m_bCompiled)
		return;

	std::basic_ifstream<char> f(sFile.c_str());

	if (!f.is_open())
	{
		TAssert(false);
		// Couldn't open shader file
		return;
	}

	std::shared_ptr<CData> pData(new CData());
	CDataSerializer::Read(f, pData.get());

	CData* pName = pData->FindChild("Name");
	CData* pVertex = pData->FindChild("Vertex");
	CData* pFragment = pData->FindChild("Fragment");

	TAssert(pName);
	if (!pName)
		return;

	TAssert(pVertex);
	if (!pVertex)
		return;

	TAssert(pFragment);
	if (!pFragment)
		return;

	Get()->m_aShaders.push_back(CShader(pName->GetValueString(), pVertex->GetValueString(), pFragment->GetValueString()));
	Get()->m_aShaderNames[pName->GetValueString()] = Get()->m_aShaders.size()-1;

	auto& oShader = Get()->m_aShaders.back();

	for (size_t i = 0; i < pData->GetNumChildren(); i++)
	{
		CData* pChild = pData->GetChild(i);
		if (pChild->GetKey() == "Parameter")
		{
			auto& oParameter = oShader.m_aParameters[pChild->GetValueString()];
			oParameter.m_sName = pChild->GetValueString();

			for (size_t j = 0; j < pChild->GetNumChildren(); j++)
			{
				CData* pUniform = pChild->GetChild(j);
				if (pUniform->GetKey() == "Uniform")
				{
					oParameter.m_aActions.push_back(CShader::CParameter::CUniform());
					auto& oUniform = oParameter.m_aActions.back();
					oUniform.m_sName = pUniform->GetValueString();
					oUniform.m_bTexture = false;
					CData* pValue = pUniform->FindChild("Value");
					CData* pTexture = pUniform->FindChild("Texture");
					TAssert(!(pValue && pTexture));
					TAssert(pValue || pTexture);

					if (pValue)
						oUniform.m_sValue = pValue->GetValueString();
					else if (pTexture)
					{
						oUniform.m_sValue = pTexture->GetValueString();
						oShader.m_asTextures.push_back(pUniform->GetValueString());
						oUniform.m_bTexture = true;
					}
				}
				else if (pUniform->GetKey() == "Blend")
				{
					string& sBlend = oParameter.m_sBlend;
					sBlend = pUniform->GetValueString();
				}
			}
		}
		else if (pChild->GetKey() == "Defaults")
		{
			for (size_t j = 0; j < pChild->GetNumChildren(); j++)
			{
				CData* pUniform = pChild->GetChild(j);
				auto& oDefault = oShader.m_aDefaults[pUniform->GetKey()];
				oDefault.m_sName = pUniform->GetKey();
				oDefault.m_sValue = pUniform->GetValueString();
			}
		}
	}
}
开发者ID:Raki,项目名称:MathForGameDevelopers,代码行数:89,代码来源:shaders.cpp

示例8: ReadLesson

void CInstructor::ReadLesson(const class CData* pData)
{
    tstring sLessonName = pData->GetValueString();
    if (!sLessonName.length())
    {
        TError("Found a lesson with no name.\n");
        return;
    }

    CLesson* pLesson = new CLesson(this, sLessonName);
    m_apLessons[sLessonName] = pLesson;

    for (size_t i = 0; i < pData->GetNumChildren(); i++)
    {
        CData* pChildData = pData->GetChild(i);

        if (pChildData->GetKey() == "Position")
        {
            tstring sPosition = pChildData->GetValueString();
            if (sPosition == "top-center")
                pLesson->m_iPosition = POSITION_TOPCENTER;
            else if (sPosition == "top-left")
                pLesson->m_iPosition = POSITION_TOPLEFT;
            else if (sPosition == "left")
                pLesson->m_iPosition = POSITION_LEFT;
        }
        else if (pChildData->GetKey() == "Width")
            pLesson->m_iWidth = pChildData->GetValueInt();
        else if (pChildData->GetKey() == "Next")
            pLesson->m_sNextLesson = pChildData->GetValueString();
        else if (pChildData->GetKey() == "Text")
            pLesson->m_sText = pChildData->GetValueString();
        else if (pChildData->GetKey() == "SlideAmount")
            pLesson->m_flSlideAmount = pChildData->GetValueFloat();
        else if (pChildData->GetKey() == "SlideX")
            pLesson->m_bSlideX = pChildData->GetValueBool();
        else if (pChildData->GetKey() == "Rotation")
            pLesson->m_bRotation = pChildData->GetValueBool();
        else if (pChildData->GetKey() == "Output")
            ReadLessonOutput(pChildData, pLesson);
        else if (pChildData->GetKey() == "Priority")
            pLesson->m_iPriority = pChildData->GetValueInt();
        else if (pChildData->GetKey() == "LessonType")
        {
            tstring sLessonType = pChildData->GetValueString();
            if (sLessonType == "button")
                pLesson->m_iLessonType = CLesson::LESSON_BUTTON;
            else if (sLessonType == "info")
                pLesson->m_iLessonType = CLesson::LESSON_INFO;
            else if (sLessonType == "environment")
                pLesson->m_iLessonType = CLesson::LESSON_ENVIRONMENT;
        }
        else if (pChildData->GetKey() == "LearningMethod")
        {
            tstring sLearningMethod = pChildData->GetValueString();
            if (sLearningMethod == "displaying")
                pLesson->m_iLearningMethod = CLesson::LEARN_DISPLAYING;
            else if (sLearningMethod == "display")
                pLesson->m_iLearningMethod = CLesson::LEARN_DISPLAYING;
            else if (sLearningMethod == "performing")
                pLesson->m_iLearningMethod = CLesson::LEARN_PERFORMING;
            else if (sLearningMethod == "perform")
                pLesson->m_iLearningMethod = CLesson::LEARN_PERFORMING;
        }
        else if (pChildData->GetKey() == "TimesToLearn")
            pLesson->m_iTimesToLearn = pChildData->GetValueInt();
        else if (pChildData->GetKey() == "Conditions")
            pLesson->m_pfnConditions = Game_GetInstructorConditions(pChildData->GetValueString()); // A dirty hack, but not a scary one.
    }
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:70,代码来源:instructor.cpp

示例9: Open

void CToySource::Open(const tstring& sFile)
{
	Clear();

	FILE* fp = tfopen_asset(sFile, "r");
	if (!fp)
	{
		TError("Could not read input script '" + sFile + "'\n");
		return;
	}

	m_sFilename = sFile;

	std::shared_ptr<CData> pData(new CData());
	CDataSerializer::Read(fp, pData.get());

	CData* pOutput = pData->FindChild("Output");
	CData* pSceneAreas = pData->FindChild("SceneAreas");
	CData* pMesh = pData->FindChild("Mesh");
	CData* pPhysics = pData->FindChild("Physics");
	CData* pPhysicsShapes = pData->FindChild("PhysicsShapes");

	if (pOutput)
		m_sToyFile = pOutput->GetValueString();
	else
		m_sToyFile = "";

	if (pMesh)
		m_sMesh = pMesh->GetValueString();
	else
		m_sMesh = "";

	if (pPhysics)
		m_sPhys = pPhysics->GetValueString();
	else
		m_sPhys = "";

	CData* pGlobalTransforms = pData->FindChild("UseGlobalTransforms");
	m_bUseLocalTransforms = !pGlobalTransforms;

	if (pPhysicsShapes)
	{
		for (size_t i = 0; i < pPhysicsShapes->GetNumChildren(); i++)
		{
			CData* pChild = pPhysicsShapes->GetChild(i);

			TAssert(pChild->GetKey() == "Box");
			if (pChild->GetKey() != "Box")
				continue;

			tvector<tstring> asTokens;
			strtok(pChild->GetValueString(), asTokens);
			TAssert(asTokens.size() == 9);
			if (asTokens.size() != 9)
				continue;

			CPhysicsShape& oShape = m_aShapes.push_back();

			oShape.m_trsTransform = pChild->GetValueTRS();
		}
	}

	if (pSceneAreas)
	{
		for (size_t i = 0; i < pSceneAreas->GetNumChildren(); i++)
		{
			CData* pChild = pSceneAreas->GetChild(i);

			if (pChild->GetKey() == "NeighborDistance")
			{
				m_flNeighborDistance = pChild->GetValueFloat();
				continue;
			}

			if (pChild->GetKey() == "UseGlobalTransforms")
			{
				m_bUseLocalTransforms = false;
				continue;
			}

			if (pChild->GetKey() == "UseLocalTransforms")
			{
				m_bUseLocalTransforms = true;
				continue;
			}

			TAssert(pChild->GetKey() == "Area");
			if (pChild->GetKey() != "Area")
				continue;

			auto& oArea = m_aAreas.push_back();

			oArea.m_sName = pChild->GetValueString();

			CData* pFile = pChild->FindChild("File");
			CData* pMesh = pChild->FindChild("Mesh");
			CData* pPhysics = pChild->FindChild("Physics");

			if (pFile)
				oArea.m_sFilename = pFile->GetValueString();
//.........这里部分代码省略.........
开发者ID:BSVino,项目名称:Digitanks,代码行数:101,代码来源:toyeditor.cpp

示例10: Open

void CToySource::Open(const tstring& sFile)
{
	std::basic_ifstream<tchar> f((sFile).c_str());
	if (!f.is_open())
	{
		TError("Could not read input script '" + sFile + "'\n");
		return;
	}

	m_sFilename = sFile;

	std::shared_ptr<CData> pData(new CData());
	CDataSerializer::Read(f, pData.get());

	CData* pOutput = pData->FindChild("Output");
	CData* pSceneAreas = pData->FindChild("SceneAreas");
	CData* pMesh = pData->FindChild("Mesh");
	CData* pPhysics = pData->FindChild("Physics");
	CData* pPhysicsShapes = pData->FindChild("PhysicsShapes");

	TAssert(!pSceneAreas);	// This is unimplemented.

	if (pOutput)
		m_sToyFile = pOutput->GetValueString();
	else
		m_sToyFile = "";

	if (pMesh)
		m_sMesh = pMesh->GetValueString();
	else
		m_sMesh = "";

	if (pPhysics)
		m_sPhys = pPhysics->GetValueString();
	else
		m_sPhys = "";

	if (pPhysicsShapes)
	{
		for (size_t i = 0; i < pPhysicsShapes->GetNumChildren(); i++)
		{
			CData* pChild = pPhysicsShapes->GetChild(i);

			TAssert(pChild->GetKey() == "Box");
			if (pChild->GetKey() != "Box")
				continue;

			tvector<tstring> asTokens;
			strtok(pChild->GetValueString(), asTokens);
			TAssert(asTokens.size() == 9);
			if (asTokens.size() != 9)
				continue;

			CPhysicsShape& oShape = m_aShapes.push_back();

			oShape.m_trsTransform = pChild->GetValueTRS();
		}
	}

	ToyEditor()->MarkSaved();
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:61,代码来源:toyeditor.cpp


注:本文中的CData::GetKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。