#include "StdAfx.h" #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* towerDoc, const CRect& rect) { T2ToolDef *theToolDef = GetToolDef(); theToolDef->DrawProc(this, rect, towerDoc); } /*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* towerDoc, RECT& rect) { GetOutObjArea(rect); T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); if (theFloorInfo) { theFloorInfo->FillOutObjID(rect, 0); if (GetToolDef()) GetToolDef()->DestructFinish(towerDoc, this); } SetUsed(false); return ProcCode_1; } /*virtual*/ void T2OutObj::GetOutObjArea(RECT& rect) const { rect = mOutObjArea; } /*virtual*/ unsigned int T2OutObj::Idle(T2TowerDoc* towerDoc) { unsigned int result = 0; if (GetToolDef()) result = GetToolDef()->IdleProc(this, towerDoc); if (result) towerDoc->GetMainView()->InvalUnitRect(mOutObjArea); return result; } /*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& 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 { char tmp; int len; archive >> len; for (int i = 0; i < len; i++) { archive >> tmp; } } } } /*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* towerDoc) { mStatus = kOutObjStatus1; } /*virtual*/ T2InfoDialog* T2OutObj::ShowInfoDialog(T2TowerDoc* towerDoc) { return ((T2OuterObjDef *) mToolDef)->ShowInfoDialog(towerDoc, this); } /*virtual*/ void T2OutObj::DrawHitMask(T2TowerDoc* towerDoc) { CRect rect = mOutObjArea; Draw(towerDoc, rect); }