From c0c336500955a23e344651e5412c9d9d441ef4ee Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 28 Jun 2023 22:22:32 +0100 Subject: first pass of T2DLL --- src/T2DLL/T2PeopleLoader.cpp | 67 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) (limited to 'src/T2DLL/T2PeopleLoader.cpp') diff --git a/src/T2DLL/T2PeopleLoader.cpp b/src/T2DLL/T2PeopleLoader.cpp index 3552889..f2e76a3 100644 --- a/src/T2DLL/T2PeopleLoader.cpp +++ b/src/T2DLL/T2PeopleLoader.cpp @@ -1,13 +1,72 @@ +#include "CResFile.h" +#include "T2PeopleDef.h" #include "T2PeopleLoader.h" +#include "T2SilhouetteDef.h" +#include "T2TemplatePluginDB.h" +#include "T2TemplatePluginList.h" -/*static*/ void T2PeopleLoader::Load(T2PluginSpecifier*, T2TemplatePluginDB*) { +/*static*/ void T2PeopleLoader::Load(T2PluginSpecifier* specifier, T2TemplatePluginDB* db) { + LoadSilhouette(specifier, db); + LoadPeople(specifier, db); } -/*static*/ void T2PeopleLoader::Unload(T2TemplatePluginDB*) { +/*static*/ void T2PeopleLoader::Unload(T2TemplatePluginDB* db) { + LArrayIterator silhouetteIterator(*db->GetTemplatePluginList('SlDf')); + T2SilhouetteDef *silhouetteDef; + while (silhouetteIterator.Next(&silhouetteDef)) + delete silhouetteDef; + + LArrayIterator peopleIterator(*db->GetTemplatePluginList('PPDf')); + T2PeopleDef *peopleDef; + while (peopleIterator.Next(&peopleDef)) + delete peopleDef; } -/*static*/ int T2PeopleLoader::LoadSilhouette(T2PluginSpecifier*, T2TemplatePluginDB*) { +/*static*/ BOOL T2PeopleLoader::LoadSilhouette(T2PluginSpecifier* specifier, T2TemplatePluginDB* db) { + CResFile resFile; + if (resFile.OpenResource(specifier->mInstance, 1, 'SlDf')) { + T2TemplatePluginList *silhouetteList = db->GetTemplatePluginList('SlDf'); + + int count; + resFile >> count; + + for (int i = 0; i < count; i++) { +#line 47 + T2SilhouetteDef *silhouetteDef = DEBUG_NEW T2SilhouetteDef('SlDf', *specifier, &resFile); + + if (!silhouetteList->FindSilhouette(silhouetteDef->GetSilhouetteType())) + silhouetteList->Add(silhouetteDef); + else + delete silhouetteDef; + } + + return true; + } + return false; } -/*static*/ int T2PeopleLoader::LoadPeople(T2PluginSpecifier*, T2TemplatePluginDB*) { +/*static*/ BOOL T2PeopleLoader::LoadPeople(T2PluginSpecifier* specifier, T2TemplatePluginDB* db) { + CResFile resFile; + if (resFile.OpenResource(specifier->mInstance, 1, 'PPDf')) { + T2TemplatePluginList *peopleList = db->GetTemplatePluginList('PPDf'); + T2TemplatePluginList *silhouetteList = db->GetTemplatePluginList('SlDf'); + + int count; + resFile >> count; + + for (int i = 0; i < count; i++) { +#line 70 + T2PeopleDef *peopleDef = DEBUG_NEW T2PeopleDef('PPDf', *specifier, &resFile); + + if (!peopleList->FindPeopleDef(peopleDef->GetPeopleType())) { + peopleDef->AssignSilhouette(silhouetteList); + peopleList->Add(peopleDef); + } else { + delete peopleDef; + } + } + + return true; + } + return false; } -- cgit v1.2.3