#include "StdAfx.h" #include "CResFile.h" #include "T2Archive.h" #include "T2BitImage.h" #include "T2Equip.h" #include "T2EquipDef.h" #include "T2EquipPlugin.h" #include "T2ImageObj.h" #include "T2InfoDialog.h" #include "T2People.h" #include "T2PeopleLinkIterator.h" #include "T2Tenant.h" #include "../T2TowerDoc.h" #include "T2WordDefArray.h" #include "T2WorldDef.h" #include "UT2Coordinate.h" T2EquipDef::T2EquipDef(DWORD type, T2PluginSpecifier& specifier, CResFile* resFile, T2WorldDef* worldDef, T2EquipPlugin* plugin) : T2ToolDef(type, specifier, resFile, worldDef, plugin) { unsigned long tmp; *resFile >> mCapacity; *resFile >> mStress; *resFile >> tmp; for (int j = 0; j < mValiationCount; j++) { *resFile >> m154; *resFile >> tmp; *resFile >> tmp; } *resFile >> mOutSpan; *resFile >> mInSpan; *resFile >> mNumOfInMoney; for (int i = 0; i < mNumOfInMoney; i++) { if (i < 4) { *resFile >> mInMoney[i]; } else { int moneyTmp; *resFile >> moneyTmp; } } m124 = NULL; m128 = NULL; m130 = NULL; m140 = 0; if (mNumOfInMoney > 4) mNumOfInMoney = 4; try { int outViewKind = worldDef->GetOutViewKind() + 1001; m124 = new T2BitImage(mModuleHandle, outViewKind, 1); mImageObj->AddObject(mModuleHandle, outViewKind, m124); } catch (int e) { } try { m128 = new T2BitImage(mModuleHandle, 1010, 1); mImageObj->AddObject(mModuleHandle, 1010, m128); } catch (int e) { } try { m130 = new T2BitImage(mModuleHandle, 1100, 1); mImageObj->AddObject(mModuleHandle, 1100, m130); } catch (int e) { } mWordDefArray = MakeWordDefArray(); } /*virtual*/ T2EquipDef::~T2EquipDef() { if (m124) delete m124; if (m128) delete m128; if (m130) delete m130; if (mWordDefArray) delete mWordDefArray; } /*virtual*/ BOOL T2EquipDef::InitObject(T2Object* object) { object->SetUsed(true); ((T2Equip *) object)->mEquipType = GetEquipType(); ((T2Equip *) object)->mCapacity = mCapacity; ((T2Equip *) object)->mAttribute = mAttribute; ((T2Equip *) object)->SetEquipDef(this); return true; } /*virtual*/ int T2EquipDef::ClickProc(T2TowerDoc*, RECT*, unsigned int&) { return 1; } /*virtual*/ int T2EquipDef::GetDestructPartProc(int, POINT, POINT, T2Equip*) { return -1; } /*virtual*/ AREACHECKCODE T2EquipDef::AreaCheck(T2TowerDoc* inDoc, RECT& inRect, unsigned int, BOOL inShowError) { return AreaCheckCode_0; } /*virtual*/ PARTCODE T2EquipDef::GetPartFromPoint(T2TowerDoc* towerDoc, T2Equip* equip, POINT pt, int*) { UT2Coordinate::QDToUnit(pt, towerDoc->mZoomLevel); if (PtInRect(&equip->mArea, pt)) return PartCode_2; else return PartCode_0; } /*virtual*/ void T2EquipDef::BuildFinish(T2TowerDoc* towerDoc, T2Equip* equip) { towerDoc->GetWorldDef()->CalcOptionObj(towerDoc, equip); } /*virtual*/ unsigned long T2EquipDef::OptionProc(T2TowerDoc*, T2Equip*, void*) { return 0; } /*virtual*/ void T2EquipDef::DebugInfo(CWnd&, CListCtrl&, T2Equip*) { } /*virtual*/ BOOL T2EquipDef::FingerToolProc(T2TowerDoc*, T2Equip*, const POINT&, MOUSEEVENT) { return false; } /*virtual*/ T2InfoDialog* T2EquipDef::ShowInfoDialog(T2TowerDoc* towerDoc, T2Equip* equip) { CRect rect; AfxGetMainWnd()->GetWindowRect(rect); T2DLGTEMPLATE tmpl; tmpl.pt = rect.CenterPoint(); tmpl.moduleHandle = mModuleHandle; tmpl.resID = GetInfoDialogID(towerDoc, equip); T2InfoDialog *dialog = ConstructInfoDialog(equip); dialog->Realize(this, &tmpl, towerDoc, mImageObj, NULL, true, NULL, 0, 1); return dialog; } /*virtual*/ int T2EquipDef::GetInfoDialogID(T2TowerDoc*, const T2Equip*) const { return 1000; } /*virtual*/ T2InfoDialog* T2EquipDef::ConstructInfoDialog(T2Equip* equip) { return new T2InfoDialog(equip); } /*virtual*/ void T2EquipDef::DrawPeople(T2TowerDoc* inDoc, T2Equip* inEquip) { T2Tenant *theTenant = (T2Tenant *) inEquip; T2PeopleLinkIterator iterator(theTenant->mFirstPeople); T2People *thePeople; while (iterator.Next(&thePeople)) thePeople->Draw(inDoc, inEquip); } int T2EquipDef::GetInMoney(int i) { int cost = 0; if (i < mNumOfInMoney) cost = mInMoney[i]; return cost; } /*virtual*/ void T2EquipDef::LoadExtraData(T2Archive& inArchive, T2TowerDoc*, T2HaveOutViewObject*) { int size; inArchive >> size; for (int i = 0; i < size; i++) { unsigned char b; inArchive >> b; } } /*virtual*/ void T2EquipDef::SaveExtraData(T2Archive& inArchive, T2HaveOutViewObject*) { int size = 0; inArchive << size; } T2WordDefArray* T2EquipDef::MakeWordDefArray() { return new T2WordDefArray(mModuleHandle); } void T2EquipDef::GetWords(T2People*, CString&) const { }