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/T2TemplatePluginList.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to 'src/T2DLL/T2TemplatePluginList.cpp')
-rw-r--r-- | src/T2DLL/T2TemplatePluginList.cpp | 146 |
1 files changed, 136 insertions, 10 deletions
diff --git a/src/T2DLL/T2TemplatePluginList.cpp b/src/T2DLL/T2TemplatePluginList.cpp index c3063a2..1d1158f 100644 --- a/src/T2DLL/T2TemplatePluginList.cpp +++ b/src/T2DLL/T2TemplatePluginList.cpp @@ -1,46 +1,172 @@ +#include "T2MoverDef.h" +#include "T2OuterObjDef.h" +#include "T2PeopleDef.h" +#include "T2SilhouetteDef.h" #include "T2TemplatePluginList.h" +#include "T2TempPluginComparator.h" +#include "T2TenantDef.h" -T2TemplatePluginList::T2TemplatePluginList(unsigned long) { +T2TemplatePluginList::T2TemplatePluginList(DWORD pluginType) + : LArray(sizeof(T2TemplatePlugin *)) +{ + mPluginType = pluginType; + SetComparator(T2TempPluginComparator::GetComparator()); + mOwnsComparator = false; + SetKeepSorted(true); } /*virtual*/ T2TemplatePluginList::~T2TemplatePluginList() { } void T2TemplatePluginList::AllClear() { + RemoveItemsAt(mItemCount, 1); } -void T2TemplatePluginList::Regist(T2TemplatePlugin*) { +void T2TemplatePluginList::Regist(T2TemplatePlugin* plugin) { + if (!plugin) + return; + + InsertItemsAt(1, mItemCount + 1, &plugin); } -void T2TemplatePluginList::Add(T2TemplatePlugin*) { +void T2TemplatePluginList::Add(T2TemplatePlugin* plugin) { + if (!plugin) + return; + + InsertItemsAt(1, mItemCount + 1, &plugin); } unsigned int T2TemplatePluginList::GetItemCount() { + return GetCount(); } -T2TemplatePlugin* T2TemplatePluginList::GetItemAt(int) { +T2TemplatePlugin* T2TemplatePluginList::GetItemAt(int index) { + T2TemplatePlugin *plugin; + if (FetchItemAt(index, &plugin)) + return plugin; + else + return NULL; } T2TenantDef* T2TemplatePluginList::FindFloor() { + if (mPluginType != 'TnDf') + return NULL; + + LArrayIterator iterator(*this); + T2TenantDef *plugin; + while (iterator.Next(&plugin)) { + if (plugin->IsFloor()) + return plugin; + } + + return NULL; } -T2TenantDef* T2TemplatePluginList::FindTenantDef(int) { +T2TenantDef* T2TemplatePluginList::FindTenantDef(int equipType) { + if (mPluginType != 'TnDf') + return NULL; + + LArrayIterator iterator(*this); + T2TenantDef *plugin; + while (iterator.Next(&plugin)) { + if (plugin->GetEquipType() == equipType) + return plugin; + } + + return NULL; } -T2MoverDef* T2TemplatePluginList::FindMoverDef(int) { +T2MoverDef* T2TemplatePluginList::FindMoverDef(int equipType) { + if (mPluginType != 'MvDf') + return NULL; + + LArrayIterator iterator(*this); + T2MoverDef *plugin; + while (iterator.Next(&plugin)) { + if (plugin->GetEquipType() == equipType) + return plugin; + } + + return NULL; } -T2OuterObjDef* T2TemplatePluginList::FindOutObjDef(int) { +T2OuterObjDef* T2TemplatePluginList::FindOutObjDef(int toolType) { + if (mPluginType != 'OODf') + return NULL; + + LArrayIterator iterator(*this); + T2OuterObjDef *plugin; + while (iterator.Next(&plugin)) { + if (plugin->GetToolType() == toolType) + return plugin; + } + + return NULL; } -T2PeopleDef* T2TemplatePluginList::FindPeopleDef(int) { +T2PeopleDef* T2TemplatePluginList::FindPeopleDef(int peopleType) { + if (mPluginType != 'PPDf') + return NULL; + + LArrayIterator iterator(*this); + T2PeopleDef *plugin; + while (iterator.Next(&plugin)) { + if (plugin->GetPeopleType() == peopleType) + return plugin; + } + + return NULL; } -T2SilhouetteDef* T2TemplatePluginList::FindSilhouette(int) { +T2SilhouetteDef* T2TemplatePluginList::FindSilhouette(int silhouetteType) { + if (mPluginType != 'SlDf') + return NULL; + + LArrayIterator iterator(*this); + T2SilhouetteDef *plugin; + while (iterator.Next(&plugin)) { + if (plugin->GetSilhouetteType() == silhouetteType) + return plugin; + } + + return NULL; } int T2TemplatePluginList::CalcCategoryCount() { + int count = 0; + LArray categories(sizeof(int)); + LArrayIterator toolDefIterator(*this); + T2ToolDef *toolDef; + + while (toolDefIterator.Next(&toolDef)) { + int categoryNo = toolDef->mCategoryNo; + BOOL found = false; + + LArrayIterator categoryIterator(categories); + int check; + while (categoryIterator.Next(&check)) { + if (check == categoryNo) { + found = true; + break; + } + } + + if (!found) { + categories.InsertItemsAt(1, categories.GetCount() + 1, &categoryNo); + count++; + } + } + + return count; } -void T2TemplatePluginList::DispatchIdle(T2TowerDoc*) { +void T2TemplatePluginList::DispatchIdle(T2TowerDoc* towerDoc) { + if (mPluginType != 'OODf' && mPluginType != 'MvDf' && mPluginType != 'TnDf') + return; + + LArrayIterator iterator(*this); + T2ToolDef *toolDef; + + while (iterator.Next(&toolDef)) + toolDef->DefIdleProc(towerDoc); } |