#include "StdAfx.h" #include "CResFile.h" #include "T2PeopleDef.h" #include "T2PeopleLoader.h" #include "T2SilhouetteDef.h" #include "T2TemplatePluginDB.h" #include "T2TemplatePluginList.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif /*static*/ void T2PeopleLoader::Load(T2PluginSpecifier* specifier, T2TemplatePluginDB* db) { LoadSilhouette(specifier, db); LoadPeople(specifier, db); } /*static*/ void T2PeopleLoader::Unload(T2TemplatePluginDB* db) { LArrayIterator silhouetteIter(*db->GetTemplatePluginList('SlDf')); T2SilhouetteDef *silhouetteDef; while (silhouetteIter.Next(&silhouetteDef)) delete silhouetteDef; LArrayIterator peopleIter(*db->GetTemplatePluginList('PPDf')); T2PeopleDef *peopleDef; while (peopleIter.Next(&peopleDef)) delete peopleDef; } /*static*/ BOOL T2PeopleLoader::LoadSilhouette(T2PluginSpecifier* specifier, T2TemplatePluginDB* db) { CResFile resFile; if (resFile.OpenResource(specifier->mInstance, 1, 'SlDf')) { T2TemplatePluginList *silhouetteDefList = db->GetTemplatePluginList('SlDf'); int numOfDefs; resFile >> numOfDefs; for (int index = 0; index < numOfDefs; index++) { #line 47 T2SilhouetteDef *silhouetteDef = new T2SilhouetteDef('SlDf', *specifier, &resFile); if (!silhouetteDefList->FindSilhouette(silhouetteDef->GetSilhouetteType())) silhouetteDefList->Add(silhouetteDef); else delete silhouetteDef; } return true; } return false; } /*static*/ BOOL T2PeopleLoader::LoadPeople(T2PluginSpecifier* specifier, T2TemplatePluginDB* db) { CResFile resFile; if (resFile.OpenResource(specifier->mInstance, 1, 'PPDf')) { T2TemplatePluginList *peopleDefList = db->GetTemplatePluginList('PPDf'); T2TemplatePluginList *silhouetteDefList = db->GetTemplatePluginList('SlDf'); int numOfDefs; resFile >> numOfDefs; for (int index = 0; index < numOfDefs; index++) { #line 70 T2PeopleDef *peopleDef = new T2PeopleDef('PPDf', *specifier, &resFile); if (!peopleDefList->FindPeopleDef(peopleDef->GetPeopleType())) { peopleDef->AssignSilhouette(silhouetteDefList); peopleDefList->Add(peopleDef); } else { delete peopleDef; } } return true; } return false; }