summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2StairModuleList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/T2StairModuleList.cpp')
-rw-r--r--src/T2DLL/T2StairModuleList.cpp82
1 files changed, 77 insertions, 5 deletions
diff --git a/src/T2DLL/T2StairModuleList.cpp b/src/T2DLL/T2StairModuleList.cpp
index 4f99087..876e571 100644
--- a/src/T2DLL/T2StairModuleList.cpp
+++ b/src/T2DLL/T2StairModuleList.cpp
@@ -1,3 +1,5 @@
+#include "T2Archive.h"
+#include "T2StairModule.h"
#include "T2StairModuleList.h"
T2StairModuleList::T2StairModuleList() {
@@ -6,23 +8,93 @@ T2StairModuleList::T2StairModuleList() {
/*virtual*/ T2StairModuleList::~T2StairModuleList() {
}
-void T2StairModuleList::AddModule(int, const RECT&) {
+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*, const RECT&, int) {
+void T2StairModuleList::AddModule(T2TowerDoc* towerDoc, const RECT& rect, BOOL insertAtEnd) {
+ T2StairModule *module1 = new T2StairModule;
+ if (module1) {
+ module1->SetModuleRect(rect);
+ module1->mDirection = kStairDirection1;
+ module1->SetUsed(true);
+ module1->SetModuleID(towerDoc);
+ }
+
+ T2StairModule *module2 = new T2StairModule;
+ if (module2) {
+ module2->SetModuleRect(rect);
+ module2->mDirection = kStairDirection2;
+ module2->SetUsed(true);
+ module2->SetModuleID(towerDoc);
+ }
+
+ if (module1 && module2) {
+ if (insertAtEnd) {
+ InsertModuleAt(mItemCount + 1, module1);
+ InsertModuleAt(mItemCount + 1, module2);
+ } else {
+ InsertModuleAt(1, module2);
+ InsertModuleAt(1, module1);
+ }
+ }
}
-int T2StairModuleList::GetIndex(int, ERequestUpDown) const {
+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*, unsigned int) {
+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&, T2TowerDoc*) {
+/*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;
}