#include "CResFile.h" #include "T2BitImage.h" #include "T2FloorInfo.h" #include "T2ImageObj.h" #include "T2InfoDialog.h" #include "T2Mover.h" #include "T2MoverDef.h" #include "T2MoverModuleList.h" #include "T2MoverPlugin.h" #include "T2TowerDoc.h" #include "UT2Coordinate.h" T2MoverDef::T2MoverDef(DWORD type, T2PluginSpecifier& specifier, CResFile* resFile, T2WorldDef* worldDef, T2MoverPlugin* plugin) : T2EquipDef(type, specifier, resFile, worldDef, plugin) { *resFile >> mAddSize; *resFile >> mMaxLength; *resFile >> mMinLength; *resFile >> mMaxStop; *resFile >> mScore; *resFile >> mDefaultWait; for (int i = 0; i < 3; i++) *resFile >> mSpeed[i]; *resFile >> mMaxModule; *resFile >> m188; *resFile >> m18C; *resFile >> m190; *resFile >> m194; *resFile >> mModuleInset; m1AC = 5; m1B0[0] = 3; m1B0[1] = 10; m1B0[2] = 15; DWORD tmp; *resFile >> tmp; *resFile >> tmp; *resFile >> tmp; *resFile >> tmp; mOffBitMap = NULL; mOffBitMap = new T2BitImage(mModuleHandle, 200, true); mImageObj->AddObject(mModuleHandle, 200, mOffBitMap); mIsLoaded = true; } /*virtual*/ T2MoverDef::~T2MoverDef() { if (mOffBitMap) delete mOffBitMap; } /*virtual*/ void T2MoverDef::GetName(CString& outStr) { outStr = "MOVER"; } BOOL T2MoverDef::InitObject(T2Mover* mover, const POINT&) { T2EquipDef::InitObject(mover); return true; } /*virtual*/ AREACHECKCODE T2MoverDef::AreaCheck(T2TowerDoc* towerDoc, RECT& rect, unsigned int, int) { if (!towerDoc->mFloorInfo->IsThereMover(rect)) return AreaCheckCode_1; RECT adjRect = rect; adjRect.top++; adjRect.bottom--; if (adjRect.top < adjRect.bottom && !towerDoc->mFloorInfo->IsThereMover(adjRect)) return AreaCheckCode_0; if (!towerDoc->mFloorInfo->IsThereOtherKindMover(rect, GetEquipType())) return AreaCheckCode_2; return AreaCheckCode_0; } /*virtual*/ int T2MoverDef::ClickProc(T2TowerDoc*, RECT*, unsigned int&) { return 0; } /*virtual*/ int T2MoverDef::MakeRequestProc(T2TowerDoc*, T2Equip*) { return -1; } /*virtual*/ PROCCODE T2MoverDef::AddModuleProc(T2TowerDoc*, T2Equip*, RECT*) { return ProcCode_0; } /*virtual*/ int T2MoverDef::GetMinMaxRangeProc(T2TowerDoc*, T2Equip*, int) { return -1; } /*virtual*/ int T2MoverDef::HandleUpProc(T2TowerDoc*, T2Equip*, POINT pt) { return -1; } /*virtual*/ int T2MoverDef::HandleDownProc(T2TowerDoc*, T2Equip*, POINT pt) { return -1; } /*virtual*/ int T2MoverDef::ClickShaftProc(T2TowerDoc*, T2Equip*, POINT pt) { return -1; } /*virtual*/ int T2MoverDef::CalcModulePatIndex(int numPeople) { int result = 0; if (numPeople > 0) { if (numPeople == mCapacity) { result = m1AC - 1; } else { BOOL done = false; for (int i = 0; i < 3 && !done; i++) { if (numPeople < m1B0[i]) { result = i + 1; done = true; } } if (!done) result = 3; } } return result; } /*virtual*/ CURSORTYPE T2MoverDef::QueryCursor(T2TowerDoc* towerDoc, POINT pt, CString& outStr, RECT& ioRect, POINT& outPt, int factor, unsigned int, int) { outStr = "Csr"; pt.x -= (mWidth * (UT2Coordinate::UnitHSize(factor)) / 2 - UT2Coordinate::UnitHSize(factor) / 2); pt.y -= (mHeight * (UT2Coordinate::UnitVSize(factor)) / 2 - UT2Coordinate::UnitVSize(factor) / 2); UT2Coordinate::QDToUnit(pt, factor); SetRect(&ioRect, pt.x, pt.y, pt.x + mWidth, pt.y + mHeight); outPt.x = ioRect.left; outPt.y = ioRect.top; ioRect.top += mAddSize.top; ioRect.left += mAddSize.left; ioRect.right += mAddSize.right; ioRect.bottom += mAddSize.bottom; UT2Coordinate::UnitToQD(ioRect, factor); return CursorType_0; } /*virtual*/ int T2MoverDef::IsaKindOfStopProc(T2TowerDoc* towerDoc, T2Equip*, int, int unk) const { int result = 0; switch (unk) { case 0: result = 1; break; case 1: result = 1; break; } return result; } /*virtual*/ int T2MoverDef::CalcMentenanceCostProc(const T2HaveOutViewObject* obj) const { int result = 0; T2ToolDef *otherDef = obj->GetToolDef(); if (otherDef->IsSetAttribute(kToolAttrNormalMenteCost)) { result = otherDef->GetOutMoney(0); int moduleCount = ((T2Mover *) obj)->mModuleList->GetModuleCount(); if (((T2Mover *) obj)->IsStair()) moduleCount /= 2; result = result * moduleCount; } return result; } /*virtual*/ T2InfoDialog* T2MoverDef::ShowInfoDialog(T2TowerDoc* towerDoc, T2Mover* mover, CPoint pt) { int var = 0; PARTCODE partCode = GetPartFromPoint(towerDoc, mover, pt, &var); T2InfoDialog *dialog = NULL; if (partCode != PartCode_0) { CRect rect; AfxGetMainWnd()->GetWindowRect(rect); T2DLGTEMPLATE tmpl; tmpl.pt = rect.CenterPoint(); tmpl.moduleHandle = mModuleHandle; tmpl.resID = GetInfoDialogID(towerDoc, mover, partCode, var); dialog = ConstructInfoDialog(mover, partCode, var); dialog->Realize(this, &tmpl, towerDoc, mImageObj, NULL, true, NULL, 0, true); } return dialog; } /*virtual*/ int T2MoverDef::GetInfoDialogID(T2TowerDoc* towerDoc, const T2Mover* mover, PARTCODE, int) const { return T2EquipDef::GetInfoDialogID(towerDoc, mover); } /*virtual*/ T2InfoDialog* T2MoverDef::ConstructInfoDialog(T2Mover* mover, PARTCODE, int) { return T2EquipDef::ConstructInfoDialog(mover); }