#include "T2Archive.h" #include "T2StairModule.h" #include "T2StairModuleList.h" T2StairModuleList::T2StairModuleList() { } /*virtual*/ T2StairModuleList::~T2StairModuleList() { } void T2StairModuleList::AddModule(int position, const RECT& rect) { T2StairModule *module = new T2StairModule; if (module) { InsertModuleAt(GetIndex(position, ERequestUpDown_0), module); module->SetModuleRect(rect); module->mDirection = kStairDirection1; module->SetUsed(true); } module = new T2StairModule; if (module) { InsertModuleAt(GetIndex(position, ERequestUpDown_1), module); module->SetModuleRect(rect); module->mDirection = kStairDirection2; module->SetUsed(true); } } void T2StairModuleList::AddModule(T2TowerDoc* towerDoc, const RECT& rect, BOOL insertAtEnd) { T2StairModule *theUpModule = new T2StairModule; if (theUpModule) { theUpModule->SetModuleRect(rect); theUpModule->mDirection = kStairDirection1; theUpModule->SetUsed(true); theUpModule->SetModuleID(towerDoc); } T2StairModule *theDownModule = new T2StairModule; if (theDownModule) { theDownModule->SetModuleRect(rect); theDownModule->mDirection = kStairDirection2; theDownModule->SetUsed(true); theDownModule->SetModuleID(towerDoc); } if (theUpModule && theDownModule) { if (insertAtEnd) { InsertModuleAt(mItemCount + 1, theUpModule); InsertModuleAt(mItemCount + 1, theDownModule); } else { InsertModuleAt(1, theDownModule); InsertModuleAt(1, theUpModule); } } } int T2StairModuleList::GetIndex(int position, ERequestUpDown upDown) const { int index = 1; index += position * 2; if (upDown == ERequestUpDown_1) index++; return index; } void T2StairModuleList::Union(T2MoverModuleList* list, unsigned int moverID) { LArrayIterator iterator(*list); T2StairModule *stairModule; while (iterator.Next(&stairModule)) { stairModule->MoverIDChanged(moverID); InsertItemsAt(1, mItemCount + 1, &stairModule); } list->AllClear(); } /*virtual*/ T2MoverModule* T2StairModuleList::ConstructModule() { return new T2StairModule; } /*virtual*/ void T2StairModuleList::Read(T2Archive& archive, T2TowerDoc* towerDoc) { T2MoverModuleList::Read(archive, towerDoc); int count; archive >> count; BOOL failed = false; for (int i = 0; i < count && !failed; i++) { T2StairModule *stairModule = new T2StairModule; if (stairModule) { stairModule->Load(archive, towerDoc); failed = !InsertModuleAt(mItemCount + 1, stairModule); } } } /*virtual*/ int T2StairModuleList::GetModuleCount() const { return mItemCount; }