summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2PeopleLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/T2PeopleLoader.cpp')
-rw-r--r--src/T2DLL/T2PeopleLoader.cpp67
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;
}