diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
commit | c0c336500955a23e344651e5412c9d9d441ef4ee (patch) | |
tree | 790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2PeopleLoader.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/T2PeopleLoader.cpp | 67 |
1 files changed, 63 insertions, 4 deletions
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; } |