bool CCampaignData::Save(CString pathName) { FitIniFile fitFile; int32_t result = fitFile.create(pathName.GetBuffer(0)); if(result != NO_ERROR) { return false; } fitFile.writeBlock("Campaign"); fitFile.writeIdBoolean("NameUseResourceString", m_NameUseResourceString); if(!m_NameUseResourceString) { fitFile.writeIdString("CampaignName", m_Name.GetBuffer(0)); } else { fitFile.writeIdLong("NameID", m_NameResourceStringID); } fitFile.writeIdLong("CBills", m_CBills); fitFile.writeIdString("FinalVideo", m_FinalVideo.GetBuffer(0)); fitFile.writeIdLong("GroupCount", m_GroupList.Count()); CGroupList::EIterator it; int32_t index; for(it = m_GroupList.Begin(), index = 0; !it.IsDone(); it++, index += 1) { ECharString blockName; blockName.Format("Group%d", index); fitFile.writeBlock(blockName.Data()); (*it).Save(fitFile, blockName.Data()); } fitFile.close(); return true; }
bool CCampaignData::Read(CString pathName) { FitIniFile fitFile; int result = fitFile.open(pathName.GetBuffer(0)); if (NO_ERR != result) { assert(false); return false; } result = fitFile.seekBlock("Campaign"); if (NO_ERR != result) { assert(false); } result = sReadIdString(fitFile, "CampaignName", m_Name); if (NO_ERR == result) { m_NameUseResourceString = false; } result = sReadIdInteger(fitFile, "NameID", m_NameResourceStringID); if (NO_ERR == result) { m_NameUseResourceString = true; } result = sReadIdBoolean(fitFile, "NameUseResourceString", m_NameUseResourceString); result = sReadIdInteger(fitFile, "CBills", m_CBills); result = sReadIdString(fitFile, "FinalVideo", m_FinalVideo); int groupCount = 0; result = sReadIdInteger(fitFile, "GroupCount", groupCount); if (NO_ERR != result) { return false; } int index; for (index = 0; groupCount > index; index+=1) { ECharString blockName; blockName.Format("Group%d", index); result = fitFile.seekBlock(blockName.Data()); if (NO_ERR != result) { assert(false); continue; } CGroupData groupData; bool bresult = groupData.Read(fitFile, blockName.Data()); if (true != bresult) { assert(false); continue; } m_GroupList.Append(groupData); } fitFile.close(); return true; }
bool CGroupData::Read(FitIniFile &fitFile, const char *groupName) { int result; result = sReadIdString(fitFile, "Label", m_Label); result = sReadIdInteger(fitFile, "NumberToComplete", m_NumMissionsToComplete); result = sReadIdString(fitFile, "OperationFile", m_OperationFile); result = sReadIdString(fitFile, "Video", m_VideoFile); result = sReadIdString(fitFile, "PreVideo", m_PreVideoFile); result = sReadIdInteger(fitFile, "Tune", m_TuneNumber); result = sReadIdString(fitFile, "ABLScript", m_ABLScript); int missionCount = 0; result = sReadIdInteger(fitFile, "MissionCount", missionCount); if (NO_ERR != result) { return false; } int index; for (index = 0; missionCount > index; index+=1) { ECharString blockName; blockName.Format("%sMission%d", groupName, index); result = fitFile.seekBlock(blockName.Data()); if (NO_ERR != result) { assert(false); continue; } CMissionData missionData; bool bresult = missionData.Read(fitFile); if (true != bresult) { assert(false); continue; } m_MissionList.Append(missionData); } return true; }
bool CGroupData::Save(FitIniFile &fitFile, const char *groupName) { fitFile.writeIdString( "Label", m_Label.GetBuffer(0)); fitFile.writeIdLong("NumberToComplete", m_NumMissionsToComplete); fitFile.writeIdString( "OperationFile", m_OperationFile.GetBuffer(0)); fitFile.writeIdString( "Video", m_VideoFile.GetBuffer(0)); fitFile.writeIdString( "PreVideo", m_PreVideoFile.GetBuffer(0)); fitFile.writeIdLong("Tune", m_TuneNumber); fitFile.writeIdLong("MissionCount", m_MissionList.Count()); if (!m_ABLScript.IsEmpty()) { fitFile.writeIdString( "ABLScript", m_ABLScript.GetBuffer(0)); } CMissionList::EIterator it; int index; for (it = m_MissionList.Begin(), index = 0; !it.IsDone(); it++, index+=1) { ECharString blockName; blockName.Format("%sMission%d", groupName, index); fitFile.writeBlock(blockName.Data()); (*it).Save(fitFile); } return true; }