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


C++ IArchive::SetIsWriting方法代码示例

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


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

示例1: GetCreditCount

int GameComponent::GetCreditCount()
{
#ifdef _SHELL
	// get hardware credits
	return ::GetCreditCount();	
#else
	// get software credits
	IArchive *archive = CreateMemoryArchive();
	if (archive)
	{
		archive->SetIsWriting(true);
		CHashString hsAttribName(_T("Credits"));
		GetGlobalAttribute(&hsAttribName, archive);

		archive->SetIsWriting(false);
		int credits = 0;
		archive->Read(credits, _T("Credits"));
		archive->Close();
		return credits;
	}

	return 0;

#endif
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:25,代码来源:GameComponent.cpp

示例2: DeductCredits

int GameComponent::DeductCredits( int credits )
{
#ifdef _SHELL
	// deduct hardware credits
	return ::DeductCredits( credits );
#else
	// deduct software credits
	IArchive *archive = CreateMemoryArchive();
	if (archive)
	{
		archive->SetIsWriting(true);
		CHashString hsAttribName(_T("Credits"));
		GetGlobalAttribute(&hsAttribName, archive);

		archive->SetIsWriting(false);
		int currCredits = 0;
		archive->Read(currCredits, _T("Credits"));
		
		currCredits -= credits;
        SetGlobalAttribute(&hsAttribName, currCredits);

		archive->Close();
	}

	return 0;
#endif
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:27,代码来源:GameComponent.cpp

示例3: UpdateWorldEventTrigger

void CWorldEventToolPal::UpdateWorldEventTrigger( void )
{
	static DWORD msgHash_FindObject = CHashString(_T("FindObject")).GetUniqueID();
	static DWORD msgHash_GetComponentType = CHashString(_T("GetComponentType")).GetUniqueID();
	static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
	static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();

	static CHashString Hash_Type = CHashString(_T("CWorldEventTrigger"));

	CString buf;
	m_Name.GetLBText(m_Name.GetCurSel(), buf);
	CHashString hszName((TCHAR*)buf.GetBuffer());
	FINDOBJECTPARAMS param;
	param.hszName = &hszName;
	DWORD result = m_ToolBox->SendMessage(msgHash_FindObject, sizeof(FINDOBJECTPARAMS), &param);

	// object exists 
	if( param.bFound == true )
	{
		GETCOMPONENTTYPEPARAMS gctp;
		gctp.name = &hszName;
		m_ToolBox->SendMessage(msgHash_GetComponentType, sizeof(gctp), &gctp);

		// it is a world event, get values from it
		if ( (gctp.componenttype != NULL) && (gctp.componenttype->GetUniqueID() == Hash_Type.GetUniqueID()) )
		{
			CREATEARCHIVE ca;
			CHashString streamType(_T("Memory"));
			ca.streamData = NULL;
			ca.mode = STREAM_MODE_WRITE | STREAM_MODE_READ;
			ca.streamType = &streamType;
	 	
			m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca, NULL, NULL);
			IArchive *MemArchive = (ca.archive);

			MemArchive->SetIsWriting(true);
			MemArchive->SeekTo(0);

			SERIALIZEOBJECTPARAMS sop;
			sop.name = &hszName;
			sop.archive = MemArchive;
			m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);

			MemArchive->SetIsWriting(false);
			MemArchive->SeekTo(0);

			StdString tmp;
			MemArchive->Read( tmp );
			m_EntityName.SetWindowText( tmp.c_str() );
			MemArchive->Read( tmp );
			m_EntityType.SetWindowText( tmp.c_str() );
			MemArchive->Read( tmp );
			m_EventName.SetWindowText( tmp.c_str() );
			
			MemArchive->Close();
		}
	}
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:58,代码来源:WorldEventToolPal.cpp

示例4: LoadModel

void CModelViewRender::LoadModel()
{
    ASSERT(GetDocument() != NULL);
    CString strPath = GetDocument()->GetPathName();
    LPCTSTR szPath = strPath;
    TCHAR extStr[_MAX_EXT];
    TCHAR fileName[_MAX_FNAME];
    _tsplitpath(szPath, NULL, NULL, fileName, extStr);

    if (strPath.IsEmpty())
    {
        m_ToolBox->Log(LOGWARNING, _T("%s(%i):LoadModel shouldn't have been called with NULL path\n"), __FILE__, __LINE__);
        return;
    }

    StdString szFilename = fileName;
    szFilename += extStr;
    m_hszModelName = szFilename;

    CFileVersionSetter setter( _T("2.5") );

    if (0 == _tcsicmp(extStr, _T(".cfg")))
    {
        IArchive *pArchive = CreateMemoryArchive();
        if (pArchive != NULL)
        {
            pArchive->Write(szPath, _T("Filepath"));
            pArchive->SetIsWriting(false);
            static CHashString hszCal3DRenderObject(_T("Cal3DRenderObject"));
            CreateEEObject(&m_hszEntityName, &hszCal3DRenderObject, m_hszModelName, pArchive);
            FillAnimationList();
            pArchive->Close();
        }
    }
    else if (0 == _tcsicmp(extStr, _T(".hrc")))
    {
        IArchive *pArchive = CreateMemoryArchive();
        if (pArchive != NULL)
        {
            pArchive->Write(szPath);
            pArchive->SetIsWriting(false);
            static CHashString hszCal3DRenderObject(_T("CHierarchicalModel"));
            CreateEEObject(&m_hszEntityName, &hszCal3DRenderObject, m_hszModelName, pArchive);
            pArchive->Close();
        }
    }
    else
    {
        m_ToolBox->Log(LOGWARNING, _T("%s(%i):LoadModel was passed %s extension, which is not recognized\n"), __FILE__, __LINE__, extStr);
    }
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:51,代码来源:ModelViewRender.cpp

示例5: SetGlobalAttribute

void GameComponent::SetGlobalAttribute( IHashString *attributeName, bool value )
{
	if( attributeName != NULL )
	{
		IArchive *archive = CreateMemoryArchive();
		archive->SetIsWriting( true );
		archive->Write( (bool)value );
		archive->SetIsWriting( false );

		SetGlobalAttribute( attributeName, archive );

		archive->Close();
	}
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:14,代码来源:GameComponent.cpp

示例6: CreateScene

void CModelViewRender::CreateScene()
{
    Vec3 v3Zero(0.0f, 0.0f, 0.0f);
    EulerAngle eZero;
    Vec3 v3Scale(1.0f,1.0f,1.0f);
    StdString szEntityType(_T("EditorObject"));

    IArchive *pArchive = CreateMemoryArchive();
    pArchive->Write(_T("EditorObject"), _T("EntityType"));
    pArchive->Write(v3Zero, _T("Position"));
    pArchive->Write(eZero, _T("Rotation"));
    pArchive->Write(v3Scale, _T("Scale"));
    pArchive->SetIsWriting(false);

    // Create Instance of CEntity
    static CHashString hszEntity(_T("CEntity"));
    CreateEEObject(&m_hszSceneName, &hszEntity, m_hszEntityName, pArchive);

    pArchive->Close();

    m_v3Position.Set(0, 0, 0);
    m_v3CameraPos.Set(0.0f, 0.0f, 200.0f);
    m_v3Rotation.Set(0.0f, 0.0f, 0.0f);

    LoadModel();
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:26,代码来源:ModelViewRender.cpp

示例7: GetType

DWORD CSchemaItem::GetType( DATABASEATTRIBUTEPARAMS *databaseAttributeParams )
{
	DWORD retVal = MSG_NOT_HANDLED;
	if( databaseAttributeParams != NULL )
	{
		
		if( databaseAttributeParams->m_AttributeTypeArchive != NULL )
		{
			IArchive *ar = databaseAttributeParams->m_AttributeTypeArchive;
			ar->SetIsWriting( true );
			ar->SeekTo( 0 );
			ar->Write( m_hszType.GetString() );
		}
		else
		{
			m_ToolBox->Log( LOGWARNING, _T("No archive specified for GetAttributeType.\n") );
		}

		retVal = MSG_HANDLED_STOP;
	}
	else
	{
		m_ToolBox->Log( LOGWARNING, _T("Attribute parameters not defined.\n") );
	}

	return retVal;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:27,代码来源:SchemaItem.cpp

示例8: OnUpdateLanguageEntryParams

DWORD CGUIStaticText::OnUpdateLanguageEntryParams(DWORD size, void *param)
{
	VERIFY_MESSAGE_SIZE(size, sizeof(IArchive*));
	IArchive* ar = (IArchive*) param;

	if (ar)
	{
		if (m_LanguageTextParams != NULL)
		{
			delete [] m_LanguageTextParams;
			m_LanguageTextParams = NULL;
		}
		// do deep copy of archive params
		UINT archiveSize = ar->SeekTo(0, SEEK_END);

		if (archiveSize > 0)
		{		
			ar->SeekTo(0, SEEK_SET);
			ar->SetIsWriting(false);

			m_LanguageTextParams = new BYTE[archiveSize];
			ar->Read(m_LanguageTextParams, archiveSize);

			m_iLangTextParamSize = archiveSize;
		}
	}

	UpdateLanguageEntryText();

	return MSG_HANDLED_STOP;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:31,代码来源:CGUIStaticText.cpp

示例9: CreateAndFillArchive

IArchive* CGUIStaticText::CreateAndFillArchive()
{
	if (m_LanguageTextParams)
	{
		CREATEARCHIVE ca;
		static CHashString memType(_T("Memory"));

		ca.mode = STREAM_MODE_WRITE | STREAM_MODE_READ;
		ca.streamData = NULL;
		ca.streamSize = 0;
		ca.streamType = &memType;
		static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
		m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca);

		IArchive *ar = ca.archive;
		if (ar)
		{
			ar->SetIsWriting(true);
			ar->SeekTo(0);
			ar->Write(m_LanguageTextParams, m_iLangTextParamSize);
		}
		return ar;
	}
	else
	{
		return NULL;
	}
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:28,代码来源:CGUIStaticText.cpp

示例10: TestCreateNode

bool CNodeSystemTest::TestCreateNode()
{
	bool result = true;
	bool subResult = false;

	CHashString hszNodeName(_T("Node1"));
	CHashString hszNodeType(_T("CNode"));

	m_dialogEditControl->ReplaceSel(_T("  Testing Creation of Node 1 - \n"));
	CreateObject( &hszNodeName, NULL, &hszNodeType );

	InitializeObject( &hszNodeName );

	m_dialogEditControl->ReplaceSel(_T("    Created node found in engine: "));

	subResult = FindObject( &hszNodeName );
	SUBREPORT( subResult );
	result = result && subResult;

	m_dialogEditControl->ReplaceSel(_T("    Verify default values: "));
	IArchive *archive = CreateMemoryArchive();
	SerializeObject( &hszNodeName, archive, true );

	float fVersion;
	float fX;
	float fY;
	float fZ;
	archive->SetIsWriting( false );
	archive->Read( fVersion );
	archive->Read( fX );
	archive->Read( fY );
	archive->Read( fZ );
	archive->Close();

	subResult = fVersion == 1.0f;
	subResult = subResult && fX == 0.0f;
	subResult = subResult && fY == 0.0f;
	subResult = subResult && fZ == 0.0f;
	SUBREPORT( subResult );

	result = result && subResult;

	DeleteObject( &hszNodeName );

	m_dialogEditControl->ReplaceSel(_T("  TestCreateNode overall: "));
	return result;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:47,代码来源:NodeSystemTest.cpp

示例11: PlaySequence

void CModelViewRender::PlaySequence(const ANIMATIONSEQUENCE &sequence)
{
    // make a copy of the requested sequence
    m_PlayingAnimationSequence.clear();
    std::copy(sequence.begin(), sequence.end(), std::back_inserter(m_PlayingAnimationSequence));
    m_itCurrentAnimationID = m_PlayingAnimationSequence.begin();

    // create all the callbacks at once for the sequence
    set<int> uniqueCallbackSet;
    for (ANIMATIONSEQUENCE::iterator itrAnim = m_PlayingAnimationSequence.begin(); itrAnim != m_PlayingAnimationSequence.end(); itrAnim++)
    {
        // skip duplicate animations (only need to make one callback per animation)
        if (uniqueCallbackSet.find( *itrAnim ) != uniqueCallbackSet.end())
            continue;

        IArchive* pArchive = CreateMemoryArchive();
        pArchive->Write(m_hszEntityName.GetString(), _T("EntityName"));
        pArchive->Write(*itrAnim);
        pArchive->SetIsWriting(false);
        m_AnimationCallbackArchives.push_back( pArchive );

        static CHashString hszCal3DRenderObject = _T("Cal3DRenderObject");
        static CHashString hszCModelViewComponent(_T("CModelViewComponent"));
        static CHashString hszPlayAnimationSequenceStep(_T("PlayAnimationSequenceStep"));

        REGISTERCAL3DANIMATIONCALLBACK ac;
        ac.AnimationId = *itrAnim;
        ac.bTriggerOnComplete = true;
        ac.bTriggerOnStop = false;
        ac.StateObjectName = &hszCModelViewComponent;
        ac.EventName = &hszPlayAnimationSequenceStep;
        ac.EventParamsArchive = pArchive;

        static DWORD msgHash_RegisterAnimationCallback = CHashString(_T("RegisterAnimationCallback")).GetUniqueID();
        DWORD res = m_ToolBox->SendMessage(msgHash_RegisterAnimationCallback, sizeof(ac), &ac, &m_hszEntityName, &hszCal3DRenderObject);
        if (MSG_HANDLED != res)
        {
            m_ToolBox->Log(LOGERROR, _T("%s(%i): Cannot register animation callback. \n"), __FILE__, __LINE__);
        }
        uniqueCallbackSet.insert( *itrAnim );
    }

    if (HasAnimation())
    {
        SINGLETONINSTANCE(CModelViewComponent)->PlayAnimation(this);
    }
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:47,代码来源:ModelViewRender.cpp

示例12: OnCreateXMLArchiveStream

DWORD CArchiveFactory::OnCreateXMLArchiveStream(DWORD size, void *param)
{
	IArchive *newArchive;
	CREATEARCHIVE *ca;
	CREATESTREAM cs;
	StdString csMessage;
	DWORD retVal;
	VERIFY_MESSAGE_SIZE(size, sizeof(CREATEARCHIVE));
	ca = (CREATEARCHIVE *)param;

	cs.streamData = ca->streamData;
	cs.streamSize = ca->streamSize;
	cs.mode = ca->mode;
	csMessage = _T("CreateStream_");
	csMessage += ca->streamType->GetString();
	// try and create the stream
	DWORD msgHash_csMessage = CHashString(csMessage).GetUniqueID();
	retVal = m_ToolBox->SendMessage(msgHash_csMessage, sizeof(CREATESTREAM), &cs);
	if (retVal != MSG_HANDLED)
	{
		return retVal;
	}

	try
	{
		newArchive = new CXMLArchive();
	}
	catch(...)
	{
		delete cs.openStream;
		return MSG_ERROR;
	}

	// check if we are creating a read and write stream
	if( (cs.mode & (STREAM_MODE_READ | STREAM_MODE_WRITE)) == (STREAM_MODE_READ | STREAM_MODE_WRITE))
	{
		newArchive->SetIsWriting( true );
	}

	// initalize it with the stream
	newArchive->Init(cs.openStream);

	ca->archive = newArchive;

	return MSG_HANDLED_STOP;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:46,代码来源:CArchiveFactory.cpp

示例13: TestCreateNodeConnection

bool CNodeSystemTest::TestCreateNodeConnection()
{
	bool result = true;
	bool subResult = false;

	CHashString hszNodeConnectionName(_T("NodeConnection1"));
	CHashString hszNodeConnectionType(_T("CNodeConnection"));

	m_dialogEditControl->ReplaceSel(_T("  Testing Creation of Node Connection 1 - \n"));
	CreateObject( &hszNodeConnectionName, NULL, &hszNodeConnectionType );

	InitializeObject( &hszNodeConnectionName );

	m_dialogEditControl->ReplaceSel(_T("    Created node found in engine: "));

	subResult = FindObject( &hszNodeConnectionName );
	SUBREPORT( subResult );
	result = result && subResult;

	m_dialogEditControl->ReplaceSel(_T("    Verify default values: "));
	IArchive *archive = CreateMemoryArchive();
	SerializeObject( &hszNodeConnectionName, archive, true );

	float fVersion;
	StdString szNode1;
	StdString szNode2;
	archive->SetIsWriting( false );
	archive->Read( fVersion );
	archive->Read( szNode1 );
	archive->Read( szNode2 );
	archive->Close();

	subResult = fVersion == 1.0f;
	subResult = subResult && szNode1 == "";
	subResult = subResult && szNode2 == "";
	SUBREPORT( subResult );

	result = result && subResult;

	DeleteObject( &hszNodeConnectionName );
	m_dialogEditControl->ReplaceSel(_T("  TestCreateNodeConnection overall: "));
	return result;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:43,代码来源:NodeSystemTest.cpp

示例14: OnPlaySound

DWORD CSoundManager::OnPlaySound(DWORD size, void *params)
{
	VERIFY_MESSAGE_SIZE(sizeof(PLAYSOUNDPARAMS), size);
	PLAYSOUNDPARAMS psp = *(PLAYSOUNDPARAMS *)params;

	if ( psp.fileName == NULL )
	{
		m_ToolBox->SetErrorValue(ERR_NULL_POINTER);
		m_ToolBox->Log( LOGWARNING, _T("CSoundManager error: malformed PLAYSOUNDPARAMS struct (fileName is NULL)\n"));
		return MSG_NOT_HANDLED;
	}

	CHashString hsObjName;
	GENERATEUNIQUEOBJECTNAMEPARAMS guonp;
	guonp.name = psp.fileName;
	guonp.newname = &hsObjName;
	static DWORD msgGenerateUniqueObjectName = CHashString(_T("GenerateUniqueObjectName")).GetUniqueID();
	if (m_ToolBox->SendMessage(msgGenerateUniqueObjectName, sizeof(GENERATEUNIQUEOBJECTNAMEPARAMS), &guonp) != MSG_HANDLED)
	{
		m_ToolBox->Log(LOGERROR, _T("CSoundManager could not generate a unique object name for sound %s\n"), psp.fileName->GetString());
		return MSG_ERROR;
	}

	IComponent *soundComp = m_ToolBox->CreateComponent(&m_hsSoundObjTypeName, 3, &hsObjName, psp.hsParentName, psp.bInHierarchy);
	if (soundComp == NULL)
	{
		m_ToolBox->Log(LOGWARNING, _T("Sound manager: unable to create Sound Object %s, in file %s at line %d\n"),
			hsObjName.GetString(), __FILE__, __LINE__);
		return MSG_NOT_HANDLED;
	}

	OFACTORYADDPARAMS ofap;
	ofap.name = &hsObjName;
	ofap.component = soundComp;
	static DWORD msgHash_AddObjectToFactory = CHashString(_T("AddObjectToFactory")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_AddObjectToFactory, sizeof(OFACTORYADDPARAMS), &ofap);

	ISoundObject *newSoundObject = dynamic_cast<ISoundObject*>(soundComp);
	if (newSoundObject == NULL)
	{
		m_ToolBox->Log(LOGWARNING, _T("COpenALSoundManager: could not cast component to a CSoundObject!\n"));
		assert(newSoundObject);
		return MSG_NOT_HANDLED;
	}

	CREATEARCHIVE ca;
	ca.mode = STREAM_MODE_WRITE | STREAM_MODE_READ;
	ca.streamData = NULL; // use internal buffer
	ca.streamSize = 0;
	CHashString memType(_T("Memory"));
	ca.streamType = &memType;
	static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
	if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca) != MSG_HANDLED)
	{
		return MSG_ERROR;
	}
	IArchive *MemArchive = ca.archive;

	MemArchive->SetIsWriting(true);

	// some pre-checks
	bool autoRemove = true;
	bool is3DSound = false;

	// always have to auto remove if the remote creator isn't going to keep track of the object
	if (psp.objectName != NULL)
	{
		autoRemove = psp.autoRemove;
	}

	if (psp.is3DSound)
	{
		if (psp.soundPosition != NULL)
		{
			is3DSound = true;
		}
		else
		{
			m_ToolBox->Log(LOGWARNING, _T("Sound manager: play sound position is null for sound %s; 3D sound will play in 2D space\n"), psp.fileName->GetString());
		}
	}

	// coordinates with sound obj serialization
	MemArchive->Write(1.1f, _T("Version"));
	MemArchive->Write(psp.fileName->GetString(), _T("FileName"));
	MemArchive->Write(psp.volume, _T("MaxVolume"));
	MemArchive->Write(autoRemove, _T("AutoRemove"));
	MemArchive->Write(is3DSound, _T("Is3DSound"));	
	MemArchive->Write(psp.looping, _T("IsLooping"));
	MemArchive->Write(true, _T("AutoStart"));
	MemArchive->Write(psp.pitch, _T("PitchMultiplier"));

	MemArchive->SetIsWriting(false);

	SERIALIZEOBJECTPARAMS sop;
	sop.name = &hsObjName;
	sop.archive = MemArchive;
	static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);

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

示例15: OnLoadSoundDatabase

DWORD COpenALSoundUtility::OnLoadSoundDatabase(DWORD size, void* param)
{
	VERIFY_MESSAGE_SIZE(size, sizeof(IHashString));
	IHashString *dbFileName = (IHashString*) param;

	if ((dbFileName != NULL) && (_tcscmp(dbFileName->GetString(), _T("")) != 0))
	{
		TCHAR *fileName = _tcsdup(dbFileName->GetString());
		LOADFILEEXTPARAMS lfep;
		lfep.fileName = fileName;
		lfep.bInternalLoad = true;

		static DWORD msgLoadFileByExtension = CHashString(_T("LoadFileByExtension")).GetUniqueID();
		DWORD retval = m_ToolBox->SendMessage(msgLoadFileByExtension, sizeof(LOADFILEEXTPARAMS), &lfep);
		free( fileName );
		if (retval == MSG_HANDLED)
		{
			// clear prior sound list - not additive, exclusive!
			m_SoundMap.clear();
			
			CHashString hsSoundDBObject;
			DATABASEINFO dbi;
			dbi.m_FileName = dbFileName;
			static DWORD msgGetDatabase = CHashString(_T("GetDatabase")).GetUniqueID();
			retval = m_ToolBox->SendMessage(msgGetDatabase, sizeof(DATABASEINFO), &dbi);
			if (retval == MSG_HANDLED)
			{
				hsSoundDBObject.Init(dbi.m_DatabaseName->GetString());
				DATABASEATTRIBUTEPARAMS dap;
				CREATEARCHIVE ca;
				static CHashString memType(_T("Memory"));

				ca.mode = STREAM_MODE_WRITE | STREAM_MODE_READ;
				ca.streamData = NULL;
				ca.streamSize = 0;
				ca.streamType = &memType;
				static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
				m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca);

				IArchive *attribArchive = ca.archive;
				if (attribArchive == NULL)
				{
					m_ToolBox->Log(LOGERROR, _T("Sound manager: archive is null; could not get sound attributes!\n\tNo sounds loaded!\n"));
					return MSG_ERROR;
				}

				dap.m_AttributeArchive = attribArchive;

				static DWORD msgGetAttribute = CHashString(_T("GetAttribute")).GetUniqueID();
				static CHashString hsKeyString(_T("KeyString"));
				static CHashString hsFileName(_T("FileName"));
				static CHashString hsGlobalVolume(_T("GlobalVolume"));
				static CHashString hsCachedUncompressed(_T("CacheUncompressed"));

				static CHashString hsDBType(_T("CDefinedDatabase"));
				for (UINT i=0; i<(UINT)dbi.m_nItems; i++)
				{
					// get key string
					attribArchive->SeekTo(0, SEEK_SET);
					dap.m_Index = i;
					dap.m_AttributeName = &hsKeyString;
					retval = m_ToolBox->SendMessage(msgGetAttribute, sizeof(DATABASEATTRIBUTEPARAMS), &dap, &hsSoundDBObject, &hsDBType);
					if (retval != MSG_HANDLED)
					{
						m_ToolBox->Log(LOGERROR, _T("Sound manager: could not get key attribute for row %d; sounds not fully loaded!\n"), i);
						attribArchive->Close();
						return MSG_ERROR;
					}

					CHashString hsKey;
					StdString szKey;
					attribArchive->SetIsWriting(false);
					attribArchive->Read(szKey);
					hsKey = szKey;

					// get filename
					attribArchive->SeekTo(0, SEEK_SET);
					dap.m_AttributeName = &hsFileName;
					retval = m_ToolBox->SendMessage(msgGetAttribute, sizeof(DATABASEATTRIBUTEPARAMS), &dap, &hsSoundDBObject, &hsDBType);
					if (retval != MSG_HANDLED)
					{
						m_ToolBox->Log(LOGERROR, _T("Sound manager: could not get file attribute for row %d; sounds not fully loaded!\n"), i);
						attribArchive->Close();
						return MSG_ERROR;
					}

					CHashString hsFile;
					StdString szFile;
					attribArchive->SetIsWriting(false);
					attribArchive->Read(szFile);
					szFile.tolower();
					hsFile = szFile;

					// get volume
					attribArchive->SeekTo(0, SEEK_SET);
					dap.m_AttributeName = &hsGlobalVolume;
					retval = m_ToolBox->SendMessage(msgGetAttribute, sizeof(DATABASEATTRIBUTEPARAMS), &dap, &hsSoundDBObject, &hsDBType);
					if (retval != MSG_HANDLED)
					{
						m_ToolBox->Log(LOGERROR, _T("Sound manager: could not get volume attribute for row %d; sounds not fully loaded!\n"), i);
//.........这里部分代码省略.........
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:101,代码来源:OpenALSoundUtility.cpp


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