本文整理汇总了C++中IArchive::IsReading方法的典型用法代码示例。如果您正苦于以下问题:C++ IArchive::IsReading方法的具体用法?C++ IArchive::IsReading怎么用?C++ IArchive::IsReading使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IArchive
的用法示例。
在下文中一共展示了IArchive::IsReading方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SerializeDatabaseItem
void CSchemaItem::SerializeDatabaseItem( ATTRIBUTEIDTODATAMAP &valuesMap, IArchive &ar )
{
if( valuesMap.find( m_hszLabel.GetUniqueID() ) == valuesMap.end() || valuesMap[m_hszLabel.GetUniqueID()] == NULL )
{
valuesMap[m_hszLabel.GetUniqueID()] = new DATABASEDATA( m_DefaultValue );
}
DATABASEDATA *value = valuesMap[m_hszLabel.GetUniqueID()];
TCHAR *tag = (TCHAR*)m_hszLabel.GetString();
if( ar.IsReading() )
{
DBRead( value, &ar, tag );
}
else
{
DBWrite( value, &ar, tag );
}
}
示例2: Serialize
void CPrecacheObject::Serialize( IArchive &ar )
{
if( ar.IsReading() )
{
// Version
ar.Read( m_iVersion );
// Number of Entries
unsigned int tmpCount;
ar.Read( tmpCount );
// Read Entries and insert into the list
for( unsigned int i = 0; i < tmpCount; i++ )
{
CHashString hszResourceName;
StdString szResourceName;
ar.Read( szResourceName );
hszResourceName.Init( szResourceName );
m_ResourceSet.insert( hszResourceName.GetUniqueID());
}
}
else
{
// Version
ar.Write( m_iVersion, _T("Version") );
// Number of Entries
ar.Write( (int)m_ResourceSet.size(), _T("NumEntries") );
// Write out all the Entries from the list
RESOURCESET::iterator itr = m_ResourceSet.begin();
StdString szPrecacheEntry( _T("PrecacheEntry") );
while( itr != m_ResourceSet.end() )
{
ar.StartClass( szPrecacheEntry );
ar.Write( m_ToolBox->GetHashString( *itr ), _T("Name") );
ar.EndClass();
itr++;
}
}
}
示例3: Serialize
void CQHStateMachineActionHandler::Serialize( IArchive &ar )
{
if( ar.IsReading() )
{
float fVersion;
StdString tempStr;
ar.Read( fVersion, _T("version") );
if( fVersion > m_fCurrentVersion )
{
LPCTSTR fmt = _T("%s(%d): Unsupported version (%f) of state machine action handler");
m_ToolBox->Log( LOGERROR, fmt, __FILE__, __LINE__, fVersion );
return;
}
ar.Read( tempStr, _T("name") );
m_szName.Init( tempStr );
ar.Read( tempStr, _T("actionName") );
m_szActionName.Init( tempStr );
IComponent *amanagerComponent = m_ToolBox->GetComponent( GetManagerName() );
CQHStateMachineManager *amanager = static_cast<CQHStateMachineManager*>( amanagerComponent );
CQHStateMachineEvent *aparentEvent = amanager->GetEvent( GetParentName() );
if( aparentEvent != NULL )
{
aparentEvent->AddActionHandler( this );
}
else
{
m_ToolBox->Log( LOGERROR, _T("Could not find parent event %s for action handler %s."), GetParentName()->GetString(), GetName()->GetString() );
}
}
else
{
ar.Write( m_fCurrentVersion, _T("version") );
ar.Write( m_szName.GetString(), _T("name") );
ar.Write( m_szActionName.GetString(), _T("actionName") );
}
}
示例4: Serialize
void CSchemaItem::Serialize( IArchive &ar )
{
if( ar.IsReading() )
{
StdString name; // Dummy variable to read the name. It should already be stored as CObjectTemplate
StdString type;
StdString attributeClass;
ar.Read( m_fVersion, _T("Version") );
ar.Read( name, _T("Name") );
ar.Read( type, _T("Type") );
ar.Read( attributeClass, _T("Class") );
m_hszLabel.Init( name );
m_hszType.Init( type );
m_hszClass.Init( attributeClass );
DBRead( &m_DefaultValue, &ar, _T("Default") ); // IMPORTANT: DBRead is dependent on m_hszType. Make sure m_hszType has been initialized before calling DBRead.
// NOTE: We are assuming the order in which schema items are instantiated will be
// the order in which to read data items.
if( m_Schema != NULL )
{
m_Schema->RegisterSchemaItem( this );
}
}
else
{
ar.StartClass(_T("CSchemaItem"));
ar.Write( m_fVersion, _T("Version") );
ar.Write( m_hszLabel.GetString(), _T("Name") );
ar.Write( m_hszType.GetString(), _T("Type") );
ar.Write( m_hszClass.GetString(), _T("Class") );
DBWrite( &m_DefaultValue, &ar, _T("Default") );
ar.EndClass();
}
}
示例5: Serialize
//---------------------------------------------------------------------
// Function: Serialize
// Description: serializes the values
// (deserializaton if ar.IsReading() returns ture)
// The order of the values if bound
// Parameters: ar - IArchive object which shows if we are reading or writing
//---------------------------------------------------------------------
void CProjectSettings::Serialize(IArchive &ar)
{
unsigned int i;
if (ar.IsReading())
{
// Restore everthing to default
Init();
// set the variables according to the data in the file
ar.Read(m_szProjectName);
ar.Read(m_szVersion);
ar.Read(m_szDirectory);
ar.Read(m_szStartScriptName);
ar.Read(m_szLastWorldFile);
ar.Read(m_iNumDlls);
// clear the previous Dll list
m_ProjectDLLs.clear();
for (i=0; i<m_iNumDlls; i++)
{
StdString dllName;
ar.Read(dllName);
m_ProjectDLLs.push_back( dllName );
}
//reading the other tags are done in the loadSaver project
//it attempts to call the serialize function of the objects
//with the names of the xml tags.
}
else
{
ar.Write(m_szProjectName, "ProjectName");
ar.Write(m_szVersion, "Version");
ar.Write(m_szDirectory, "Directory");
ar.Write(m_szStartScriptName, "StartupScript");
ar.Write(m_szLastWorldFile, "LastWorldFile");
ar.Write(m_iNumDlls, "NumDLLS");
for (i=0; i<m_iNumDlls; i++)
{
ar.StartClass("ProjectDLL");
ar.Write(m_ProjectDLLs[i], "name");
ar.EndClass();
}
}
// both save and load means that no change has happend "since last save"
IsChangedSinceLastSave = FALSE;
// make the project ready to save/close
// save happens only if IsChangedSince... is also true, so incorrect
// data can't be saved, because the dialog box checks consistency.
SetSettingsStateConsistency( TRUE );
//TODO: the following are necessary only on project load?
// than they can be moved to the load part of the if branches above...
// change EE resource directory manually
EngineGetToolBox()->SetDirectories(NULL , &m_szDirectory);
// Loading a new project usually changes the resource directory as well.
// As the m_szDirectory setter would send out the change message but it is
// not called if on project load, we need to send it manually
// Although the new dir is the content of the message, the most plugins will
// use only the message to recognize they need to refresh their value and they
// we get the new value from EE toolbox instead of the content of this message.
SETWORKINGDIRECTORIESPARAMS swdp;
swdp.ResourceDirectory = NULL;
swdp.BaseDirectory = &m_szDirectory;
static DWORD msgHash_SetDirectories = CHashString(_T("SetResourceDirectory")).GetUniqueID();
EngineGetToolBox()->SendMessage(msgHash_SetDirectories, sizeof(SETWORKINGDIRECTORIESPARAMS), &swdp );
// we need to set the current working dir of the OS.
// this is a win32 plugin, so we can call it directly:
SetCurrentDirectory( m_szDirectory.c_str() );
}
示例6: Serialize
void CLuaScriptVarList::Serialize(IArchive &ar )
{
if(ar.IsReading())
{
// Read the Schema File Name
StdString tmpFileName;
ar.Read( tmpFileName, _T("Schema") );
m_SchemaFileName = tmpFileName;
// Read the VarCount for Parsing Purposes
unsigned int VarCount = 0;
ar.Read( VarCount, _T("VarCount") );
for( unsigned int i = 0; i < VarCount; i++ )
{
CLuaScriptVar tmpVar;
StdString tmpStringName;
StdString tmpStringValue;
bool tmpBoolIsDefault;
ar.Read( tmpStringName, _T("Name") );
ar.Read( tmpStringValue, _T("Value") );
ar.Read( tmpBoolIsDefault, _T("Default") );
tmpVar.SetName( tmpStringName );
tmpVar.SetValue( tmpStringValue );
tmpVar.SetIsDefault( tmpBoolIsDefault );
bool bFound = false;
for( unsigned int j = 0; j < m_Variables.size(); j++ )
{
if( tmpVar.GetName() == m_Variables[j].GetName() )
{
bFound = true;
if( tmpVar.GetValueAsString() != m_Variables[j].GetValueAsString() )
{
m_Variables[j].SetValue( tmpVar.GetValueAsString() );
m_Variables[j].SetIsDefault( false );
}
break;
}
}
if( bFound == false )
{
m_Variables.push_back( tmpVar );
}
}
}
else
{
ar.Write( m_SchemaFileName.GetString(), _T("Schema") );
// Read the VarCount for Parsing Purposes
ar.Write( (unsigned int)m_Variables.size(), _T("VarCount") );
for( unsigned int i = 0; i < m_Variables.size(); i++ )
{
ar.StartClass(_T("CLuaScriptVar") );
ar.Write( m_Variables[i].GetName(), _T("Name") );
ar.Write( m_Variables[i].GetValueAsString(), _T("Value") );
ar.Write( m_Variables[i].GetIsDefault(), _T("Default") );
ar.EndClass();
}
}
}
示例7: Serialize
void CTimeOfDayObject::Serialize( IArchive &ar )
{
if(ar.IsReading())
{
// clear lists otherwise we will keep adding to them!!
m_vSunLightFrames.clear();
m_vFogFrames.clear();
ar.Read( m_fTimeStart, _T("TimeStart") );
ar.Read( m_fTimeRate, _T("TimeRate") );
int iNumSunLightFrames = 0;
ar.Read( iNumSunLightFrames, _T("NumSunLightFrames") );
int iNumFogFrames = 0;
ar.Read( iNumFogFrames, _T("NumFogFrames") );
for( int i = 0; i < iNumSunLightFrames; i++ )
{
SUNLIGHTKEYFRAME tmpSunLightFrame;
ar.Read( tmpSunLightFrame.m_wszName, _T("Name") );
ar.Read( tmpSunLightFrame.m_AmbientColor, _T("AmbientColor") );
ar.Read( tmpSunLightFrame.m_FullbrightColor, _T("FulLBrightColor") );
ar.Read( tmpSunLightFrame.m_fDawnWeight, _T("DawnWeight") );
ar.Read( tmpSunLightFrame.m_fNightWeight, _T("NightWeight") );
m_vSunLightFrames.push_back( tmpSunLightFrame );
}
for( int i = 0; i < iNumFogFrames; i++ )
{
FOGKEYFRAME tmpFogFrame;
ar.Read( tmpFogFrame.m_wszName, _T("Name") );
ar.Read( tmpFogFrame.m_FogColor, _T("FogColor") );
ar.Read( tmpFogFrame.m_fFogStart, _T("FogStart") );
ar.Read( tmpFogFrame.m_fFogEnd, _T("FogEnd") );
m_vFogFrames.push_back( tmpFogFrame );
}
}
else
{
ar.Write( m_fTimeStart, _T("TimeStart") );
ar.Write( m_fTimeRate, _T("TimeRate") );
ar.Write( (int)m_vSunLightFrames.size(), _T("NumSunLightFrames") );
ar.Write( (int)m_vFogFrames.size(), _T("NumFogFrames") );
for( unsigned int i = 0; i < m_vSunLightFrames.size(); i++ )
{
ar.StartClass( _T("SunLightFrame") );
ar.Write( m_vSunLightFrames[i].m_wszName, _T("Name") );
ar.Write( m_vSunLightFrames[i].m_AmbientColor, _T("AmbientColor") );
ar.Write( m_vSunLightFrames[i].m_FullbrightColor, _T("FulLBrightColor") );
ar.Write( m_vSunLightFrames[i].m_fDawnWeight, _T("DawnWeight") );
ar.Write( m_vSunLightFrames[i].m_fNightWeight, _T("NightWeight") );
ar.EndClass();
}
for( unsigned int i = 0; i < m_vFogFrames.size(); i++ )
{
ar.StartClass( _T("FogFrame") );
ar.Write( m_vFogFrames[i].m_wszName, _T("Name") );
ar.Write( m_vFogFrames[i].m_FogColor, _T("FogColor") );
ar.Write( m_vFogFrames[i].m_fFogStart, _T("FogStart") );
ar.Write( m_vFogFrames[i].m_fFogEnd, _T("FogEnd") );
ar.EndClass();
}
}
}
示例8: Serialize
void CLanguage::Serialize( IArchive &ar )
{
float saveVersion = 1.0f;
if (ar.IsReading())
{
float readVersion;
StdString szLanguageName;
ar.Read(readVersion, _T("Version"));
ar.Read(szLanguageName, _T("LanguageName"));
ar.Read(m_iNumEntries, _T("NumEntries"));
m_hszLanguageName = szLanguageName;
CREATEOBJECTPARAMS cop;
INITOBJECTPARAMS iop;
SERIALIZEOBJECTPARAMS sop;
static DWORD msgCreateObject = CHashString(_T("CreateObject")).GetUniqueID();
static DWORD msgSerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();
static DWORD msgInitObject = CHashString(_T("InitObject")).GetUniqueID();
StdString szEntryObjName;
CHashString hszEntryObjBase, hszEntryObjName;
static CHashString hszEntryType(_T("CLanguageEntry"));
for (UINT i=0; i<m_iNumEntries; i++)
{
szEntryObjName = m_hszLanguageName.GetString();
szEntryObjName += _T("_Entry");
hszEntryObjBase = szEntryObjName;
GENERATEUNIQUEOBJECTNAMEPARAMS generateNameParams;
generateNameParams.name = &hszEntryObjBase;
generateNameParams.newname = &hszEntryObjName;
static DWORD msgHash_GenerateUniqueObjectName = CHashString(_T("GenerateUniqueObjectName")).GetUniqueID();
m_ToolBox->SendMessage(msgHash_GenerateUniqueObjectName, sizeof(generateNameParams), &generateNameParams );
cop.name = &hszEntryObjName;
cop.parentName = GetName();
cop.typeName = &hszEntryType;
if (m_ToolBox->SendMessage(msgCreateObject, sizeof(CREATEOBJECTPARAMS), &cop) == MSG_HANDLED)
{
sop.name = &hszEntryObjName;
sop.archive = &ar;
m_ToolBox->SendMessage(msgSerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop);
iop.name = &hszEntryObjName;
m_ToolBox->SendMessage(msgInitObject, sizeof(INITOBJECTPARAMS), &iop);
IObject *entryObj = SINGLETONINSTANCE(CLanguageManager)->GetObjectByName(&hszEntryObjName, &hszEntryType);
if (entryObj)
{
ILanguageEntry *langEntry = dynamic_cast<ILanguageEntry*>(entryObj);
if (langEntry)
{
IHashString *hsKey = langEntry->GetKey();
if (hsKey)
{
ENTRYKEYMAP::iterator mapIter = m_mEntryMapByKey.find(hsKey->GetUniqueID());
if (mapIter == m_mEntryMapByKey.end())
{
m_mEntryMapByKey[hsKey->GetUniqueID()] = langEntry;
}
else
{
m_ToolBox->Log(LOGERROR, _T("%s %d: duplicate key found for %s, deleting language entry!\n"),
__FILE__, __LINE__, hsKey->GetString());
DELETEOBJECTPARAMS dop;
dop.name = &hszEntryObjName;
static DWORD msgDeleteObject = CHashString(_T("DeleteObject")).GetUniqueID();
m_ToolBox->SendMessage(msgDeleteObject, sizeof(DELETEOBJECTPARAMS), &dop);
}
}
else
{
m_ToolBox->Log(LOGERROR, _T("%s %d: could not get key string from entry!\n"),
__FILE__, __LINE__);
}
}
else
{
m_ToolBox->Log(LOGERROR, _T("%s %d: could not cast to language entry!\n"),
__FILE__, __LINE__);
}
}
else
{
m_ToolBox->Log(LOGERROR, _T("%s %d: could not get object pointer from manager!\n"),
__FILE__, __LINE__);
}
}
else
{
m_ToolBox->Log(LOGERROR, _T("%s %d: could not create entry object %s!\n"),
__FILE__, __LINE__, hszEntryObjName.GetString());
}
}
//.........这里部分代码省略.........
示例9: Serialize
void CGUIItem::Serialize( IArchive &ar )
{
if(ar.IsReading())
{
CHashString versionName;
static DWORD msgHash_GetFileVersion = CHashString(_T("GetFileVersion")).GetUniqueID();
DWORD retval = EngineGetToolBox()->SendMessage(msgHash_GetFileVersion, sizeof(IHashString), &versionName);
static DWORD Vers2_0a = CHashString(_T("2.0a")).GetUniqueID();
static DWORD Vers2_0b = CHashString(_T("2.0b")).GetUniqueID();
static DWORD Vers2_0c = CHashString(_T("2.0c")).GetUniqueID();
int verNum = 0;
if (versionName.GetUniqueID() == Vers2_0a)
{
verNum = 3;
}
else if (versionName.GetUniqueID() == Vers2_0b)
{
verNum = 4;
}
else if (versionName.GetUniqueID() == Vers2_0c)
{
verNum = 5;
}
else
{
m_ToolBox->Log(LOGERROR, _T("Bad GUI file version!"));
assert(0);
return;
}
float loadVersion = 0.0f;
if (verNum >= 4)
{
ar.Read(loadVersion);
if (loadVersion == 0.0f)
{
// initial serialize from editor; set to save version (up to date schema)
loadVersion = m_fSaveVersion;
}
}
ar.Read(m_szNorm);
ar.Read(m_szHigh);
ar.Read(m_szSelect);
ar.Read(m_szGrayed);
ar.Read(m_szDecalNorm);
ar.Read(m_szDecalHigh);
ar.Read(m_szDecalSelect);
ar.Read(m_szDecalGrayed);
ar.Read(m_fDecalOffsetX);
ar.Read(m_fDecalOffsetY);
ar.Read(m_szText);
ar.Read(m_szTextHigh);
ar.Read(m_szTextSelect);
ar.Read(m_szTextGrayed);
ar.Read(m_szFont);
ar.Read(m_szFontBold);
ar.Read(m_iFontsize);
ar.Read(m_iNormFontColor);
ar.Read(m_iHighFontColor);
ar.Read(m_iSelFontColor);
ar.Read(m_iGrayFontColor);
ar.Read(m_iTextOffSetX);
ar.Read(m_iTextOffSetY);
ar.Read(m_bCenterText);
ar.Read(m_bSmartScale);
CreateItem();
}
else
{
ar.Write(m_fSaveVersion, _T("Version"));
ar.Write(m_szNorm, _T("NormTexture"));
ar.Write(m_szHigh, _T("HighTexture"));
ar.Write(m_szSelect, _T("SelectTexture"));
ar.Write(m_szGrayed, _T("GrayTexture"));
ar.Write(m_szDecalNorm, _T("NormDecalTexture"));
ar.Write(m_szDecalHigh, _T("HighDecalTexture"));
ar.Write(m_szDecalSelect, _T("SelectDecalTexture"));
ar.Write(m_szDecalGrayed, _T("GrayDecalTexture"));
ar.Write(m_fDecalOffsetX, _T("DecalOffsetX"));
ar.Write(m_fDecalOffsetY, _T("DecalOffsetY"));
ar.Write(m_szText, _T("StaticText"));
ar.Write(m_szTextHigh, _T("StaticTextHigh"));
ar.Write(m_szTextSelect, _T("StaticTextSelect"));
ar.Write(m_szTextGrayed, _T("StaticTextGrayed"));
ar.Write(m_szFont, _T("FontName"));
ar.Write(m_szFontBold, _T("BoldFontName"));
ar.Write(m_iFontsize, _T("Fontsize"));
ar.Write(m_iNormFontColor, _T("NormFontColor"));
ar.Write(m_iHighFontColor, _T("HighFontColor"));
ar.Write(m_iSelFontColor, _T("SelFontColor"));
ar.Write(m_iGrayFontColor, _T("GrayFontColor"));
ar.Write(m_iTextOffSetX, _T("TextOffSetX"));
ar.Write(m_iTextOffSetY, _T("TextOffSetY"));
ar.Write(m_bCenterText, _T("CenterText"));
//.........这里部分代码省略.........
示例10: Serialize
void CGUIStatusBar::Serialize(IArchive &ar)
{
if(ar.IsReading())
{
CHashString versionName;
static DWORD msgHash_GetFileVersion = CHashString(_T("GetFileVersion")).GetUniqueID();
DWORD retval = EngineGetToolBox()->SendMessage(msgHash_GetFileVersion, sizeof(IHashString), &versionName);
static DWORD vers2_0a = CHashString(_T("2.0a")).GetUniqueID();
static DWORD vers2_0b = CHashString(_T("2.0b")).GetUniqueID();
static DWORD vers2_0c = CHashString(_T("2.0c")).GetUniqueID();
int verNum = 0;
if (versionName.GetUniqueID() == vers2_0a)
{
verNum = 3;
}
else if (versionName.GetUniqueID() == vers2_0b)
{
verNum = 4;
}
else if (versionName.GetUniqueID() == vers2_0c)
{
verNum = 5;
}
else
{
m_ToolBox->Log(LOGERROR, _T("Bad GUI file version!"));
assert(0);
return;
}
float unitVersion = 0.0f;
if (verNum >= 4)
{
ar.Read(unitVersion);
if (unitVersion == 0.0f)
{
// initial serialize from editor; set to save version (up to date schema)
unitVersion = m_fSaveVersion;
}
}
ar.Read(m_szFullTex);
ar.Read(m_szBackgroundTex);
ar.Read(m_szTwoHundredTex);
ar.Read(m_szThreeHundredTex);
ar.Read(m_szFourHundredTex);
if (unitVersion >= 1.1f)
{
ar.Read(m_szAnimGhostBarTex, _T("AnimGhostBarTex"));
}
ar.Read(m_bForwardRender);
ar.Read(m_iLeftOffset);
ar.Read(m_iTopOffset);
ar.Read(m_iRightOffset);
ar.Read(m_iBottomOffset);
int percentage;
ar.Read(percentage);
m_fLastPercentage = m_fPercentComplete;
m_fPercentComplete = (float)percentage / 100.f;
if (unitVersion >= 1.1f)
{
ar.Read(m_bAnimateBarShift, _T("AnimateBarShift"));
ar.Read(m_fBarAnimationTime, _T("BarAnimationTime"));
}
if (unitVersion >= 1.2f)
{
ar.Read(m_bLastPercentLinger, _T("LingerGhostAnim"));
ar.Read(m_fLingerTime, _T("LingerTime"));
}
if (unitVersion >= 1.3f)
{
ar.Read(m_bIsLoadingBar, _T("IsLoadingBar"));
}
m_fBarAnimationET = 0.0f;
CreateStatusBar();
}
else
{
ar.Write(m_fSaveVersion, _T("Version"));
ar.Write(m_szFullTex, _T("FullTex"));
ar.Write(m_szBackgroundTex, _T("BGTex"));
ar.Write(m_szTwoHundredTex, _T("TwoHndrPcntTex"));
ar.Write(m_szThreeHundredTex, _T("ThreeHndrPcntTex"));
ar.Write(m_szFourHundredTex, _T("FourHndrPcntTex"));
ar.Write(m_szAnimGhostBarTex, _T("AnimGhostBarTex"));
ar.Write(m_bForwardRender, _T("FowardRender"));
ar.Write(m_iLeftOffset, _T("LeftOffset"));
ar.Write(m_iTopOffset, _T("TopOffset"));
ar.Write(m_iRightOffset, _T("RightOffset"));
ar.Write(m_iBottomOffset, _T("BottomOffset"));
ar.Write(0, _T("EditorRenderPercent"));
ar.Write(m_bAnimateBarShift, _T("AnimateBarShift"));
//.........这里部分代码省略.........
示例11: Serialize
void CGUIPage::Serialize(IArchive &ar)
{
CGUIManager *manager;
static CHashString managerName(_T("CGUIManager"));
IObject *Object;
StdString pageName;
StdString guiName;
StdString guiType;
StdString type;
int iNumGuiElements;
OBJECTLIST::iterator olIter;
if(ar.IsReading())
{
CHashString versionName;
static DWORD msgHash_GetFileVersion = CHashString(_T("GetFileVersion")).GetUniqueID();
DWORD retval = EngineGetToolBox()->SendMessage(msgHash_GetFileVersion, sizeof(IHashString), &versionName);
static DWORD Vers2_0a = CHashString(_T("2.0a")).GetUniqueID();
static DWORD Vers2_0b = CHashString(_T("2.0b")).GetUniqueID();
static DWORD Vers2_0c = CHashString(_T("2.0c")).GetUniqueID();
int verNum = 0;
if (versionName.GetUniqueID() == Vers2_0a)
{
verNum = 3;
}
else if (versionName.GetUniqueID() == Vers2_0b)
{
verNum = 4;
}
else if (versionName.GetUniqueID() == Vers2_0c)
{
verNum = 5;
}
else
{
m_ToolBox->Log(LOGERROR, _T("Bad GUI file version!"));
assert(0);
return;
}
float loadVersion = 0.0f;
if (verNum >= 4)
{
ar.Read(loadVersion);
if (loadVersion == 0.0f)
{
// initial serialize from editor; set to save version (up to date schema)
loadVersion = m_fSaveVersion;
}
}
ar.Read(iNumGuiElements);
while(iNumGuiElements != 0)
{
ar.Read(guiName);
ar.Read(guiType);
CHashString szhGuiName(guiName.c_str());
CHashString szhGuiType(guiType.c_str());
// ask gui manager for the object to add
manager = dynamic_cast<CGUIManager*>(EngineGetToolBox()->GetComponent( &managerName ));
if (!manager)
{
EngineGetToolBox()->SetErrorValue(ERR_NULL_POINTER);
EngineGetToolBox()->Log(LOGERROR, _T("could not cast IComponent from EngineToolBox to CGUIManager\n"));
return;
}
Object = manager->GetObject(&szhGuiName, &szhGuiType);
if(Object == NULL)
{
CREATEOBJECTPARAMS cop;
INITOBJECTPARAMS iop;
cop.name = &szhGuiName;
cop.typeName = &szhGuiType;
cop.parentName = GetName();
iop.name = &szhGuiName;
static DWORD msgHash_CreateObject = CHashString(_T("CreateObject")).GetUniqueID();
m_ToolBox->SendMessage(msgHash_CreateObject, sizeof(CREATEOBJECTPARAMS), &cop, NULL, NULL);
static DWORD msgHash_InitObject = CHashString(_T("InitObject")).GetUniqueID();
m_ToolBox->SendMessage(msgHash_InitObject, sizeof(INITOBJECTPARAMS), &cop, NULL, NULL);
Object = manager->GetObject(&szhGuiName, &szhGuiType);
}
m_ObjectList.push_back(Object);
iNumGuiElements--;
}
}
else //ar.IsWritting()
{
TCHAR strNum[50];
int count = 1;
StdString itemName;
StdString itemType;
//.........这里部分代码省略.........
示例12: Serialize
void CGUIStaticText::Serialize( IArchive &ar )
{
float fSaveVersion = 1.2f;
if(ar.IsReading())
{
CHashString versionName;
static DWORD msgHash_GetFileVersion = CHashString(_T("GetFileVersion")).GetUniqueID();
DWORD retval = EngineGetToolBox()->SendMessage(msgHash_GetFileVersion, sizeof(IHashString), &versionName);
static DWORD vers2_0a = CHashString(_T("2.0a")).GetUniqueID();
static DWORD vers2_0b = CHashString(_T("2.0b")).GetUniqueID();
static DWORD vers2_0c = CHashString(_T("2.0c")).GetUniqueID();
int verNum = 0;
if (versionName.GetUniqueID() == vers2_0a)
{
verNum = 3;
}
else if (versionName.GetUniqueID() == vers2_0b)
{
verNum = 4;
}
else if (versionName.GetUniqueID() == vers2_0c)
{
verNum = 5;
}
else
{
m_ToolBox->Log(LOGERROR, _T("Bad GUI file version!"));
assert(0);
return;
}
float loadVersion = 0.0f;
if (verNum >= 4)
{
ar.Read(loadVersion);
if (loadVersion == 0.0f)
{
// initial serialize from editor; set to save version (up to date schema)
loadVersion = fSaveVersion;
}
}
ar.Read(m_szNorm);
ar.Read(m_szText);
ar.Read(m_szFilename);
ar.Read(m_bLoadFromFile);
if (loadVersion >= 1.2f)
{
ar.Read(m_bUseLanguageEntry);
ar.Read(m_szLangEntryKey);
}
ar.Read(m_szFont);
ar.Read(m_iFontsize);
ar.Read(m_iNormFontColor);
ar.Read(m_iHighFontColor);
ar.Read(m_iSelectFontColor);
ar.Read(m_iGrayFontColor);
ar.Read(m_iTextOffSetX);
ar.Read(m_iTextOffSetY);
ar.Read(m_bCenterText);
ar.Read(m_bHideTexture);
if (loadVersion >= 1.1f)
{
ar.Read(m_bUseFontShadow, _T("UseFontDropShadow"));
ar.Read(m_iFontShadowColor, _T("FontShadowColor"));
ar.Read(m_iFontShadowXScale, _T("FontShadowXScale"));
ar.Read(m_iFontShadowYScale, _T("FontShadowYScale"));
ar.Read(m_iFontShadowXOffset, _T("FontShadowXOffset"));
ar.Read(m_iFontShadowYOffset, _T("FontShadowYOffset"));
}
CreateItem();
}
else
{
ar.Write(fSaveVersion, _T("Version"));
ar.Write(m_szNorm, _T("NormTexture"));
ar.Write(m_szText, _T("StaticText"));
ar.Write(m_szFilename, _T("Filename"));
ar.Write(m_bLoadFromFile, _T("LoadFromFile"));
ar.Write(m_bUseLanguageEntry, _T("UseLanguageEntry"));
ar.Write(m_szLangEntryKey, _T("LanguageEntryKey"));
ar.Write(m_szFont, _T("FontName"));
ar.Write(m_iFontsize, _T("Fontsize"));
ar.Write(m_iNormFontColor, _T("NormFontColor"));
ar.Write(m_iHighFontColor, _T("HighFontColor"));
ar.Write(m_iSelectFontColor, _T("SelectFontColor"));
ar.Write(m_iGrayFontColor, _T("GrayFontColor"));
ar.Write(m_iTextOffSetX, _T("TextOffSetX"));
ar.Write(m_iTextOffSetY, _T("TextOffSetY"));
ar.Write(m_bCenterText, _T("CenterText"));
ar.Write(m_bHideTexture, _T("HideTexture"));
ar.Write(m_bUseFontShadow, _T("UseFontDropShadow"));
//.........这里部分代码省略.........