summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2OutObj.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/T2OutObj.cpp')
-rw-r--r--src/T2DLL/T2OutObj.cpp131
1 files changed, 120 insertions, 11 deletions
diff --git a/src/T2DLL/T2OutObj.cpp b/src/T2DLL/T2OutObj.cpp
index 7eb99b0..570e77c 100644
--- a/src/T2DLL/T2OutObj.cpp
+++ b/src/T2DLL/T2OutObj.cpp
@@ -1,40 +1,149 @@
+#include "T2Archive.h"
+#include "T2FloorInfo.h"
#include "T2OutObj.h"
+#include "T2OuterObjDef.h"
+#include "T2TemplatePluginList.h"
+#include "T2TowerDoc.h"
+#include "T2TowerMainView.h"
T2OutObj::T2OutObj() {
+ mID = 0;
+ SetRect(&mOutObjArea, 0, 0, 0, 0);
+ mToolType = 0;
+
+ mToolDef = NULL;
+ mRefCon = 0;
+ mSubPlugin = NULL;
}
/*virtual*/ T2OutObj::~T2OutObj() {
}
-/*virtual*/ void T2OutObj::Draw(T2TowerDoc*, const CRect&) {
+/*virtual*/ void T2OutObj::Draw(T2TowerDoc* towerDoc, const CRect& rect) {
+ T2ToolDef *theToolDef = GetToolDef();
+ theToolDef->DrawProc(this, rect, towerDoc);
}
-/*virtual*/ PROCCODE T2OutObj::DoDestruct(T2TowerDoc*, int, CPoint, CPoint, CRect&) {
+/*virtual*/ PROCCODE T2OutObj::DoDestruct(T2TowerDoc* towerDoc, int, CPoint pt1, CPoint, CRect& rect) {
+ PROCCODE result = ProcCode_0;
+
+ if (GetToolDef())
+ result = GetToolDef()->DoDestructProc(towerDoc, this, pt1, rect);
+ else
+ result = Destruct(towerDoc, rect);
+
+ return result;
}
-/*virtual*/ PROCCODE T2OutObj::Destruct(T2TowerDoc*, RECT&) {
+/*virtual*/ PROCCODE T2OutObj::Destruct(T2TowerDoc* towerDoc, RECT& rect) {
+ GetOutObjArea(rect);
+
+ T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C();
+ if (theFloorInfo) {
+ theFloorInfo->FillOutObjID(rect, 0);
+ if (GetToolDef())
+ GetToolDef()->DestructFinish(towerDoc, this);
+ }
+
+ SetUsed(false);
+
+ return ProcCode_1;
}
-/*virtual*/ void T2OutObj::GetOutObjArea(RECT&) const {
+/*virtual*/ void T2OutObj::GetOutObjArea(RECT& rect) const {
+ rect = mOutObjArea;
}
-/*virtual*/ unsigned int T2OutObj::Idle(T2TowerDoc*) {
+/*virtual*/ unsigned int T2OutObj::Idle(T2TowerDoc* towerDoc) {
+ unsigned int result = 0;
+
+ if (GetToolDef())
+ result = GetToolDef()->IdleProc(this, towerDoc);
+
+ if (result)
+ towerDoc->GetTowerMainView()->tmv_vf128(mOutObjArea);
+
+ return result;
}
-/*virtual*/ int T2OutObj::InitOutObj(T2OuterObjDef*, const RECT&, unsigned int) {
+/*virtual*/ int T2OutObj::InitOutObj(T2OuterObjDef* def, const RECT& outObjArea, unsigned int valiation) {
+ int result = 0;
+
+ mSubPlugin = NULL;
+
+ if (def) {
+ mToolType = def->GetToolType();
+ mToolDef = def;
+ }
+
+ mOutObjArea = outObjArea;
+ mValiation = valiation;
+ mRefCon = 0;
+ mStatus = kOutObjStatus0;
+ SetUsed(true);
+
+ return result;
}
-/*virtual*/ void T2OutObj::LoadSelf(T2Archive&, T2TowerDoc*) {
+/*virtual*/ void T2OutObj::LoadSelf(T2Archive& archive, T2TowerDoc* towerDoc) {
+ T2Object::LoadSelf(archive, towerDoc);
+
+ if (IsUsed()) {
+ unsigned short us;
+ short s;
+
+ archive >> us;
+ mID = us;
+
+ archive.ReadSRect(mOutObjArea);
+
+ archive >> mValiation;
+
+ archive >> s;
+ mToolType = s;
+
+ mToolDef = towerDoc->mOuterObjTemplates->FindOutObjDef(mToolType);
+ if (mToolDef) {
+ mToolDef->LoadExtraData(archive, towerDoc, this);
+ } else {
+ int count;
+ archive >> count;
+
+ for (int i = 0; i < count; i++) {
+ char tmp;
+ archive >> tmp;
+ }
+ }
+ }
}
-/*virtual*/ void T2OutObj::SaveSelf(T2Archive&) {
+/*virtual*/ void T2OutObj::SaveSelf(T2Archive& archive) {
+ T2Object::SaveSelf(archive);
+
+ if (IsUsed()) {
+ archive << (unsigned short) mID;
+ archive.WriteSRect(mOutObjArea);
+ archive << mValiation;
+ archive << (short) mToolType;
+
+ if (mToolDef) {
+ mToolDef->SaveExtraData(archive, this);
+ } else {
+ int count = 0;
+ archive << count;
+ }
+ }
}
-/*virtual*/ void T2OutObj::StartBuild(T2TowerDoc*) {
+/*virtual*/ void T2OutObj::StartBuild(T2TowerDoc* towerDoc) {
+ mStatus = kOutObjStatus1;
}
-/*virtual*/ T2InfoDialog* T2OutObj::ShowInfoDialog(T2TowerDoc*) {
+/*virtual*/ T2InfoDialog* T2OutObj::ShowInfoDialog(T2TowerDoc* towerDoc) {
+ return ((T2OuterObjDef *) mToolDef)->ShowInfoDialog(towerDoc, this);
}
-/*virtual*/ void T2OutObj::DrawHitMask(T2TowerDoc*) {
+/*virtual*/ void T2OutObj::DrawHitMask(T2TowerDoc* towerDoc) {
+ CRect rect = mOutObjArea;
+ Draw(towerDoc, rect);
}