#include "CResFile.h" #include "GlobalFunc.h" #include "T2Archive.h" #include "T2BitImage.h" #include "T2ColdTableDef.h" #include "T2DateTime.h" #include "T2DlgItemAnimation.h" #include "T2FInfoAreaIterator.h" #include "T2FloorInfo.h" #include "T2ImageObj.h" #include "T2Message.h" #include "T2MWControl.h" #include "T2PaletteAnime.h" #include "T2PaletteAnimeDef.h" #include "T2Pool.h" #include "T2PoolDef.h" #include "T2SeasonParamDef.h" #include "T2Tenant.h" #include "T2TenantDef.h" #include "T2TowerDoc.h" #include "T2TowerEvent.h" #include "T2TowerMainView.h" #include "T2WordDefArray.h" #include "T2WorldDef.h" #include "T2WorldPlugin.h" #include "URect.h" #include "UT2BkgndInfo.h" #include "UT2Coordinate.h" T2WorldDef::T2WorldDef(DWORD inType, T2PluginSpecifier& inSpecifier, CResFile* inResFile, T2WorldPlugin* inPlugin) : T2TemplatePlugin(inType, inSpecifier, inResFile, inPlugin) { int i; int a; m1D0 = new T2ImageObj; *inResFile >> mWorldType; *inResFile >> mHeight; *inResFile >> mWidth; *inResFile >> mGroundLine; *inResFile >> mBuildArea; *inResFile >> mInitPos; *inResFile >> mTopFloorLine; *inResFile >> mBottomFloorLine; *inResFile >> m70; *inResFile >> m74; *inResFile >> mLobbyHeight; *inResFile >> mOutViewKind; *inResFile >> m17C; *inResFile >> m228; *inResFile >> mNumOfGradeDef; for (i = 0; i < 8; i++) { if (i < mNumOfGradeDef) { *inResFile >> mGradeDef[i].m0; *inResFile >> mGradeDef[i].m4; *inResFile >> mGradeDef[i].m8; *inResFile >> mGradeDef[i].mC; *inResFile >> mGradeDef[i].m10; *inResFile >> mGradeDef[i].m14; } else { mGradeDef[i].m0 = 0; mGradeDef[i].m4 = 0; mGradeDef[i].m8 = 0; mGradeDef[i].mC = 0; mGradeDef[i].m10 = 0; mGradeDef[i].m14 = 0; } } *inResFile >> mBGVUnit; *inResFile >> mBGHUnit; *inResFile >> mSkyVSize; *inResFile >> mSkyHSize; *inResFile >> a; *inResFile >> a; *inResFile >> a; *inResFile >> a; *inResFile >> a; *inResFile >> a; *inResFile >> a; *inResFile >> a; *inResFile >> a; *inResFile >> a; *inResFile >> m148[0]; *inResFile >> m148[1]; *inResFile >> m148[2]; *inResFile >> m148[3]; *inResFile >> m148[4]; *inResFile >> m15C; *inResFile >> mDustOnThreshold; *inResFile >> mToiletVar1; *inResFile >> mToiletVar2; *inResFile >> a; memset(mCashAmount, 0, sizeof(mCashAmount)); int numOfCashAmount; *inResFile >> numOfCashAmount; for (i = 0; i < numOfCashAmount; i++) { int v; *inResFile >> v; if (i < 8) mCashAmount[i] = v; } CResFile resFile; resFile.OpenResource(mModuleHandle, 128, 'WAtr'); resFile >> a; resFile >> a; resFile >> a; resFile >> a; resFile >> a; resFile >> a; resFile >> mInitialFunds; resFile >> mMoneyNumerator; resFile >> mMoneyDenominator; resFile >> mMoneyUnit; mSkyOffscreen = NULL; m1A0 = NULL; m1AC = NULL; m1B0 = NULL; for (i = 0; i < 2; i++) m1A4[i] = NULL; mImage = NULL; m1C4 = NULL; m1C8 = NULL; m1CC = NULL; mWordDefArray = new T2WordDefArray(mModuleHandle); mPaletteAnimeDef = MakePaletteAnimeDef(); SetupOffscreen(mModuleHandle); mPoolDef = MakePoolDef(); mSeasonParamDef = MakeSeasonParamDef(); mColdTableDef = MakeColdTableDef(); m190.x = 0; m190.y = 0; int craneObjectID = mImageObj->FindObject("OutCrane"); if (craneObjectID >= 0) { mImageObj->GetObjectSize(craneObjectID, (SIZE *) &m190); UT2Coordinate::QDToUnit(m190, 0); } _210 = 0; _214 = false; mIsLoaded = true; } T2PaletteAnimeDef* T2WorldDef::MakePaletteAnimeDef() { CResFile resFile; resFile.OpenResource(mModuleHandle, 1, 'PtDf'); T2PaletteAnimeDef *theAnimeDef = new T2PaletteAnimeDef(mModuleHandle, &resFile); return theAnimeDef; } T2PoolDef* T2WorldDef::MakePoolDef() { CResFile resFile; resFile.OpenResource(mModuleHandle, 1, 'PoDf'); T2PoolDef *thePoolDef = new T2PoolDef(resFile, (T2WorldPlugin *) mPlugin); return thePoolDef; } T2SeasonParamDef* T2WorldDef::MakeSeasonParamDef() { CResFile resFile; T2SeasonParamDef *theSeasonDef = NULL; if (resFile.OpenResource(mModuleHandle, 1, 'SpDf')) { theSeasonDef = new T2SeasonParamDef(resFile); resFile.End(); } return theSeasonDef; } T2ColdTableDef* T2WorldDef::MakeColdTableDef() { CResFile resFile; T2ColdTableDef *theTableDef = NULL; if (resFile.OpenResource(mModuleHandle, 1, 'CoDf')) { theTableDef = new T2ColdTableDef(resFile); resFile.End(); } return theTableDef; } /*virtual*/ T2WorldDef::~T2WorldDef() { DisposePalette(); DisposeOffscreen(); if (mImage) delete mImage; delete m1D0; m1D0 = NULL; delete mPoolDef; delete mWordDefArray; if (mTowerEvent) delete mTowerEvent; } /*virtual*/ void T2WorldDef::GetName(CString& outStr) { outStr = (char) mWorldType; } /*virtual*/ void T2WorldDef::DrawWorld(T2TowerDoc* inDoc) { RECT srcRect; SetRect(&srcRect, 0, 0, 64, 72); RECT destRect = srcRect; mImage->CopyImage(*inDoc->towerDoc_vf10C(), srcRect, destRect); } /*virtual*/ void T2WorldDef::DrawBkgnd(unsigned int inImageIndex, const RECT& inDestRect, T2TowerDoc* inDoc) { int width = mBGHUnit; int height = mBGVUnit; RECT srcRect; SetRect(&srcRect, 0, 0, width, height); OffsetRect(&srcRect, 0, inImageIndex * height); RECT destRect = inDestRect; UT2Coordinate::BkgndToQD(destRect, inDoc->towerDoc_vf108()); mSkyOffscreen->CopyImage(*inDoc->towerDoc_vf10C(), srcRect, destRect); } /*virtual*/ void T2WorldDef::DrawBkgnd(const RECT& inRect, T2TowerDoc* inDoc) { if (m228) { BkgndInfo *infoPtr = inDoc->mBkgndInfo; for (int v = inRect.top; v < inRect.bottom; v++) { for (int h = inRect.left; h < inRect.right; h++) { unsigned int imageIndex = UT2BkgndInfo::GetBkgndInfo(infoPtr, v, h); RECT rect; SetRect(&rect, h, v, h + 1, v + 1); DrawBkgnd(imageIndex, rect, inDoc); } } } else { RECT srcRect = inRect; srcRect.top *= mBGVUnit; srcRect.left *= mBGHUnit; srcRect.bottom *= mBGVUnit; srcRect.right *= mBGHUnit; RECT destRect; UT2Coordinate::BkgndToQD(inRect, destRect, inDoc->towerDoc_vf108()); mSkyOffscreen->CopyImage(*inDoc->towerDoc_vf10C(), srcRect, destRect); } } /*virtual*/ void T2WorldDef::DrawRoofAndFloor(const RECT& inRect, T2TowerDoc* inDoc, ROOFANDFLOOR inRoofAndFloor) { RECT unitRect = inRect; RECT qdRect; int id; if (inRoofAndFloor & RoofAndFloor_Roof) { UT2Coordinate::UnitToQDRoof(unitRect, qdRect, inDoc->mZoomLevel); id = mImageObj->FindObject("Roof"); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), id, qdRect, inDoc->towerDoc_vf108()); } if (inRoofAndFloor & RoofAndFloor_Floor) { UT2Coordinate::UnitToQDFloor(unitRect, qdRect, inDoc->mZoomLevel); id = mImageObj->FindObject("Floor"); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), id, qdRect, inDoc->towerDoc_vf108()); } } /*virtual*/ void T2WorldDef::DrawSideObj(T2Equip* inEquip, T2TowerDoc* inDoc, SIDEOBJPATTERN inSideObjPattern) { if (inSideObjPattern == SideObjPattern_0 || inSideObjPattern == SideObjPattern_1) { CString name1, name2; if (((T2Tenant *) inEquip)->IsFloor() && inEquip->mValiation == 1) name1 = "Tent"; else name1 = "Side"; if (inSideObjPattern == SideObjPattern_0) name2 = "L"; else name2 = "R"; int numPattern = 0; if (inDoc->towerDoc_vf140() == ViewMode_1) { numPattern = 1; if (inDoc->towerDoc_vf160()->IsSnow()) numPattern = 2; } int objectID = mImageObj->FindObject(name1 + name2, numPattern); SIZE size; mImageObj->GetObjectSize(objectID, &size); size.cx = size.cx / 8; size.cy = (size.cy + 35) / 36; RECT unitRect, rect; if (inSideObjPattern == SideObjPattern_0) { unitRect.right = inEquip->mArea.left; unitRect.left = unitRect.right - size.cx; } else if (inSideObjPattern == SideObjPattern_1) { unitRect.left = inEquip->mArea.right; unitRect.right = unitRect.left + size.cx; } if (((T2Tenant *) inEquip)->IsFloor() && inEquip->mValiation == 1) { unitRect.bottom = inEquip->mArea.bottom; unitRect.top = unitRect.bottom - size.cy; UT2Coordinate::UnitToQD(unitRect, rect, inDoc->mZoomLevel, true); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, rect, inDoc->towerDoc_vf108()); objectID = mImageObj->FindObject("Side" + name2, numPattern); mImageObj->GetObjectSize(objectID, &size); size.cx = size.cx / 8; size.cy = (size.cy + 35) / 36; if (inSideObjPattern == SideObjPattern_0) { unitRect.right = inEquip->mArea.left; unitRect.left = unitRect.right - size.cx; } else if (inSideObjPattern == SideObjPattern_1) { unitRect.left = inEquip->mArea.right; unitRect.right = unitRect.left + size.cx; } unitRect.top = inEquip->mArea.top; unitRect.bottom = unitRect.top + size.cy; for (int v = inEquip->mArea.top; v < (inEquip->mArea.bottom - 1); v++) { UT2Coordinate::UnitToQD(unitRect, rect, inDoc->mZoomLevel, true); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, rect, inDoc->towerDoc_vf108()); unitRect.top++; unitRect.bottom++; } } else if (((T2TenantDef *) inEquip->GetEquipDef())->m198 && !((T2TenantDef *) inEquip->GetEquipDef())->m194) { unitRect.bottom = inEquip->mArea.bottom; unitRect.top = unitRect.bottom - size.cy; UT2Coordinate::UnitToQD(unitRect, rect, inDoc->mZoomLevel, true); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, rect, inDoc->towerDoc_vf108()); } else if (!((T2TenantDef *) inEquip->GetEquipDef())->m198 && ((T2TenantDef *) inEquip->GetEquipDef())->m194) { unitRect.top = inEquip->mArea.top; unitRect.bottom = unitRect.top + -size.cy; UT2Coordinate::UnitToQD(unitRect, rect, inDoc->mZoomLevel, true); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, rect, inDoc->towerDoc_vf108()); } else if (((T2TenantDef *) inEquip->GetEquipDef())->m198 && ((T2TenantDef *) inEquip->GetEquipDef())->m194) { unitRect.top = inEquip->mArea.top; unitRect.bottom = unitRect.top + size.cy; for (int v = inEquip->mArea.top; v < inEquip->mArea.bottom; v++) { UT2Coordinate::UnitToQD(unitRect, rect, inDoc->mZoomLevel, true); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, rect, inDoc->towerDoc_vf108()); unitRect.top++; unitRect.bottom++; } } } } /*virtual*/ void T2WorldDef::DrawCrane(T2TowerDoc* inDoc, const RECT& inRect) { T2FloorInfo *floorInfo = inDoc->towerDoc_vf12C(); T2BitImage *theViewImage = inDoc->GetTowerMainView()->m60; int theZoomLevel = inDoc->mZoomLevel; RECT craneArea; craneArea.top = 0; craneArea.left = 0; craneArea.bottom = m190.y; craneArea.right = m190.x; int id = mImageObj->FindObject("OutCrane"); if (id >= 0) { for (int i = 0; i < inDoc->mCraneCount; i++) { RECT unitRect, qdRect, intersection; unitRect = craneArea; OffsetRect(&unitRect, inDoc->mCranePosArray[i].x, inDoc->mCranePosArray[i].y); if (IntersectRect(&intersection, &inRect, &unitRect)) { UT2Coordinate::UnitToQD(unitRect, qdRect, theZoomLevel, true); mImageObj->DrawObject(theViewImage, id, qdRect, theZoomLevel); } } } } /*virtual*/ void T2WorldDef::CalcCranePos(T2TowerDoc* inDoc) { int count = 0; POINT *array = (POINT *) malloc(GetWidth() * sizeof(POINT) / m190.x); T2FloorInfo *floorInfo = inDoc->towerDoc_vf12C(); RECT rect; SetRect(&rect, 0, 0, GetWidth(), mGroundLine); T2FInfoAreaIterator iterator(*floorInfo, rect); T2Tenant *theTenant; ClearCranePos(inDoc); while (iterator.NextTenant(theTenant)) { T2Tenant *theFloor; if (theTenant->IsFloor()) theFloor = theTenant; else theFloor = floorInfo->GetTenant(theTenant->GetFloorID(theTenant->mArea.top)); BOOL valid = true; if (theTenant->mArea.top < mTopFloorLine || (theTenant->mArea.right - theTenant->mArea.left) < 6) valid = false; if (valid) { RECT rect2; rect2.left = theFloor->mArea.left; rect2.bottom = theFloor->mArea.top; rect2.right = theFloor->mArea.right; rect2.top = rect2.bottom - 1; T2FInfoAreaIterator iterator2(*floorInfo, rect2); T2Tenant *theTenant2; while (iterator2.NextTenant(theTenant2)) { T2Tenant *theFloor2; if (theTenant2->IsFloor()) theFloor2 = theTenant2; else theFloor2 = floorInfo->GetTenant(theTenant2->GetFloorID(-1)); if ((theFloor2->mArea.right - theFloor2->mArea.left) >= 6) { valid = false; break; } } } if (valid) { RECT rect2; rect2.left = theFloor->mArea.left; rect2.bottom = theFloor->mArea.top; rect2.right = theFloor->mArea.left + 6; rect2.top = rect2.bottom - 1; T2FInfoAreaIterator iterator2(*floorInfo, rect2); T2Tenant *theTenant2; if (iterator2.NextTenant(theTenant2)) valid = false; } if (valid) { if (floorInfo->GetTenantID(theFloor->mArea.top, theFloor->mArea.left - 1)) valid = false; } if (valid) { array[count].x = theFloor->mArea.left; array[count].y = theFloor->mArea.top - m190.y; count++; } } if (count) { inDoc->mCranePosArray = (POINT *) malloc(count * sizeof(POINT)); inDoc->mCraneCount = count; memcpy(inDoc->mCranePosArray, array, count * sizeof(POINT)); } free(array); } /*virtual*/ void T2WorldDef::ClearCranePos(T2TowerDoc* inDoc) { if (inDoc->mCranePosArray) free(inDoc->mCranePosArray); inDoc->mCranePosArray = NULL; inDoc->mCraneCount = 0; } /*virtual*/ void T2WorldDef::DrawBuild(T2Equip* inEquip, T2TowerDoc* inDoc) { RECT area; inEquip->GetEquipArea(area); int pattern; if (inEquip->GetStatus() < 2) pattern = 0; else pattern = 1; int objIndex = mImageObj->FindObject("BuildPrc", pattern); for (int v = area.top; v < area.bottom; v++) { RECT rect = area; rect.top = v; rect.bottom = rect.top + 1; UT2Coordinate::UnitToQD(rect, inDoc->mZoomLevel, true); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objIndex, rect, inDoc->towerDoc_vf108()); } } void T2WorldDef::SetupOffscreen(HINSTANCE inModule) { // background mSkyOffscreen = new T2BitImage(inModule, 1000, true); // emergency stairs (side of building) m1A4[0] = new T2BitImage(inModule, 1002, true); mImageObj->AddObject(inModule, 1002, m1A4[0]); // side of lobby m1A4[1] = new T2BitImage(inModule, 1003, true); mImageObj->AddObject(inModule, 1003, m1A4[1]); // under-construction floor m1AC = new T2BitImage(inModule, 1004, true); mImageObj->AddObject(inModule, 1004, m1AC); // some person m1B0 = new T2BitImage(inModule, 1005, true); mImageObj->AddObject(inModule, 1005, m1B0); // tool buttons m1B4 = new T2BitImage(inModule, 2000, true); m1D0->AddObject(inModule, 2000, m1B4); // message window m1B8 = new T2BitImage(inModule, 10000, true); mImageObj->AddObject(inModule, 10000, m1B8); // control window m1BC = new T2BitImage(inModule, 10001, true); mImageObj->AddObject(inModule, 10001, m1BC); // dialog sprites m1C0 = new T2BitImage(inModule, 10002, true); mImageObj->AddObject(inModule, 10002, m1C0); // crane m1C4 = new T2BitImage(inModule, 3000, true); mImageObj->AddObject(inModule, 3000, m1C4); // icons shown over tenants m1C8 = new T2BitImage(inModule, 1006, true); mImageObj->AddObject(inModule, 1006, m1C8); try { // burning floor m1CC = new T2BitImage(inModule, 1007, true); mImageObj->AddObject(inModule, 1007, m1CC); } catch (int x) { } } void T2WorldDef::DisposeOffscreen() { if (mSkyOffscreen) delete mSkyOffscreen; if (m1A0) delete m1A0; for (int i = 0; i < 2; i++) { if (m1A4[i]) delete m1A4[i]; } if (m1AC) delete m1AC; if (m1B0) delete m1B0; if (m1B4) delete m1B4; delete m1B8; delete m1BC; delete m1C0; delete m1C4; delete m1C8; if (m1CC) delete m1CC; } void T2WorldDef::SetupPalette(HINSTANCE inModule) { } void T2WorldDef::DisposePalette() { } /*virtual*/ void T2WorldDef::DoAnimate(T2TowerDoc* inDoc) { } /*virtual*/ BOOL T2WorldDef::TenantAreaCheck(T2TowerDoc* inDoc, RECT& inRect, BOOL inShowMessage) { if (inRect.bottom != mGroundLine) { int v, h; v = mGroundLine - 1; for (h = inRect.left; h < inRect.right; h++) { if (!inDoc->mFloorInfo->GetTenant(v, h)) { if (inShowMessage) { // "1Fのフロアからはみ出して設置することはできません" // It cannot be installed protruding from the 1F floor. (new T2Message)->ShowMessage("\x82\x50\x82\x65\x82\xCC\x83\x74\x83\x8D\x83\x41\x82\xA9\x82\xE7\x82\xCD\x82\xDD\x8F\x6F\x82\xB5\x82\xC4\x90\xDD\x92\x75\x82\xB7\x82\xE9\x82\xB1\x82\xC6\x82\xCD\x82\xC5\x82\xAB\x82\xDC\x82\xB9\x82\xF1"); } return false; } } } return true; } /*virtual*/ int T2WorldDef::IdleProc(T2TowerDoc* inDoc) { return mTowerEvent->Idle(inDoc); } /*virtual*/ void T2WorldDef::DrawCtrl(T2TowerDoc* inDoc, T2MWControl* inControl) { T2Pool *thePool; int population; switch (inControl->GetDlgCtrlID()) { case 1000: DrawClock(inControl, *inDoc->mNow); break; case 1001: DrawCalendar(inControl, *inDoc->mNow, inDoc); break; case 1002: DrawFunds(inControl, inDoc->towerDoc_vf26C()); break; case 2000: DrawPauseButton(inControl); break; case 1004: DrawMessage(inControl); break; case 1003: thePool = inDoc->towerDoc_vf130(); #line 755 _ASSERT(thePool != NULL); population = thePool->GetPopulation(); DrawPopulation(inControl, population); break; case 2001: DrawInViewButton(inControl); break; case 2006: DrawOutViewButton(inControl); break; case 2004: DrawMaintButton(inControl); break; case 2003: DrawEvalButton(inControl); break; case 2002: DrawPriceButton(inControl); break; case 2005: DrawTransButton(inControl); break; case 2007: DrawSlider(inControl); break; } } /*virtual*/ void T2WorldDef::ButtonDownOnCtrl(T2TowerDoc* inDoc, T2MWControl* inControl, CPoint inPt, CWnd* inWnd) { inControl->SetCapture(); int pattern = inControl->GetData(); int newValue; switch (inControl->GetDlgCtrlID()) { case 1000: case 1001: case 1002: case 1003: if (pattern < 100) inControl->SetData(pattern + 100); break; case 2000: if (pattern == 0) { _214 = true; inControl->SetData(100); ClickPauseButton(inControl, inDoc); } else { _214 = false; } break; case 2001: ClickInViewButton(inControl, inDoc); goto refreshButtons; case 2006: ClickOutViewButton(inControl, inDoc); goto refreshButtons; case 2004: ClickMaintButton(inControl, inDoc); goto refreshButtons; case 2003: ClickEvalButton(inControl, inDoc); goto refreshButtons; case 2002: ClickPriceButton(inControl, inDoc); goto refreshButtons; case 2005: ClickTransButton(inControl, inDoc); refreshButtons: ((T2MWControl *) inWnd->GetDlgItem(2001))->SetData(0); ((T2MWControl *) inWnd->GetDlgItem(2006))->SetData(0); ((T2MWControl *) inWnd->GetDlgItem(2004))->SetData(0); ((T2MWControl *) inWnd->GetDlgItem(2003))->SetData(0); ((T2MWControl *) inWnd->GetDlgItem(2002))->SetData(0); ((T2MWControl *) inWnd->GetDlgItem(2005))->SetData(0); inControl->SetData(100); break; case 2007: newValue = SliderPointToValue(inControl, inPt); if (newValue != inControl->GetData()) { inControl->SetData(newValue); if (newValue == 0) inDoc->towerDoc_vf14C(-1); else inDoc->towerDoc_vf14C(7 - newValue); } break; } } /*virtual*/ void T2WorldDef::ButtonUpOnCtrl(T2TowerDoc* inDoc, T2MWControl* inControl, CPoint inPt, CWnd* inWnd) { if (GetCapture() == inControl->m_hWnd) { ReleaseCapture(); int pattern = inControl->GetData(); switch (inControl->GetDlgCtrlID()) { case 1000: ClickClock(inControl, inDoc); break; case 1001: ClickCalendar(inControl, inDoc); break; case 1002: ClickFunds(inControl, inDoc); break; case 1003: ClickPopulation(inControl, inDoc); break; case 2000: if (!_214) { inControl->SetData(0); ClickPauseButton(inControl, inDoc); } break; } } } /*virtual*/ void T2WorldDef::MouseMoveOnCtrl(T2TowerDoc* inDoc, T2MWControl* inControl, CPoint inPt, CWnd* inWnd) { int newValue; if (GetCapture() == inControl->m_hWnd) { switch (inControl->GetDlgCtrlID()) { case 2007: newValue = SliderPointToValue(inControl, inPt); if (newValue != inControl->GetData()) { inControl->SetData(newValue); if (newValue == 0) inDoc->towerDoc_vf14C(-1); else inDoc->towerDoc_vf14C(7 - newValue); } break; } } } /*virtual*/ void T2WorldDef::ClickClock(T2MWControl* inControl, T2TowerDoc* inDoc) { int value = inControl->GetData(); if (value >= 100) value -= 100; inControl->SetData(value); } /*virtual*/ void T2WorldDef::ClickCalendar(T2MWControl* inControl, T2TowerDoc* inDoc) { int value = inControl->GetData(); if (value >= 100) value -= 100; inControl->SetData(value); inDoc->CallbackCalendar(); } /*virtual*/ void T2WorldDef::ClickFunds(T2MWControl* inControl, T2TowerDoc* inDoc) { int value = inControl->GetData(); if (value >= 100) value -= 100; inControl->SetData(value); inDoc->CallbackFunds(); } /*virtual*/ void T2WorldDef::ClickPopulation(T2MWControl* inControl, T2TowerDoc* inDoc) { int value = inControl->GetData(); if (value >= 100) value -= 100; inControl->SetData(value); inDoc->CallbackPopulation(); } /*virtual*/ void T2WorldDef::DrawClock(T2MWControl* inControl, T2DateTime& inDateTime) { #pragma var_order(angle, dc2, theImage, save2, save, x, hours, y, imageRect, rect2, objectID, minutes, bitmap, pDC) int objectID = mImageObj->FindObject("Clock", 1); RECT imageRect; T2BitImage *theImage = mImageObj->GetObjectImage(objectID, imageRect); RECT rect2 = imageRect; OffsetRect(&rect2, -rect2.left, -rect2.top); CDC *pDC = inControl->GetDC(); int save = pDC->SaveDC(); pDC->SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); pDC->RealizePalette(); CDC dc2; dc2.CreateCompatibleDC(pDC); int save2 = dc2.SaveDC(); dc2.SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); dc2.RealizePalette(); HBITMAP bitmap = Create256DIBitmap(dc2.m_hDC, rect2.right, rect2.bottom); SelectObject(dc2.m_hDC, bitmap); theImage->CopyImage(&dc2, imageRect, rect2); float hours = inDateTime.GetHour() + inDateTime.GetMinutes() / 60.0f; float angle = (6.283186f * hours) / 12.0f; int x = (rect2.right / 2) + (rect2.right * 0.3 * sin(angle)) + 0.5; int y = (rect2.bottom / 2) - (rect2.bottom * 0.3 * cos(angle)) + 0.5; dc2.MoveTo(rect2.right / 2, rect2.bottom / 2); dc2.LineTo(x, y); float minutes = inDateTime.GetMinutes(); angle = (6.283186f * minutes) / 60.0f; x = (rect2.right / 2) + (rect2.right * 0.4 * sin(angle)) + 0.5; y = (rect2.bottom / 2) - (rect2.bottom * 0.4 * cos(angle)) + 0.5; dc2.MoveTo(rect2.right / 2, rect2.bottom / 2); dc2.LineTo(x, y); pDC->BitBlt(0, 0, rect2.right, rect2.bottom, &dc2, 0, 0, SRCCOPY); dc2.RestoreDC(save2); dc2.DeleteDC(); DeleteObject(bitmap); pDC->RestoreDC(save); inControl->ReleaseDC(pDC); } /*virtual*/ void T2WorldDef::DrawCalendar(T2MWControl* inControl, T2DateTime& inDateTime, T2TowerDoc* inDoc) { #pragma var_order(year, imageRect, tempDC, theImage, save2, text, rect3, month, font, save, rect2, pattern, theBitmap, pDC) int pattern = inControl->GetData(); RECT imageRect; T2BitImage *theImage = mImageObj->GetObjectImage(mImageObj->FindObject("Calendar", pattern), imageRect); RECT rect2 = imageRect; OffsetRect(&rect2, -rect2.left, -rect2.top); CDC *pDC = inControl->GetDC(); int save = pDC->SaveDC(); pDC->SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); pDC->RealizePalette(); CDC tempDC; tempDC.CreateCompatibleDC(pDC); int save2 = tempDC.SaveDC(); tempDC.SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); tempDC.RealizePalette(); HBITMAP theBitmap = Create256DIBitmap(tempDC.m_hDC, rect2.right, rect2.bottom); SelectObject(tempDC.m_hDC, theBitmap); m1B8->CopyImage(&tempDC, imageRect, rect2); CRect rect3 = rect2; rect3.top += 2; rect3.left += 2; rect3.bottom -= 2; rect3.right -= 2; if (pattern == 100) rect3.OffsetRect(1, 1); CFont font; font.CreateFont(-rect3.Height(), 0, 0, 0, FW_BOLD, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); tempDC.SelectObject(&font); tempDC.SetBkMode(TRANSPARENT); int year = inDateTime.GetYear(); int month = inDateTime.GetMonth(); tempDC.SetTextAlign(TA_UPDATECP); tempDC.MoveTo(rect3.left, rect3.top); char text[80]; wsprintf(text, "\x91\xE6%d\x8A\xFA %d\x8C\x8E ", year, month); tempDC.TextOut(0, 0, text, strlen(text)); if (inDateTime.IsHoliday(inDoc)) { lstrcpy(text, "\x8B\x78\x93\xFA"); tempDC.SetTextColor(PALETTERGB(192, 0, 0)); } else { lstrcpy(text, "\x95\xBD\x93\xFA"); } tempDC.TextOut(0, 0, text, strlen(text)); tempDC.SetTextColor(RGB(0, 0, 0)); tempDC.SetTextAlign(TA_NOUPDATECP); pDC->BitBlt(0, 0, rect2.right, rect2.bottom, &tempDC, 0, 0, SRCCOPY); tempDC.RestoreDC(save2); tempDC.DeleteDC(); DeleteObject(theBitmap); font.DeleteObject(); pDC->RestoreDC(save); inControl->ReleaseDC(pDC); } /*virtual*/ void T2WorldDef::DrawFunds(T2MWControl* inControl, int inFunds) { #pragma var_order(imageRect, tempDC, theImage, save2, text, rect3, font, save, rect2, pattern, theBitmap, pDC) int pattern = inControl->GetData(); RECT imageRect; T2BitImage *theImage = mImageObj->GetObjectImage(mImageObj->FindObject("Funds", pattern), imageRect); RECT rect2 = imageRect; OffsetRect(&rect2, -rect2.left, -rect2.top); CDC *pDC = inControl->GetDC(); int save = pDC->SaveDC(); pDC->SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); pDC->RealizePalette(); CDC tempDC; tempDC.CreateCompatibleDC(pDC); int save2 = tempDC.SaveDC(); tempDC.SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); tempDC.RealizePalette(); HBITMAP theBitmap = Create256DIBitmap(tempDC.m_hDC, rect2.right, rect2.bottom); SelectObject(tempDC.m_hDC, theBitmap); m1B8->CopyImage(&tempDC, imageRect, rect2); CRect rect3 = rect2; rect3.top += 2; rect3.left += 11; rect3.bottom -= 2; rect3.right -= 23; if (pattern == 100) rect3.OffsetRect(1, 1); CFont font; font.CreateFont(-rect3.Height(), 0, 0, 0, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); tempDC.SelectObject(&font); tempDC.SetBkMode(TRANSPARENT); char text[80]; wsprintf(text, "%d", inFunds); tempDC.DrawText(text, &rect3, DT_RIGHT); pDC->BitBlt(0, 0, rect2.right, rect2.bottom, &tempDC, 0, 0, SRCCOPY); tempDC.RestoreDC(save2); tempDC.DeleteDC(); DeleteObject(theBitmap); font.DeleteObject(); pDC->RestoreDC(save); inControl->ReleaseDC(pDC); } /*virtual*/ void T2WorldDef::DrawMessage(T2MWControl* inControl) { #pragma var_order(imageRect, tempDC, theImage, save2, rect3, font, save, str, rect2, pattern, theBitmap, pDC) int pattern = inControl->GetData(); RECT imageRect; T2BitImage *theImage = mImageObj->GetObjectImage(mImageObj->FindObject("Message", pattern), imageRect); RECT rect2 = imageRect; OffsetRect(&rect2, -rect2.left, -rect2.top); CDC *pDC = inControl->GetDC(); int save = pDC->SaveDC(); pDC->SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); pDC->RealizePalette(); CDC tempDC; tempDC.CreateCompatibleDC(pDC); int save2 = tempDC.SaveDC(); tempDC.SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); tempDC.RealizePalette(); HBITMAP theBitmap = Create256DIBitmap(tempDC.m_hDC, rect2.right, rect2.bottom); SelectObject(tempDC.m_hDC, theBitmap); m1B8->CopyImage(&tempDC, imageRect, rect2); CRect rect3 = rect2; rect3.top = rect3.top; rect3.left = rect3.left + 4; rect3.bottom = rect3.bottom; rect3.right = rect3.right - 4; CFont font; font.CreateFont(-rect3.Height(), 0, 0, 0, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); tempDC.SelectObject(&font); tempDC.SetBkMode(TRANSPARENT); CString str; inControl->GetWindowText(str); tempDC.DrawText(str, &rect3, DT_SINGLELINE | DT_NOPREFIX); pDC->BitBlt(0, 0, rect2.right, rect2.bottom, &tempDC, 0, 0, SRCCOPY); tempDC.RestoreDC(save2); tempDC.DeleteDC(); DeleteObject(theBitmap); font.DeleteObject(); pDC->RestoreDC(save); inControl->ReleaseDC(pDC); } /*virtual*/ void T2WorldDef::DrawPauseButton(T2MWControl* inControl) { DrawSimpleMWControl(inControl, "Pause"); } /*virtual*/ void T2WorldDef::DrawPopulation(T2MWControl* inControl, int inPop) { #pragma var_order(imageRect, tempDC, theImage, save2, text, rect3, font, save, rect2, pattern, theBitmap, pDC) int pattern = inControl->GetData(); RECT imageRect; T2BitImage *theImage = mImageObj->GetObjectImage(mImageObj->FindObject("Population", pattern), imageRect); RECT rect2 = imageRect; OffsetRect(&rect2, -rect2.left, -rect2.top); CDC *pDC = inControl->GetDC(); int save = pDC->SaveDC(); pDC->SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); pDC->RealizePalette(); CDC tempDC; tempDC.CreateCompatibleDC(pDC); int save2 = tempDC.SaveDC(); tempDC.SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); tempDC.RealizePalette(); HBITMAP theBitmap = Create256DIBitmap(tempDC.m_hDC, rect2.right, rect2.bottom); SelectObject(tempDC.m_hDC, theBitmap); m1B8->CopyImage(&tempDC, imageRect, rect2); CRect rect3 = rect2; rect3.top += 2; rect3.left += 11; rect3.bottom -= 2; rect3.right -= 23; if (pattern == 100) rect3.OffsetRect(1, 1); CFont font; font.CreateFont(-rect3.Height(), 0, 0, 0, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); tempDC.SelectObject(&font); tempDC.SetBkMode(TRANSPARENT); char text[80]; wsprintf(text, "%d", inPop); tempDC.DrawText(text, &rect3, DT_RIGHT); pDC->BitBlt(0, 0, rect2.right, rect2.bottom, &tempDC, 0, 0, SRCCOPY); tempDC.RestoreDC(save2); tempDC.DeleteDC(); DeleteObject(theBitmap); font.DeleteObject(); pDC->RestoreDC(save); inControl->ReleaseDC(pDC); } /*virtual*/ void T2WorldDef::ClickPauseButton(T2MWControl* inControl, T2TowerDoc* inDoc) { inDoc->CallbackPause(_214); } /*virtual*/ void T2WorldDef::DrawInViewButton(T2MWControl* inControl) { DrawSimpleMWControl(inControl, "InView"); } /*virtual*/ void T2WorldDef::DrawOutViewButton(T2MWControl* inControl) { DrawSimpleMWControl(inControl, "OutView"); } /*virtual*/ void T2WorldDef::DrawMaintButton(T2MWControl* inControl) { DrawSimpleMWControl(inControl, "Maint"); } /*virtual*/ void T2WorldDef::DrawEvalButton(T2MWControl* inControl) { DrawSimpleMWControl(inControl, "Eval"); } /*virtual*/ void T2WorldDef::DrawPriceButton(T2MWControl* inControl) { DrawSimpleMWControl(inControl, "Price"); } /*virtual*/ void T2WorldDef::DrawTransButton(T2MWControl* inControl) { DrawSimpleMWControl(inControl, "Trans"); } /*virtual*/ void T2WorldDef::DrawSlider(T2MWControl* inControl) { #pragma var_order(threadRect, theImage, x, save, theImage2, imageRect, rect4, rect2, y, objectID, value, pDC) CDC *pDC = inControl->GetDC(); int save = pDC->SaveDC(); pDC->SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); pDC->RealizePalette(); int value = inControl->GetData(); int objectID = mImageObj->FindObject("Slider"); CRect imageRect; T2BitImage *theImage = mImageObj->GetObjectImage(objectID, imageRect); T2BitImage *theImage2 = new T2BitImage(imageRect); int x = imageRect.left; int y = imageRect.top; RECT rect2 = imageRect; OffsetRect(&rect2, -rect2.left, -rect2.top); theImage->CopyImage(*theImage2, imageRect, rect2); objectID = mImageObj->FindObject("SliderLever"); theImage = mImageObj->GetObjectImage(objectID, imageRect); CRect threadRect; mImageObj->GetObjectImage(mImageObj->FindObject("SliderThread"), threadRect); threadRect.OffsetRect(-x, -y); CRect rect4; rect4.left = 0; rect4.top = 0; rect4.right = imageRect.Width(); rect4.bottom = imageRect.Height(); rect4.OffsetRect( threadRect.left + ((threadRect.Width() * value) / 6) - (imageRect.Width() / 2), threadRect.top + (threadRect.Height() / 2) - (imageRect.Height() / 2) - 1 ); theImage->SetBackGndColor(0); theImage->CopyImage(*theImage2, imageRect, rect4); theImage2->CopyImage(pDC, rect2, rect2); delete theImage2; pDC->RestoreDC(save); inControl->ReleaseDC(pDC); } /*virtual*/ void T2WorldDef::ClickInViewButton(T2MWControl* inControl, T2TowerDoc* inDoc) { inDoc->CallbackInView(); } /*virtual*/ void T2WorldDef::ClickOutViewButton(T2MWControl* inControl, T2TowerDoc* inDoc) { inDoc->CallbackOutView(); } /*virtual*/ void T2WorldDef::ClickMaintButton(T2MWControl* inControl, T2TowerDoc* inDoc) { inDoc->CallbackMaintView(); } /*virtual*/ void T2WorldDef::ClickEvalButton(T2MWControl* inControl, T2TowerDoc* inDoc) { inDoc->CallbackEvalView(); } /*virtual*/ void T2WorldDef::ClickPriceButton(T2MWControl* inControl, T2TowerDoc* inDoc) { inDoc->CallbackPriceView(); } /*virtual*/ void T2WorldDef::ClickTransButton(T2MWControl* inControl, T2TowerDoc* inDoc) { inDoc->CallbackTransView(); } /*virtual*/ int T2WorldDef::SliderPointToValue(T2MWControl* inControl, CPoint inPt) { int objectIndex; CRect sliderArea, threadArea; objectIndex = mImageObj->FindObject("Slider"); mImageObj->GetObjectImage(objectIndex, sliderArea); objectIndex = mImageObj->FindObject("SliderThread"); mImageObj->GetObjectImage(objectIndex, threadArea); threadArea.OffsetRect(-sliderArea.left, -sliderArea.top); int result = ((inPt.x - threadArea.left) * 7 + threadArea.Width() / 12) / threadArea.Width(); if (result < 0) result = 0; else if (result >= 7) result = 6; return result; } /*virtual*/ void T2WorldDef::DrawSimpleMWControl(T2MWControl* inControl, const char* inStr) { #pragma var_order(tempDC, theImage, save2, save, imageRect, rect2, objectID, theBitmap, pDC) RECT imageRect; int objectID = mImageObj->FindObject(inStr, inControl->GetData()); T2BitImage *theImage = mImageObj->GetObjectImage(objectID, imageRect); RECT rect2 = imageRect; OffsetRect(&rect2, -rect2.left, -rect2.top); CDC *pDC = inControl->GetDC(); int save = pDC->SaveDC(); pDC->SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); pDC->RealizePalette(); CDC tempDC; tempDC.CreateCompatibleDC(pDC); int save2 = tempDC.SaveDC(); tempDC.SelectPalette(GetPaletteAnimeDef()->GetTowerPalette(), false); tempDC.RealizePalette(); HBITMAP theBitmap = Create256DIBitmap(tempDC.m_hDC, rect2.right, rect2.bottom); SelectObject(tempDC.m_hDC, theBitmap); theImage->CopyImage(&tempDC, imageRect, rect2); pDC->BitBlt(0, 0, rect2.right, rect2.bottom, &tempDC, 0, 0, SRCCOPY); tempDC.RestoreDC(save2); tempDC.DeleteDC(); DeleteObject(theBitmap); pDC->RestoreDC(save); inControl->ReleaseDC(pDC); } /*virtual*/ void T2WorldDef::GetToolTipText(T2TowerDoc* inDoc, T2MWControl* inControl, LPNMTTDISPINFO outInfo) { int id = inControl->GetDlgCtrlID(); if (id == 1000) GetClockTip(inDoc, inControl, outInfo->szText); else if (id == 1001) GetCalendarTip(inDoc, inControl, outInfo->szText); else if (id == 1002) GetFundsTip(inDoc, inControl, outInfo->szText); else if (id == 1003) GetPopulationTip(inDoc, inControl, outInfo->szText); else if (id == 2000) GetPauseButtonTip(inDoc, inControl, outInfo->szText); } /*virtual*/ void T2WorldDef::GetClockTip(T2TowerDoc* inDoc, T2MWControl* inControl, char* outStr) { strcpy(outStr, "Clock"); } /*virtual*/ void T2WorldDef::GetCalendarTip(T2TowerDoc* inDoc, T2MWControl* inControl, char* outStr) { // "カレンダー表示" strcpy(outStr, "\x83\x4A\x83\x8C\x83\x93\x83\x5F\x81\x5B\x95\x5C\x8E\xA6"); } /*virtual*/ void T2WorldDef::GetFundsTip(T2TowerDoc* inDoc, T2MWControl* inControl, char* outStr) { // "収支情報表示" strcpy(outStr, "\x8E\xFB\x8E\x78\x8F\xEE\x95\xF1\x95\x5C\x8E\xA6"); } /*virtual*/ void T2WorldDef::GetPopulationTip(T2TowerDoc* inDoc, T2MWControl* inControl, char* outStr) { // "人口情報表示" strcpy(outStr, "\x90\x6C\x8C\xFB\x8F\xEE\x95\xF1\x95\x5C\x8E\xA6"); } /*virtual*/ void T2WorldDef::GetPauseButtonTip(T2TowerDoc* inDoc, T2MWControl* inControl, char* outStr) { // 実行/停止 strcpy(outStr, "\x8E\xC0\x8D\x73\x81\x5E\x92\xE2\x8E\x7E"); } unsigned int T2WorldDef::GetToiletDenomi(unsigned int inVal) const { unsigned int result = 0; if (mToiletVar1 > 0 && inVal >= mToiletVar1) result = mToiletVar2; return result; } unsigned int T2WorldDef::GetColdDenomi(unsigned int inVal1, unsigned int inVal2) const { unsigned int result = 0; if (mColdTableDef) result = mColdTableDef->GetDenomi(inVal1, inVal2); return result; } BOOL T2WorldDef::IsDustOn(unsigned int inVal) const { return (mDustOnThreshold > 0) && (inVal >= mDustOnThreshold); } T2TowerVision* T2WorldDef::GetTowerVision() { return mTowerEvent ? mTowerEvent->GetTowerVision() : NULL; } void T2WorldDef::SetLatestBuild(T2Equip* inEquip, BOOL inFlag) { if (mTowerEvent) { T2ToolDef *theDef = inEquip->GetToolDef(); mTowerEvent->SetLatestBuild(inEquip, theDef, inFlag); } } void T2WorldDef::SetLatestBuild(T2ToolDef* inToolDef, BOOL inFlag) { mTowerEvent->SetLatestBuild(NULL, inToolDef, inFlag); } void T2WorldDef::InitTowerEvent(T2TowerDoc* inDoc) { if (mTowerEvent) mTowerEvent->InitTowerEvent(inDoc); } void T2WorldDef::WriteTowerEvent(T2Archive& inArchive) { if (mTowerEvent) mTowerEvent->Write(inArchive); } void T2WorldDef::ReadTowerEvent(T2Archive& inArchive) { if (mTowerEvent) mTowerEvent->Read(inArchive); } void T2WorldDef::StopEvent() { if (mTowerEvent) mTowerEvent->StopEvent(); } T2TowerEvent* T2WorldDef::GetTowerEvent() { return mTowerEvent; } T2FireBurning* T2WorldDef::GetFireBurning() { return mTowerEvent ? mTowerEvent->GetFireBurning() : NULL; } T2MetroRailway* T2WorldDef::GetMetroRailway() { return mTowerEvent ? mTowerEvent->GetMetroRailway() : NULL; } T2BlackOut* T2WorldDef::GetBlackOut() { return mTowerEvent ? mTowerEvent->GetBlackOut() : NULL; } BOOL T2WorldDef::IsBlackOut() { return mTowerEvent ? mTowerEvent->IsBlackOut() : false; } /*virtual*/ void T2WorldDef::DrawRubble(T2TowerDoc* inDoc, T2Tenant* inTenant) { mTowerEvent->DrawRubble(inDoc, inTenant); } /*virtual*/ void T2WorldDef::DrawMark(T2BitImage* inDestImage, const RECT& inRect, int inZoomLevel, unsigned int inPattern) { RECT rect; rect.left = 0; rect.top = 0; rect.right = 3; rect.bottom = 1; UT2Coordinate::UnitToQD(rect, inZoomLevel); URect::Center(inRect, rect); int objectID = mImageObj->FindObject("Mark", inPattern); mImageObj->DrawObject(inDestImage, objectID, rect, inZoomLevel); } /*virtual*/ void T2WorldDef::InitializeBkgndInfo(BkgndInfo* inBkgndInfoPtr) { ((T2WorldPlugin *) mPlugin)->InitBkgndInfoProc(this, inBkgndInfoPtr); } /*virtual*/ void T2WorldDef::InitializeFloorInfo(T2FloorInfo* inFloorInfo) { ((T2WorldPlugin *) mPlugin)->InitFloorInfoProc(this, *inFloorInfo); } /*virtual*/ void T2WorldDef::InitializeDocument(T2TowerDoc* inDoc) { mTowerEvent = new T2TowerEvent(this); ((T2WorldPlugin *) mPlugin)->InitializeDocumentProc(inDoc); } /*virtual*/ int T2WorldDef::CheckGameLevelProc(T2TowerDoc* inDoc) { int result = 0; if (inDoc->mGameLevel <= mNumOfGradeDef) { T2Pool *thePool = inDoc->towerDoc_vf130(); if (thePool) { GradeDef theDef = mGradeDef[inDoc->mGameLevel - 1]; int population = thePool->GetPopulation(); if ((inDoc->mA0 & theDef.m0) == theDef.m0 && population >= theDef.m4) result = 10005; } } return result; } /*virtual*/ BOOL T2WorldDef::CheckTreasure(T2TowerDoc* inDoc, T2TreasureStatus* inTreasureStatus) { return false; } /*virtual*/ void T2WorldDef::GetGradeUpMessage(int inGradeNum, CString& outStr) { // "あなたのビルは%d星に認定されました" // Your building has been awarded %d stars outStr.Format("\x82\xA0\x82\xC8\x82\xBD\x82\xCC\x83\x72\x83\x8B\x82\xCD\x25\x64\x90\xAF\x82\xC9\x94\x46\x92\xE8\x82\xB3\x82\xEA\x82\xDC\x82\xB5\x82\xBD", inGradeNum); } /*virtual*/ void T2WorldDef::CalcOptionObj(T2TowerDoc* inDoc, T2Equip* inEquip) { T2TowerMainView *theView = inDoc->GetTowerMainView(); T2FloorInfo *floorInfo = inDoc->towerDoc_vf12C(); if (inEquip) { RECT equipArea; inEquip->GetEquipArea(equipArea); if (equipArea.bottom > mTopFloorLine && !inEquip->IsMover() && ((T2Tenant *) inEquip)->IsFloor()) { CString objectName; if (inEquip->mValiation == 0) objectName = "Side"; else objectName = "Tent"; objectName += "L"; int objectIndex = mImageObj->FindObject(objectName, 0); SIZE objectSize; mImageObj->GetObjectSize(objectIndex, &objectSize); equipArea.left -= objectSize.cx; equipArea.right += objectSize.cx; theView->tmv_vf128(equipArea, true); } } } /*virtual*/ void T2WorldDef::DrawOptionObj(T2TowerDoc* inDoc, const RECT& inRect) { #pragma var_order(name, theFloor, tentObjectSize, rect1, rect2, v, sideObjectSize, objectID, theFloorInfo) RECT rect1 = inRect; if (rect1.bottom > mGroundLine) rect1.bottom = mGroundLine; T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); CString name = "Side"; int objectID = mImageObj->FindObject(name + "L"); SIZE sideObjectSize; mImageObj->GetObjectSize(objectID, &sideObjectSize); sideObjectSize.cx /= UT2Coordinate::UnitHSize(0); sideObjectSize.cy /= UT2Coordinate::UnitVSize(0); name = "Tent"; objectID = mImageObj->FindObject(name + "L"); SIZE tentObjectSize; mImageObj->GetObjectSize(objectID, &tentObjectSize); tentObjectSize.cx /= UT2Coordinate::UnitHSize(0); tentObjectSize.cy /= UT2Coordinate::UnitVSize(0); RECT rect2 = rect1; rect2.left -= max(sideObjectSize.cx, tentObjectSize.cx); rect2.right += max(sideObjectSize.cx, tentObjectSize.cx); IntersectRect(&rect2, &rect2, &mBuildArea); rect2.top = max(rect2.top, mTopFloorLine); T2Tenant *theFloor; for (int v = rect2.top; v < rect2.bottom; v++) { for (int h = rect2.left; h < rect2.right; h++) { theFloor = theFloorInfo->GetFloor(v, h); if (theFloor) { h = theFloor->mArea.right - 1; if (theFloor->mValiation == 0) { if (theFloorInfo->GetTenantID(theFloor->mArea.bottom - 1, theFloor->mArea.left - 1) == 0) { name = "Side"; objectID = mImageObj->FindObject(name + "L", 0); RECT rect = theFloor->mArea; rect.right = rect.left; rect.left = rect.right - sideObjectSize.cx; UT2Coordinate::UnitToQD(rect, rect, inDoc->mZoomLevel, true); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, rect, inDoc->towerDoc_vf108()); } if (theFloorInfo->GetTenantID(theFloor->mArea.bottom - 1, theFloor->mArea.right) == 0) { name = "Side"; objectID = mImageObj->FindObject(name + "R", 0); RECT rect = theFloor->mArea; rect.left = rect.right; rect.right = rect.left + sideObjectSize.cx; UT2Coordinate::UnitToQD(rect, rect, inDoc->mZoomLevel, true); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, rect, inDoc->towerDoc_vf108()); } } else { if (theFloorInfo->GetTenantID(theFloor->mArea.bottom - 1, theFloor->mArea.left - 1) == 0) { name = "Side"; objectID = mImageObj->FindObject(name + "L", 0); RECT baseRect = theFloor->mArea; baseRect.right = baseRect.left; baseRect.left = baseRect.right - sideObjectSize.cx; baseRect.bottom = baseRect.top + 1; RECT workRect; for (int i = theFloor->mArea.top; i < (theFloor->mArea.bottom - 1); i++) { UT2Coordinate::UnitToQD(baseRect, workRect, inDoc->mZoomLevel, true); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, workRect, inDoc->towerDoc_vf108()); OffsetRect(&baseRect, 0, 1); } name = "Tent"; objectID = mImageObj->FindObject(name + "L", 0); baseRect.left = baseRect.right - tentObjectSize.cx; UT2Coordinate::UnitToQD(baseRect, workRect, inDoc->mZoomLevel, true); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, workRect, inDoc->towerDoc_vf108()); } if (theFloorInfo->GetTenantID(theFloor->mArea.bottom - 1, theFloor->mArea.right) == 0) { name = "Side"; objectID = mImageObj->FindObject(name + "R", 0); RECT baseRect = theFloor->mArea; baseRect.left = baseRect.right; baseRect.right = baseRect.left + sideObjectSize.cx; baseRect.bottom = baseRect.top + 1; RECT workRect; for (int i = theFloor->mArea.top; i < (theFloor->mArea.bottom - 1); i++) { UT2Coordinate::UnitToQD(baseRect, workRect, inDoc->mZoomLevel, true); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, workRect, inDoc->towerDoc_vf108()); OffsetRect(&baseRect, 0, 1); } name = "Tent"; objectID = mImageObj->FindObject(name + "R", 0); baseRect.right = baseRect.left + tentObjectSize.cx; UT2Coordinate::UnitToQD(baseRect, workRect, inDoc->mZoomLevel, true); mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, workRect, inDoc->towerDoc_vf108()); } } } } } } /*virtual*/ void T2WorldDef::SetupGradeUpAnimation(T2DlgItemAnimation* inAnimation, int inGradeNum) { if (inGradeNum >= 2) { int grade = inGradeNum - 2; inAnimation->SetAnimation(mModuleHandle, mGradeDef[grade].m8, 0); inAnimation->SetAnimationParam(100, mGradeDef[grade].m14); } } /*virtual*/ void T2WorldDef::WriteStatisticsProc(T2TowerDoc* inDoc, T2Archive& inArchive) { } /*virtual*/ void T2WorldDef::ReadStatisticsProc(T2TowerDoc* inDoc, T2Archive& inArchive) { } /*virtual*/ void T2WorldDef::ViewModeChanged(T2TowerDoc* inDoc, VIEWMODE) { } /*virtual*/ void T2WorldDef::ReplaceSkyOffscreen(int inResID) { delete mSkyOffscreen; mSkyOffscreen = new T2BitImage(mModuleHandle, inResID, true); } /*virtual*/ T2EventItem* T2WorldDef::MakeXEvent(T2TowerEvent* inTowerEvent, CResFile*, unsigned long, int) { return NULL; }