diff options
Diffstat (limited to '')
148 files changed, 12152 insertions, 964 deletions
diff --git a/src/256CheckDialog.cpp b/src/256CheckDialog.cpp index b8e0fe8..8aea8d7 100644 --- a/src/256CheckDialog.cpp +++ b/src/256CheckDialog.cpp @@ -1,2 +1,203 @@ +#define ATOI_KLUDGE +#include "common.h" + +// Since this is the first TU in T2.exe, we pull the same trick as +// in CDefRsrcPlugin.cpp for T2DLL and include all the headers that +// will force inline functions to be emitted in the right order +#include "UT2Utils.h" +#include "T2PaletteAnimeDef.h" +#include "LAttachment.h" +#include "LAttachable.h" +#include "CLink.h" +#include "LArray.h" +#include "LBroadcaster.h" +#include "LListener.h" +#include "T2Archive.h" +#include "T2BitImage.h" +#include "T2ImageObj.h" +#include "T2SpriteObj.h" +#include "Wave.h" +#include "T2SoundPlayer.h" +#include "T2Balloon.h" +#include "T2DlgItemButtonBase.h" +#include "T2DlgItemIButton.h" +#include "T2DlgItemOK.h" +#include "T2DlgItemCANCEL.h" +#include "T2DlgItemTButton.h" +#include "T2DlgItemICheck.h" +#include "T2DlgItemCheck.h" +#include "T2DlgItemScr.h" +#include "T2DlgItemHScr.h" +#include "T2DlgItemVScr.h" +#include "T2DlgItemBox.h" +#include "T2DlgItemText.h" +#include "T2DlgItemGageBase.h" +#include "T2DlgItemStressGage.h" +#include "T2DlgItemPPLEvalGage.h" +#include "T2DlgItemBelongGage.h" +#include "T2DlgItemCustomerGage.h" +#include "T2DlgItemProfitsGage.h" +#include "T2DlgItemImageTable.h" +#include "T2DlgItemImage.h" +#include "CToggleButtonDisabled.h" +#include "T2VerticalTable.h" +#include "T2MovieTable.h" +#include "T2GuestroomTable.h" +#include "T2HallEventTable.h" +#include "CTokenizer.h" +#include "T2Dialog.h" +#include "T2PluginSpecifier.h" +#include "CResFile.h" +#include "CPlugin.h" +#include "CFilePlugin.h" +#include "CFilePluginList.h" +#include "CFilePluginDB.h" +#include "T2EquipInfoDialog.h" +#include "T2TenantInfoDialog.h" +#include "T2Object.h" +#include "T2ObjectArray.h" +#include "T2DrawableObject.h" +#include "CDefRsrcPlugin.h" +#include "T2TemplatePlugin.h" +#include "T2HaveOutViewObject.h" +#include "CProgramPlugin.h" +#include "T2TemplatePluginList.h" +#include "T2TemplatePluginDB.h" +#include "T2ToolPlugin.h" +#include "UT2Coordinate.h" +#include "T2DateTime.h" +#include "T2PeoplePtrList.h" +#include "T2TowerMessage.h" +#include "CResourcePlugin.h" +#include "T2SubPlugin.h" +#include "T2HallEventPlugin.h" +#include "T2MoviePlugin.h" +#include "T2ToolDef.h" +#include "T2EquipDef.h" +#include "T2TenantDef.h" +#include "T2MoverDef.h" +#include "T2OuterObjDef.h" +#include "T2SilhouetteDef.h" +#include "T2MatterDef.h" +#include "T2PeopleDef.h" +#include "T2Pool.h" +#include "T2Equip.h" +#include "T2Tenant.h" +#include "T2OutObj.h" +#include "T2Request.h" +#include "T2Mover.h" +#include "T2PlaceParamDef.h" +#include "T2TenantMemberTableDef.h" +#include "T2TenantMemberDef.h" +#include "T2PeopleTypeArray.h" +#include "T2PeopleTimeZoneList.h" +#include "T2PeopleDemandList.h" +#include "T2PeopleType.h" +#include "T2Matter.h" +#include "T2OuterObjList.h" +#include "T2OutObjArrayList.h" +#include "T2People.h" +#include "T2PeopleArray.h" +#include "T2PeopleArrayList.h" +#include "T2RequestArray.h" +#include "T2RequestArrayList.h" +#include "T2TenantArray.h" +#include "T2TenantArrayList.h" +#include "T2MoverArray.h" +#include "T2MoverArrayList.h" +#include "T2RegistedTenantDB.h" +#include "T2EquipPlugin.h" +#include "T2TenantPlugin.h" +#include "T2MoverPlugin.h" +#include "T2OuterObjPlugin.h" +#include "T2PeopleLoader.h" +#include "T2CrossEquipArray.h" +#include "T2TenantCEArray.h" +#include "T2RouteCEArray.h" +#include "T2FloorCEArray.h" +#include "T2MoverCEArray.h" +#include "T2UnitInfo.h" +#include "T2FloorInfo.h" +#include "T2FInfoAreaIterator.h" +#include "T2FInfoPtIterator.h" +#include "UT2BkgndInfo.h" +#include "T2WorldDef.h" +#include "T2WorldPlugin.h" +#include "T2AdvertisePlugin.h" +#include "T2GlobalData.h" +#include "T2EquipPtrList.h" +#include "T2FloorPtrList.h" +#include "T2RoutingTableElem.h" +#include "T2MoverRoutingTable.h" +#include "T2RoutingTable.h" +#include "T2RouteNavigator.h" +#include "T2Name.h" +#include "T2NameList.h" +#include "T2TrafficInfo.h" +#include "T2Settlement.h" +#include "T2PaletteAnime.h" +#include "T2OptionPlugin.h" +#include "T2OptionPluginList.h" +#include "T2TowerEvent.h" +#include "T2EventItem.h" +#include "T2BlackOut.h" +#include "T2FireBurning.h" +#include "T2MetroRailway.h" +#include "T2SantaClaus.h" +#include "T2Terrorist.h" +#include "T2VisitVIP.h" +#include "T2MsgWindowCallback.h" +#include "T2ToolWindow.h" +#include "T2ToolCallback.h" +#include "T2StewardDialog.h" +#include "T2ClassFactory.h" + #include "256CheckDialog.h" +#include "T2.h" +#include "T2DLL.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +C256ColorDialog::C256ColorDialog(CWnd *pParentWnd) + : CDialog(227, pParentWnd) +{ + +} + +/*virtual*/ void C256ColorDialog::DoDataExchange(CDataExchange *pDX) { + CWnd::DoDataExchange(pDX); + DDX_Control(pDX, 1028, mButton); +} + +BEGIN_MESSAGE_MAP(C256ColorDialog, CDialog) +END_MESSAGE_MAP() + +/*virtual*/ void C256ColorDialog::OnOK() { + Save(); + CDialog::OnOK(); +} + +/*virtual*/ void C256ColorDialog::OnCancel() { + Save(); + CDialog::OnCancel(); +} + +void C256ColorDialog::Save() { + if (mButton.GetCheck()) + gT2App->WriteProfileInt("Settings", "CheckDisplay", 0); + else + gT2App->WriteProfileInt("Settings", "CheckDisplay", 1); +} + +/*virtual*/ int C256ColorDialog::DoModal() { + int value = gT2App->GetProfileInt("Settings", "CheckDisplay", 1); + + if (value == 0) + return 1; + return CDialog::DoModal(); +} diff --git a/src/256CheckDialog.h b/src/256CheckDialog.h index fcaf1ff..f95925b 100644 --- a/src/256CheckDialog.h +++ b/src/256CheckDialog.h @@ -1,3 +1,18 @@ #pragma once #include "common.h" +class C256ColorDialog : public CDialog { + DECLARE_MESSAGE_MAP() + +public: + C256ColorDialog(CWnd *pParentWnd); + virtual int DoModal(); + +protected: + virtual void DoDataExchange(CDataExchange *pDX); + virtual void OnOK(); + virtual void OnCancel(); + void Save(); + + CButton mButton; +}; diff --git a/src/Bitmap.cpp b/src/Bitmap.cpp new file mode 100644 index 0000000..44674d6 --- /dev/null +++ b/src/Bitmap.cpp @@ -0,0 +1,363 @@ +#define DONT_INCLUDE_AFXTEMPL +#include "Bitmap.h" + +static int getColoursUsed(BITMAPINFO *bmp); + +Bitmap::Bitmap() { + mBitmap = NULL; + mPixels = NULL; + Allocate(640, 480); +} + +Bitmap::~Bitmap() { + Free(); +} + +void Bitmap::Free() { + if (mBitmap) { + GlobalUnlock(GlobalHandle(mBitmap)); + GlobalFree(GlobalHandle(mBitmap)); + } + + if (mPixels) { + GlobalUnlock(GlobalHandle(mPixels)); + GlobalFree(GlobalHandle(mPixels)); + } +} + +BOOL Bitmap::AllocateHeader() { + int size = GetBitmapHeaderSize(); + + if (mBitmap) { + GlobalUnlock(GlobalHandle(mBitmap)); + GlobalFree(GlobalHandle(mBitmap)); + } + + mBitmap = (BITMAPINFO *) GlobalLock(GlobalAlloc(GMEM_MOVEABLE, size)); + + if (!mBitmap) { + SetErrorCode(8); + return false; + } + + memset(mBitmap, 0, size); + return true; +} + +void Bitmap::SetErrorCode(int code) { + mErrorCode = code; +} + +BOOL Bitmap::SetHeader(const Bitmap *other) { + int size = GetBitmapHeaderSize(); + AllocateHeader(); + memcpy(mBitmap, other->mBitmap, size); + return true; +} + +BOOL Bitmap::LoadFile(const char *path) { +#pragma var_order(fileHeader, infoHeader, fd, colorsSize, ofstruct, startOffset, colorsUsed, bufferSize) + OFSTRUCT ofstruct; + int fd = OpenFile(path, &ofstruct, 0); + if (fd == -1) { + SetErrorCode(1); + return false; + } + + BITMAPFILEHEADER fileHeader; + int startOffset = _llseek(fd, 0, FILE_BEGIN); + + if (_lread(fd, &fileHeader, sizeof(fileHeader)) != sizeof(fileHeader)) { + SetErrorCode(3); + _lclose(fd); + return false; + } + + if (fileHeader.bfType != 'MB') { + SetErrorCode(4); + _lclose(fd); + return false; + } + + BITMAPINFOHEADER infoHeader; + if (_lread(fd, &infoHeader, sizeof(infoHeader)) != sizeof(infoHeader)) { + SetErrorCode(5); + _lclose(fd); + return false; + } + + AllocateHeader(); + if (!mBitmap) { + _lclose(fd); + return false; + } + + memcpy(&mBitmap->bmiHeader, &infoHeader, sizeof(infoHeader)); + + int colorsUsed = getColoursUsed((BITMAPINFO *) &infoHeader); + int colorsSize = colorsUsed * sizeof(RGBQUAD); + if (_lread(fd, mBitmap->bmiColors, colorsSize) != colorsSize) { + SetErrorCode(6); + _lclose(fd); + return false; + } + + mColors = GetColors(); + + if (mPixels) { + GlobalUnlock(GlobalHandle(mPixels)); + GlobalFree(GlobalHandle(mPixels)); + } + + int bufferSize = fileHeader.bfSize - fileHeader.bfOffBits; + mPixels = (BYTE *) GlobalLock(GlobalAlloc(GMEM_MOVEABLE, bufferSize)); + + if (!mPixels) { + SetErrorCode(11); + _lclose(fd); + return false; + } + + _llseek(fd, startOffset + fileHeader.bfOffBits, FILE_BEGIN); + if (_lread(fd, mPixels, bufferSize) != bufferSize) { + SetErrorCode(12); + _lclose(fd); + return false; + } + + _lclose(fd); + return true; +} + +static int getColoursUsed(BITMAPINFO *bmp) { + BITMAPINFOHEADER *header = &bmp->bmiHeader; + int bitCount = header->biBitCount; + int colors; + + switch (bitCount) { + case 1: + colors = 2; + break; + case 4: + colors = 16; + break; + case 8: + colors = 256; + break; + default: + colors = 0; + } + + if (header->biClrUsed != 0) + colors = header->biClrUsed; + + return colors; +} + +BOOL Bitmap::InitHeader(int width, int height) { + if (!mBitmap) + return false; + + BITMAPINFOHEADER *header = &mBitmap->bmiHeader; + header->biSize = sizeof(BITMAPINFOHEADER); + header->biWidth = width; + header->biHeight = height; + header->biPlanes = 1; + header->biBitCount = 8; + header->biCompression = 0; + header->biSizeImage = 0; + header->biXPelsPerMeter = 0; + header->biYPelsPerMeter = 0; + header->biClrUsed = 0; + header->biClrImportant = 0; + + return true; +} + +BOOL Bitmap::InitGreyscalePalette() { + mColors = GetColors(); + + for (int i = 0; i < 256; i++) { + mColors->rgbRed = i; + mColors->rgbGreen = i; + mColors->rgbBlue = i; + mColors->rgbReserved = 0; + mColors++; + } + + return true; +} + +BOOL Bitmap::Allocate(int width, int height) { + Free(); + + unsigned int bmiSize = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256; + mBitmap = (BITMAPINFO *) GlobalLock(GlobalAlloc(GMEM_MOVEABLE, bmiSize)); + if (!mBitmap) + return false; + + InitHeader(width, height); + SetDefaultRect(); + InitGreyscalePalette(); + + unsigned int bufferSize = ((width + 3) & ~3) * height; + mPixels = (BYTE *) GlobalLock(GlobalAlloc(GMEM_MOVEABLE, bufferSize)); + if (!mPixels) { + Free(); + return false; + } + + for (unsigned int i = 0; i < bufferSize; i++) + mPixels[i] = 0; + + return true; +} + +void Bitmap::Draw(HDC dc, int x, int y) { + StretchDIBits(dc, x, y, mBitmap->bmiHeader.biWidth, mBitmap->bmiHeader.biHeight, 0, 0, mBitmap->bmiHeader.biWidth, mBitmap->bmiHeader.biHeight, mPixels, mBitmap, DIB_RGB_COLORS, SRCCOPY); +} + +void Bitmap::Draw(HDC dc, const RECT &rect) { + int theWidth = rect.right - rect.left; + int theHeight = rect.bottom - rect.top; + StretchDIBits(dc, rect.left, rect.right, theWidth, theHeight, 0, 0, theWidth, theHeight, mPixels, mBitmap, DIB_RGB_COLORS, SRCCOPY); +} + +// surely this can't be what they did??? +struct LOGPALETTE256 { + WORD palVersion; + WORD palNumEntries; + PALETTEENTRY palPalEntry[256]; +}; + +HPALETTE Bitmap::CreatePalette() { + unsigned int count = getColoursUsed(mBitmap); + LOGPALETTE256 logPalette = {0x300, 256}; + + for (unsigned int i = 0; i < count; i++) { + logPalette.palPalEntry[i].peRed = mColors[i].rgbRed; + logPalette.palPalEntry[i].peGreen = mColors[i].rgbGreen; + logPalette.palPalEntry[i].peBlue = mColors[i].rgbBlue; + logPalette.palPalEntry[i].peFlags = 0; + } + + HPALETTE palette = ::CreatePalette((LOGPALETTE *) &logPalette); + return palette; +} + +BOOL Bitmap::DrawBitmap(const Bitmap *bmp, RECT srcRect, RECT destRect) { +#pragma var_order(x, rectWidth, y, srcHeight, rectHeight, srcBitmap, destStride, destBuffer, srcStride, srcBuffer) + int rectHeight = srcRect.bottom - srcRect.top; + int rectWidth = srcRect.right - srcRect.left; + + int srcStride = bmp->mRect.right - bmp->mRect.left; + int destStride = mRect.right - mRect.left; + + const BYTE *srcBuffer = bmp->mPixels; + BYTE *destBuffer = mPixels; + + const BITMAPINFO *srcBitmap = bmp->mBitmap; + int srcHeight = srcBitmap->bmiHeader.biHeight; + + for (int x = 0, y = 0; y < rectHeight; y++) { + for (x = 0; x < rectWidth; x++) { + destBuffer[x + (destStride * (GetHeight() - y - 1 - destRect.top)) + destRect.left] = srcBuffer[x + (srcStride * (srcHeight - y - 1 - srcRect.top)) + srcRect.left]; + } + } + + return true; +} + +BOOL Bitmap::DrawBitmap(const Bitmap *bmp, RECT srcRect, RECT destRect, BYTE transparentCol) { +#pragma var_order(x, rectWidth, y, srcHeight, rectHeight, unk1C, srcAddress, unk24, srcBitmap, destStride, destAddress, destBuffer, srcStride, srcBuffer) + int rectHeight = srcRect.bottom - srcRect.top; + int rectWidth = srcRect.right - srcRect.left; + + int srcStride = bmp->mRect.right - bmp->mRect.left; + int destStride = mRect.right - mRect.left; + + const BYTE *srcBuffer = bmp->mPixels; + BYTE *destBuffer = mPixels; + + const BITMAPINFO *srcBitmap = bmp->mBitmap; + int srcHeight = srcBitmap->bmiHeader.biHeight; + + int unk24 = 0; + BYTE unk1C = transparentCol; + + int srcAddress, destAddress; + + for (int x = 0, y = 0; y < rectHeight; y++) { + for (x = 0; x < rectWidth; x++) { + srcAddress = x + (srcStride * (srcHeight - y - 1 - srcRect.top)) + srcRect.left; + destAddress = x + (destStride * (GetHeight() - y - 1 - destRect.top)) + destRect.left; + if (srcBuffer[srcAddress] != transparentCol) + destBuffer[destAddress] = srcBuffer[srcAddress]; + } + } + + return true; +} + +BOOL Bitmap::SetPalette(const Bitmap *other) { + unsigned int count = getColoursUsed(other->mBitmap); + for (unsigned int i = 0; i < count; i++) { + mColors[i].rgbRed = other->mColors[i].rgbRed; + mColors[i].rgbGreen = other->mColors[i].rgbGreen; + mColors[i].rgbBlue = other->mColors[i].rgbBlue; + } + + return true; +} + +BYTE Bitmap::GetPixel(int x, int y) const { + const BYTE *buffer = mPixels; + int stride = mRect.right - mRect.left; + int address = x + stride * (GetHeight() - y - 1); + return mPixels[address]; +} + +int Bitmap::GetPixel(POINT pt) const { + const BYTE *buffer = mPixels; + int stride = mRect.right - mRect.left; + int address = pt.x + stride * (GetHeight() - pt.y - 1); + return mPixels[address]; +} + +void Bitmap::SetRect(int left, int top, int right, int bottom) { + mRect.left = left; + mRect.top = top; + mRect.right = right; + mRect.bottom = bottom; +} + +void Bitmap::SetDefaultRect() { + if (mBitmap) { + BITMAPINFOHEADER *theBitmap = &mBitmap->bmiHeader; + mRect.left = 0; + mRect.top = 0; + mRect.right = theBitmap->biWidth; + mRect.bottom = theBitmap->biHeight; + } else { + mRect.bottom = 0; + mRect.right = 0; + mRect.top = 0; + mRect.left = 0; + } +} + +int Bitmap::GetHeight() const { + if (mBitmap) { + BITMAPINFO *bmp = mBitmap; + return bmp->bmiHeader.biHeight; + } + return 0; +} + +int Bitmap::GetWidth() const { + if (mBitmap) { + BITMAPINFO *bmp = mBitmap; + return bmp->bmiHeader.biWidth; + } + return 0; +} diff --git a/src/Bitmap.h b/src/Bitmap.h new file mode 100644 index 0000000..3c11764 --- /dev/null +++ b/src/Bitmap.h @@ -0,0 +1,37 @@ +#pragma once +#include "common.h" + +class Bitmap { +public: + Bitmap(); + ~Bitmap(); + void Free(); + BOOL AllocateHeader(); + void SetErrorCode(int code); + BOOL SetHeader(const Bitmap *other); + BOOL LoadFile(const char *path); + BOOL InitHeader(int width, int height); + BOOL InitGreyscalePalette(); + BOOL Allocate(int width, int height); + void Draw(HDC dc, int x, int y); + void Draw(HDC dc, const RECT &rect); + HPALETTE CreatePalette(); + BOOL DrawBitmap(const Bitmap *bmp, RECT srcRect, RECT destRect); + BOOL DrawBitmap(const Bitmap *bmp, RECT srcRect, RECT destRect, BYTE transparentCol); + BOOL SetPalette(const Bitmap *other); + BYTE GetPixel(int x, int y) const; + int GetPixel(POINT pt) const; + void SetRect(int left, int top, int right, int bottom); + void SetDefaultRect(); + int GetHeight() const; + int GetWidth() const; + int GetBitmapHeaderSize() const { return sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256; } + RGBQUAD *GetColors() { return mBitmap->bmiColors; } + +protected: + BITMAPINFO *mBitmap; + BYTE *mPixels; + RGBQUAD *mColors; + int mErrorCode; + RECT mRect; +}; diff --git a/src/CT2App.h b/src/CT2App.h deleted file mode 100644 index ab22fa3..0000000 --- a/src/CT2App.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "common.h" - -class CT2App : public CWinApp { -public: - // stuff will go here later - - // modifies counter _DC - called from T2MoverModuleTable ctor - // also called on Debug Step Run - virtual void app_vfA4(BOOL); - - // sets mMessage - virtual void app_vfA8(T2Message *); - - // clears mMessage - virtual void app_vfAC(); - - // gets global data - virtual T2GlobalData *app_vfB0(); - - // runs a message loop - called from T2PluginLoader - virtual void app_vfB4(); - - T2GlobalData *mGlobalData; - T2PluginLoader *mPluginLoader; - T2ToolWindow *mToolWindow; - T2TowerDoc *mDocument; - T2MainWindow *mMainWindow; - int _DC; - CString mStrE0; - int _E4; - T2Message *mMessage; -}; diff --git a/src/DbgEquipInfo.cpp b/src/DbgEquipInfo.cpp index 43ee079..b9c4487 100644 --- a/src/DbgEquipInfo.cpp +++ b/src/DbgEquipInfo.cpp @@ -1,2 +1,99 @@ #include "DbgEquipInfo.h" +#include "LArray.h" +#include "T2CrossEquipArray.h" +#include "T2EquipDef.h" +#include "T2FloorInfo.h" +#include "T2Mover.h" +#include "T2Tenant.h" +#include "T2TowerDoc.h" +#include "T2TowerMainView.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +DbgEquipInfo::DbgEquipInfo(CWnd *pParentWnd) + : CDialog(160, pParentWnd) +{ +} + +/*virtual*/ void DbgEquipInfo::DoDataExchange(CDataExchange *pDX) { + CWnd::DoDataExchange(pDX); + DDX_Control(pDX, 1014, mButton); + DDX_Control(pDX, 1013, mList1); + DDX_Control(pDX, 1011, mStatic1); + DDX_Control(pDX, 1012, mStatic2); + DDX_Control(pDX, 1010, mList2); +} + +void DbgEquipInfo::SetEquip(T2Equip *inEquip) { + mEquip = inEquip; +} + +void DbgEquipInfo::SetDocument(T2TowerDoc *inDoc) { + mDocument = inDoc; +} + +void DbgEquipInfo::SetTowerMainView(T2TowerMainView *inView) { + mTowerMainView = inView; +} + +BEGIN_MESSAGE_MAP(DbgEquipInfo, CDialog) + ON_NOTIFY(NM_CLICK, 1010, OnListClick) +END_MESSAGE_MAP() + +/*virtual*/ BOOL DbgEquipInfo::OnInitDialog() { + CDialog::OnInitDialog(); + + CString str; + + mStatic1.SetWindowText(mEquip->GetEquipDef()->mStr48); + str.Format("%d", mEquip->mEquipID); + mStatic2.SetWindowText(str); + + RECT rect; + mList2.GetClientRect(&rect); + + int width = rect.right; + mList2.InsertColumn(0, "ID", LVCFMT_LEFT, width / 3); + mList2.InsertColumn(1, "Type", LVCFMT_LEFT, (width * 2) / 3); + + LArrayIterator iterator(*mEquip->mCEArray); + unsigned int id; + int index = 0; + + while (iterator.Next(&id)) { + if (id >= 1000) { + str.Format("%d", id); + mList2.InsertItem(index, str); + + T2Tenant *tenant = mDocument->mFloorInfo->GetTenant(id); + if (tenant) + mList2.SetItemText(index, 1, tenant->GetEquipDef()->mStr48); + else + mList2.SetItemText(index, 1, "UNKNOWN"); + } else if (id >= 1) { + str.Format("%d", id); + mList2.InsertItem(index, str); + + T2Mover *mover = mDocument->mFloorInfo->GetMover(id); + if (mover) + mList2.SetItemText(index, 1, mover->GetEquipDef()->mStr48); + else + mList2.SetItemText(index, 1, "UNKNOWN"); + } + index++; + } + + mEquip->GetEquipDef()->DebugInfo(mButton, mList1, mEquip); + return true; +} + +void DbgEquipInfo::OnListClick(NMHDR *inHdr, LRESULT *outResult) { + int item = mList2.GetNextItem(-1, LVNI_SELECTED); + if (item != -1) + mTowerMainView->SendMessage(WM_COMMAND, MAKELONG(10000 + item, 0), 0); + *outResult = 0; +} diff --git a/src/DbgEquipInfo.h b/src/DbgEquipInfo.h index fcaf1ff..719fd43 100644 --- a/src/DbgEquipInfo.h +++ b/src/DbgEquipInfo.h @@ -1,3 +1,26 @@ #pragma once #include "common.h" +class DbgEquipInfo : public CDialog { + DECLARE_MESSAGE_MAP() + +public: + DbgEquipInfo(CWnd *pParentWnd); + void SetEquip(T2Equip *inEquip); + void SetDocument(T2TowerDoc *inDoc); + void SetTowerMainView(T2TowerMainView *inView); + virtual BOOL OnInitDialog(); + +protected: + afx_msg void OnListClick(NMHDR *inHdr, LRESULT *outResult); + virtual void DoDataExchange(CDataExchange *pDX); + + CButton mButton; + CListCtrl mList1; + CStatic mStatic1; + CStatic mStatic2; + CListCtrl mList2; + T2Equip *mEquip; + T2TowerDoc *mDocument; + T2TowerMainView *mTowerMainView; +}; diff --git a/src/DbgEventList.cpp b/src/DbgEventList.cpp index e1548e1..107f33f 100644 --- a/src/DbgEventList.cpp +++ b/src/DbgEventList.cpp @@ -1,2 +1,98 @@ #include "DbgEventList.h" +#include "GlobalFunc.h" +#include "LArray.h" +#include "T2EventItem.h" +#include "T2TowerDoc.h" +#include "T2TowerEvent.h" +#include "T2WorldDef.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +DbgEventList::DbgEventList(CWnd *pParentWnd) + : CDialog(182, pParentWnd) +{ +} + +/*virtual*/ void DbgEventList::DoDataExchange(CDataExchange *pDX) { + CWnd::DoDataExchange(pDX); + DDX_Control(pDX, 1020, mList); +} + +BEGIN_MESSAGE_MAP(DbgEventList, CDialog) + ON_COMMAND(1021, OnEventStart) +END_MESSAGE_MAP() + +/*virtual*/ BOOL DbgEventList::OnInitDialog() { + CDialog::OnInitDialog(); + + RECT rect; + mList.GetClientRect(&rect); + int width = rect.right; + + mList.InsertColumn(0, "Type", LVCFMT_LEFT, width / 6); + mList.InsertColumn(1, "ID", LVCFMT_LEFT, width / 6); + mList.InsertColumn(2, "Mode", LVCFMT_LEFT, width / 6); + mList.InsertColumn(3, "Status", LVCFMT_LEFT, width / 6); + mList.InsertColumn(4, "Start", LVCFMT_LEFT, width / 6); + mList.InsertColumn(5, "End", LVCFMT_LEFT, width / 6); + + mTowerEvent = GetCurrentT2TowerDoc()->GetWorldDef()->GetTowerEvent(); + RefreshEvents(); + + return true; +} + +void DbgEventList::RefreshEvents() { + mList.DeleteAllItems(); + AddEvents(mTowerEvent->mStandby, "Standby"); + AddEvents(mTowerEvent->mWaiting, "Waiting"); + AddEvents(mTowerEvent->mRunning, "Running"); +} + +void DbgEventList::AddEvents(LArray &array, const char *mode) { + LArrayIterator iterator(array); + CString str; + T2EventItem *eventItem; + + while (iterator.Next(&eventItem)) { + DWORD id = eventItem->GetID(); + str.Format("%c%c%c%c", ((BYTE *) &id)[3], ((BYTE *) &id)[2], ((BYTE *) &id)[1], ((BYTE *) &id)[0]); + int index = mList.InsertItem(0, str); + + str.Format("%d", eventItem->GetSubID()); + mList.SetItemText(index, 1, str); + + str = mode; + if (eventItem->mForceStart) + str += "!"; + mList.SetItemText(index, 2, str); + + str.Format("%d", eventItem->GetStatus()); + mList.SetItemText(index, 3, str); + + str.Format("%d", eventItem->GetBeginTime()); + mList.SetItemText(index, 4, str); + + str.Format("%d", eventItem->GetEndTime()); + mList.SetItemText(index, 5, str); + + mList.SetItemData(index, (DWORD) eventItem); + } +} + +void DbgEventList::OnEventStart() { + int numOfItems = mList.GetItemCount(); + for (int index = 0; index < numOfItems; index++) { + if (mList.GetItemState(index, LVIS_SELECTED)) { + T2EventItem *eventItem = (T2EventItem *) mList.GetItemData(index); + eventItem->mForceStart = true; + } + } + + mTowerEvent->Idle(GetCurrentT2TowerDoc()); + RefreshEvents(); +} diff --git a/src/DbgEventList.h b/src/DbgEventList.h index fcaf1ff..d6ae2cb 100644 --- a/src/DbgEventList.h +++ b/src/DbgEventList.h @@ -1,3 +1,19 @@ #pragma once #include "common.h" +class DbgEventList : public CDialog { + DECLARE_MESSAGE_MAP() + +public: + DbgEventList(CWnd *pParentWnd); + virtual BOOL OnInitDialog(); + +protected: + virtual void DoDataExchange(CDataExchange *pDX); + void RefreshEvents(); + void AddEvents(LArray &array, const char *mode); + afx_msg void OnEventStart(); + + CListCtrl mList; + T2TowerEvent *mTowerEvent; +}; diff --git a/src/DbgIPS.cpp b/src/DbgIPS.cpp index 1ff48bd..746ffc6 100644 --- a/src/DbgIPS.cpp +++ b/src/DbgIPS.cpp @@ -1,2 +1,20 @@ #include "DbgIPS.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +DbgIPS::DbgIPS(CWnd *pParentWnd) + : CDialog(171, pParentWnd) +{ + Create(171, pParentWnd); +} + +/*virtual*/ void DbgIPS::DoDataExchange(CDataExchange *pDX) { + CWnd::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(DbgIPS, CDialog) +END_MESSAGE_MAP() diff --git a/src/DbgIPS.h b/src/DbgIPS.h index fcaf1ff..f66208e 100644 --- a/src/DbgIPS.h +++ b/src/DbgIPS.h @@ -1,3 +1,12 @@ #pragma once #include "common.h" +class DbgIPS : public CDialog { + DECLARE_MESSAGE_MAP() + +public: + DbgIPS(CWnd *pParentWnd); + +protected: + virtual void DoDataExchange(CDataExchange *pDX); +}; diff --git a/src/DbgPeopleView.cpp b/src/DbgPeopleView.cpp index 84682a1..3419b77 100644 --- a/src/DbgPeopleView.cpp +++ b/src/DbgPeopleView.cpp @@ -1,2 +1,117 @@ #include "DbgPeopleView.h" +#include "T2People.h" +#include "T2PeopleArray.h" +#include "T2PeopleArrayList.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#line 16 +IMPLEMENT_DYNCREATE(DbgPeopleView, CFrameWnd) + +DbgPeopleView::DbgPeopleView() { + mPeopleArrayList = NULL; +} + +/*virtual*/ DbgPeopleView::~DbgPeopleView() { +} + +BEGIN_MESSAGE_MAP(DbgPeopleView, CFrameWnd) + ON_WM_ERASEBKGND() + ON_WM_CREATE() + ON_WM_TIMER() + ON_WM_DESTROY() +END_MESSAGE_MAP() + +void DbgPeopleView::SetPeople(T2PeopleArrayList *inList) { + mPeopleArrayList = inList; +} + +BOOL DbgPeopleView::OnEraseBkgnd(CDC *pDC) { +#pragma var_order(str, font, save, height, iter, y, peopleArray, theFrameRect, brush) + if (!mPeopleArrayList) + return CFrameWnd::OnEraseBkgnd(pDC); + + int save = pDC->SaveDC(); + + CRect theFrameRect; + GetClientRect(theFrameRect); + + pDC->SetTextColor(RGB(0, 0, 0)); + pDC->SetBkColor(RGB(255, 255, 255)); + + CBrush brush; + brush.CreateStockObject(WHITE_BRUSH); + pDC->FillRect(theFrameRect, &brush); + + CFont font; + font.CreateFont(-12, 0, 0, 0, FW_NORMAL, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, DRAFT_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); + pDC->SelectObject(&font); + + int height = pDC->GetTextExtent("A").cy + 1; + pDC->SetTextAlign(TA_UPDATECP); + int y = 2; + + CString str; + LArrayIterator iter(*mPeopleArrayList); + T2PeopleArray *peopleArray; + + while (iter.Next(&peopleArray)) { + for (int i = 0; i < T2PeopleArray::kGroupSize; i++) { + T2People *people = &peopleArray->mPeople[i]; + + if (people->IsUsed() && !people->mPrev) { + pDC->MoveTo(2, y); + + str.Format("(%04d) %04d", people->mCurrEquipID, people->mMatterID); + pDC->TextOut(0, 0, str); + + T2People *prevPeople = people; + people = (T2People *) people->mNext; + int j = 0; + + while (people && j < 100) { + if (prevPeople == people->mPrev) + pDC->SetTextColor(RGB(0, 0, 0)); + else + pDC->SetTextColor(RGB(255, 0, 0)); + pDC->TextOut(0, 0, " \x81\xA8 "); + + pDC->SetTextColor(RGB(0, 0, 0)); + + str.Format("%04d:%02d", people->mMatterID, people->GetStatus()); + pDC->TextOut(0, 0, str); + + prevPeople = people; + people = (T2People *) people->mNext; + j++; + } + + y += height; + } + } + } + + pDC->RestoreDC(save); + return true; +} + +int DbgPeopleView::OnCreate(LPCREATESTRUCT lpCreateStruct) { + if (CFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + SetTimer(1, 100, NULL); + return 0; +} + +void DbgPeopleView::OnTimer(UINT nIDEvent) { + InvalidateRect(NULL); +} + +void DbgPeopleView::OnDestroy() { + CFrameWnd::OnDestroy(); + KillTimer(1); +} diff --git a/src/DbgPeopleView.h b/src/DbgPeopleView.h index fcaf1ff..6be9d18 100644 --- a/src/DbgPeopleView.h +++ b/src/DbgPeopleView.h @@ -1,3 +1,20 @@ #pragma once #include "common.h" +class DbgPeopleView : public CFrameWnd { + DECLARE_DYNCREATE(DbgPeopleView) + DECLARE_MESSAGE_MAP() + +public: + DbgPeopleView(); + ~DbgPeopleView(); + void SetPeople(T2PeopleArrayList *inList); + +protected: + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg void OnDestroy(); + + T2PeopleArrayList *mPeopleArrayList; +}; diff --git a/src/DbgStepRun.cpp b/src/DbgStepRun.cpp index f268da2..09ae722 100644 --- a/src/DbgStepRun.cpp +++ b/src/DbgStepRun.cpp @@ -1,2 +1,25 @@ #include "DbgStepRun.h" +#include "T2MainWindow.h" +#include "T2TowerDoc.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +DbgStepRun::DbgStepRun(CWnd *pParentWnd) { + Create(158, pParentWnd); +} + +/*virtual*/ void DbgStepRun::DoDataExchange(CDataExchange *pDX) { + CWnd::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(DbgStepRun, CDialog) + ON_COMMAND(1006, OnCommand1006) +END_MESSAGE_MAP() + +void DbgStepRun::OnCommand1006() { + ((T2TowerDoc *) T2_MAIN_WINDOW->GetActiveDocument())->towerDoc_vfC0(true); +} diff --git a/src/DbgStepRun.h b/src/DbgStepRun.h index fcaf1ff..5330b47 100644 --- a/src/DbgStepRun.h +++ b/src/DbgStepRun.h @@ -1,3 +1,13 @@ #pragma once #include "common.h" +class DbgStepRun : public CDialog { + DECLARE_MESSAGE_MAP() + +public: + DbgStepRun(CWnd *pParentWnd); + +protected: + virtual void DoDataExchange(CDataExchange *pDX); + afx_msg void OnCommand1006(); +}; @@ -1,2 +1,520 @@ +#include "256CheckDialog.h" +#include "GlobalFunc.h" #include "T2.h" +#include "T2ClassFactory.h" +#include "T2DLL.h" +#include "T2GlobalData.h" +#include "T2MainWindow.h" +#include "T2Message.h" +#include "T2OpenFileDialog.h" +#include "T2OpenningWindow.h" +#include "T2OpenSelectDlg.h" +#include "T2PluginLoader.h" +#include "T2PluginSpecifier.h" +#include "T2TowerDoc.h" +#include "T2TowerMainView.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +BEGIN_MESSAGE_MAP(CT2App, CWinApp) + ON_COMMAND(ID_APP_ABOUT, OnCmdAbout) + ON_COMMAND(ID_FILE_OPEN, OnCmdOpen) + ON_COMMAND(ID_FILE_NEW, OnFileNew) + ON_COMMAND(ID_FILE_OPEN, OnFileOpen) +END_MESSAGE_MAP() + +CT2App::CT2App() { + gT2App = this; + _E4 = 0; +} + +CT2App theApp; + +static void setRegValue(HKEY rootKey, const char *subKey, const char *name, const char *value); + +/*virtual*/ BOOL CT2App::InitInstance() { + SetRegistryKey("OPeNBooK9003"); + + _DC = 1; + + char *theStr = (char *) malloc(1000); + + setRegValue(HKEY_CLASSES_ROOT, "CLSID\\{F6FC9820-57D7-11d2-A2FD-0040056140CF}", NULL, "Tower2 Plugin Helper"); + + GetTowerDirectory(theStr); + strcat(theStr, "T2Icons.dll"); + setRegValue(HKEY_CLASSES_ROOT, "CLSID\\{F6FC9820-57D7-11d2-A2FD-0040056140CF}\\InProcServer32", NULL, theStr); + setRegValue(HKEY_CLASSES_ROOT, "CLSID\\{F6FC9820-57D7-11d2-A2FD-0040056140CF}\\InProcServer32", "ThreadingModel", "Apartment"); + + setRegValue(HKEY_CLASSES_ROOT, ".t2p", NULL, "Tower2 plugin"); + setRegValue(HKEY_CLASSES_ROOT, "Tower2 plugin", NULL, "Tower2 plugin"); + GetModuleFileName(NULL, theStr, 1000); + strcat(theStr, ",1"); + setRegValue(HKEY_CLASSES_ROOT, "Tower2 plugin\\DefaultIcon", NULL, theStr); + setRegValue(HKEY_CLASSES_ROOT, "Tower2 plugin\\shellex\\IconHandler", NULL, "{F6FC9820-57D7-11d2-A2FD-0040056140CF}"); + setRegValue(HKEY_CLASSES_ROOT, "Tower2 plugin\\shellex\\PropertySheetHandlers", NULL, "T2Page"); + setRegValue(HKEY_CLASSES_ROOT, "Tower2 plugin\\shellex\\PropertySheetHandlers\\T2Page", NULL, "{F6FC9820-57D7-11d2-A2FD-0040056140CF}"); + + setRegValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", "{F6FC9820-57D7-11d2-A2FD-0040056140CF}", "Tower2 Plugin Helper"); + + setRegValue(HKEY_CLASSES_ROOT, ".bld", NULL, "Tower2 Building"); + setRegValue(HKEY_CLASSES_ROOT, "Tower2 Building", NULL, "Tower2 Building"); + GetModuleFileName(NULL, theStr, 1000); + strcat(theStr, ",1"); + setRegValue(HKEY_CLASSES_ROOT, "Tower2 Building\\DefaultIcon", NULL, theStr); + GetModuleFileName(NULL, theStr, 1000); + strcat(theStr, " %1"); + setRegValue(HKEY_CLASSES_ROOT, "Tower2 Building\\shell\\open\\command", NULL, theStr); + + free(theStr); + +#line 99 + mPluginLoader = new T2PluginLoader; + + mPluginLoader->InitFileList(); + + CoInitialize(NULL); + T2ClassFactory::Initialize(); + + T2PluginSpecifier *thePluginSpecifier; + POSITION pos; + mPluginLoader->SetTypeFilter(pos, 'CLAS'); + while ((thePluginSpecifier = mPluginLoader->GetNext(pos))) { + if (!thePluginSpecifier->mAttrib) { + CLASSFACTORY_CLASSINFO *clsInfo = (CLASSFACTORY_CLASSINFO *) T2PluginLoader::LoadPlugin(thePluginSpecifier); + T2ClassFactory::Register(clsInfo); + free(clsInfo); + } + } + +#line 118 + mGlobalData = new T2GlobalData; + if (!mGlobalData->IsCheckSerial()) { + MessageBox( + NULL, + // "シリアル番号が間違っています。" + "\x83\x56\x83\x8A\x83\x41\x83\x8B\x94\xD4\x8D\x86\x82\xAA\x8A\xD4\x88\xE1\x82\xC1\x82\xC4\x82\xA2\x82\xDC\x82\xB7\x81\x42", + // "The Tower Ⅱ" + "The Tower \x87\x55", + MB_ICONERROR); + return false; + } + + Enable3dControls(); + SetDialogBkColor(); + LoadStdProfileSettings(); + + BOOL isPaletteMode = false; + HDC hdc = GetDC(NULL); + if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) + isPaletteMode = true; + ReleaseDC(NULL, hdc); + + if (!isPaletteMode) { + C256ColorDialog dlg(NULL); + if (dlg.DoModal() != IDOK) + return false; + } + +#line 154 + (new T2OpenningWindow)->ShowOpenningWindow(); + +#line 161 + CDocTemplate *pDocTemplate = new CSingleDocTemplate( + 128, + RUNTIME_CLASS(T2TowerDoc), + RUNTIME_CLASS(T2MainWindow), + RUNTIME_CLASS(T2TowerMainView) + ); + AddDocTemplate(pDocTemplate); + + app_vfB4(); + + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + BOOL bResult = true; + + switch (cmdInfo.m_nShellCommand) { + case CCommandLineInfo::FileNew: + if (!AfxGetApp()->OnCmdMsg(ID_FILE_NEW, 0, NULL, NULL)) + CWinApp::OnFileNew(); + if (!m_pMainWnd) + bResult = false; + break; + + case CCommandLineInfo::FileOpen: + mStrE0 = cmdInfo.m_strFileName; + if (!AfxGetApp()->OnCmdMsg(ID_FILE_NEW, 0, NULL, NULL)) + CWinApp::OnFileNew(); + if (!m_pMainWnd) + bResult = false; + break; + } + + return true; +} + +static void setRegValue(HKEY rootKey, const char *subKey, const char *name, const char *value) { + HKEY key; + RegCreateKey(rootKey, subKey, &key); + RegSetValueEx(key, name, 0, REG_SZ, (const BYTE *) value, strlen(value)); + RegCloseKey(key); +} + +class AboutDialog : public CDialog { + DECLARE_MESSAGE_MAP(); + +public: + AboutDialog(); + +protected: + virtual void DoDataExchange(CDataExchange *pDX); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg void OnDestroy(); + afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); + + int mCounter; + CBitmap mBitmap; + int mCreditsWidth; + int mCreditsViewHeight; + int mCreditsFullHeight; + BOOL mIsSetUp; +}; + +AboutDialog::AboutDialog() + : CDialog(100) +{ + mIsSetUp = false; +} + +/*virtual*/ void AboutDialog::DoDataExchange(CDataExchange *pDX) { + CWnd::DoDataExchange(pDX); +} + +void AboutDialog::OnShowWindow(BOOL bShow, UINT nStatus) { + CWnd::OnShowWindow(bShow, nStatus); + + if (!mIsSetUp) { +#pragma var_order(windowRect, okRect, serialNo, logoItem, bitmap, serialLabelItem, serialItem, app, okButton, niceSerialNo, serialLabelRect, clientRect, logoRect, creditsWnd) + mIsSetUp = true; + mCounter = 0; + + SetTimer(1, 50, NULL); + + CWnd *logoItem = GetDlgItem(1026); + logoItem->SetWindowPos(NULL, 16, 16, 0, 0, SWP_NOSIZE); + + RECT logoRect; + logoItem->GetClientRect(&logoRect); + + CWnd *serialLabelItem = GetDlgItem(1027); + serialLabelItem->SetWindowPos(NULL, 16, logoRect.bottom + 32, 0, 0, SWP_NOSIZE); + + RECT serialLabelRect; + serialLabelItem->GetClientRect(&serialLabelRect); + + CT2App *app = T2_APP; + CString serialNo = app->app_vfB0()->mSerial; + + CString niceSerialNo; + niceSerialNo = serialNo.Mid(0, 4); + niceSerialNo += " - "; + niceSerialNo += serialNo.Mid(4, 4); + niceSerialNo += " - "; + niceSerialNo += serialNo.Mid(8, 4); + niceSerialNo += " - "; + niceSerialNo += serialNo.Mid(12, 4); + + CWnd *serialItem = GetDlgItem(1024); + serialItem->SetWindowText(niceSerialNo); + serialItem->SetWindowPos(NULL, serialLabelRect.right + 20, logoRect.bottom + 32, 0, 0, SWP_NOSIZE); + + mBitmap.LoadBitmap(224); + BITMAP bitmap; + mBitmap.GetBitmap(&bitmap); + + CWnd *creditsWnd = GetDlgItem(1025); + + mCreditsWidth = bitmap.bmWidth; + mCreditsViewHeight = logoRect.bottom; + creditsWnd->SetWindowPos(NULL, logoRect.right + 32, 16, mCreditsWidth, mCreditsViewHeight, 0); + mCreditsFullHeight = bitmap.bmHeight; + + CWnd *okButton = GetDlgItem(1); + + RECT okRect; + okButton->GetClientRect(&okRect); + + okButton->SetWindowPos(NULL, logoRect.right + 32 + mCreditsWidth - okRect.right, mCreditsViewHeight + 32, 0, 0, SWP_NOSIZE); + + RECT windowRect, clientRect; + GetWindowRect(&windowRect); + windowRect.bottom -= windowRect.top; + GetClientRect(&clientRect); + windowRect.bottom -= clientRect.bottom; + + SetWindowPos(NULL, 0, 0, logoRect.right + 48 + mCreditsWidth, mCreditsViewHeight + 48 + okRect.bottom + windowRect.bottom, SWP_NOMOVE); + } +} + +void AboutDialog::OnDestroy() { + KillTimer(1); + mBitmap.DeleteObject(); + CWnd::OnDestroy(); +} + +void AboutDialog::OnTimer(UINT nIDEvent) { +#pragma var_order(prevBitmap, dc, newDC, creditsWnd) + mCounter++; + if (mCounter > (mCreditsFullHeight - mCreditsViewHeight)) + mCounter = 0; + + CWnd *creditsWnd = GetDlgItem(1025); + + CDC newDC; + CDC *dc = creditsWnd->GetDC(); + newDC.CreateCompatibleDC(dc); + + CBitmap *prevBitmap = newDC.SelectObject(&mBitmap); + dc->BitBlt(0, 0, mCreditsWidth, mCreditsViewHeight, &newDC, 0, mCounter, SRCCOPY); + newDC.SelectObject(prevBitmap); + + newDC.DeleteDC(); + CWnd::OnTimer(nIDEvent); +} + +BEGIN_MESSAGE_MAP(AboutDialog, CDialog) + ON_WM_TIMER() + ON_WM_DESTROY() + ON_WM_SHOWWINDOW() +END_MESSAGE_MAP() + +void CT2App::OnCmdAbout() { + AboutDialog dlg; + dlg.DoModal(); +} + + + +/*virtual*/ int CT2App::ExitInstance() { + T2ClassFactory::Discard(); + CoUninitialize(); + delete mGlobalData; + delete mPluginLoader; + + OutputDebugString("***** TowerII : PROGRAM TERMINATED *****\n"); + return CWinApp::ExitInstance(); +} + +/*virtual*/ BOOL CT2App::OnIdle(LONG lCount) { + if (_E4 && _DC > 0) { + T2MainWindow *mainWindow = T2_MAIN_WINDOW; + if (mainWindow) { + T2TowerDoc *doc = (T2TowerDoc *) mainWindow->GetActiveDocument(); + if (doc) + doc->towerDoc_vfC0(0); + } + } + + return true; +} + +/*virtual*/ void CT2App::app_vfA4(BOOL inEnable) { + if (inEnable) + _DC++; + else + _DC--; +} + +/*virtual*/ void CT2App::app_vfA8(T2Message *inMessage) { + mMessage = inMessage; +} + +/*virtual*/ void CT2App::app_vfAC() { + mMessage = NULL; +} + +/*virtual*/ BOOL CT2App::PreTranslateMessage(MSG *pMsg) { + if (mMessage) + mMessage->SendMessage(WM_USER + 10, 0, (LPARAM) pMsg); + + return CWinThread::PreTranslateMessage(pMsg); +} + +/*virtual*/ void CT2App::app_vfB4() { + MSG msg; + + while (PeekMessage(&msg, NULL, 0, 0, 0)) + PumpMessage(); +} + +/*virtual*/ int CT2App::Run() { + // this is just CWinThread::Run()'s body +#line 451 + ASSERT_VALID(this); + + // for tracking the idle time state + BOOL bIdle = TRUE; + LONG lIdleCount = 0; + + // acquire and dispatch messages until a WM_QUIT message is received. + for (;;) { + // phase1: check to see if we can do idle work + while (bIdle && + !::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE)) + { + // call OnIdle while in bIdle state + if (!OnIdle(lIdleCount++)) + bIdle = FALSE; // assume "no idle" state + } + + // phase2: pump messages while available + do + { + // pump message, but quit on WM_QUIT + if (!PumpMessage()) + return ExitInstance(); + + // reset "no idle" state after pumping "normal" message + if (IsIdleMessage(&m_msgCur)) + { + bIdle = TRUE; + lIdleCount = 0; + } + + } while (::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE)); + } + +#line 485 + ASSERT(FALSE); // not reachable +} + +void CT2App::OnCmdOpen() { + CString str; + + T2OpenFileDialog ofd( + true, + "bld", + NULL, + OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_EXPLORER, + // "Tower2.0ビルファイル (*.bld)|*.bld|すべてのファイル (*.*)|*.*||" + "Tower2.0\xCB\xDE\xD9\xCC\xA7\xB2\xD9 (*.bld)|*.bld|\x82\xB7\x82\xD7\x82\xC4\x82\xCC\xCC\xA7\xB2\xD9 (*.*)|*.*||", + AfxGetMainWnd() + ); + + if (ofd.DoModal() == IDOK) { + str = ofd.GetPathName(); + + if (g_TowerDoc->SaveModified()) { + if (!g_TowerDoc->OnOpenDocument(str)) { + if (g_TowerDoc->mErrorFlag) { + g_TowerDoc->SetModifiedFlag(false); + OnFileNew(); + } + } else { + g_TowerDoc->SetPathName(str); + } + } + } else if (GetCurrentT2TowerDoc()->Get228()) { + T2MainWindow *mainWindow = T2_MAIN_WINDOW; + if (mainWindow) { + T2TowerDoc *theDoc = (T2TowerDoc *) mainWindow->GetActiveDocument(); + if (theDoc) { +#line 535 + T2OpenSelectDlg *dlg = new T2OpenSelectDlg(theDoc); + dlg->ShowOpenSelectDialog(); + } + } + } +} + +static BOOL CALLBACK EnumFFJoysticksCallback(LPCDIDEVICEINSTANCE pinst, LPVOID lpvContext); + +void ffInit(HWND hwnd) { + HINSTANCE hInstance = AfxGetApp()->m_hInstance; + + HRESULT hr = DirectInputCreate(hInstance, DIRECTINPUT_VERSION, &FFgpdi, NULL); + if (FAILED(hr)) + return; + + hr = FFgpdi->EnumDevices(DIDEVTYPE_JOYSTICK, EnumFFJoysticksCallback, NULL, DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK); + + if (!FFJoystick) + return; + + hr = FFJoystick->SetDataFormat(&c_dfDIJoystick); + if (FAILED(hr)) + return; + + hr = FFJoystick->SetCooperativeLevel(hwnd, DISCL_EXCLUSIVE | DISCL_BACKGROUND); + if (FAILED(hr)) + return; + + DIEFFECT eff; + DWORD rgdwAxes[2] = { DIJOFS_X, DIJOFS_Y }; + LONG rglDirection[2] = { 0, 0 }; + DICONSTANTFORCE cf = { 0 }; + + eff.dwSize = sizeof(DIEFFECT); + eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS; + eff.dwDuration = INFINITE; + eff.dwSamplePeriod = 0; + eff.dwGain = DI_FFNOMINALMAX; + eff.dwTriggerButton = DIEB_NOTRIGGER; + eff.dwTriggerRepeatInterval = 0; + eff.cAxes = 2; + eff.rgdwAxes = rgdwAxes; + eff.rglDirection = rglDirection; + eff.lpEnvelope = NULL; + eff.cbTypeSpecificParams = sizeof(DICONSTANTFORCE); + eff.lpvTypeSpecificParams = &cf; + + hr = FFJoystick->CreateEffect(GUID_ConstantForce, &eff, &FFStatic, NULL); + if (FAILED(hr)) + return; + + FFJoystick->Acquire(); + FFStatic->Start(1, 0); + FFEnable = true; +} + +static BOOL CALLBACK EnumFFJoysticksCallback(LPCDIDEVICEINSTANCE pinst, LPVOID lpvContext) { + HRESULT hr; + LPDIRECTINPUTDEVICE pdev; + LPDIRECTINPUTDEVICE2 pdev2; + + hr = FFgpdi->CreateDevice(pinst->guidInstance, &pdev, NULL); + if (FAILED(hr)) + return DIENUM_CONTINUE; + + hr = pdev->QueryInterface(IID_IDirectInputDevice2, (LPVOID *) &pdev2); + + pdev->Release(); + + if (FAILED(hr)) + return DIENUM_CONTINUE; + + FFJoystick = pdev2; + return DIENUM_STOP; +} + +void ffDestroy() { + if (FFBuild) + FFBuild->Release(); + + if (FFStatic) + FFStatic->Release(); + + if (FFJoystick) { + FFJoystick->Unacquire(); + FFJoystick->Release(); + } + + if (FFgpdi) + FFgpdi->Release(); +} @@ -1,3 +1,51 @@ #pragma once #include "common.h" +#define T2_APP ((CT2App *) AfxGetApp()) + +class CT2App : public CWinApp { + DECLARE_MESSAGE_MAP() + +public: + CT2App(); + + virtual BOOL InitInstance(); + virtual int Run(); + virtual BOOL PreTranslateMessage(MSG *pMsg); + virtual BOOL OnIdle(LONG lCount); + virtual int ExitInstance(); + + // modifies counter _DC - called from T2MoverModuleTable ctor + // also called on Debug Step Run + virtual void app_vfA4(BOOL inEnable); + + // sets mMessage + virtual void app_vfA8(T2Message * inMessage); + + // clears mMessage + virtual void app_vfAC(); + + // gets global data + virtual T2GlobalData *app_vfB0() { return mGlobalData; } + + // runs a message loop - called from T2PluginLoader + virtual void app_vfB4(); + + T2GlobalData *mGlobalData; + T2PluginLoader *mPluginLoader; + T2ToolWindow *mToolWindow; + T2TowerDoc *mDocument; + T2MainWindow *mMainWindow; + int _DC; + CString mStrE0; + int _E4; + T2Message *mMessage; + +protected: + afx_msg void OnCmdAbout(); + afx_msg void OnCmdOpen(); + + friend class T2OpenSelectDlg; +}; + +void ffDestroy(); diff --git a/src/T2CtrlPalette.cpp b/src/T2CtrlPalette.cpp index ee01d9a..d751a9c 100644 --- a/src/T2CtrlPalette.cpp +++ b/src/T2CtrlPalette.cpp @@ -4,19 +4,25 @@ #include "T2TowerDoc.h" #include "T2WorldDef.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + // T2.exe 44795C /*static*/ int T2CtrlPalette::sUnknown = 0; T2CtrlPalette::T2CtrlPalette() { #line 19 - mPauseControl = DEBUG_NEW T2MWControl; - mInViewControl = DEBUG_NEW T2MWControl; - mOutViewControl = DEBUG_NEW T2MWControl; - mMaintControl = DEBUG_NEW T2MWControl; - mEvalControl = DEBUG_NEW T2MWControl; - mTransControl = DEBUG_NEW T2MWControl; - mPriceControl = DEBUG_NEW T2MWControl; - mSliderControl = DEBUG_NEW T2MWControl; + mPauseControl = new T2MWControl; + mInViewControl = new T2MWControl; + mOutViewControl = new T2MWControl; + mMaintControl = new T2MWControl; + mEvalControl = new T2MWControl; + mTransControl = new T2MWControl; + mPriceControl = new T2MWControl; + mSliderControl = new T2MWControl; mDocument = NULL; mWorldDef = NULL; @@ -42,7 +48,7 @@ BEGIN_MESSAGE_MAP(T2CtrlPalette, CFrameWnd) ON_WM_CLOSE() END_MESSAGE_MAP() -/*virtual*/ void T2CtrlPalette::Setup(T2TowerDoc *inDoc) { +/*virtual*/ void T2CtrlPalette::SetDocument(T2TowerDoc *inDoc) { mDocument = inDoc; mWorldDef = inDoc->mWorldDef; @@ -87,7 +93,7 @@ END_MESSAGE_MAP() InvalidateRect(NULL); } -/*virtual*/ void T2CtrlPalette::vf100(int which) { +/*virtual*/ void T2CtrlPalette::vf100(int inViewMode) { mInViewControl->SetData(0); mOutViewControl->SetData(0); mMaintControl->SetData(0); @@ -95,30 +101,30 @@ END_MESSAGE_MAP() mTransControl->SetData(0); mPriceControl->SetData(0); - int walkRate = mDocument->towerDoc_vf148(); + int walkRate = mDocument->GetWalkRate(); if (walkRate == -1) walkRate = 0; else walkRate = 7 - walkRate; mSliderControl->SetData(walkRate); - switch (which) { - case 0: + switch (inViewMode) { + case kInView: mInViewControl->SetData(100); break; - case 1: + case kOutView: mOutViewControl->SetData(100); break; - case 4: + case kMaintView: mMaintControl->SetData(100); break; - case 2: + case kEvalView: mEvalControl->SetData(100); break; - case 5: + case kTransView: mTransControl->SetData(100); break; - case 3: + case kPriceView: mPriceControl->SetData(100); break; } @@ -126,34 +132,35 @@ END_MESSAGE_MAP() InvalidateRect(NULL); } -/*virtual*/ void T2CtrlPalette::vf104(int which) { +/*virtual*/ void T2CtrlPalette::vf104(int inViewMode) { +#pragma var_order(windowRect, y, clientRect, flag) RECT windowRect; RECT clientRect; int flag = 0; int y; - switch (which) { - case 0: - case 6: + switch (inViewMode) { + case kInView: + case ViewMode_6: y = 0; break; - case 1: + case kOutView: y = 0; flag = 1; break; - case 4: + case kMaintView: y = 21; mE0 = "Maint"; break; - case 2: + case kEvalView: y = 21; mE0 = "Eval"; break; - case 5: + case kTransView: y = 21; mE0 = "Trans"; break; - case 3: + case kPriceView: y = 21; mE0 = "Price"; break; @@ -226,8 +233,5 @@ afx_msg void T2CtrlPalette::OnClose() { if (!mDocument) return; - mDocument->towerDoc_vf198(kTowerDocWindowType0); -} - -/*virtual*/ void T2CtrlPalette::vf108() { + mDocument->towerDoc_vf198(kControlWindow); } diff --git a/src/T2CtrlPalette.h b/src/T2CtrlPalette.h index 78a2806..b262fee 100644 --- a/src/T2CtrlPalette.h +++ b/src/T2CtrlPalette.h @@ -8,10 +8,10 @@ public: T2CtrlPalette(); virtual ~T2CtrlPalette(); - virtual void Setup(T2TowerDoc *inDoc); - virtual void vf100(int which); - virtual void vf104(int which); - virtual void vf108(int what); // SetViewModeInternally? + virtual void SetDocument(T2TowerDoc *inDoc); + virtual void vf100(int inViewMode); + virtual void vf104(int inViewMode); + virtual void vf108(int what) {} T2MWControl *mPauseControl; T2MWControl *mInViewControl; diff --git a/src/T2DLL/CLink.h b/src/T2DLL/CLink.h index 6edfdca..ed7304a 100644 --- a/src/T2DLL/CLink.h +++ b/src/T2DLL/CLink.h @@ -21,6 +21,7 @@ protected: CLink *mPrev; friend class CLinkIterator; + friend class DbgPeopleView; friend class T2PeopleLinkIterator; }; diff --git a/src/T2DLL/CPluginInfo.h b/src/T2DLL/CPluginInfo.h index 71fa3c7..cec185d 100644 --- a/src/T2DLL/CPluginInfo.h +++ b/src/T2DLL/CPluginInfo.h @@ -28,4 +28,6 @@ protected: CString mName; CString mFileName; BOOL mUsed; + + friend class T2TowerDoc; }; diff --git a/src/T2DLL/GlobalFunc.cpp b/src/T2DLL/GlobalFunc.cpp index a5f6f6f..71139b0 100644 --- a/src/T2DLL/GlobalFunc.cpp +++ b/src/T2DLL/GlobalFunc.cpp @@ -56,7 +56,7 @@ HBITMAP Create256DIBitmap(HDC inDC, int inWidth, int inHeight) { if (GetDeviceCaps(inDC, BITSPIXEL) == 8) { theBitmap = CreateBitmap(inWidth, inHeight, 1, 8, NULL); } else { - Bitmap *bitmap = (Bitmap *) malloc(sizeof(Bitmap)); + Bitmap256 *bitmap = (Bitmap256 *) malloc(sizeof(Bitmap256)); memset(&bitmap->header, 0, sizeof(BITMAPINFOHEADER)); bitmap->header.biSize = sizeof(BITMAPINFOHEADER); @@ -192,7 +192,7 @@ T2TowerDoc *GetCurrentT2TowerDoc() { } HINSTANCE GetWorldModuleHandle() { - return GetCurrentT2TowerDoc()->towerDoc_vf170()->mModuleHandle; + return GetCurrentT2TowerDoc()->GetWorldDef()->mModuleHandle; } CString GetModuleName(HINSTANCE inModule) { diff --git a/src/T2DLL/MoverSearchDlg.cpp b/src/T2DLL/MoverSearchDlg.cpp index 48dfc31..f4733fc 100644 --- a/src/T2DLL/MoverSearchDlg.cpp +++ b/src/T2DLL/MoverSearchDlg.cpp @@ -42,7 +42,7 @@ void MoverSearchDlg::DoFind() { return; T2Name *theName = (T2Name *) listBox->GetItemDataPtr(sel); - mDocument->towerDoc_vf238(theName); + mDocument->DoFind(theName); } void MoverSearchDlg::DoDelete() { diff --git a/src/T2DLL/PeopleSearchDlg.cpp b/src/T2DLL/PeopleSearchDlg.cpp index d7f5277..deed18a 100644 --- a/src/T2DLL/PeopleSearchDlg.cpp +++ b/src/T2DLL/PeopleSearchDlg.cpp @@ -45,7 +45,7 @@ void PeopleSearchDlg::DoFind() { return; T2Name *theName = (T2Name *) listBox->GetItemDataPtr(sel); - mDocument->towerDoc_vf238(theName); + mDocument->DoFind(theName); } void PeopleSearchDlg::DoDelete() { diff --git a/src/T2DLL/SoundDlg.cpp b/src/T2DLL/SoundDlg.cpp index 705bd70..0bc2236 100644 --- a/src/T2DLL/SoundDlg.cpp +++ b/src/T2DLL/SoundDlg.cpp @@ -1,5 +1,5 @@ #include "SoundDlg.h" -#include "CT2App.h" +#include "T2.h" #include "T2DlgItem.h" #include "T2DlgItemText.h" #include "T2MainWindow.h" @@ -57,7 +57,7 @@ static unsigned int masks[4] = { }; void SoundDlg::Save() { - T2SoundPlayer *theSoundPlayer = mDocument->towerDoc_vf134(); + T2SoundPlayer *theSoundPlayer = mDocument->GetSoundPlayer(); T2DlgItem *theCheck = GetT2DlgItem(100); if (theCheck->GetValue()) @@ -78,7 +78,7 @@ void SoundDlg::Save() { /*virtual*/ void SoundDlg::OnT2Create() { T2DlgItem *theCheck, *theICheck; - T2SoundPlayer *theSoundPlayer = mDocument->towerDoc_vf134(); + T2SoundPlayer *theSoundPlayer = mDocument->GetSoundPlayer(); theCheck = GetT2DlgItem(100); if (theSoundPlayer->IsSoundOn()) { diff --git a/src/T2DLL/SpeedDlg.cpp b/src/T2DLL/SpeedDlg.cpp index 37d5441..281bb36 100644 --- a/src/T2DLL/SpeedDlg.cpp +++ b/src/T2DLL/SpeedDlg.cpp @@ -1,5 +1,5 @@ #include "SpeedDlg.h" -#include "CT2App.h" +#include "T2.h" #include "T2DlgItem.h" #include "T2MainWindow.h" #include "T2MWControl.h" @@ -21,7 +21,7 @@ SpeedDlg::SpeedDlg() { void SpeedDlg::Setup(T2TowerDoc *inDoc, HINSTANCE inInstance, CWnd *inParentWnd, const POINT &inPt, T2ImageObj *inImageObj) { mDocument = inDoc; - mCurrentSpeed = mDocument->towerDoc_vf2A4(); + mCurrentSpeed = mDocument->GetDrawSpeed(); T2DLGTEMPLATE tmpl; tmpl.resID = 7010; @@ -50,7 +50,7 @@ void SpeedDlg::Revert() { } void SpeedDlg::Save() { - mDocument->towerDoc_vf2A8(mCurrentSpeed); + mDocument->SetDrawSpeed(mCurrentSpeed); } /*virtual*/ void SpeedDlg::OnT2Create() { diff --git a/src/T2DLL/T2Animation.cpp b/src/T2DLL/T2Animation.cpp index 9031777..1a3208d 100644 --- a/src/T2DLL/T2Animation.cpp +++ b/src/T2DLL/T2Animation.cpp @@ -112,7 +112,7 @@ void T2Animation::Play(POINT inPt, int inLen) { while (playing) { playing = Step(); - mDocument->GetTowerMainView()->tmv_vf120(); + mDocument->GetMainView()->tmv_vf120(); int now; for (now = GetTickCount(); now < endTick; now = GetTickCount()) { diff --git a/src/T2DLL/T2ArrowWnd.cpp b/src/T2DLL/T2ArrowWnd.cpp index 6c60c08..da7466e 100644 --- a/src/T2DLL/T2ArrowWnd.cpp +++ b/src/T2DLL/T2ArrowWnd.cpp @@ -32,7 +32,7 @@ void T2ArrowWnd::Show(int inX, int inY, T2TowerDoc* inDoc) { mWndClass = AfxRegisterWndClass(CS_NOCLOSE, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); CRect rect(0, 0, 50, 50); - Create(mWndClass, "ArrowWnd", WS_CHILD, rect, inDoc->GetTowerMainView(), NULL, WS_EX_TOPMOST); + Create(mWndClass, "ArrowWnd", WS_CHILD, rect, inDoc->GetMainView(), NULL, WS_EX_TOPMOST); mRgn.CreatePolygonRgn(rgnPoints, 7, ALTERNATE); diff --git a/src/T2DLL/T2Balloon.cpp b/src/T2DLL/T2Balloon.cpp index 2fe2ef0..34ab19f 100644 --- a/src/T2DLL/T2Balloon.cpp +++ b/src/T2DLL/T2Balloon.cpp @@ -63,7 +63,7 @@ void T2Balloon::Show(int inX, int inY, const CString& inText, BOOL inDoPause) { rect1.OffsetRect(rect2.left, rect2.top); CRect rect4; - GetCurrentT2TowerDoc()->GetTowerMainView()->tmv_vf140(rect4); + GetCurrentT2TowerDoc()->GetMainView()->GetVisibleUnitRect(rect4); UT2Coordinate::UnitToQD(rect4, 0); CRect rect5; @@ -200,7 +200,7 @@ void T2Balloon::Show(int inX, int inY, const CString& inText, BOOL inDoPause) { mImage = new T2BitImage(rect8); mImage->Clear(0); - CPalette *thePalette = GetCurrentT2TowerDoc()->towerDoc_vf170()->GetPalette(); + CPalette *thePalette = GetCurrentT2TowerDoc()->GetWorldDef()->GetPalette(); dc.SelectPalette(thePalette, false); dc.RealizePalette(); diff --git a/src/T2DLL/T2BitImage.h b/src/T2DLL/T2BitImage.h index 11e143d..838e909 100644 --- a/src/T2DLL/T2BitImage.h +++ b/src/T2DLL/T2BitImage.h @@ -2,7 +2,7 @@ #include "common.h" // unknown name -struct Bitmap { +struct Bitmap256 { BITMAPINFOHEADER header; short palette[256]; }; @@ -35,7 +35,7 @@ public: int GetParam() { return mParam; } void SetParam(int v) { mParam = v; } - Bitmap mBitmap; + Bitmap256 mBitmap; unsigned char *mData; POINT mOrigin; HGLOBAL mMemHandle; diff --git a/src/T2DLL/T2BlackOut.cpp b/src/T2DLL/T2BlackOut.cpp index c3b69a8..25868ea 100644 --- a/src/T2DLL/T2BlackOut.cpp +++ b/src/T2DLL/T2BlackOut.cpp @@ -38,7 +38,7 @@ static int anims[] = {2, 8400, 8401}; if (mConsumptionPower > mSupplyPower) { mStatus = kBlackOutStatus1; - T2TowerMainView *theView = inDoc->GetTowerMainView(); + T2TowerMainView *theView = inDoc->GetMainView(); if (theView) { inDoc->towerDoc_vf284(); @@ -82,7 +82,7 @@ static int anims[] = {2, 8400, 8401}; /*virtual*/ int T2BlackOut::Exec(T2TowerDoc* inDoc) { int resultCode = IsExclusive() ? 1 : 0; - T2DateTime *theNow = inDoc->towerDoc_vf120(); + T2DateTime *theNow = inDoc->GetNow(); unsigned int theNowMinutes = theNow->GetRawMinutes(); T2TowerMainView *theMainView; T2TowerMessage *theTowerMsg; @@ -116,7 +116,7 @@ static int anims[] = {2, 8400, 8401}; case kBlackOutStatus4: mStatus = kBlackOutStatus0; - theMainView = inDoc->GetTowerMainView(); + theMainView = inDoc->GetMainView(); if (theMainView) { inDoc->towerDoc_vf284(); if (mAttach) { @@ -152,7 +152,7 @@ void T2BlackOut::AddConsumptionPower(int inPower) { // "変圧器を増設" - Add a transformer text += "\x95\xCF\x88\xB3\x8A\xED\x82\xF0\x91\x9D\x90\xDD"; } else { - CFilePlugin *plugin = theDoc->mTenantPluginsListOther->GetItem('HEND'); + CFilePlugin *plugin = theDoc->mTenantPlugins->GetItem('HEND'); if (plugin) { // "変電室を設置" - Install substation room text += "\x95\xCF\x93\x64\x8E\xBA\x82\xF0\x90\xDD\x92\x75"; @@ -245,15 +245,15 @@ T2BlackOutAttach::~T2BlackOutAttach() { void T2BlackOutAttach::ExecuteSelf(unsigned int inMessage, void *ioData) { BOOL newExecuteHost = true; - if (inMessage == 0x201) { - int sel = ((T2MainWindow *) AfxGetMainWnd())->mToolWindow->GetSel(); - CString *theToolName = ((T2MainWindow *) AfxGetMainWnd())->mToolWindow->GetIconName(sel); - T2TemplatePlugin *theDef = ((T2MainWindow *) AfxGetMainWnd())->mToolWindow->GetIconPlugin(sel); + if (inMessage == WM_LBUTTONDOWN) { + int sel = T2_MAIN_WINDOW->mToolWindow->GetSel(); + CString *theToolName = T2_MAIN_WINDOW->mToolWindow->GetIconName(sel); + T2TemplatePlugin *theDef = T2_MAIN_WINDOW->mToolWindow->GetIconPlugin(sel); CProgramPlugin *thePlugin = theDef->GetPlugin(); - unsigned int theValiation = ((T2MainWindow *) AfxGetMainWnd())->mToolWindow->GetIconValiation(sel); - DWORD theOption = ((T2MainWindow *) AfxGetMainWnd())->mToolWindow->GetIconOption(sel); + unsigned int theValiation = T2_MAIN_WINDOW->mToolWindow->GetIconValiation(sel); + DWORD theOption = T2_MAIN_WINDOW->mToolWindow->GetIconOption(sel); - if (theOption == 0) + if (theOption == kToolOption0) newExecuteHost = true; else newExecuteHost = (thePlugin && thePlugin->GetID() == 'HEND'); diff --git a/src/T2DLL/T2ColdTableDef.cpp b/src/T2DLL/T2ColdTableDef.cpp index 3af5ca7..f112a5c 100644 --- a/src/T2DLL/T2ColdTableDef.cpp +++ b/src/T2DLL/T2ColdTableDef.cpp @@ -2,7 +2,7 @@ #include "T2ColdTableDef.h" T2ColdTableDef::T2ColdTableDef(CResFile &inResFile) { - inResFile >> mVar; + inResFile >> mMinimumGameLevel; for (unsigned int i = 0; i < 12; i++) inResFile >> mEntries[i]; } @@ -10,11 +10,11 @@ T2ColdTableDef::T2ColdTableDef(CResFile &inResFile) { /*virtual*/ T2ColdTableDef::~T2ColdTableDef() { } -unsigned int T2ColdTableDef::GetDenomi(unsigned int inA, unsigned int inB) const { +unsigned int T2ColdTableDef::GetDenomi(unsigned int inGameLevel, unsigned int inMonth) const { unsigned int result = 0; - if (inA >= mVar && inB < 12) - result = mEntries[inB]; + if (inGameLevel >= mMinimumGameLevel && inMonth < 12) + result = mEntries[inMonth]; return result; } diff --git a/src/T2DLL/T2ColdTableDef.h b/src/T2DLL/T2ColdTableDef.h index 087402a..54162bb 100644 --- a/src/T2DLL/T2ColdTableDef.h +++ b/src/T2DLL/T2ColdTableDef.h @@ -5,9 +5,9 @@ class T2ColdTableDef { public: T2ColdTableDef(CResFile &inResFile); virtual ~T2ColdTableDef(); - unsigned int GetDenomi(unsigned int inA, unsigned int inB) const; + unsigned int GetDenomi(unsigned int inGameLevel, unsigned int inMonth) const; protected: - unsigned int mVar; + unsigned int mMinimumGameLevel; unsigned int mEntries[12]; }; diff --git a/src/T2DLL/T2DLL.cpp b/src/T2DLL/T2DLL.cpp index 9e270be..48cb3a7 100644 --- a/src/T2DLL/T2DLL.cpp +++ b/src/T2DLL/T2DLL.cpp @@ -18,14 +18,14 @@ END_MESSAGE_MAP() T2DLLApp::T2DLLApp() { } -T2DLLApp theApp; -T2SoundPlayer *Sounds; -CT2App *gT2App; -int gCommonColor[20]; -BOOL FFEnable = 0; -DWORD FFBaseForce = 0; -IDirectInput *FFgpdi = NULL; -IDirectInputDevice2 *FFJoystick = NULL; -IDirectInputEffect *FFBuild = NULL; -IDirectInputEffect *FFStatic = NULL; -T2TowerDoc *g_TowerDoc = NULL; +AFX_DATA_EXPORT T2DLLApp theApp; +AFX_DATA_EXPORT T2SoundPlayer *Sounds; +AFX_DATA_EXPORT CT2App *gT2App; +AFX_DATA_EXPORT int gCommonColor[20]; +AFX_DATA_EXPORT BOOL FFEnable = 0; +AFX_DATA_EXPORT DWORD FFBaseForce = 0; +AFX_DATA_EXPORT IDirectInput *FFgpdi = NULL; +AFX_DATA_EXPORT IDirectInputDevice2 *FFJoystick = NULL; +AFX_DATA_EXPORT IDirectInputEffect *FFBuild = NULL; +AFX_DATA_EXPORT IDirectInputEffect *FFStatic = NULL; +AFX_DATA_EXPORT T2TowerDoc *g_TowerDoc = NULL; diff --git a/src/T2DLL/T2DLL.h b/src/T2DLL/T2DLL.h index c88e1c7..e72bef2 100644 --- a/src/T2DLL/T2DLL.h +++ b/src/T2DLL/T2DLL.h @@ -8,13 +8,13 @@ public: DECLARE_MESSAGE_MAP() }; -extern AFX_DATA_EXPORT T2SoundPlayer *Sounds; -extern AFX_DATA_EXPORT CT2App *gT2App; -extern AFX_DATA_EXPORT int gCommonColor[20]; -extern AFX_DATA_EXPORT BOOL FFEnable; -extern AFX_DATA_EXPORT DWORD FFBaseForce; -extern AFX_DATA_EXPORT IDirectInput *FFgpdi; -extern AFX_DATA_EXPORT IDirectInputDevice2 *FFJoystick; -extern AFX_DATA_EXPORT IDirectInputEffect *FFBuild; -extern AFX_DATA_EXPORT IDirectInputEffect *FFStatic; -extern AFX_DATA_EXPORT T2TowerDoc *g_TowerDoc; +extern AFX_EXT_DATA T2SoundPlayer *Sounds; +extern AFX_EXT_DATA CT2App *gT2App; +extern AFX_EXT_DATA int gCommonColor[20]; +extern AFX_EXT_DATA BOOL FFEnable; +extern AFX_EXT_DATA DWORD FFBaseForce; +extern AFX_EXT_DATA IDirectInput *FFgpdi; +extern AFX_EXT_DATA IDirectInputDevice2 *FFJoystick; +extern AFX_EXT_DATA IDirectInputEffect *FFBuild; +extern AFX_EXT_DATA IDirectInputEffect *FFStatic; +extern AFX_EXT_DATA T2TowerDoc *g_TowerDoc; diff --git a/src/T2DLL/T2Dialog.cpp b/src/T2DLL/T2Dialog.cpp index d240f07..4823c7d 100644 --- a/src/T2DLL/T2Dialog.cpp +++ b/src/T2DLL/T2Dialog.cpp @@ -135,9 +135,9 @@ int T2Dialog::OnCreate(CREATESTRUCT* cs) { if (mTowerDoc && !(GetWindowLong(m_hWnd, GWL_STYLE) & WS_CHILD)) { if (mModal != 0) - mTowerDoc->towerDoc_vf1A0(1); + mTowerDoc->towerDoc_vf1A0(true); if (mModal == 1) - mTowerDoc->towerDoc_vf290(1); + mTowerDoc->towerDoc_vf290(true); } if (mAutoShow && !(cs->style & WS_CHILD)) @@ -717,9 +717,9 @@ void T2Dialog::OnDestroy() { if (mTowerDoc && !(GetWindowLong(m_hWnd, GWL_STYLE) & WS_CHILD)) { if (mModal != 0) - mTowerDoc->towerDoc_vf1A0(0); + mTowerDoc->towerDoc_vf1A0(false); if (mModal == 1) - mTowerDoc->towerDoc_vf290(0); + mTowerDoc->towerDoc_vf290(false); } } diff --git a/src/T2DLL/T2ElevatorModule.cpp b/src/T2DLL/T2ElevatorModule.cpp index 5fa8438..5835aad 100644 --- a/src/T2DLL/T2ElevatorModule.cpp +++ b/src/T2DLL/T2ElevatorModule.cpp @@ -112,15 +112,15 @@ BOOL T2ElevatorModule::IsPtInArea(POINT pt, const RECT& area) const { if (position == mHomePosition) { flag = !HomePosRemoved(mover, position); - if (!flag && !towerDoc->towerDoc_vf16C() && mover->IsShaftVisible()) { + if (!flag && !towerDoc->GetElevTransparent() && mover->IsShaftVisible()) { RECT area; CalcUintArea(mover, mHomePosition, area); - T2TowerMainView *theView = towerDoc->GetTowerMainView(); + T2TowerMainView *theView = towerDoc->GetMainView(); #line 142 ASSERT(theView != NULL); - theView->tmv_vf128(area); + theView->InvalUnitRect(area); } } @@ -135,7 +135,7 @@ BOOL T2ElevatorModule::IsPtInArea(POINT pt, const RECT& area) const { } void T2ElevatorModule::Remove(T2TowerDoc* towerDoc, T2Mover* mover) { - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); T2People *theRemovePeople = NULL; BOOL isDown = true; T2Request *theRequest; @@ -174,7 +174,7 @@ void T2ElevatorModule::RemoveContents(T2TowerDoc* towerDoc, T2Mover* mover, int if (mLink1) { POINT theStopPos = mover->PositionToStopPt(position, ERequestUpDown_0); - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); #line 221 ASSERT(theFloorInfo != NULL); @@ -204,11 +204,11 @@ void T2ElevatorModule::RemoveContents(T2TowerDoc* towerDoc, T2Mover* mover, int RECT theRect; CalcUintArea(mover, theRect); - T2TowerMainView *theView = towerDoc->GetTowerMainView(); + T2TowerMainView *theView = towerDoc->GetMainView(); #line 251 ASSERT(theView != NULL); - theView->tmv_vf128(theRect); + theView->InvalUnitRect(theRect); } } } diff --git a/src/T2DLL/T2ElvModuleList.cpp b/src/T2DLL/T2ElvModuleList.cpp index 4fc835b..0ed388f 100644 --- a/src/T2DLL/T2ElvModuleList.cpp +++ b/src/T2DLL/T2ElvModuleList.cpp @@ -65,7 +65,7 @@ void T2ElvModuleList::CalcBaseQDRect(RECT& outRect) { int T2ElvModuleList::DestructModule(T2TowerDoc* towerDoc, T2Mover* mover, POINT inPt) { RECT theBaseQDRect; int theModuleIndex = -1; - int theZoomLevel = towerDoc->towerDoc_vf108(); + int theZoomLevel = towerDoc->GetZoomLevel(); POINT pt = inPt; CalcBaseQDRect(theBaseQDRect); diff --git a/src/T2DLL/T2Equip.cpp b/src/T2DLL/T2Equip.cpp index d42cf4e..f2221d2 100644 --- a/src/T2DLL/T2Equip.cpp +++ b/src/T2DLL/T2Equip.cpp @@ -44,7 +44,7 @@ int T2Equip::InitEquip(T2EquipDef* def, const RECT& area, unsigned int valiation T2TowerDoc *towerDoc = GetCurrentT2TowerDoc(); if (towerDoc) - mBuildDay = towerDoc->towerDoc_vf120()->CalcTotalDays(); + mBuildDay = towerDoc->GetNow()->CalcTotalDays(); else mBuildDay = 0; @@ -63,7 +63,7 @@ int T2Equip::InitEquip(T2EquipDef* def, const RECT& area, unsigned int valiation } int T2Equip::DaysSinceBuilt(const T2TowerDoc* towerDoc) const { - return towerDoc->towerDoc_vf120()->CalcLapseDays(mBuildDay); + return towerDoc->GetNow()->CalcLapseDays(mBuildDay); } void T2Equip::SetEquipArea(const RECT& rect) { @@ -182,9 +182,9 @@ void T2Equip::ReplaceCEID(unsigned int oldID, unsigned int newID) { } /*virtual*/ void T2Equip::PlaySound(T2TowerDoc* inDoc, int id, unsigned int inMask, unsigned int inFlags) const { - if (inDoc->towerDoc_vf15C(mArea)) { + if (inDoc->IsRectInView(mArea)) { T2EquipDef *equipDef = GetEquipDef(); - T2SoundPlayer *soundPlayer = inDoc->towerDoc_vf134(); + T2SoundPlayer *soundPlayer = inDoc->GetSoundPlayer(); if (equipDef && soundPlayer) { CRect theArea; GetEquipArea(theArea); diff --git a/src/T2DLL/T2EquipDef.cpp b/src/T2DLL/T2EquipDef.cpp index 6084b5c..2888811 100644 --- a/src/T2DLL/T2EquipDef.cpp +++ b/src/T2DLL/T2EquipDef.cpp @@ -101,7 +101,7 @@ T2EquipDef::T2EquipDef(DWORD type, T2PluginSpecifier& specifier, CResFile* resFi return -1; } -/*virtual*/ AREACHECKCODE T2EquipDef::AreaCheck(T2TowerDoc*, RECT&, unsigned int, int) { +/*virtual*/ AREACHECKCODE T2EquipDef::AreaCheck(T2TowerDoc* inDoc, RECT& inRect, unsigned int, BOOL inShowError) { return AreaCheckCode_0; } @@ -114,7 +114,7 @@ T2EquipDef::T2EquipDef(DWORD type, T2PluginSpecifier& specifier, CResFile* resFi } /*virtual*/ void T2EquipDef::BuildFinish(T2TowerDoc* towerDoc, T2Equip* equip) { - towerDoc->towerDoc_vf170()->CalcOptionObj(towerDoc, equip); + towerDoc->GetWorldDef()->CalcOptionObj(towerDoc, equip); } /*virtual*/ unsigned long T2EquipDef::OptionProc(T2TowerDoc*, T2Equip*, void*) { @@ -124,8 +124,8 @@ T2EquipDef::T2EquipDef(DWORD type, T2PluginSpecifier& specifier, CResFile* resFi /*virtual*/ void T2EquipDef::DebugInfo(CWnd&, CListCtrl&, T2Equip*) { } -/*virtual*/ int T2EquipDef::FingerToolProc(T2TowerDoc*, T2Equip*, const POINT&, MOUSEEVENT) { - return 0; +/*virtual*/ BOOL T2EquipDef::FingerToolProc(T2TowerDoc*, T2Equip*, const POINT&, MOUSEEVENT) { + return false; } /*virtual*/ T2InfoDialog* T2EquipDef::ShowInfoDialog(T2TowerDoc* towerDoc, T2Equip* equip) { diff --git a/src/T2DLL/T2EquipDef.h b/src/T2DLL/T2EquipDef.h index fe6fe3e..8b5b780 100644 --- a/src/T2DLL/T2EquipDef.h +++ b/src/T2DLL/T2EquipDef.h @@ -17,14 +17,14 @@ public: virtual void LoadExtraData(T2Archive& inArchive, T2TowerDoc*, T2HaveOutViewObject*); virtual void SaveExtraData(T2Archive& inArchive, T2HaveOutViewObject*); - virtual AREACHECKCODE AreaCheck(T2TowerDoc*, RECT&, unsigned int, int); + virtual AREACHECKCODE AreaCheck(T2TowerDoc* inDoc, RECT& inRect, unsigned int, BOOL inShowError); virtual int ClickProc(T2TowerDoc*, RECT*, unsigned int&); virtual int GetDestructPartProc(int, POINT, POINT, T2Equip*); virtual PARTCODE GetPartFromPoint(T2TowerDoc*, T2Equip*, POINT, int*); virtual PROCCODE DoBuildProc(T2TowerDoc*, RECT&, unsigned int) { return ProcCode_0; } - virtual int FingerToolProc(T2TowerDoc*, T2Equip*, const POINT&, MOUSEEVENT); + virtual BOOL FingerToolProc(T2TowerDoc*, T2Equip*, const POINT&, MOUSEEVENT); virtual void BuildFinish(T2TowerDoc*, T2Equip*); virtual unsigned long OptionProc(T2TowerDoc*, T2Equip*, void*); virtual void DrawPeople(T2TowerDoc* inDoc, T2Equip* inEquip); diff --git a/src/T2DLL/T2EventItem.cpp b/src/T2DLL/T2EventItem.cpp index 302752f..bcd6f52 100644 --- a/src/T2DLL/T2EventItem.cpp +++ b/src/T2DLL/T2EventItem.cpp @@ -27,7 +27,7 @@ T2EventItem::T2EventItem(T2TowerEvent* inTowerEvent, CResFile* inResFile, int in *inResFile >> mEndTime; mOriginalDef = this; - _4 = 0; + mForceStart = false; } T2EventItem::T2EventItem(T2TowerEvent* inTowerEvent, int inSubID, int inLevelBit, BOOL inExclusive, int inCycleDay, int inBeginTime, int inEndTime) { @@ -41,7 +41,7 @@ T2EventItem::T2EventItem(T2TowerEvent* inTowerEvent, int inSubID, int inLevelBit mStatus = 0; mOriginalDef = NULL; - _4 = 0; + mForceStart = false; } T2EventItem::T2EventItem(T2EventItem* inItem, int inSubID) { @@ -56,7 +56,7 @@ T2EventItem::T2EventItem(T2EventItem* inItem, int inSubID) { mStatus = 0; mOriginalDef = inItem; - _4 = 0; + mForceStart = false; } /*virtual*/ T2EventItem::~T2EventItem() { @@ -134,7 +134,7 @@ T2EventItem* T2EventItem::GetOriginalDef() { /*virtual*/ unsigned int T2EventItem::DoDialog(T2TowerDoc* inDoc, int inDlgResID, int inAnimResID, int inAnimUnk, const char* inText) { T2WorldDef *theWorldDef = GetWorldDef(); - inDoc->GetTowerMainView()->tmv_vf154(); + inDoc->GetMainView()->HideToolSprite(); inDoc->towerDoc_vf290(true); unsigned int result = 0; @@ -160,13 +160,13 @@ T2EventItem* T2EventItem::GetOriginalDef() { } inDoc->towerDoc_vf290(false); - inDoc->GetTowerMainView()->tmv_vf150(); + inDoc->GetMainView()->UnhideToolSprite(); return result; } /*virtual*/ void T2EventItem::DoAlert(T2TowerDoc* inDoc, CString& inText, int inSoundID) { T2WorldDef *theWorldDef = GetWorldDef(); - inDoc->GetTowerMainView()->tmv_vf154(); + inDoc->GetMainView()->HideToolSprite(); inDoc->towerDoc_vf290(true); T2EventDialog *theDialog = T2EventDialog::Show(this, inDoc, theWorldDef->mModuleHandle, 8000); @@ -195,7 +195,7 @@ T2EventItem* T2EventItem::GetOriginalDef() { } inDoc->towerDoc_vf294(); - inDoc->GetTowerMainView()->tmv_vf150(); + inDoc->GetMainView()->UnhideToolSprite(); } /*virtual*/ void T2EventItem::Write(T2Archive& inArchive) { diff --git a/src/T2DLL/T2EventItem.h b/src/T2DLL/T2EventItem.h index 844186a..0167def 100644 --- a/src/T2DLL/T2EventItem.h +++ b/src/T2DLL/T2EventItem.h @@ -35,7 +35,7 @@ public: void SetStatus(int inStatus); T2EventItem* GetOriginalDef(); - int _4; + BOOL mForceStart; int mSubID; T2TowerEvent *mTowerEvent; int mStatus; diff --git a/src/T2DLL/T2FireBurning.cpp b/src/T2DLL/T2FireBurning.cpp index eee04c3..9d76af6 100644 --- a/src/T2DLL/T2FireBurning.cpp +++ b/src/T2DLL/T2FireBurning.cpp @@ -69,13 +69,13 @@ T2FireBurning::T2FireBurning(T2TowerEvent* inTowerEvent, CResFile* inResFile, in { CString text = LoadStringTable(GetWorldModuleHandle(), 8100, 1); DoAlert(inDoc, text, 0); - inDoc->towerDoc_vf270(mHelicopterPrice, kFundGroup2); - inDoc->towerDoc_vf2A8(25); + inDoc->DoPay(mHelicopterPrice, kFundGroup2); + inDoc->SetDrawSpeed(25); Sounds->Play("FIREBURNING:HELI", SoundMask_10, SoundFlags_10 | SoundFlags_10000, NULL, PlayMode_3, 100); break; } case kFireFightFireman: - inDoc->towerDoc_vf2A8(25); + inDoc->SetDrawSpeed(25); break; } @@ -97,7 +97,7 @@ T2FireBurning::T2FireBurning(T2TowerEvent* inTowerEvent, CResFile* inResFile, in mTimePassed++; IdleEvent(inDoc); - T2DateTime *theNow = inDoc->towerDoc_vf120(); + T2DateTime *theNow = inDoc->GetNow(); if (!mFireArray || mFireArray->GetCount() == 0 || theNow->GetRawMinutes() == mEndTime) mStatus = kFireBurningStatus2; } @@ -115,17 +115,17 @@ T2FireBurning::T2FireBurning(T2TowerEvent* inTowerEvent, CResFile* inResFile, in } /*virtual*/ void T2FireBurning::StartEvent(T2TowerDoc* inTowerDoc, POINT inPt, const T2Tenant* inTenant) { - T2FloorInfo *theFloorInfo = inTowerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inTowerDoc->GetFloorInfo(); mFightAction = kFireFightNull; mFireArray = new LArray; - inTowerDoc->towerDoc_vf144(ViewMode_0); - inTowerDoc->towerDoc_vf2A8(25); + inTowerDoc->SetViewMode(kInView); + inTowerDoc->SetDrawSpeed(25); inTowerDoc->SetFireBurning(true); inTowerDoc->towerDoc_vf1A0(true); inTowerDoc->towerDoc_vf2A0()->EnableIcon(false); - inTowerDoc->GetTowerMainView()->tmv_vf154(); - inTowerDoc->towerDoc_vf1B4(); + inTowerDoc->GetMainView()->HideToolSprite(); + inTowerDoc->BreakoutEmergency(); Sounds->FadeOut(); Sounds->AddSound("FIREBURNING:", SoundPriority_1, 8100, GetWorldModuleHandle()); @@ -134,7 +134,7 @@ T2FireBurning::T2FireBurning(T2TowerEvent* inTowerEvent, CResFile* inResFile, in Sounds->Play("FIREBURNING:", SoundMask_10, SoundFlags_10 | SoundFlags_10000, NULL, PlayMode_0, 100); CString dialogText; - dialogText.Format("%d", inTowerDoc->towerDoc_vf12C()->UnitToFloor(inPt.y)); + dialogText.Format("%d", inTowerDoc->GetFloorInfo()->UnitToFloor(inPt.y)); dialogText += LoadStringTable(GetWorldModuleHandle(), 8100, 3); DoDialog(inTowerDoc, 8100, 5100, 3, dialogText); @@ -153,13 +153,13 @@ T2FireBurning::T2FireBurning(T2TowerEvent* inTowerEvent, CResFile* inResFile, in MakeFire(inPt, inTowerDoc); // should this be called theView? as per Mac asserts - T2TowerMainView *theTowerMainView = inTowerDoc->GetTowerMainView(); + T2TowerMainView *theTowerMainView = inTowerDoc->GetMainView(); CRect area; inTenant->GetEquipArea(area); - theTowerMainView->tmv_vf15C(area); + theTowerMainView->CenterOnRect(area); - ((T2MainWindow *) AfxGetMainWnd())->mCtrlPalette->vf108(0); + T2_MAIN_WINDOW->mCtrlPalette->vf108(0); Sounds->Play("FIREBURNING:FIRE", SoundMask_10, SoundFlags_10 | SoundFlags_10000, NULL, PlayMode_3, 100); @@ -202,7 +202,7 @@ T2FireBurning::T2FireBurning(T2TowerEvent* inTowerEvent, CResFile* inResFile, in switch (inResult) { case 8114: - if (inDoc->towerDoc_vf26C() < mHelicopterPrice) { + if (inDoc->GetCurrentFunds() < mHelicopterPrice) { theString = LoadStringTable(GetWorldModuleHandle(), 8100, 5); DoAlert(inDoc, theString, 9000); inResult = 0; @@ -210,7 +210,7 @@ T2FireBurning::T2FireBurning(T2TowerEvent* inTowerEvent, CResFile* inResFile, in break; case 8115: - theFloorInfo = inDoc->towerDoc_vf12C(); + theFloorInfo = inDoc->GetFloorInfo(); theTenant = theFloorInfo ? theFloorInfo->GetTenantByPID('KEBI') : NULL; if (!theTenant) { theString = LoadStringTable(GetWorldModuleHandle(), 8100, 6); @@ -265,7 +265,7 @@ T2FireBurning::T2FireBurning(T2TowerEvent* inTowerEvent, CResFile* inResFile, in } /*virtual*/ void T2FireBurning::StopEvent(T2TowerDoc* inDoc) { - T2TowerMainView *theView = inDoc->GetTowerMainView(); + T2TowerMainView *theView = inDoc->GetMainView(); theView->KillTimer(100); if (mFireArray) { @@ -295,7 +295,7 @@ T2FireBurning::T2FireBurning(T2TowerEvent* inTowerEvent, CResFile* inResFile, in delete mAttach; mAttach = NULL; - theView->tmv_vf124(true); + theView->Invalidate(true); theView->tmv_vf120(); } @@ -328,8 +328,8 @@ T2FireBurning::T2FireBurning(T2TowerEvent* inTowerEvent, CResFile* inResFile, in inDoc->towerDoc_vf1A0(false); inDoc->SetFireBurning(false); - if (inDoc->GetTowerMainView()) - inDoc->GetTowerMainView()->tmv_vf150(); + if (inDoc->GetMainView()) + inDoc->GetMainView()->UnhideToolSprite(); if (inDoc->towerDoc_vf2A0()) inDoc->towerDoc_vf2A0()->EnableIcon(true); } @@ -337,7 +337,7 @@ T2FireBurning::T2FireBurning(T2TowerEvent* inTowerEvent, CResFile* inResFile, in BOOL T2FireBurning::MakeFire(POINT inPt, T2TowerDoc* inDoc) { BOOL createdFire = false; - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); T2Tenant *theTenant = theFloorInfo->GetTenant(inPt.y, inPt.x); if (theTenant && !theTenant->IsFire() && !theTenant->IsFireproof()) { @@ -426,13 +426,13 @@ BOOL T2FireBurning::DoExtinguish(CPoint& inPt) { } void T2FireBurning::CallFireman(T2TowerDoc* inDoc, const T2Tenant* inTenant) { - T2RegistedTenantDB *theDB = inDoc->towerDoc_vf174(); + T2RegistedTenantDB *theDB = inDoc->GetRegistedTenantDB(); T2EquipPtrList *theList = theDB->GetList(kTenantRegistID5); if (theList) { LArrayIterator iterator(*theList); unsigned int numFiremen = 0; - unsigned int nowMinutes = inDoc->towerDoc_vf120()->GetRawMinutes(); + unsigned int nowMinutes = inDoc->GetNow()->GetRawMinutes(); T2Tenant *theFireStation; while (numFiremen < 6 && iterator.Next(&theFireStation)) { @@ -453,10 +453,10 @@ void T2FireBurning::CallFireman(T2TowerDoc* inDoc, const T2Tenant* inTenant) { BOOL T2FireBurning::IsBreakoutFire(const T2TowerDoc* inDoc, POINT& outPt, T2Tenant*& outTenant) const { BOOL done = false; - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); unsigned int curAttempt = 0; - unsigned int numAttempt = _4 ? 100000 : 100; + unsigned int numAttempt = mForceStart ? 100000 : 100; while (!done && curAttempt < numAttempt) { curAttempt++; @@ -505,7 +505,7 @@ T2Fire::T2Fire(POINT& inPt, T2TowerDoc* inDoc, int inVar, T2ImageObj* inImageObj mFireman = NULL; for (unsigned int h = 0; h < x1C; h++) { - T2Tenant *theTenant = inDoc->towerDoc_vf12C()->GetTenant(inPt.y, inPt.x + h); + T2Tenant *theTenant = inDoc->GetFloorInfo()->GetTenant(inPt.y, inPt.x + h); if (theTenant && !theTenant->IsFireproof() && !theTenant->IsFire()) { if (xC > 0) { if (mArsonTenant != theTenant) @@ -555,7 +555,7 @@ BOOL T2Fire::Move() { p.x = (xC > 0) ? (rect.right + 1) : (rect.left - 1); UT2Coordinate::QDToUnit(p, 0); - T2Tenant *theTenant = mDocument->towerDoc_vf12C()->GetTenant(p.y, p.x); + T2Tenant *theTenant = mDocument->GetFloorInfo()->GetTenant(p.y, p.x); if (theTenant && !theTenant->IsFireproof() && (!theTenant->IsFire() || mArsonTenant == theTenant)) { p.y = rect.top; p.x = rect.left + xC; @@ -567,13 +567,13 @@ BOOL T2Fire::Move() { } } else { x4++; - T2TowerMainView *theView = mDocument->GetTowerMainView(); + T2TowerMainView *theView = mDocument->GetMainView(); if (theView) { CRect unitRect = rect; UT2Coordinate::QDToUnit(unitRect.TopLeft(), 0); UT2Coordinate::QDToUnit(unitRect.BottomRight(), 0); unitRect.right++; - theView->tmv_vf128(unitRect, true); + theView->InvalUnitRect(unitRect, true); } } @@ -718,16 +718,16 @@ T2Helicopter::~T2Helicopter() { } void T2Helicopter::Move(T2TowerDoc* inDoc) { - T2TowerMainView *theMainView = inDoc->GetTowerMainView(); + T2TowerMainView *theMainView = inDoc->GetMainView(); CRect rect; CPoint cursorPt, p; GetCursorPos(&cursorPt); theMainView->ScreenToClient(&cursorPt); - cursorPt += theMainView->m64; + cursorPt += theMainView->mScrollOffset; - UT2Coordinate::QDToUnit(cursorPt, mDocument->towerDoc_vf108()); + UT2Coordinate::QDToUnit(cursorPt, mDocument->GetZoomLevel()); cursorPt.y -= 1; cursorPt.x += 1; UT2Coordinate::UnitToQD(cursorPt, 0, true); diff --git a/src/T2DLL/T2FloorInfo.cpp b/src/T2DLL/T2FloorInfo.cpp index 0bd508c..a4366af 100644 --- a/src/T2DLL/T2FloorInfo.cpp +++ b/src/T2DLL/T2FloorInfo.cpp @@ -124,7 +124,7 @@ void T2FloorInfo::Read(T2Archive& inArchive, T2TowerDoc* inDoc) { inArchive >> classID; if (classID == 'TntA') { mTenantArrayList->Read(inArchive, inDoc); - T2RegistedTenantDB *theDB = inDoc->towerDoc_vf174(); + T2RegistedTenantDB *theDB = inDoc->GetRegistedTenantDB(); theDB->Init(mTenantArrayList); mTenantArrayList->RecoverRelatedTenantList(theDB); inArchive >> classID; @@ -1022,7 +1022,7 @@ BOOL T2FloorInfo::BuildFinishForce(const RECT& inRect) { if (theTenant && theTenant->GetStatus() < kTenantStatus10) { theTenant->SetStatus(kTenantStatus9); theTenant->Idle(GetCurrentT2TowerDoc()); - GetCurrentT2TowerDoc()->mTowerMainView->tmv_vf128(theTenant->mArea); + GetCurrentT2TowerDoc()->mTowerMainView->InvalUnitRect(theTenant->mArea); finished = true; } } diff --git a/src/T2DLL/T2FloorNumberTable.cpp b/src/T2DLL/T2FloorNumberTable.cpp index 41bd585..ce20205 100644 --- a/src/T2DLL/T2FloorNumberTable.cpp +++ b/src/T2DLL/T2FloorNumberTable.cpp @@ -64,7 +64,7 @@ void T2FloorNumberTable::RefreshCell(int inFloor) { RECT theDrawArea = mRect; OffsetRect(&theDrawArea, cellRect.left, cellRect.top); - T2FloorInfo *theFloorInfo = GetCurrentT2TowerDoc()->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = GetCurrentT2TowerDoc()->GetFloorInfo(); RECT moverArea; mMover->GetEquipArea(moverArea); diff --git a/src/T2DLL/T2GlobalData.h b/src/T2DLL/T2GlobalData.h index f7b3da9..1e13644 100644 --- a/src/T2DLL/T2GlobalData.h +++ b/src/T2DLL/T2GlobalData.h @@ -11,13 +11,13 @@ public: BOOL IsCheckSerial(); int Get1stCinemaDate() { return m1stCinemaDate; } + BOOL mChanged; + int m1stCinemaDate; + T2MovieParamArray *mMovieParamArray; + char mSerial[20]; + protected: void Read(T2Archive& inArchive); void Write(T2Archive& inArchive); BOOL Check_Serial(char* inSerial); - - BOOL mChanged; - int m1stCinemaDate; - T2MovieParamArray *mMovieParamArray; - char mSerial[20]; }; diff --git a/src/T2DLL/T2GuestroomTable.cpp b/src/T2DLL/T2GuestroomTable.cpp index 4458d0f..752f276 100644 --- a/src/T2DLL/T2GuestroomTable.cpp +++ b/src/T2DLL/T2GuestroomTable.cpp @@ -409,12 +409,12 @@ int T2GuestroomItem::GetOutMoney() { void T2GuestroomItem::UpdateTenantEstimation(T2TowerDoc* inDoc) { BOOL isChanged = mTenant->UpdateResidencialEstimate(inDoc); - int viewMode = inDoc->towerDoc_vf140(); - if ((viewMode == ViewMode_2 && isChanged) || (viewMode == ViewMode_3)) { + int viewMode = inDoc->GetViewMode(); + if ((viewMode == kEvalView && isChanged) || (viewMode == kPriceView)) { mTenant->SetDrawMode(DrawMode1); RECT rect; mTenant->GetEquipArea(rect); - inDoc->GetTowerMainView()->tmv_vf128(rect); + inDoc->GetMainView()->InvalUnitRect(rect); } } diff --git a/src/T2DLL/T2HallEventTable.cpp b/src/T2DLL/T2HallEventTable.cpp index b522ed2..3bc08d7 100644 --- a/src/T2DLL/T2HallEventTable.cpp +++ b/src/T2DLL/T2HallEventTable.cpp @@ -184,7 +184,7 @@ T2MonthlyTable::T2MonthlyTable(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalet void T2MonthlyTable::SetStartMonth(T2TowerDoc* inDoc, int inMonth) { mStartMonth = inMonth; - T2DateTime *theNow = inDoc->towerDoc_vf120(); + T2DateTime *theNow = inDoc->GetNow(); T2DateTime date = *theNow; int months = 12; diff --git a/src/T2DLL/T2HaveOutViewObject.cpp b/src/T2DLL/T2HaveOutViewObject.cpp index 1b24415..125a0be 100644 --- a/src/T2DLL/T2HaveOutViewObject.cpp +++ b/src/T2DLL/T2HaveOutViewObject.cpp @@ -1,4 +1,5 @@ #include "T2HaveOutViewObject.h" +#include "T2Settlement.h" #include "T2ToolDef.h" #include "T2TowerDoc.h" @@ -63,6 +64,6 @@ int T2HaveOutViewObject::CalcMentenanceCost(T2TowerDoc* towerDoc) const { ASSERT(mToolDef); cost = mToolDef->CalcMentenanceCostProc(this); - towerDoc->DoPayTool(cost, 0, mToolDef); + towerDoc->DoPayTool(cost, kFundGroup0, mToolDef); return cost; } diff --git a/src/T2DLL/T2Maru_Reggae.cpp b/src/T2DLL/T2Maru_Reggae.cpp index d236e36..ee863ea 100644 --- a/src/T2DLL/T2Maru_Reggae.cpp +++ b/src/T2DLL/T2Maru_Reggae.cpp @@ -77,7 +77,7 @@ T2Maru_Reggae::T2Maru_Reggae(T2TowerEvent* inTowerEvent, CResFile* inResFile, in T2Tenant *theTenant = FindTargetTenant(inDoc); if (theTenant) { - T2Pool *thePool = inDoc->towerDoc_vf130(); + T2Pool *thePool = inDoc->GetPool(); #line 85 _ASSERT(thePool != NULL); @@ -95,7 +95,7 @@ T2Maru_Reggae::T2Maru_Reggae(T2TowerEvent* inTowerEvent, CResFile* inResFile, in } T2MatterDef *theMatterDef = thePeople->GetMatterDef(); - T2TemplatePluginList *thePluginList = inDoc->towerDoc_vf128(); + T2TemplatePluginList *thePluginList = inDoc->GetSilhouetteTemplates(); T2SilhouetteDef *theSilhouetteDef = thePluginList ? thePluginList->FindSilhouette(theMatterDef->mSilhouetteID + 1) : NULL; if (theSilhouetteDef) { @@ -182,7 +182,7 @@ BOOL T2Maru_Reggae::DoReception(T2TowerDoc* inDoc) { } mStatus = kMaruReggaeStatus8; } else if (mGuardman == NULL) { - T2Pool *thePool = inDoc->towerDoc_vf130(); + T2Pool *thePool = inDoc->GetPool(); #line 208 _ASSERT(thePool != NULL); @@ -201,7 +201,7 @@ BOOL T2Maru_Reggae::DoReception(T2TowerDoc* inDoc) { unsigned int theNextTenant; switch (mStatus) { case kMaruReggaeStatus1: - theTenant = inDoc->towerDoc_vf12C()->GetTenant(mVisitTenantID); + theTenant = inDoc->GetFloorInfo()->GetTenant(mVisitTenantID); if (theTenant) { T2EquipDef *theDef = theTenant->GetEquipDef(); if (theTenant->IsTherePeople() && !theTenant->IsFireproof()) { @@ -291,15 +291,15 @@ void T2Maru_Reggae::MaruReception(T2TowerDoc* inDoc, T2People* inPeople) { POINT curPos = inPeople->GetCurPosition(); CRect theRect; - T2TowerMainView *theView = inDoc->GetTowerMainView(); + T2TowerMainView *theView = inDoc->GetMainView(); theView->GetClientRect(theRect); - theRect.OffsetRect(theView->m64); + theRect.OffsetRect(theView->mScrollOffset); - UT2Coordinate::QDToUnit(theRect, inDoc->towerDoc_vf108()); + UT2Coordinate::QDToUnit(theRect, inDoc->GetZoomLevel()); - if (theRect.PtInRect(curPos) && inDoc->towerDoc_vf140() != ViewMode_1) { + if (theRect.PtInRect(curPos) && inDoc->GetViewMode() != kOutView) { UT2Coordinate::MakeRect(theRect, curPos, 2, 1); - theView->tmv_vf128(theRect, true); + theView->InvalUnitRect(theRect, true); } else { mStatus = kMaruReggaeStatus4; } @@ -329,7 +329,7 @@ void T2Maru_Reggae::ReggaeReception(T2TowerDoc* inDoc, T2People* inPeople) { inPeople->SetDestination(0); inPeople->UpdateEstimation(); - theTenant = inDoc->towerDoc_vf12C()->GetTenant(mVisitTenantID); + theTenant = inDoc->GetFloorInfo()->GetTenant(mVisitTenantID); if (theTenant) { CRect rect; theTenant->GetEquipArea(rect); @@ -354,18 +354,18 @@ void T2Maru_Reggae::ReggaeReception(T2TowerDoc* inDoc, T2People* inPeople) { case kMaruReggaeStatus6: curPos = inPeople->GetCurPosition(); - theTenant = inDoc->towerDoc_vf12C()->GetTenant(curPos.y, curPos.x); + theTenant = inDoc->GetFloorInfo()->GetTenant(curPos.y, curPos.x); if (theTenant && !theTenant->IsFloor() && mLastMinutes < GetEndTime()) { CRect theRect; - T2TowerMainView *theView = inDoc->GetTowerMainView(); + T2TowerMainView *theView = inDoc->GetMainView(); theView->GetClientRect(&theRect); - theRect.OffsetRect(theView->m64); + theRect.OffsetRect(theView->mScrollOffset); - UT2Coordinate::QDToUnit(theRect, inDoc->towerDoc_vf108()); + UT2Coordinate::QDToUnit(theRect, inDoc->GetZoomLevel()); - if (theRect.PtInRect(curPos) && inDoc->towerDoc_vf140() != ViewMode_1) { + if (theRect.PtInRect(curPos) && inDoc->GetViewMode() != kOutView) { UT2Coordinate::MakeRect(theRect, curPos, 2, 1); - theView->tmv_vf128(theRect, true); + theView->InvalUnitRect(theRect, true); if (inPeople->GetWalkStyle() == 0) inPeople->ChangeWalkStyle(1); @@ -407,7 +407,7 @@ void T2Maru_Reggae::ReggaeReception(T2TowerDoc* inDoc, T2People* inPeople) { CString message; curPos = inPeople->GetCurPosition(); - theTenant = inDoc->towerDoc_vf12C()->GetTenant(curPos.y, curPos.x); + theTenant = inDoc->GetFloorInfo()->GetTenant(curPos.y, curPos.x); MakeClaimMessage(inDoc, theTenant, message); inDoc->towerDoc_vf13C()->CancelInfoBarMessage(message); @@ -434,13 +434,13 @@ void T2Maru_Reggae::ReggaeReception(T2TowerDoc* inDoc, T2People* inPeople) { void T2Maru_Reggae::MakeClaimMessage(T2TowerDoc* inDoc, T2Tenant* inTenant, CString& outStr) { CString floorStr, roomStr, nameStr; - int floorNum = inTenant->GetFloorNumber(inDoc->towerDoc_vf12C()); + int floorNum = inTenant->GetFloorNumber(inDoc->GetFloorInfo()); if (floorNum < 0) floorStr.Format("B%d", -floorNum); else floorStr.Format("%d", floorNum); - int roomNum = inTenant->GetRoomNumber(inDoc->towerDoc_vf12C()); + int roomNum = inTenant->GetRoomNumber(inDoc->GetFloorInfo()); if (roomNum < 0) roomStr.Format("B%d", -roomNum); else @@ -458,7 +458,7 @@ void T2Maru_Reggae::MakeClaimMessage(T2TowerDoc* inDoc, T2Tenant* inTenant, CStr } T2Tenant* T2Maru_Reggae::FindTargetTenant(T2TowerDoc* inDoc) { - T2RouteNavigator *theNavi = inDoc->towerDoc_vf124(); + T2RouteNavigator *theNavi = inDoc->GetRouteNavi(); #line 521 _ASSERT(theNavi != NULL); @@ -494,7 +494,7 @@ T2Tenant* T2Maru_Reggae::FindTargetTenant(T2TowerDoc* inDoc) { unsigned int T2Maru_Reggae::FindNextTenant(T2TowerDoc* inDoc) { unsigned int theNextTenantID = 0; - T2FloorInfo *fInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *fInfo = inDoc->GetFloorInfo(); #line 550 _ASSERT(fInfo != NULL); T2People *thePeople = GetReggaeMan(); @@ -526,7 +526,7 @@ T2People* T2Maru_Reggae::GetReggaeMan() { } T2Tenant* T2Maru_Reggae::GetVisitTenant() { - return (mStatus == kMaruReggaeStatus6) ? GetTowerDoc()->towerDoc_vf12C()->GetTenant(mVisitTenantID) : NULL; + return (mStatus == kMaruReggaeStatus6) ? GetTowerDoc()->GetFloorInfo()->GetTenant(mVisitTenantID) : NULL; } /*virtual*/ void T2Maru_Reggae::Write(T2Archive& inArchive) { @@ -575,7 +575,7 @@ T2Guardman::T2Guardman(T2Maru_Reggae *inOwner, T2TowerDoc *inDoc, T2Tenant *inTe mOwner = inOwner; mPeople = NULL; - T2RegistedTenantDB *theDB = inDoc->towerDoc_vf174(); + T2RegistedTenantDB *theDB = inDoc->GetRegistedTenantDB(); #line 647 _ASSERT(theDB != NULL); @@ -585,7 +585,7 @@ T2Guardman::T2Guardman(T2Maru_Reggae *inOwner, T2TowerDoc *inDoc, T2Tenant *inTe theList->FetchItemAt(1, &theTenant); if (theTenant) { - T2RouteNavigator *theNavi = inDoc->towerDoc_vf124(); + T2RouteNavigator *theNavi = inDoc->GetRouteNavi(); #line 656 _ASSERT(theNavi != NULL); @@ -638,11 +638,11 @@ BOOL T2Guardman::DoReception(T2TowerDoc *inDoc) { case kStatus15: { CPoint curPos = mPeople->GetCurPosition(); - T2Tenant *theTenant = inDoc->towerDoc_vf12C()->GetTenant(curPos.y, curPos.x); + T2Tenant *theTenant = inDoc->GetFloorInfo()->GetTenant(curPos.y, curPos.x); T2People *theReggaeMan = mOwner->GetReggaeMan(); if (theTenant && theReggaeMan && mOwner->mStatus == kMaruReggaeStatus6) { CPoint reggaeManPos = theReggaeMan->GetCurPosition(); - if (theTenant == inDoc->towerDoc_vf12C()->GetTenant(reggaeManPos.y, reggaeManPos.x)) { + if (theTenant == inDoc->GetFloorInfo()->GetTenant(reggaeManPos.y, reggaeManPos.x)) { if (reggaeManPos == curPos) { mOwner->mStatus = kMaruReggaeStatus7; } else { diff --git a/src/T2DLL/T2Message.cpp b/src/T2DLL/T2Message.cpp index 15876af..0d6b1bd 100644 --- a/src/T2DLL/T2Message.cpp +++ b/src/T2DLL/T2Message.cpp @@ -1,4 +1,4 @@ -#include "CT2App.h" +#include "T2.h" #include "T2Message.h" #ifdef _DEBUG @@ -98,7 +98,7 @@ END_MESSAGE_MAP() /*virtual*/ void T2Message::PostNcDestroy() { sVisible = false; delete this; - ((CT2App *) AfxGetApp())->app_vfAC(); + T2_APP->app_vfAC(); } int T2Message::OnCreate(CREATESTRUCT* cs) { @@ -151,7 +151,7 @@ int T2Message::OnCreate(CREATESTRUCT* cs) { m74 = GetTickCount(); - ((CT2App *) AfxGetApp())->app_vfA8(this); + T2_APP->app_vfA8(this); return 0; } diff --git a/src/T2DLL/T2MetroRailway.cpp b/src/T2DLL/T2MetroRailway.cpp index 5653e83..560c58d 100644 --- a/src/T2DLL/T2MetroRailway.cpp +++ b/src/T2DLL/T2MetroRailway.cpp @@ -142,7 +142,7 @@ void T2MetroRailway::Init(T2Transport* inParent, CResFile* inResFile) { var1C += mStation; if (var1C < GetWorldDef()->GetWidth()) { - T2TowerMainView *theMainView = inDoc->GetTowerMainView(); + T2TowerMainView *theMainView = inDoc->GetMainView(); if (theMainView) { POINT p; RECT metroRect; @@ -155,12 +155,12 @@ void T2MetroRailway::Init(T2Transport* inParent, CResFile* inResFile) { p.y = metroRect.top; p.x = metroRect.left; - UT2Coordinate::ZoomOut(metroRect, inDoc->towerDoc_vf108()); + UT2Coordinate::ZoomOut(metroRect, inDoc->GetZoomLevel()); CRect visibleRect; theMainView->GetClientRect(&visibleRect); - visibleRect.OffsetRect(theMainView->m64); - visibleRect.right += UT2Coordinate::UnitHSize(inDoc->towerDoc_vf108()); + visibleRect.OffsetRect(theMainView->mScrollOffset); + visibleRect.right += UT2Coordinate::UnitHSize(inDoc->GetZoomLevel()); RECT intersection; if (IntersectRect(&intersection, &metroRect, &visibleRect)) { diff --git a/src/T2DLL/T2Mover.cpp b/src/T2DLL/T2Mover.cpp index 65120c1..7440364 100644 --- a/src/T2DLL/T2Mover.cpp +++ b/src/T2DLL/T2Mover.cpp @@ -193,7 +193,7 @@ void T2Mover::GetTypicalName(CString& outStr) const { /*virtual*/ BOOL T2Mover::Destruct(T2TowerDoc* towerDoc, CRect& rect) { GetEquipArea(rect); - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); mModuleList->Destruct(towerDoc); for (int p = 0; p < mLength; p++) { @@ -208,7 +208,7 @@ void T2Mover::GetTypicalName(CString& outStr) const { BOOL done = true; - towerDoc->towerDoc_vf124()->MoverRemoved(this, 1); + towerDoc->GetRouteNavi()->MoverRemoved(this, 1); return done; } @@ -231,7 +231,7 @@ int T2Mover::GetNumStop() const { void T2Mover::AddStopBoth(T2TowerDoc* towerDoc, int position) { BOOL ok = false; - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); ok |= AddStop(theFloorInfo, position, ERequestUpDown_0); ok |= AddStop(theFloorInfo, position, ERequestUpDown_1); @@ -274,7 +274,7 @@ void T2Mover::RemoveStopBoth(T2TowerDoc* towerDoc, int position) { RemoveStop(towerDoc, position, ERequestUpDown_0); RemoveStop(towerDoc, position, ERequestUpDown_1); - RemoveCrossEquipID(towerDoc->towerDoc_vf12C(), position); + RemoveCrossEquipID(towerDoc->GetFloorInfo(), position); mReqIDArray->StopRemoved(towerDoc, PositionToUnit(position)); if (mModuleList) @@ -308,7 +308,7 @@ void T2Mover::RemoveUnstoppable(T2TowerDoc* towerDoc) { } if (changed) - towerDoc->GetTowerMainView()->tmv_vf128(mArea); + towerDoc->GetMainView()->InvalUnitRect(mArea); } void T2Mover::AddCrossEquipID(T2FloorInfo* floorInfo, int position) { @@ -544,7 +544,7 @@ int T2Mover::CalcScore(int multiplier) const { int T2Mover::ExpandArea(T2TowerDoc* inDoc, EEquipPos inEquipPos, int inCount) { int result = 0; - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); RECT theMoverArea = mArea; @@ -638,7 +638,7 @@ int T2Mover::ExpandArea(T2TowerDoc* inDoc, EEquipPos inEquipPos, int inCount) { } if (inCount != 0) - inDoc->GetTowerMainView()->tmv_vf128(theMoverArea, true); + inDoc->GetMainView()->InvalUnitRect(theMoverArea, true); return result; } @@ -675,7 +675,7 @@ void T2Mover::ShowShaft() { mShowShaft = true; T2TowerDoc *theTowerDoc = GetCurrentT2TowerDoc(); - theTowerDoc->GetTowerMainView()->tmv_vf128(mArea); + theTowerDoc->GetMainView()->InvalUnitRect(mArea); } } @@ -684,8 +684,8 @@ void T2Mover::HideShaft() { mShowShaft = false; T2TowerDoc *theTowerDoc = GetCurrentT2TowerDoc(); - theTowerDoc->GetTowerMainView()->tmv_vf128(mArea); - theTowerDoc->towerDoc_vf12C()->SetTenantDrawModeByRect(mArea, DrawMode2); + theTowerDoc->GetMainView()->InvalUnitRect(mArea); + theTowerDoc->GetFloorInfo()->SetTenantDrawModeByRect(mArea, DrawMode2); } } diff --git a/src/T2DLL/T2MoverArray.h b/src/T2DLL/T2MoverArray.h index c832cd1..a2266c7 100644 --- a/src/T2DLL/T2MoverArray.h +++ b/src/T2DLL/T2MoverArray.h @@ -20,6 +20,8 @@ public: protected: friend class T2MoverArrayList; + friend class T2TowerDoc; + friend class T2TowerMainView; T2Mover mMover[kGroupSize]; }; diff --git a/src/T2DLL/T2MoverDef.cpp b/src/T2DLL/T2MoverDef.cpp index 3d39f27..9277fb8 100644 --- a/src/T2DLL/T2MoverDef.cpp +++ b/src/T2DLL/T2MoverDef.cpp @@ -62,18 +62,18 @@ BOOL T2MoverDef::InitObject(T2Mover* mover, const POINT&) { return true; } -/*virtual*/ AREACHECKCODE T2MoverDef::AreaCheck(T2TowerDoc* towerDoc, RECT& rect, unsigned int, int) { - if (!towerDoc->mFloorInfo->IsThereMover(rect)) +/*virtual*/ AREACHECKCODE T2MoverDef::AreaCheck(T2TowerDoc* inDoc, RECT& inRect, unsigned int, BOOL inShowError) { + if (!inDoc->mFloorInfo->IsThereMover(inRect)) return AreaCheckCode_1; - RECT adjRect = rect; + RECT adjRect = inRect; adjRect.top++; adjRect.bottom--; - if (adjRect.top < adjRect.bottom && !towerDoc->mFloorInfo->IsThereMover(adjRect)) + if (adjRect.top < adjRect.bottom && !inDoc->mFloorInfo->IsThereMover(adjRect)) return AreaCheckCode_0; - if (!towerDoc->mFloorInfo->IsThereOtherKindMover(rect, GetEquipType())) + if (!inDoc->mFloorInfo->IsThereOtherKindMover(inRect, GetEquipType())) return AreaCheckCode_2; return AreaCheckCode_0; diff --git a/src/T2DLL/T2MoverDef.h b/src/T2DLL/T2MoverDef.h index e8e4057..d4ef617 100644 --- a/src/T2DLL/T2MoverDef.h +++ b/src/T2DLL/T2MoverDef.h @@ -15,7 +15,7 @@ public: virtual BOOL InitObject(T2Object*) { return false; } virtual CURSORTYPE QueryCursor(T2TowerDoc*, POINT, CString&, RECT&, POINT&, int, unsigned int, int); virtual int CalcMentenanceCostProc(const T2HaveOutViewObject*) const; - virtual AREACHECKCODE AreaCheck(T2TowerDoc*, RECT&, unsigned int, int); + virtual AREACHECKCODE AreaCheck(T2TowerDoc* inDoc, RECT& inRect, unsigned int, BOOL inShowError); virtual int ClickProc(T2TowerDoc*, RECT*, unsigned int&); virtual BOOL MakeRequestProc(T2TowerDoc*, T2Equip*); virtual PROCCODE AddModuleProc(T2TowerDoc*, T2Equip*, RECT*); @@ -63,6 +63,8 @@ protected: int m1AC; int m1B0[3]; T2BitImage *mOffBitMap; + + friend class T2TowerDoc; }; inline BOOL T2MoverDef::IsStair() { diff --git a/src/T2DLL/T2MoverModule.cpp b/src/T2DLL/T2MoverModule.cpp index ae7de97..1d1db71 100644 --- a/src/T2DLL/T2MoverModule.cpp +++ b/src/T2DLL/T2MoverModule.cpp @@ -225,7 +225,7 @@ void T2MoverModule::AddPosition(int value) { /*static*/ unsigned int T2MoverModule::GetNewModuleID(T2TowerDoc* towerDoc) { incAgain: sModuleID++; - if (towerDoc->towerDoc_vf12C()->GetModule(sModuleID)) + if (towerDoc->GetFloorInfo()->GetModule(sModuleID)) goto incAgain; return sModuleID; diff --git a/src/T2DLL/T2MoverModuleTable.cpp b/src/T2DLL/T2MoverModuleTable.cpp index f025e6e..80741e1 100644 --- a/src/T2DLL/T2MoverModuleTable.cpp +++ b/src/T2DLL/T2MoverModuleTable.cpp @@ -1,5 +1,5 @@ -#include "CT2App.h" #include "GlobalFunc.h" +#include "T2.h" #include "T2BitImage.h" #include "T2DlgItemVScr.h" #include "T2ElevatorModule.h" @@ -19,7 +19,7 @@ T2MoverModuleTable::T2MoverModuleTable(T2TowerDoc* inDoc, T2ImageObj* inImageObj { mImage = NULL; SetRect(&mRect, 0, 0, 0, 0); - ((CT2App *) AfxGetApp())->app_vfA4(true); + T2_APP->app_vfA4(true); } /*virtual*/ T2MoverModuleTable::~T2MoverModuleTable() { diff --git a/src/T2DLL/T2Name.cpp b/src/T2DLL/T2Name.cpp index 5febc0c..078071e 100644 --- a/src/T2DLL/T2Name.cpp +++ b/src/T2DLL/T2Name.cpp @@ -107,8 +107,8 @@ void T2Name::MakeFullName(T2TowerDoc* inDoc, CString& outStr) { if (mName != NULL) { switch (GetType()) { case kTenantNameType: - if (inDoc && inDoc->towerDoc_vf12C()) { - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + if (inDoc && inDoc->GetFloorInfo()) { + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); T2Tenant *theTenant = theFloorInfo->GetTenant(GetID()); if (theTenant) { CString str; @@ -121,10 +121,10 @@ void T2Name::MakeFullName(T2TowerDoc* inDoc, CString& outStr) { break; case kPeopleNameType: - if (inDoc && inDoc->towerDoc_vf12C() && inDoc->mPeopleArrayList) { + if (inDoc && inDoc->GetFloorInfo() && inDoc->mPeopleArrayList) { T2People *thePeople = inDoc->mPeopleArrayList->FindPeople(GetID()); if (thePeople) { - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); int theTenantID = (thePeople->GetWorkTenant() > 1) ? thePeople->GetWorkTenant() : (thePeople->GetHomeTenant() > 1) ? thePeople->GetHomeTenant() : 1; CString str; diff --git a/src/T2DLL/T2OptionPluginList.cpp b/src/T2DLL/T2OptionPluginList.cpp index 278086d..13c08e6 100644 --- a/src/T2DLL/T2OptionPluginList.cpp +++ b/src/T2DLL/T2OptionPluginList.cpp @@ -17,7 +17,7 @@ void T2OptionPluginList::Add(T2OptionPlugin* plugin) { } void T2OptionPluginList::OnIdle(T2TowerDoc* towerDoc) { - DispatchEvent(OptionEventType_0, towerDoc, NULL); + DispatchEvent(kIdleOptionEvent, towerDoc, NULL); } BOOL T2OptionPluginList::DispatchEvent(OPTIONEVENTTYPE eventType, T2TowerDoc* towerDoc, void* data) { diff --git a/src/T2DLL/T2OutDecoration.cpp b/src/T2DLL/T2OutDecoration.cpp index 575f0f8..e8d7d74 100644 --- a/src/T2DLL/T2OutDecoration.cpp +++ b/src/T2DLL/T2OutDecoration.cpp @@ -43,11 +43,11 @@ T2OutDecoration::T2OutDecoration(T2TowerEvent* inTowerEvent, CResFile* inResFile } /*virtual*/ int T2OutDecoration::Exec(T2TowerDoc* inDoc) { - T2PaletteAnime *thePalette = inDoc->towerDoc_vf160(); + T2PaletteAnime *thePalette = inDoc->GetPaletteAnime(); int frame = thePalette->IsSnow() ? 1 : 0; - if (inDoc->towerDoc_vf140() != mCurrentViewMode || frame != mCurrentFrame) - DoDecoration(inDoc, (VIEWMODE) inDoc->towerDoc_vf140(), frame); + if (inDoc->GetViewMode() != mCurrentViewMode || frame != mCurrentFrame) + DoDecoration(inDoc, (VIEWMODE) inDoc->GetViewMode(), frame); return 0; } @@ -55,7 +55,7 @@ T2OutDecoration::T2OutDecoration(T2TowerEvent* inTowerEvent, CResFile* inResFile void T2OutDecoration::DoDecoration(T2TowerDoc* inDoc, VIEWMODE inViewMode, int inFrame) { T2OutDeco *theOutDeco; - if (inViewMode == ViewMode_1) { + if (inViewMode == kOutView) { LArray *theRoofList = MakeLoofList(); if (theRoofList) { T2Sprite *theSprite = &inDoc->mSprite; @@ -109,8 +109,8 @@ void T2OutDecoration::DoDecoration(T2TowerDoc* inDoc, VIEWMODE inViewMode, int i } /*virtual*/ void T2OutDecoration::ViewModeChanged(T2TowerDoc* inDoc, VIEWMODE inViewMode) { - if (inViewMode != mCurrentViewMode && (inViewMode == ViewMode_1 || mCurrentViewMode == ViewMode_1)) { - T2PaletteAnime *thePalette = inDoc->towerDoc_vf160(); + if (inViewMode != mCurrentViewMode && (inViewMode == kOutView || mCurrentViewMode == kOutView)) { + T2PaletteAnime *thePalette = inDoc->GetPaletteAnime(); int frame = thePalette->IsSnow() ? 1 : 0; DoDecoration(inDoc, inViewMode, frame); @@ -125,7 +125,7 @@ LArray* T2OutDecoration::MakeLoofList() { LArray *theArray = new LArray; if (theArray) { - T2FloorInfo *theFloorInfo = GetTowerDoc()->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = GetTowerDoc()->GetFloorInfo(); int curV; int groundV = GetWorldDef()->mGroundLine - 1; int nextH; diff --git a/src/T2DLL/T2OutObj.cpp b/src/T2DLL/T2OutObj.cpp index 29c1fca..d6f7090 100644 --- a/src/T2DLL/T2OutObj.cpp +++ b/src/T2DLL/T2OutObj.cpp @@ -38,7 +38,7 @@ T2OutObj::T2OutObj() { /*virtual*/ PROCCODE T2OutObj::Destruct(T2TowerDoc* towerDoc, RECT& rect) { GetOutObjArea(rect); - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); if (theFloorInfo) { theFloorInfo->FillOutObjID(rect, 0); if (GetToolDef()) @@ -61,7 +61,7 @@ T2OutObj::T2OutObj() { result = GetToolDef()->IdleProc(this, towerDoc); if (result) - towerDoc->GetTowerMainView()->tmv_vf128(mOutObjArea); + towerDoc->GetMainView()->InvalUnitRect(mOutObjArea); return result; } diff --git a/src/T2DLL/T2OutObj.h b/src/T2DLL/T2OutObj.h index aea795a..f6cec0b 100644 --- a/src/T2DLL/T2OutObj.h +++ b/src/T2DLL/T2OutObj.h @@ -31,6 +31,7 @@ protected: friend class T2OuterObjDef; friend class T2OutObjArray; friend class T2OutObjInfoDialog; + friend class T2TowerDoc; unsigned int mID; RECT mOutObjArea; diff --git a/src/T2DLL/T2OutObjArray.h b/src/T2DLL/T2OutObjArray.h index 008bd17..0f99639 100644 --- a/src/T2DLL/T2OutObjArray.h +++ b/src/T2DLL/T2OutObjArray.h @@ -19,6 +19,7 @@ public: protected: friend class T2OutObjArrayList; + friend class T2TowerDoc; T2OutObj mOutObj[kGroupSize]; }; diff --git a/src/T2DLL/T2OuterObjDef.cpp b/src/T2DLL/T2OuterObjDef.cpp index f06e18e..8b3adf1 100644 --- a/src/T2DLL/T2OuterObjDef.cpp +++ b/src/T2DLL/T2OuterObjDef.cpp @@ -36,20 +36,20 @@ T2OuterObjDef::T2OuterObjDef(DWORD type, T2PluginSpecifier& specifier, CResFile* /*virtual*/ void T2OuterObjDef::DrawProc(T2HaveOutViewObject* obj, const RECT& inRect, T2TowerDoc* inDoc) const { RECT rect = ((T2OutObj *) obj)->_3C; - UT2Coordinate::UnitToQD(rect, inDoc->towerDoc_vf108(), true); + UT2Coordinate::UnitToQD(rect, inDoc->GetZoomLevel(), true); int objectID = mImageObj->FindObject("View"); - mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, rect, inDoc->towerDoc_vf108()); + mImageObj->DrawObject(inDoc->GetImage(), objectID, rect, inDoc->GetZoomLevel()); } -/*virtual*/ AREACHECKCODE T2OuterObjDef::AreaCheck(T2TowerDoc* inDoc, RECT& rect, unsigned int arg1, int arg2) { +/*virtual*/ AREACHECKCODE T2OuterObjDef::AreaCheck(T2TowerDoc* inDoc, RECT& rect, unsigned int arg1, int inShowError) { LArrayIterator iterator(*inDoc->mOuterObjList); T2OutObj *theOutObj; while (iterator.Next(&theOutObj)) { RECT intersect; if (IntersectRect(&intersect, &theOutObj->_3C, &rect)) { - if (arg2) { + if (inShowError) { // "重ねて設置できません" - cannot be placed on top of each other (new T2Message)->ShowMessage("\x8F\x64\x82\xCB\x82\xC4\x90\xDD\x92\x75\x82\xC5\x82\xAB\x82\xDC\x82\xB9\x81\xF1"); } @@ -60,7 +60,7 @@ T2OuterObjDef::T2OuterObjDef(DWORD type, T2PluginSpecifier& specifier, CResFile* for (int x = rect.left; x < rect.right; x++) { for (int y = rect.top; y < rect.bottom; y++) { if (!inDoc->mFloorInfo->GetTenant(y, x)) { - if (arg2) { + if (inShowError) { // "はみだして設置できません" - it cannot be installed as it protrudes (new T2Message)->ShowMessage("\x82\xCD\x82\xDD\x82\xBE\x82\xB5\x82\xC4\x90\xDD\x92\x75\x82\xC5\x82\xAB\x82\xDC\x82\xB9\x82\xF1"); } @@ -70,7 +70,7 @@ T2OuterObjDef::T2OuterObjDef(DWORD type, T2PluginSpecifier& specifier, CResFile* } if (rect.bottom > (inDoc->mWorldDef->mGroundLine - inDoc->mWorldDef->mLobbyHeight)) { - if (arg2) { + if (inShowError) { // "ここには設置できません" - cannot be installed here (new T2Message)->ShowMessage("\x82\xB1\x82\xB1\x82\xC9\x82\xCD\x90\xDD\x92\x75\x82\xC5\x82\xAB\x82\xDC\x82\xB9\x82\xF1"); } diff --git a/src/T2DLL/T2OuterObjDef.h b/src/T2DLL/T2OuterObjDef.h index e8c1328..28683d0 100644 --- a/src/T2DLL/T2OuterObjDef.h +++ b/src/T2DLL/T2OuterObjDef.h @@ -11,7 +11,7 @@ public: virtual void DrawProc(T2HaveOutViewObject*, const RECT&, T2TowerDoc*) const; virtual PROCCODE DoDestructProc(T2TowerDoc*, T2HaveOutViewObject*, POINT, RECT&); virtual void SetTenantDef(T2TenantDef* def) { mTenantDef = def; } - virtual AREACHECKCODE AreaCheck(T2TowerDoc*, RECT&, unsigned int, int); + virtual AREACHECKCODE AreaCheck(T2TowerDoc*, RECT&, unsigned int, BOOL inShowError); virtual T2InfoDialog* ShowInfoDialog(T2TowerDoc*, T2OutObj*); virtual int GetInfoDialogID(T2TowerDoc*, const T2OutObj*) const; virtual T2InfoDialog* ConstructInfoDialog(T2OutObj*); diff --git a/src/T2DLL/T2PaletteAnime.cpp b/src/T2DLL/T2PaletteAnime.cpp index d1dee3b..fba291b 100644 --- a/src/T2DLL/T2PaletteAnime.cpp +++ b/src/T2DLL/T2PaletteAnime.cpp @@ -190,11 +190,11 @@ void T2PaletteAnime::MinuteChanged(T2DateTime* dateTime) { void T2PaletteAnime::DoAnimatePalette() { if (mPaletteUpdated) { - GetCurrentT2TowerDoc()->towerDoc_vf11C( - mPaletteAnimeDef->GetAnimStartIndex(), - mPaletteAnimeDef->GetNumOfAnimColor(), - mInterCTab->palPalEntry - ); + GetCurrentT2TowerDoc()->UpdatePalette( + mPaletteAnimeDef->GetAnimStartIndex(), + mPaletteAnimeDef->GetNumOfAnimColor(), + mInterCTab->palPalEntry + ); mPaletteUpdated = false; } } @@ -206,7 +206,7 @@ void T2PaletteAnime::ReplaceDayLightPalette(int id) { void T2PaletteAnime::SetSkyState(int skyState, int skyCount) { if (mSkyState != skyState) - GetCurrentT2TowerDoc()->GetTowerMainView()->tmv_vf124(true); + GetCurrentT2TowerDoc()->GetMainView()->Invalidate(true); mSkyState = skyState; mSkyCount = skyCount; diff --git a/src/T2DLL/T2People.cpp b/src/T2DLL/T2People.cpp index 38fd272..c83373a 100644 --- a/src/T2DLL/T2People.cpp +++ b/src/T2DLL/T2People.cpp @@ -64,7 +64,7 @@ void T2People::Initialize() { /*virtual*/ void T2People::SetUsed(BOOL used) { if (!used) { if (IsFavorite()) { - GetCurrentT2TowerDoc()->towerDoc_vf1C4(this, true); + GetCurrentT2TowerDoc()->RemoveFavoritePeople(this, true); } else if (IsNamed()) { T2NameList *nameDB = GetCurrentT2TowerDoc()->mNameDB; T2Name *name = nameDB->Search(this, false); @@ -185,17 +185,17 @@ unsigned int T2People::GetCurTenantID() const { switch (mStatus) { case kStatus1: - if (IsStartTime(towerDoc->towerDoc_vf120()->GetRawMinutes()) && IsSetDestination()) { - towerDoc->towerDoc_vf130()->Leave(this); + if (IsStartTime(towerDoc->GetNow()->GetRawMinutes()) && IsSetDestination()) { + towerDoc->GetPool()->Leave(this); MoveToTowerEntrance(towerDoc); - if (towerDoc->towerDoc_vf154()) + if (towerDoc->IsToiletFlagOn()) SetSpecialFlag(kSpecialFlag2); } break; case kStatus11: - if (IsStartTime(towerDoc->towerDoc_vf120()->GetRawMinutes())) { - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + if (IsStartTime(towerDoc->GetNow()->GetRawMinutes())) { + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); T2Tenant *theCurrTenant = theFloorInfo->GetTenant(mCurrEquipID); if (theCurrTenant) { if (IsSetDestination()) @@ -223,7 +223,7 @@ unsigned int T2People::GetCurTenantID() const { what = 1; if (!IsWalk()) { - if (IsReachDestination(towerDoc->towerDoc_vf12C()->GetGroundLine() - 1)) { + if (IsReachDestination(towerDoc->GetFloorInfo()->GetGroundLine() - 1)) { if (!IsRegistRequest(towerDoc)) ChangeStatus(kStatus3); } @@ -234,8 +234,8 @@ unsigned int T2People::GetCurTenantID() const { case kStatus10: if (!IsWalk()) { - if (IsReachDestination(towerDoc->towerDoc_vf12C()->GetGroundLine() - 1)) { - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + if (IsReachDestination(towerDoc->GetFloorInfo()->GetGroundLine() - 1)) { + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); T2Tenant *theDstTenant = theFloorInfo->GetTenant(mDstTenant); if (theDstTenant) theDstTenant->EnterTenant(towerDoc, this); @@ -245,21 +245,21 @@ unsigned int T2People::GetCurTenantID() const { case kStatus12: if (!IsWalk()) { - if (IsReachDestination(towerDoc->towerDoc_vf12C()->GetGroundLine() - 1)) + if (IsReachDestination(towerDoc->GetFloorInfo()->GetGroundLine() - 1)) GoOutTower(towerDoc); } break; case kStatus13: if (!IsWalk()) { - if (IsReachDestination(towerDoc->towerDoc_vf12C()->GetGroundLine() - 1)) + if (IsReachDestination(towerDoc->GetFloorInfo()->GetGroundLine() - 1)) MoveByEStair(towerDoc); } break; case kStatus14: if (!IsWalk()) { - if (IsReachDestination(towerDoc->towerDoc_vf12C()->GetGroundLine() - 1)) + if (IsReachDestination(towerDoc->GetFloorInfo()->GetGroundLine() - 1)) ChangeStatus(kStatus15); } break; @@ -269,7 +269,7 @@ unsigned int T2People::GetCurTenantID() const { } void T2People::IdleWaitMover(T2TowerDoc* towerDoc) { - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); BOOL didChange = IncStress(5); if (mStress >= 300) { @@ -283,7 +283,7 @@ void T2People::IdleWaitMover(T2TowerDoc* towerDoc) { if (didChange) { RECT rect; CalcWaitPersonArea(theFloorInfo, rect); - towerDoc->GetTowerMainView()->tmv_vf128(rect, false); + towerDoc->GetMainView()->InvalUnitRect(rect, false); } } @@ -313,7 +313,7 @@ void T2People::MoveToTowerEntrance(T2TowerDoc* towerDoc) { } void T2People::MoveToLobby(T2TowerDoc* towerDoc) { - T2FloorInfo *floorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *floorInfo = towerDoc->GetFloorInfo(); T2Tenant *lobby = floorInfo->GetTenant(1000); if (lobby) { @@ -338,7 +338,7 @@ void T2People::MoveToLobby(T2TowerDoc* towerDoc) { BOOL T2People::MoveToParking(T2TowerDoc* towerDoc) { BOOL ok = false; - T2RegistedTenantDB *registedTenantDB = towerDoc->towerDoc_vf174(); + T2RegistedTenantDB *registedTenantDB = towerDoc->GetRegistedTenantDB(); if (registedTenantDB) { T2Tenant *parking = NULL; if (!IsGeneral()) @@ -360,7 +360,7 @@ BOOL T2People::MoveToSubway(T2TowerDoc* towerDoc) { BOOL ok = false; T2TowerEvent *theEvent = towerDoc->mWorldDef->GetTowerEvent(); - T2DateTime *theCurrTime = towerDoc->towerDoc_vf120(); + T2DateTime *theCurrTime = towerDoc->GetNow(); T2Transport *metro = theEvent->GetMetroRailway(); if (metro) { T2Transport *available = metro->GetAvailable(theCurrTime); @@ -377,7 +377,7 @@ BOOL T2People::MoveToShip(T2TowerDoc* towerDoc) { BOOL ok = false; T2TowerEvent *event = towerDoc->mWorldDef->GetTowerEvent(); - T2DateTime *now = towerDoc->towerDoc_vf120(); + T2DateTime *now = towerDoc->GetNow(); T2Transport *cruise = event->GetCruise(); if (cruise) { T2Transport *available = cruise->GetAvailable(now); @@ -391,7 +391,7 @@ BOOL T2People::MoveToShip(T2TowerDoc* towerDoc) { } void T2People::MoveByEStair(T2TowerDoc* towerDoc) { - T2FloorInfo *floorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *floorInfo = towerDoc->GetFloorInfo(); if (floorInfo) { T2Tenant *theCurTenant = floorInfo->GetTenant(mCurrEquipID); @@ -413,11 +413,11 @@ void T2People::MoveByEStair(T2TowerDoc* towerDoc) { } if (IsWalk()) { - T2TowerMainView *towerMainView = towerDoc->GetTowerMainView(); + T2TowerMainView *towerMainView = towerDoc->GetMainView(); if (towerMainView) { RECT rect; SetRect(&rect, mCurPosition.x, mCurPosition.y, mCurPosition.x + 2, mCurPosition.y + 1); - towerMainView->tmv_vf128(rect, false); + towerMainView->InvalUnitRect(rect, false); } } } @@ -433,7 +433,7 @@ void T2People::SolveNoRoute(T2TowerDoc* towerDoc) { if (!FindRoute(towerDoc)) { changed = IncStress(30) && IsWalk(); if (mStress >= 300) { - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); if (IsWalk()) { // "道がないよ~" - there is no way CString theMessage = "\x93\xB9\x82\xAA\x82\xC8\x82\xA2\x82\xE6\x81\x60"; @@ -442,7 +442,7 @@ void T2People::SolveNoRoute(T2TowerDoc* towerDoc) { RECT theRect; CalcWalkingSilhouetteArea(theRect); theFloorInfo->SetTenantDrawModeByRect(theRect, DrawMode1); - towerDoc->GetTowerMainView()->tmv_vf128(theRect, false); + towerDoc->GetMainView()->InvalUnitRect(theRect, false); } T2Tenant *theFloor = theFloorInfo->GetTenant(mCurrEquipID); @@ -455,14 +455,14 @@ void T2People::SolveNoRoute(T2TowerDoc* towerDoc) { if (changed) { RECT rect; CalcWalkingSilhouetteArea(rect); - towerDoc->GetTowerMainView()->tmv_vf128(rect, false); + towerDoc->GetMainView()->InvalUnitRect(rect, false); } } BOOL T2People::FindRoute(T2TowerDoc* towerDoc) { BOOL ok = false; int status = mStatus; - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); if (theFloorInfo) { mCurrDestPos = theFloorInfo->GetEntrancePt(mDstTenant); @@ -477,7 +477,7 @@ BOOL T2People::FindRoute(T2TowerDoc* towerDoc) { ok = true; } else { int routeType = GetRouteType(); - if (towerDoc->towerDoc_vf124()->GetNextRoute(mCurPosition, mCurrDestPos, routeType)) { + if (towerDoc->GetRouteNavi()->GetNextRoute(mCurPosition, mCurrDestPos, routeType)) { if (routeType >= kRouteType0) status = kStatus5; else @@ -496,7 +496,7 @@ BOOL T2People::FindRoute(T2TowerDoc* towerDoc) { ChangeStatus(status); - T2TrafficInfo *trafficInfo = towerDoc->towerDoc_vf150(); + T2TrafficInfo *trafficInfo = towerDoc->GetTrafficInfo(); if (trafficInfo) trafficInfo->Pass(mCurPosition, mCurrDestPos, 1); } @@ -505,7 +505,7 @@ BOOL T2People::FindRoute(T2TowerDoc* towerDoc) { } void T2People::JumpToDestination(T2TowerDoc* towerDoc) { - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); POINT theDestPos = theFloorInfo->GetEntrancePt(mDstTenant); mCurPosition = theDestPos; @@ -514,11 +514,11 @@ void T2People::JumpToDestination(T2TowerDoc* towerDoc) { } void T2People::GoOutTower(T2TowerDoc* towerDoc) { - T2Tenant *theFloor = towerDoc->towerDoc_vf12C()->GetTenant(mCurrEquipID); + T2Tenant *theFloor = towerDoc->GetFloorInfo()->GetTenant(mCurrEquipID); if (theFloor) theFloor->Leave(this); - T2Pool *pool = towerDoc->towerDoc_vf130(); + T2Pool *pool = towerDoc->GetPool(); pool->Enter(this); } @@ -543,10 +543,10 @@ void T2People::IdleSearchedPerson(T2TowerDoc* towerDoc) { case kStatus2: { - T2TowerMainView *theView = towerDoc->GetTowerMainView(); + T2TowerMainView *theView = towerDoc->GetMainView(); RECT area; CalcWalkingSilhouetteArea(area); - theView->tmv_vf128(area, false); + theView->InvalUnitRect(area, false); mStatus = kStatus3; break; } @@ -561,7 +561,7 @@ void T2People::IdleSearchedPerson(T2TowerDoc* towerDoc) { case kStatus10: { - T2FloorInfo *floorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *floorInfo = towerDoc->GetFloorInfo(); T2Tenant *theDstTenant = floorInfo->GetTenant(mDstTenant); if (theDstTenant) theDstTenant->EnterTenant(towerDoc, this); @@ -588,12 +588,12 @@ void T2People::IdleSearchedPerson(T2TowerDoc* towerDoc) { BOOL T2People::WalkSearchedPersonRight(T2TowerDoc* towerDoc) { BOOL ok = false; T2FloorInfo *floorInfo = towerDoc->mFloorInfo; - T2TowerMainView *theMainView = towerDoc->GetTowerMainView(); + T2TowerMainView *theMainView = towerDoc->GetMainView(); RECT rect; SetRect(&rect, mCurPosition.x, mCurPosition.y, mCurPosition.x + 2, mCurPosition.y + 1); floorInfo->SetTenantDrawModeByRect(rect, DrawMode1); - theMainView->tmv_vf128(rect, false); + theMainView->InvalUnitRect(rect, false); int theWalkWidth = 2; @@ -610,7 +610,7 @@ BOOL T2People::WalkSearchedPersonRight(T2TowerDoc* towerDoc) { mCurPosition.x += theWalkWidth; OffsetRect(&rect, theWalkWidth, 0); - theMainView->tmv_vf128(rect, false); + theMainView->InvalUnitRect(rect, false); if (mCurPosition.y != (floorInfo->GetGroundLine() - 1)) IncStress(theWalkWidth / 4); @@ -620,13 +620,13 @@ BOOL T2People::WalkSearchedPersonRight(T2TowerDoc* towerDoc) { BOOL T2People::WalkSearchedPersonLeft(T2TowerDoc* towerDoc) { BOOL ok = false; - T2FloorInfo *floorInfo = towerDoc->towerDoc_vf12C(); - T2TowerMainView *theMainView = towerDoc->GetTowerMainView(); + T2FloorInfo *floorInfo = towerDoc->GetFloorInfo(); + T2TowerMainView *theMainView = towerDoc->GetMainView(); RECT rect; SetRect(&rect, mCurPosition.x, mCurPosition.y, mCurPosition.x + 2, mCurPosition.y + 1); floorInfo->SetTenantDrawModeByRect(rect, DrawMode1); - theMainView->tmv_vf128(rect, false); + theMainView->InvalUnitRect(rect, false); int theWalkWidth = 2; @@ -646,7 +646,7 @@ BOOL T2People::WalkSearchedPersonLeft(T2TowerDoc* towerDoc) { mCurPosition.x -= theWalkWidth; OffsetRect(&rect, -theWalkWidth, 0); - theMainView->tmv_vf128(rect, false); + theMainView->InvalUnitRect(rect, false); if (mCurPosition.y != (floorInfo->GetGroundLine() - 1)) IncStress(theWalkWidth / 4); @@ -817,7 +817,7 @@ void T2People::SetDestinationToOutOfTower(T2TowerDoc* towerDoc) { switch (mPeopleType->GetTransportType()) { case kTransportParking: { - T2RegistedTenantDB *registedTenantDB = towerDoc->towerDoc_vf174(); + T2RegistedTenantDB *registedTenantDB = towerDoc->GetRegistedTenantDB(); if (registedTenantDB) { T2Tenant *parking = NULL; if (!IsGeneral()) { @@ -974,8 +974,8 @@ BOOL T2People::SearchToilet(T2TowerDoc* towerDoc) { BOOL ok = false; if (SetDestinationToReturn()) { - T2RegistedTenantDB *theDB = towerDoc->towerDoc_vf174(); - T2RouteNavigator *theNavi = towerDoc->towerDoc_vf124(); + T2RegistedTenantDB *theDB = towerDoc->GetRegistedTenantDB(); + T2RouteNavigator *theNavi = towerDoc->GetRouteNavi(); if (theDB && theNavi) { int toiletStatus; T2Tenant *theToilet = theDB->SearchToilet(theNavi, mCurPosition, toiletStatus); @@ -1031,7 +1031,7 @@ void T2People::DrawSearchedPerson(T2TowerDoc* towerDoc) { } /*virtual*/ void T2People::Draw(T2TowerDoc* towerDoc, const RECT& inRect) { - if (towerDoc->towerDoc_vf108() > 0) + if (towerDoc->GetZoomLevel() > 0) return; if (m18 != -1) { @@ -1042,7 +1042,8 @@ void T2People::DrawSearchedPerson(T2TowerDoc* towerDoc) { #line 1380 _ASSERT(objectID != -1); - mSilhouetteDef[mStyle]->mImageObj->DrawObject(towerDoc->towerDoc_vf10C(), objectID, rect, towerDoc->towerDoc_vf108(), T2PaletteAnimeDef::GetCommonColor(mColor)); + mSilhouetteDef[mStyle]->mImageObj->DrawObject(towerDoc->GetImage(), objectID, rect, + towerDoc->GetZoomLevel(), T2PaletteAnimeDef::GetCommonColor(mColor)); } } @@ -1066,11 +1067,12 @@ void T2People::Draw(T2TowerDoc* towerDoc, T2Equip* equip) { POINT curPosition = GetCurPosition(); SetRect(&rect, curPosition.x, curPosition.y, curPosition.x + 2, curPosition.y + 1); - UT2Coordinate::UnitToQD(rect, towerDoc->towerDoc_vf108()); + UT2Coordinate::UnitToQD(rect, towerDoc->GetZoomLevel()); int theInd = equip->GetEquipDef()->mImageObj->FindObject(1003, mFiller); if (theInd >= 0) - equip->GetEquipDef()->mImageObj->DrawObject(towerDoc->towerDoc_vf10C(), theInd, rect, towerDoc->towerDoc_vf108()); + equip->GetEquipDef()->mImageObj->DrawObject(towerDoc->GetImage(), theInd, rect, + towerDoc->GetZoomLevel()); } } @@ -1080,11 +1082,11 @@ void T2People::DrawAt(T2TowerDoc* towerDoc, T2Equip* equip, POINT pt) { SetRect(&rect, 0, 0, 2, 1); rect.OffsetRect(mCurPosition.x - pt.x, mCurPosition.y - pt.y); - UT2Coordinate::UnitToQD(rect, towerDoc->towerDoc_vf108()); + UT2Coordinate::UnitToQD(rect, towerDoc->GetZoomLevel()); int theInd = equip->GetEquipDef()->mImageObj->FindObject(1003, mFiller); if (theInd >= 0) - equip->GetEquipDef()->mImageObj->DrawObject(towerDoc->towerDoc_vf10C(), theInd, rect); + equip->GetEquipDef()->mImageObj->DrawObject(towerDoc->GetImage(), theInd, rect); } } @@ -1110,7 +1112,7 @@ void T2People::Remove(T2TowerDoc* inTowerDoc, unsigned int id) { } if (flag && IsGeneral() && GetStatus() == kStatus1) { - T2Pool *pool = inTowerDoc->towerDoc_vf130(); + T2Pool *pool = inTowerDoc->GetPool(); if (pool) pool->RemovePeople(this); } @@ -1126,7 +1128,7 @@ void T2People::TenantRemoved(unsigned int id) { } void T2People::Interview(T2TowerDoc* towerDoc) { - T2FloorInfo *floorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *floorInfo = towerDoc->GetFloorInfo(); if (floorInfo) { CString text; if (GetInterviewWords(towerDoc, text) && text.GetLength() != 0) { @@ -1155,13 +1157,13 @@ BOOL T2People::GetInterviewWords(T2TowerDoc* towerDoc, CString& outStr) { optionEvent.people = this; optionEvent.str = &outStr; - if (!DispatchOptionEvent(OptionEventType_11, &optionEvent)) + if (!DispatchOptionEvent(kPreInterviewWordsOptionEvent, &optionEvent)) return outStr != ""; unsigned int theFlags = 0; T2PeopleDef *thePeopleDef = (T2PeopleDef *) GetMatterDef(); - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); T2Tenant *theDstTenant = theFloorInfo->GetTenant(mDstTenant); T2Tenant *theWorkTenant = theFloorInfo->GetTenant(GetWorkTenant()); @@ -1189,7 +1191,7 @@ BOOL T2People::GetInterviewWords(T2TowerDoc* towerDoc, CString& outStr) { if (mDstTenant == 1 && VIPEstimation()) theFlags |= 0x10; - switch (towerDoc->towerDoc_vf138()) { + switch (towerDoc->GetLevel()) { case 1: level = 3; break; @@ -1214,7 +1216,7 @@ BOOL T2People::GetInterviewWords(T2TowerDoc* towerDoc, CString& outStr) { T2WordDefArray *theWordDefArray = NULL; if (level != 0) { - theWordDefArray = towerDoc->towerDoc_vf170()->mWordDefArray; + theWordDefArray = towerDoc->GetWorldDef()->mWordDefArray; } else { if (mStatus == kStatus6 && thePeopleDef && mStress >= thePeopleDef->GetStressYellowLimit()) { T2Request *request = theFloorInfo->GetRequest(mCurrEquipID); @@ -1235,7 +1237,7 @@ BOOL T2People::GetInterviewWords(T2TowerDoc* towerDoc, CString& outStr) { optionEvent.people = this; optionEvent.str = &outStr; - DispatchOptionEvent(OptionEventType_12, &optionEvent); + DispatchOptionEvent(kPostInterviewWordsOptionEvent, &optionEvent); return outStr != ""; } @@ -1263,7 +1265,7 @@ void T2People::BreakoutEmergency(T2TowerDoc* towerDoc) { break; case kStatus1: if (IsGeneral()) - towerDoc->towerDoc_vf130()->RemovePeople(this); + towerDoc->GetPool()->RemovePeople(this); break; } } @@ -1480,8 +1482,8 @@ void T2People::GetName(CString& outStr) { if (IsWalk()) { CRect rect; if (GetSilhouetteRect(rect)) { - UT2Coordinate::UnitToQD(rect, towerDoc->towerDoc_vf108()); - towerDoc->towerDoc_vf10C()->FillRect(rect, 1); + UT2Coordinate::UnitToQD(rect, towerDoc->GetZoomLevel()); + towerDoc->GetImage()->FillRect(rect, 1); } } } diff --git a/src/T2DLL/T2People.h b/src/T2DLL/T2People.h index 74c63d0..f84f7ca 100644 --- a/src/T2DLL/T2People.h +++ b/src/T2DLL/T2People.h @@ -132,6 +132,7 @@ protected: int CalcFreeTime(unsigned int); BOOL StressChanged(); + friend class DbgPeopleView; friend class T2ElevatorModule; friend class T2FireBurning; friend class T2Guardman; diff --git a/src/T2DLL/T2PeopleArray.cpp b/src/T2DLL/T2PeopleArray.cpp index f60debd..c5f37df 100644 --- a/src/T2DLL/T2PeopleArray.cpp +++ b/src/T2DLL/T2PeopleArray.cpp @@ -4,17 +4,17 @@ T2PeopleArray::T2PeopleArray(unsigned int startID) : T2ObjectArray(startID) { - for (unsigned int i = 0; i < 256; i++) + for (unsigned int i = 0; i < kGroupSize; i++) mPeople[i].mMatterID = mStartID + i; } T2People* T2PeopleArray::FindPeople(unsigned int peopleID) { unsigned int firstID = mPeople[0].GetPeopleID(); - if (firstID > peopleID || (firstID + 256) < peopleID) + if (firstID > peopleID || (firstID + kGroupSize) < peopleID) return NULL; - for (int i = 0; i < 256; i++) { + for (int i = 0; i < kGroupSize; i++) { if (mPeople[i].GetPeopleID() == peopleID) return &mPeople[i]; } @@ -23,7 +23,7 @@ T2People* T2PeopleArray::FindPeople(unsigned int peopleID) { } void T2PeopleArray::ResolveLink(T2PeopleArrayList* list) { - for (int i = 0; i < 256; i++) { + for (int i = 0; i < kGroupSize; i++) { if (mPeople[i].IsUsed()) mPeople[i].ResolveLink(list); } @@ -32,7 +32,7 @@ void T2PeopleArray::ResolveLink(T2PeopleArrayList* list) { T2People* T2PeopleArray::FindUnusedPeople() { T2People *result = NULL; - for (unsigned int i = 0; i < 256; i++) { + for (unsigned int i = 0; i < kGroupSize; i++) { if (!mPeople[i].IsUsed()) { result = &mPeople[i]; break; @@ -47,15 +47,15 @@ T2People* T2PeopleArray::FindUnusedPeople() { T2People *thePeople; thePeople = &mPeople[startIndex]; - for (i = startIndex; i < 256; i += 8) { + for (i = startIndex; i < kGroupSize; i += 8) { if (thePeople->mUsed) thePeople->Idle(towerDoc); thePeople += 8; } thePeople = mPeople; - int theWalkRate = towerDoc->towerDoc_vf148(); - for (i = 0; i < 256; i++) { + int theWalkRate = towerDoc->GetWalkRate(); + for (i = 0; i < kGroupSize; i++) { if (thePeople->mUsed) { if ((theWalkRate > 0 && !(i % theWalkRate)) || thePeople->IsSetSpecialFlag(kSpecialFlag20)) thePeople->IdleSearchedPerson(towerDoc); @@ -66,7 +66,7 @@ T2People* T2PeopleArray::FindUnusedPeople() { void T2PeopleArray::DrawSearchedPerson(T2TowerDoc* towerDoc) { T2People *people = mPeople; - for (int i = 0; i < 256; i++) { + for (int i = 0; i < kGroupSize; i++) { if (people->mUsed && people->IsWalk()) people->DrawSearchedPerson(towerDoc); people++; @@ -74,38 +74,38 @@ void T2PeopleArray::DrawSearchedPerson(T2TowerDoc* towerDoc) { } void T2PeopleArray::SetWalkPeople(int v) { - for (int i = 0; i < 256; i++) + for (int i = 0; i < kGroupSize; i++) mPeople[i].SetWalk(false); if (v != -1) { - for (int i = 0; i < 256; i += v) + for (int i = 0; i < kGroupSize; i += v) mPeople[i].SetWalk(true); } } void T2PeopleArray::DayChanged() { - for (int i = 0; i < 256; i++) { + for (int i = 0; i < kGroupSize; i++) { if (mPeople[i].IsUsed()) mPeople[i].DayChanged(); } } void T2PeopleArray::TenantRemoved(unsigned int v) { - for (int i = 0; i < 256; i++) { + for (int i = 0; i < kGroupSize; i++) { if (mPeople[i].IsUsed()) mPeople[i].TenantRemoved(v); } } void T2PeopleArray::AddStress(int v) { - for (int i = 0; i < 256; i++) { + for (int i = 0; i < kGroupSize; i++) { if (mPeople[i].IsUsed()) mPeople[i].IncStress(v); } } void T2PeopleArray::BreakoutEmergency(T2TowerDoc* towerDoc) { - for (int i = 0; i < 256; i++) { + for (int i = 0; i < kGroupSize; i++) { T2People *people = &mPeople[i]; if (people->IsUsed()) people->BreakoutEmergency(towerDoc); @@ -113,11 +113,11 @@ void T2PeopleArray::BreakoutEmergency(T2TowerDoc* towerDoc) { } void T2PeopleArray::Read(T2Archive& archive, T2TowerDoc* towerDoc) { - for (int i = 0; i < 256; i++) + for (int i = 0; i < kGroupSize; i++) mPeople[i].Load(archive, towerDoc); } void T2PeopleArray::Write(T2Archive& archive) { - for (int i = 0; i < 256; i++) + for (int i = 0; i < kGroupSize; i++) mPeople[i].Save(archive); } diff --git a/src/T2DLL/T2PeopleArray.h b/src/T2DLL/T2PeopleArray.h index 8e64e3d..ba692c6 100644 --- a/src/T2DLL/T2PeopleArray.h +++ b/src/T2DLL/T2PeopleArray.h @@ -5,6 +5,8 @@ class AFX_CLASS_EXPORT T2PeopleArray : public T2ObjectArray { public: + enum { kGroupSize = 256 }; + T2PeopleArray(unsigned int startID = 1); virtual ~T2PeopleArray() {} virtual void DispatchIdle(T2TowerDoc*, int); @@ -23,5 +25,7 @@ public: T2People* GetIndexPeople(int i) { return &mPeople[i]; } protected: - T2People mPeople[256]; + T2People mPeople[kGroupSize]; + friend class DbgPeopleView; + friend class T2TowerDoc; }; diff --git a/src/T2DLL/T2PeopleArrayList.h b/src/T2DLL/T2PeopleArrayList.h index 9ace5dc..cd668b7 100644 --- a/src/T2DLL/T2PeopleArrayList.h +++ b/src/T2DLL/T2PeopleArrayList.h @@ -2,7 +2,7 @@ #include "common.h" #include "LArray.h" -class AFX_CLASS_EXPORT T2PeopleArrayList : private LArray { +class AFX_CLASS_EXPORT T2PeopleArrayList : public LArray { public: T2PeopleArrayList(); virtual ~T2PeopleArrayList(); diff --git a/src/T2DLL/T2PeopleDemandList.cpp b/src/T2DLL/T2PeopleDemandList.cpp index f406515..b2085a5 100644 --- a/src/T2DLL/T2PeopleDemandList.cpp +++ b/src/T2DLL/T2PeopleDemandList.cpp @@ -60,7 +60,7 @@ void T2PeopleDemandList::Add(T2PoolGradeDef* inGradeDef) { } } -void T2PeopleDemandList::Init(unsigned int inMonth, unsigned int inSomeNum) { +void T2PeopleDemandList::Init(unsigned int inMonth, unsigned int inHour) { float theRate = 0.0f; if (mSeasonParamDef) theRate = mSeasonParamDef->GetRate(inMonth - 1); @@ -69,7 +69,7 @@ void T2PeopleDemandList::Init(unsigned int inMonth, unsigned int inSomeNum) { T2PeopleTimeZoneList *theTimeZoneList; while (iterator.Next(&theTimeZoneList)) - theTimeZoneList->Init(inSomeNum, theRate); + theTimeZoneList->Init(inHour, theRate); } void T2PeopleDemandList::IncHour(unsigned int inMonth) { diff --git a/src/T2DLL/T2PeopleDemandList.h b/src/T2DLL/T2PeopleDemandList.h index c5cbb6c..8d1ab60 100644 --- a/src/T2DLL/T2PeopleDemandList.h +++ b/src/T2DLL/T2PeopleDemandList.h @@ -2,14 +2,14 @@ #include "common.h" #include "LArray.h" -class AFX_CLASS_EXPORT T2PeopleDemandList : private LArray { +class AFX_CLASS_EXPORT T2PeopleDemandList : public LArray { public: T2PeopleDemandList(T2PoolDef* inPoolDef, T2SeasonParamDef* inSeasonParamDef, T2WorldDef* inWorldDef); T2PeopleDemandList(T2Archive& inArchive, T2SeasonParamDef* inSeasonParamDef, T2WorldDef* inWorldDef); virtual ~T2PeopleDemandList(); void Add(T2PoolGradeDef* gradeDef); - void Init(unsigned int inMonth, unsigned int inSomeNum); + void Init(unsigned int inMonth, unsigned int inHour); void IncHour(unsigned int inMonth); BOOL Find(T2TenantMemberDef* inTenantMemberDef, int inEconoType, unsigned int inTransportType, BOOL inCheckOnlyFirstEconoType) const; BOOL Call(T2TenantMemberDef* inTenantMemberDef, int inEconoType, unsigned int inTransportType, T2PeopleType& outPeopleType) const; diff --git a/src/T2DLL/T2PeopleInfoDialog.cpp b/src/T2DLL/T2PeopleInfoDialog.cpp index 9a3dbc5..8356f71 100644 --- a/src/T2DLL/T2PeopleInfoDialog.cpp +++ b/src/T2DLL/T2PeopleInfoDialog.cpp @@ -29,7 +29,7 @@ T2PeopleInfoDialog::T2PeopleInfoDialog(T2People* people) /*virtual*/ void T2PeopleInfoDialog::OnT2Create() { #pragma var_order(item1040, item1012, item7090, favName, item1030, item1010, item1020, item1011, pplEvalGage, theName, str1, nonFavName, theWorldDef, stressGage, hasAnyName, str2, theTowerDoc, theSilhouettePane, theNameID) T2TowerDoc *theTowerDoc = mTowerDoc; - T2WorldDef *theWorldDef = GetCurrentT2TowerDoc()->towerDoc_vf170(); + T2WorldDef *theWorldDef = GetCurrentT2TowerDoc()->GetWorldDef(); if (mPeople) mPeopleDef = (T2PeopleDef *) mPeople->GetMatterDef(); @@ -282,8 +282,8 @@ CString T2PeopleInfoDialog::GetTenantName(T2TowerDoc* towerDoc, unsigned int inT T2Name *favName = mTowerDoc->mNameDB->Search(mPeople, true); if (favName) { - mTowerDoc->towerDoc_vf1C4(mPeople, false); - mTowerDoc->towerDoc_vf1B8(mPeople); + mTowerDoc->RemoveFavoritePeople(mPeople, false); + mTowerDoc->AddFavoritePeople(mPeople); } } } diff --git a/src/T2DLL/T2PeopleTimeZoneList.cpp b/src/T2DLL/T2PeopleTimeZoneList.cpp index 1b3578a..7fc6d80 100644 --- a/src/T2DLL/T2PeopleTimeZoneList.cpp +++ b/src/T2DLL/T2PeopleTimeZoneList.cpp @@ -10,7 +10,7 @@ T2PeopleTimeZoneList::T2PeopleTimeZoneList(unsigned int someNum, unsigned int is : LArray(sizeof(T2PeopleTypeArray *)) { mIsFixed = isFixed; - _20 = 0; + _20 = false; mHoursPerItem = 0; mCurrentItem = 0; mCurrentHour = 0; @@ -28,7 +28,7 @@ T2PeopleTimeZoneList::T2PeopleTimeZoneList(T2Archive& archive, T2WorldDef* world : LArray(sizeof(T2PeopleTypeArray *)) { #pragma var_order(uc, c, i, count) - _20 = 0; + _20 = false; mWorldDef = worldDef; int count; @@ -89,9 +89,9 @@ void T2PeopleTimeZoneList::Add(T2PeopleType* inPeopleType, T2PoolDefDemandElem* } } -void T2PeopleTimeZoneList::Init(unsigned int someNum, float limit) { - mCurrentItem = someNum / mHoursPerItem; - mCurrentHour = someNum % mHoursPerItem; +void T2PeopleTimeZoneList::Init(unsigned int inHour, float limit) { + mCurrentItem = inHour / mHoursPerItem; + mCurrentHour = inHour % mHoursPerItem; T2PeopleTypeArray *array; LArrayIterator iterator(*this); diff --git a/src/T2DLL/T2PeopleTimeZoneList.h b/src/T2DLL/T2PeopleTimeZoneList.h index 1b00721..2f90b65 100644 --- a/src/T2DLL/T2PeopleTimeZoneList.h +++ b/src/T2DLL/T2PeopleTimeZoneList.h @@ -8,7 +8,7 @@ public: T2PeopleTimeZoneList(T2Archive&, T2WorldDef*); virtual ~T2PeopleTimeZoneList(); void Add(T2PeopleType* inPeopleType, T2PoolDefDemandElem* inDemandElem); - void Init(unsigned int someNum, float limit); + void Init(unsigned int inHour, float limit); void IncHour(float limit); BOOL Find(T2TenantMemberDef* inTenantMemberDef, int inEconoType, unsigned int inTransportType, BOOL inCheckOnlyFirstEconoType) const; BOOL Call(T2TenantMemberDef* inTenantMemberDef, int inEconoType, unsigned int inTransportType, T2PeopleType& outPeopleType); @@ -25,12 +25,14 @@ protected: int GetNumOfTimeZone() const; - int _20; + BOOL _20; BOOL mIsFixed; int mHoursPerItem; int mCurrentItem; int mCurrentHour; T2WorldDef *mWorldDef; + + friend class T2PoolView; }; inline BOOL T2PeopleTimeZoneList::IsFixed() const { diff --git a/src/T2DLL/T2PeopleType.h b/src/T2DLL/T2PeopleType.h index f38535a..b2d2969 100644 --- a/src/T2DLL/T2PeopleType.h +++ b/src/T2DLL/T2PeopleType.h @@ -76,6 +76,8 @@ protected: int mEconoType; int mLife; int mTransportType; + + friend class T2PoolView; }; inline void T2PeopleType::SetSilhouetteType(int v) { diff --git a/src/T2DLL/T2PeopleTypeArray.cpp b/src/T2DLL/T2PeopleTypeArray.cpp index 4b2c645..1512ae6 100644 --- a/src/T2DLL/T2PeopleTypeArray.cpp +++ b/src/T2DLL/T2PeopleTypeArray.cpp @@ -8,14 +8,14 @@ T2PeopleTypeArray::T2PeopleTypeArray(unsigned int val) : LArray(sizeof(T2PeopleType)) { m24 = val; - m20 = 0; + m20 = false; InitSearchLimit(1.0f); } T2PeopleTypeArray::T2PeopleTypeArray(T2Archive& archive) : LArray(sizeof(T2PeopleType)) { - m20 = 0; + m20 = false; Read(archive); } diff --git a/src/T2DLL/T2PeopleTypeArray.h b/src/T2DLL/T2PeopleTypeArray.h index 2fa8cad..48c4a2a 100644 --- a/src/T2DLL/T2PeopleTypeArray.h +++ b/src/T2DLL/T2PeopleTypeArray.h @@ -18,8 +18,10 @@ public: protected: void Read(T2Archive&); - int m20; + BOOL m20; unsigned int m24; int m28; int m2C; + + friend class T2PoolView; }; diff --git a/src/T2DLL/T2PluginLoader.cpp b/src/T2DLL/T2PluginLoader.cpp index 9018012..345d92e 100644 --- a/src/T2DLL/T2PluginLoader.cpp +++ b/src/T2DLL/T2PluginLoader.cpp @@ -1,5 +1,5 @@ -#include "CT2App.h" #include "GlobalFunc.h" +#include "T2.h" #include "T2DLL.h" #include "T2PluginLoader.h" #include "T2PluginSpecifier.h" diff --git a/src/T2DLL/T2Pool.cpp b/src/T2DLL/T2Pool.cpp index 8d280c2..007735c 100644 --- a/src/T2DLL/T2Pool.cpp +++ b/src/T2DLL/T2Pool.cpp @@ -14,7 +14,7 @@ #include "T2TenantMemberTableDef.h" #include "T2WorldDef.h" -T2Pool::T2Pool(T2PoolDef* inDef, T2SeasonParamDef* inSeason, T2TemplatePluginList* inPluginList, T2PeopleArrayList* inPeopleList, int inLevel, unsigned int inIndex, unsigned int inSomeNum, T2WorldDef* inWorldDef) { +T2Pool::T2Pool(T2PoolDef* inDef, T2SeasonParamDef* inSeason, T2TemplatePluginList* inPluginList, T2PeopleArrayList* inPeopleList, int inLevel, unsigned int inMonth, unsigned int inHour, T2WorldDef* inWorldDef) { mLevel = 0; mSpecialFlag = inDef->Get20(); mPopulation = 0; @@ -29,7 +29,7 @@ T2Pool::T2Pool(T2PoolDef* inDef, T2SeasonParamDef* inSeason, T2TemplatePluginLis for (int level = 1; level <= inLevel; level++) GameLevelChanged(level); - mDemandList->Init(inIndex, inSomeNum); + mDemandList->Init(inMonth, inHour); } T2Pool::T2Pool(T2Archive& inArchive, T2PoolDef* inDef, T2SeasonParamDef* inSeason, T2TemplatePluginList* inPluginList, T2PeopleArrayList* inPeopleList, T2WorldDef* inWorldDef) { diff --git a/src/T2DLL/T2Pool.h b/src/T2DLL/T2Pool.h index 54489f9..d874d2c 100644 --- a/src/T2DLL/T2Pool.h +++ b/src/T2DLL/T2Pool.h @@ -3,7 +3,7 @@ class AFX_CLASS_EXPORT T2Pool { public: - T2Pool(T2PoolDef* inDef, T2SeasonParamDef* inSeason, T2TemplatePluginList* inPluginList, T2PeopleArrayList* inPeopleList, int inLevel, unsigned int inIndex, unsigned int inSomeNum, T2WorldDef* inWorldDef); + T2Pool(T2PoolDef* inDef, T2SeasonParamDef* inSeason, T2TemplatePluginList* inPluginList, T2PeopleArrayList* inPeopleList, int inLevel, unsigned int inMonth, unsigned int inHour, T2WorldDef* inWorldDef); T2Pool(T2Archive& inArchive, T2PoolDef* inDef, T2SeasonParamDef* inSeason, T2TemplatePluginList* inPluginList, T2PeopleArrayList* inPeopleList, T2WorldDef* inWorldDef); virtual ~T2Pool(); void GameLevelChanged(int inLevel); @@ -36,6 +36,8 @@ protected: T2PoolDef *mPoolDef; T2TemplatePluginList *mPlugins; T2PeopleArrayList *mPeopleList; + + friend class T2PoolView; }; inline int T2Pool::GetPopulation() const { diff --git a/src/T2DLL/T2Request.cpp b/src/T2DLL/T2Request.cpp index 3ff951a..83c52f3 100644 --- a/src/T2DLL/T2Request.cpp +++ b/src/T2DLL/T2Request.cpp @@ -63,8 +63,8 @@ void T2Request::InitRequest(T2FloorInfo* floorInfo, unsigned int moverID, POINT } void T2Request::RemoveRequest(T2TowerDoc* towerDoc) { - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); - T2TowerMainView *theView = towerDoc->GetTowerMainView(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); + T2TowerMainView *theView = towerDoc->GetMainView(); RemoveContents(theFloorInfo); @@ -83,7 +83,7 @@ void T2Request::RemoveRequest(T2TowerDoc* towerDoc) { theFloorInfo->SetTenantDrawModeByRect(thePrevArea, DrawMode1); if (theView) - theView->tmv_vf128(theNextArea, false); + theView->InvalUnitRect(theNextArea, false); } void T2Request::RemoveContents(T2FloorInfo* floorInfo) { @@ -113,7 +113,7 @@ void T2Request::RemoveContents(T2FloorInfo* floorInfo) { } void T2Request::StopRemoved(T2TowerDoc* towerDoc, int y) { - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); T2Tenant *theFloor = theFloorInfo->GetFloor(mHeadPosition.y, mHeadPosition.x); #line 138 _ASSERT(theFloor != NULL); @@ -314,7 +314,7 @@ T2People* T2Request::LeaveFirst() { BOOL T2Request::Regist(T2TowerDoc* towerDoc, T2People* people) { BOOL isRegist = false; - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); POINT headPt = mHeadPosition; POINT curPt = people->GetCurPosition(); @@ -417,7 +417,7 @@ T2People* T2Request::RemoveOffPeople() { /*virtual*/ unsigned int T2Request::Idle(T2TowerDoc* towerDoc) { unsigned int result = 0; - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); if (mNumOfContent > 0 && !IsModuleReserved()) { T2Mover *theMover = theFloorInfo->GetMover(mMoverID); @@ -425,7 +425,7 @@ T2People* T2Request::RemoveOffPeople() { theMover->SetCheckRequest(true); } - T2TowerMainView *theView = towerDoc->GetTowerMainView(); + T2TowerMainView *theView = towerDoc->GetMainView(); #line 541 _ASSERT(theView != NULL); @@ -434,20 +434,20 @@ T2People* T2Request::RemoveOffPeople() { if (mPeopleRemoved) { CalcOnArea(area); theFloorInfo->SetTenantDrawModeByRect(area, DrawMode1); - theView->tmv_vf128(area, false); + theView->InvalUnitRect(area, false); } else if (mOnPeople || mOffPeople) { CalcOnArea(area); - theView->tmv_vf128(area, false); + theView->InvalUnitRect(area, false); } if (m44) { CalcPrevArea(area); theFloorInfo->SetTenantDrawModeByRect(area, DrawMode1); - theView->tmv_vf128(area, false); + theView->InvalUnitRect(area, false); } if (CalcIncQueueArea(area)) - theView->tmv_vf128(area, false); + theView->InvalUnitRect(area, false); return result; } @@ -522,7 +522,7 @@ void* T2Request::GetInfoClickDown(T2TowerDoc*, POINT) { } void T2Request::BreakoutEmergency(T2TowerDoc* towerDoc) { - RemoveContents(towerDoc->towerDoc_vf12C()); + RemoveContents(towerDoc->GetFloorInfo()); } /*virtual*/ void T2Request::LoadSelf(T2Archive& archive, T2TowerDoc* towerDoc) { @@ -774,6 +774,6 @@ void T2Request::CalcValidArea(RECT& rect) { /*virtual*/ void T2Request::DrawHitMask(T2TowerDoc* towerDoc) { RECT area; CalcValidArea(area); - UT2Coordinate::UnitToQD(area, towerDoc->towerDoc_vf108()); - towerDoc->towerDoc_vf10C()->FillRect(area, 1); + UT2Coordinate::UnitToQD(area, towerDoc->GetZoomLevel()); + towerDoc->GetImage()->FillRect(area, 1); } diff --git a/src/T2DLL/T2Request.h b/src/T2DLL/T2Request.h index 95da6e5..d946d97 100644 --- a/src/T2DLL/T2Request.h +++ b/src/T2DLL/T2Request.h @@ -60,8 +60,9 @@ protected: T2People* FindUpPeople(int) const; T2People* FindDownPeople(int) const; - friend class T2RequestArray; friend class T2ElevatorModule; + friend class T2RequestArray; + friend class T2TowerMainView; unsigned int mRequestID; unsigned int mMoverID; diff --git a/src/T2DLL/T2RequestIDArray.cpp b/src/T2DLL/T2RequestIDArray.cpp index 8758856..14236cd 100644 --- a/src/T2DLL/T2RequestIDArray.cpp +++ b/src/T2DLL/T2RequestIDArray.cpp @@ -70,7 +70,7 @@ BOOL T2RequestIDArray::IsStopPosition(int index) const { void T2RequestIDArray::RemoveRequest(T2TowerDoc* towerDoc, int index, ERequestUpDown upDown) { unsigned int requestID = GetRequestIDAt(index, upDown); if (requestID) { - T2FloorInfo *floorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *floorInfo = towerDoc->GetFloorInfo(); if (floorInfo) { T2Request *request = floorInfo->GetRequest(requestID); if (request) @@ -100,7 +100,7 @@ void T2RequestIDArray::MoverIDChanged(T2FloorInfo* floorInfo, unsigned int mover } void T2RequestIDArray::StopRemoved(T2TowerDoc* towerDoc, int y) { - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); #line 142 _ASSERT(theFloorInfo != NULL); @@ -117,7 +117,7 @@ void T2RequestIDArray::StopRemoved(T2TowerDoc* towerDoc, int y) { } void T2RequestIDArray::ModuleRemoved(T2TowerDoc* towerDoc, unsigned int moduleIndex) { - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); LArrayIterator iterator(*this); unsigned int theReqID; diff --git a/src/T2DLL/T2SantaClaus.cpp b/src/T2DLL/T2SantaClaus.cpp index 4aaa59d..37f34c3 100644 --- a/src/T2DLL/T2SantaClaus.cpp +++ b/src/T2DLL/T2SantaClaus.cpp @@ -55,7 +55,7 @@ T2SantaClaus::T2SantaClaus(T2TowerEvent* inTowerEvent, CResFile* inResFile, int } /*virtual*/ BOOL T2SantaClaus::Start(T2TowerDoc* inDoc) { - T2DateTime *theNow = inDoc->towerDoc_vf120(); + T2DateTime *theNow = inDoc->GetNow(); m48 = theNow ? (theNow->GetRawMinutes() - mBeginTime) : 0; m4C = -6; @@ -90,7 +90,7 @@ T2SantaClaus::T2SantaClaus(T2TowerEvent* inTowerEvent, CResFile* inResFile, int mSprite->ShowSprite(mSpriteID, true); mVisible = true; - mMainView = inDoc->GetTowerMainView(); + mMainView = inDoc->GetMainView(); if (mMainView) { mAttach = new T2SantaClausAttach(this, 0, true); mMainView->AddAttachment(mAttach, NULL, true); @@ -107,7 +107,7 @@ T2SantaClaus::T2SantaClaus(T2TowerEvent* inTowerEvent, CResFile* inResFile, int /*virtual*/ int T2SantaClaus::Exec(T2TowerDoc* inDoc) { if (!mMainView) - mMainView = inDoc->GetTowerMainView(); + mMainView = inDoc->GetMainView(); if (!mMainView) return 0; @@ -128,7 +128,7 @@ T2SantaClaus::T2SantaClaus(T2TowerEvent* inTowerEvent, CResFile* inResFile, int CRect intersect; mMainView->GetClientRect(viewArea); - viewArea.OffsetRect(mMainView->m64); + viewArea.OffsetRect(mMainView->mScrollOffset); spriteArea.SetRect(position.x, position.y, position.x + mSpriteHeight, position.y + mSpriteWidth); @@ -205,16 +205,16 @@ T2SantaClausAttach::T2SantaClausAttach(T2SantaClaus* inOwner, unsigned int inMes if (inMessage == WM_LBUTTONDOWN) { MSG *messagePtr = (MSG *) ioData; - int id = ((T2MainWindow *) AfxGetMainWnd())->mToolWindow->GetSel(); - CString *theIconName = ((T2MainWindow *) AfxGetMainWnd())->mToolWindow->GetIconName(id); - T2TemplatePlugin *theTemplatePlugin = ((T2MainWindow *) AfxGetMainWnd())->mToolWindow->GetIconPlugin(id); + int id = T2_MAIN_WINDOW->mToolWindow->GetSel(); + CString *theIconName = T2_MAIN_WINDOW->mToolWindow->GetIconName(id); + T2TemplatePlugin *theTemplatePlugin = T2_MAIN_WINDOW->mToolWindow->GetIconPlugin(id); CProgramPlugin *theIconProgramPlugin = theTemplatePlugin->GetPlugin(); - unsigned int theIconValiation = ((T2MainWindow *) AfxGetMainWnd())->mToolWindow->GetIconValiation(id); - DWORD theIconOption = ((T2MainWindow *) AfxGetMainWnd())->mToolWindow->GetIconOption(id); + unsigned int theIconValiation = T2_MAIN_WINDOW->mToolWindow->GetIconValiation(id); + DWORD theIconOption = T2_MAIN_WINDOW->mToolWindow->GetIconOption(id); - if (theIconOption == 0 && *theIconName == "ToolInfo") { + if (theIconOption == kToolOption0 && *theIconName == "ToolInfo") { CPoint pt(LOWORD(messagePtr->lParam), HIWORD(messagePtr->lParam)); - pt.Offset(GetCurrentT2TowerDoc()->GetTowerMainView()->m64); + pt.Offset(GetCurrentT2TowerDoc()->GetMainView()->mScrollOffset); if (mOwner) { CRect rect; diff --git a/src/T2DLL/T2Settlement.cpp b/src/T2DLL/T2Settlement.cpp index 4f84841..30ea8e5 100644 --- a/src/T2DLL/T2Settlement.cpp +++ b/src/T2DLL/T2Settlement.cpp @@ -72,24 +72,24 @@ T2Archive& T2Settlement::Write(T2Archive& archive) const { archive << m18; archive << m1C; - archive << (unsigned int) mDocument->towerDoc_vf178()->GetCount(); - LArrayIterator theTenantIter(*mDocument->towerDoc_vf178()); + archive << (unsigned int) mDocument->GetTenantTemplates()->GetCount(); + LArrayIterator theTenantIter(*mDocument->GetTenantTemplates()); T2TenantDef *theTenantDef = NULL; while (theTenantIter.Next(&theTenantDef)) { archive << (short) theTenantDef->GetToolType(); archive << theTenantDef->mSettlement; } - archive << (unsigned int) mDocument->towerDoc_vf17C()->GetCount(); - LArrayIterator theMoverIter(*mDocument->towerDoc_vf17C()); + archive << (unsigned int) mDocument->GetMoverTemplates()->GetCount(); + LArrayIterator theMoverIter(*mDocument->GetMoverTemplates()); T2MoverDef *theMoverDef = NULL; while (theMoverIter.Next(&theMoverDef)) { archive << (short) theMoverDef->GetToolType(); archive << theMoverDef->mSettlement; } - archive << (unsigned int) mDocument->towerDoc_vf180()->GetCount(); - LArrayIterator theOuterObjIter(*mDocument->towerDoc_vf180()); + archive << (unsigned int) mDocument->GetOuterObjTemplates()->GetCount(); + LArrayIterator theOuterObjIter(*mDocument->GetOuterObjTemplates()); T2OuterObjDef *theOuterObjDef = NULL; while (theOuterObjIter.Next(&theOuterObjDef)) { archive << (short) theOuterObjDef->GetToolType(); @@ -136,7 +136,7 @@ void T2Settlement::DoPayTool(int funds, short fundGroup, T2ToolDef* inToolDef) { void T2Settlement::EmitPayToolMessage(T2TowerDoc* towerDoc, T2ToolDef* inToolDef, const CString& str, int length, int type) { BOOL canPay = true; - T2DateTime *theNow = towerDoc->towerDoc_vf120(); + T2DateTime *theNow = towerDoc->GetNow(); #line 197 _ASSERT(theNow != NULL); @@ -226,13 +226,13 @@ T2DateTime* T2Settlement::FindCategoryTimeLimit(T2TowerDoc* inDoc, T2ToolDef* in switch (theCategory) { default: - thePluginList = inDoc->towerDoc_vf178(); + thePluginList = inDoc->GetTenantTemplates(); break; case 20: - thePluginList = inDoc->towerDoc_vf17C(); + thePluginList = inDoc->GetMoverTemplates(); break; case 200: - thePluginList = inDoc->towerDoc_vf180(); + thePluginList = inDoc->GetOuterObjTemplates(); break; } @@ -261,13 +261,13 @@ void T2Settlement::LinkCategoryTimeLimit(T2TowerDoc* inDoc, T2ToolDef* inToolDef switch (theCategory) { default: - thePluginList = inDoc->towerDoc_vf178(); + thePluginList = inDoc->GetTenantTemplates(); break; case 20: - thePluginList = inDoc->towerDoc_vf17C(); + thePluginList = inDoc->GetMoverTemplates(); break; case 200: - thePluginList = inDoc->towerDoc_vf180(); + thePluginList = inDoc->GetOuterObjTemplates(); break; } @@ -365,7 +365,7 @@ int T2Settlement::GetCategorySettlement(int inCategory) const { switch (inCategory) { default: { - LArrayIterator theTenantIter(*mDocument->towerDoc_vf178()); + LArrayIterator theTenantIter(*mDocument->GetTenantTemplates()); T2ToolDef *theTenantDef = NULL; while (theTenantIter.Next(&theTenantDef)) { if (theTenantDef->GetCategory() == inCategory) @@ -375,7 +375,7 @@ int T2Settlement::GetCategorySettlement(int inCategory) const { } case 20: { - LArrayIterator theMoverIter(*mDocument->towerDoc_vf17C()); + LArrayIterator theMoverIter(*mDocument->GetMoverTemplates()); T2ToolDef *theMoverDef = NULL; while (theMoverIter.Next(&theMoverDef)) { result += theMoverDef->mSettlement; @@ -384,7 +384,7 @@ int T2Settlement::GetCategorySettlement(int inCategory) const { } case 200: { - LArrayIterator theOuterObjIter(*mDocument->towerDoc_vf180()); + LArrayIterator theOuterObjIter(*mDocument->GetOuterObjTemplates()); T2ToolDef *theOuterObjDef = NULL; while (theOuterObjIter.Next(&theOuterObjDef)) { result += theOuterObjDef->mSettlement; @@ -422,19 +422,19 @@ void T2Settlement::Update() { m18 = 0; m1C = 0; - LArrayIterator theTenantIter(*mDocument->towerDoc_vf178()); + LArrayIterator theTenantIter(*mDocument->GetTenantTemplates()); T2TenantDef *theTenantDef = NULL; while (theTenantIter.Next(&theTenantDef)) { theTenantDef->mSettlement = 0; } - LArrayIterator theMoverIter(*mDocument->towerDoc_vf17C()); + LArrayIterator theMoverIter(*mDocument->GetMoverTemplates()); T2MoverDef *theMoverDef = NULL; while (theMoverIter.Next(&theMoverDef)) { theMoverDef->mSettlement = 0; } - LArrayIterator theOuterObjIter(*mDocument->towerDoc_vf180()); + LArrayIterator theOuterObjIter(*mDocument->GetOuterObjTemplates()); T2OuterObjDef *theOuterObjDef = NULL; while (theOuterObjIter.Next(&theOuterObjDef)) { theOuterObjDef->mSettlement = 0; diff --git a/src/T2DLL/T2SoundPlayer.cpp b/src/T2DLL/T2SoundPlayer.cpp index 8c06ec9..523b741 100644 --- a/src/T2DLL/T2SoundPlayer.cpp +++ b/src/T2DLL/T2SoundPlayer.cpp @@ -221,7 +221,7 @@ void T2SoundPlayer::Play(const CString& inName, unsigned int inMask, unsigned in int pan = 0; if (inPt) { CRect rect; - GetCurrentT2TowerDoc()->GetTowerMainView()->tmv_vf140(rect); + GetCurrentT2TowerDoc()->GetMainView()->GetVisibleUnitRect(rect); POINT centerPt = rect.CenterPoint(); float x = ((float) (inPt->x - centerPt.x) / (float) ((rect.right - rect.left) / 2)); diff --git a/src/T2DLL/T2SoundPlayer.h b/src/T2DLL/T2SoundPlayer.h index 344917d..667ac13 100644 --- a/src/T2DLL/T2SoundPlayer.h +++ b/src/T2DLL/T2SoundPlayer.h @@ -14,11 +14,13 @@ enum SOUNDPRIORITY { }; enum { - SoundMask_10 = 0x10 + SoundMask_10 = 0x10, + SoundMask_20 = 0x20, }; enum { SoundFlags_10 = 0x10, + SoundFlags_20 = 0x20, SoundFlags_10000 = 0x10000 }; diff --git a/src/T2DLL/T2Sprite.h b/src/T2DLL/T2Sprite.h index 3210f11..32748d3 100644 --- a/src/T2DLL/T2Sprite.h +++ b/src/T2DLL/T2Sprite.h @@ -2,7 +2,7 @@ #include "common.h" #include "T2SpriteObj.h" -class AFX_CLASS_EXPORT T2Sprite : private CList<T2SpriteObj *, T2SpriteObj *> { +class AFX_CLASS_EXPORT T2Sprite : protected CList<T2SpriteObj *, T2SpriteObj *> { public: T2Sprite(); virtual ~T2Sprite(); @@ -34,4 +34,6 @@ private: void AddUpdateRect(T2SpriteObj* obj, POINT pt); RECT mUpdateRect; + + friend class T2TowerDoc; }; diff --git a/src/T2DLL/T2StairModule.cpp b/src/T2DLL/T2StairModule.cpp index ec2e5c3..e172798 100644 --- a/src/T2DLL/T2StairModule.cpp +++ b/src/T2DLL/T2StairModule.cpp @@ -26,7 +26,7 @@ void T2StairModule::MoverIDChanged(unsigned int moverID) { } /*virtual*/ void T2StairModule::RemoveContents(T2TowerDoc* towerDoc) { - T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); while (mLink1) { T2People *thePeople = (T2People *) mLink1; diff --git a/src/T2DLL/T2TemplatePluginList.h b/src/T2DLL/T2TemplatePluginList.h index 6bcb21c..0e1673a 100644 --- a/src/T2DLL/T2TemplatePluginList.h +++ b/src/T2DLL/T2TemplatePluginList.h @@ -2,7 +2,7 @@ #include "common.h" #include "LArray.h" -class AFX_CLASS_EXPORT T2TemplatePluginList : private LArray { +class AFX_CLASS_EXPORT T2TemplatePluginList : public LArray { public: T2TemplatePluginList(DWORD pluginType); virtual ~T2TemplatePluginList(); diff --git a/src/T2DLL/T2Tenant.cpp b/src/T2DLL/T2Tenant.cpp index cec110b..0a29db6 100644 --- a/src/T2DLL/T2Tenant.cpp +++ b/src/T2DLL/T2Tenant.cpp @@ -108,13 +108,13 @@ void T2Tenant::SetFloorID(T2FloorInfo* inFloorInfo) { if (theFloorInfo) { if (IsFloor()) { - inDoc->towerDoc_vf124()->FloorRemoved(this, false); + inDoc->GetRouteNavi()->FloorRemoved(this, false); theFloorInfo->FillTenantID(outRect, 0); outRect.left -= theFloorInfo->GetEntranceWidth(); outRect.right += theFloorInfo->GetEntranceWidth(); } else { RemovePeople(inDoc); - inDoc->towerDoc_vf268(this); + inDoc->TenantRemoved(this); RECT rect = outRect; rect.top = rect.bottom - 1; @@ -281,21 +281,21 @@ void T2Tenant::LeaveTenant(T2TowerDoc* inDoc, T2People* inPeople) { } /*virtual*/ void T2Tenant::Draw(T2TowerDoc* inDoc, const RECT& inRect) { - if (inDoc->mViewMode != ViewMode_1 && IsFire() && !IsFloor()) { - inDoc->towerDoc_vf170()->DrawRubble(inDoc, this); + if (inDoc->mViewMode != kOutView && IsFire() && !IsFloor()) { + inDoc->GetWorldDef()->DrawRubble(inDoc, this); } else { GetEquipDef()->DrawProc(this, inRect, inDoc); if (true) GetEquipDef()->DrawPeople(inDoc, this); - if (mMark > -1 && inDoc->towerDoc_vf140() != ViewMode_1) { + if (mMark > -1 && inDoc->GetViewMode() != kOutView) { T2WorldDef *theWorldDef = inDoc->mWorldDef; if (theWorldDef) { RECT equipArea, qdRect; GetEquipArea(equipArea); UT2Coordinate::UnitToQD(equipArea, qdRect, inDoc->mZoomLevel); - theWorldDef->DrawMark(inDoc->towerDoc_vf10C(), qdRect, inDoc->towerDoc_vf108(), mMark); + theWorldDef->DrawMark(inDoc->GetImage(), qdRect, inDoc->GetZoomLevel(), mMark); } } } @@ -304,10 +304,10 @@ void T2Tenant::LeaveTenant(T2TowerDoc* inDoc, T2People* inPeople) { if (theWorldDef->IsBlackOut()) { CRect rect = mArea; DrawColorMesh(inDoc, rect, 1); - } else if (inDoc->towerDoc_vf140() == ViewMode_5) { + } else if (inDoc->GetViewMode() == kTransView) { CRect rect = inRect; DrawTrafficColor(inDoc, rect); - } else if (inDoc->towerDoc_vf140() != ViewMode_0) { + } else if (inDoc->GetViewMode() != kInView) { DrawViewModeColor(inDoc); } @@ -326,7 +326,7 @@ void T2Tenant::LeaveTenant(T2TowerDoc* inDoc, T2People* inPeople) { unsigned int result = GetEquipDef()->IdleProc(this, inDoc); if (result != -1 && result > 0) { - inDoc->GetTowerMainView()->tmv_vf128(mArea); + inDoc->GetMainView()->InvalUnitRect(mArea); mDrawMode = DrawMode1; } @@ -666,7 +666,7 @@ void T2Tenant::StartBuild() { mStatus = kTenantStatus1; } else { mStatus = kTenantStatus2; - mTenantNumber = GetCurrentT2TowerDoc()->towerDoc_vf27C(mArea.bottom - 1); + mTenantNumber = GetCurrentT2TowerDoc()->GetNextTenantNumber(mArea.bottom - 1); } ((T2TenantDef *) GetEquipDef())->BuildStartProc(GetCurrentT2TowerDoc(), this); @@ -693,7 +693,7 @@ int T2Tenant::CollectCustomerFromPool(T2TowerDoc* inDoc, T2TenantMemberTableDef* unsigned int checkRoute = CheckRouteFromPool(inDoc, searchScore); if (checkRoute > 0) { - T2Pool *thePool = inDoc->towerDoc_vf130(); + T2Pool *thePool = inDoc->GetPool(); unsigned int restCapacity = CalcRestCapacity(); int econoType = inTable->GetEconoType(); @@ -731,7 +731,7 @@ int T2Tenant::CollectCustomerFromPool(T2TowerDoc* inDoc, T2TenantMemberTableDef* int T2Tenant::CollectCustomerFromTenant(T2TowerDoc* inDoc, T2TenantMemberTableDef* inTable, unsigned int inTime) { int numCustomer = 0; - T2RouteNavigator *theNavi = inDoc->towerDoc_vf124(); + T2RouteNavigator *theNavi = inDoc->GetRouteNavi(); T2Tenant *theNearTenant = theNavi->SelectNearTenant(GetEntrancePt(), inTable->GetScore(T2PlaceParamDef::Place_1)); if (theNearTenant) { @@ -772,7 +772,7 @@ int T2Tenant::CollectCustomerFromTenant(T2TowerDoc* inDoc, T2TenantMemberTableDe int T2Tenant::CollectCustomerFromFloor(T2TowerDoc* inDoc, T2TenantMemberTableDef* inTable, unsigned int inTime) { int numCustomer = 0; - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); unsigned int theEntranceFloorID = GetEntranceFloorID(); T2Tenant *theFloor = theFloorInfo->GetTenant(theEntranceFloorID); @@ -817,7 +817,7 @@ int T2Tenant::CollectCustomerFromFloor(T2TowerDoc* inDoc, T2TenantMemberTableDef void T2Tenant::CollectCustomer(T2TowerDoc* inDoc, T2Tenant* inTenant) { if (!WillBeFull()) { - T2DateTime *theNow = inDoc->towerDoc_vf120(); + T2DateTime *theNow = inDoc->GetNow(); if (theNow->WithinMinutes(GetOpenTime(), GetCloseTime() - GetBindTime() - 60)) { T2TenantMemberTableDef *theTable = GetCustomerTableDef(true); if (theTable) { @@ -913,7 +913,7 @@ void T2Tenant::PushOutPeople(T2TowerDoc* inDoc, T2People* inPeople) { if (inPeople->IsSetReturn()) inPeople->SetReturnToDestination(); else - inPeople->SetDestination(inPeople->mHomeTenant, inDoc->towerDoc_vf120()->GetRawMinutes() + 180); + inPeople->SetDestination(inPeople->mHomeTenant, inDoc->GetNow()->GetRawMinutes() + 180); } LeaveTenant(inDoc, inPeople); @@ -1068,7 +1068,7 @@ int T2Tenant::GetNumOfKind() const { /*virtual*/ void T2Tenant::SetUsed(BOOL used) { if (!used && IsFavorite()) - GetCurrentT2TowerDoc()->towerDoc_vf1CC(this, false); + GetCurrentT2TowerDoc()->RemoveFavoriteTenant(this, false); T2Equip::SetUsed(used); @@ -1146,13 +1146,13 @@ void T2Tenant::Destruct(T2TowerDoc* inDoc, CRect& outRect) { T2FloorInfo *theFloorInfo = inDoc->mFloorInfo; if (theFloorInfo) { if (IsFloor()) { - inDoc->towerDoc_vf124()->FloorRemoved(this, false); + inDoc->GetRouteNavi()->FloorRemoved(this, false); theFloorInfo->FillTenantID(outRect, 0); outRect.left -= theFloorInfo->GetEntranceWidth(); outRect.right += theFloorInfo->GetEntranceWidth(); } else { RemovePeople(inDoc); - inDoc->towerDoc_vf268(this); + inDoc->TenantRemoved(this); RECT rect = outRect; rect.top = rect.bottom - 1; @@ -1297,7 +1297,7 @@ BOOL T2Tenant::IsWithinSearchRange(T2TowerDoc* inDoc, T2Tenant* inTenant) const BOOL result = false; if (inTenant) { - T2RouteNavigator *theNavi = inDoc->towerDoc_vf124(); + T2RouteNavigator *theNavi = inDoc->GetRouteNavi(); T2TenantMemberTableDef *theTable = inTenant->GetCustomerTableDef(true); if (theTable) { @@ -1339,7 +1339,7 @@ int T2Tenant::GetRoomNumber(T2FloorInfo* inFloorInfo) const { void T2Tenant::GetRoomName(T2TowerDoc* inDoc, CString& outStr) const { CString roomNum; - UT2Utils::GetRoomNumberString(inDoc->towerDoc_vf12C()->UnitToFloor(mArea.bottom - 1), roomNum); + UT2Utils::GetRoomNumberString(inDoc->GetFloorInfo()->UnitToFloor(mArea.bottom - 1), roomNum); outStr += roomNum; outStr += "\x8A\x4B"; @@ -1359,9 +1359,9 @@ void T2Tenant::GetRoomName(T2TowerDoc* inDoc, CString& outStr) const { } /*virtual*/ void T2Tenant::PlaySound(T2TowerDoc* inDoc, int inID, unsigned int inMask, unsigned int inFlags) const { - if (inDoc->towerDoc_vf15C(mArea)) { + if (inDoc->IsRectInView(mArea)) { T2EquipDef *theDef = GetEquipDef(); - T2SoundPlayer *thePlayer = inDoc->towerDoc_vf134(); + T2SoundPlayer *thePlayer = inDoc->GetSoundPlayer(); if (theDef && thePlayer) { CRect rect; GetEquipArea(rect); @@ -1423,11 +1423,11 @@ void T2Tenant::DrawViewModeColor(T2TowerDoc* inDoc) const { T2Tenant *tenant; int color = -1; - switch (inDoc->towerDoc_vf140()) { - case ViewMode_2: + switch (inDoc->GetViewMode()) { + case kEvalView: color = CalcEstimateColor(); break; - case ViewMode_3: + case kPriceView: switch (GetPriceIndex()) { case 4: color = 9; @@ -1443,12 +1443,12 @@ void T2Tenant::DrawViewModeColor(T2TowerDoc* inDoc) const { break; } break; - case ViewMode_4: + case kMaintView: if (GetRegistID() == kTenantRegistID1 && GetStatus() >= kTenantStatus35) color = 9; break; case ViewMode_6: - tenant = inDoc->towerDoc_vf18C(); + tenant = inDoc->GetSearchRangeFrom(); if (tenant) { if (this == tenant) color = 14; @@ -1465,7 +1465,7 @@ void T2Tenant::DrawViewModeColor(T2TowerDoc* inDoc) const { } void T2Tenant::DrawTrafficColor(T2TowerDoc* inDoc, const CRect& inRect) const { - T2TrafficInfo *theTrafficInfo = inDoc->towerDoc_vf150(); + T2TrafficInfo *theTrafficInfo = inDoc->GetTrafficInfo(); CRect rect1 = inRect; if (inRect.Height() > 1) { @@ -1512,7 +1512,7 @@ void T2Tenant::DrawTrafficColor(T2TowerDoc* inDoc, const CRect& inRect) const { CRect qdRect; UT2Coordinate::UnitToQD(inRect, qdRect, inDoc->mZoomLevel); - inDoc->towerDoc_vf10C()->FillMesh(qdRect, T2PaletteAnimeDef::GetCommonColor(inClr)); + inDoc->GetImage()->FillMesh(qdRect, T2PaletteAnimeDef::GetCommonColor(inClr)); } void T2Tenant::IncPeopleEstimate(int inEstimate) { @@ -1543,12 +1543,12 @@ BOOL T2Tenant::CollectEmployeeFromPool(T2TowerDoc* inDoc, T2TenantMemberTableDef BOOL found = false; int searchScore = inTable->GetScore(T2PlaceParamDef::Place_0); - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); - T2RouteNavigator *theNavigator = inDoc->towerDoc_vf124(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); + T2RouteNavigator *theNavigator = inDoc->GetRouteNavi(); unsigned int checkRoute = CheckRouteFromPool(inDoc, searchScore); if (checkRoute > 0) { - T2Pool *thePool = inDoc->towerDoc_vf130(); + T2Pool *thePool = inDoc->GetPool(); int econoType = inTable->GetEconoType(); BOOL checkOnlyFirstEconoType = inTable->IsCheckOnlyFirstEconoType(); if (thePool->Find(inTable, econoType, checkRoute, checkOnlyFirstEconoType)) { @@ -1567,7 +1567,7 @@ BOOL T2Tenant::CollectEmployeeFromPool(T2TowerDoc* inDoc, T2TenantMemberTableDef found = true; - T2DateTime *theNow = inDoc->towerDoc_vf120(); + T2DateTime *theNow = inDoc->GetNow(); mResideDay = theNow->CalcTotalDays(); } } @@ -1587,23 +1587,23 @@ BOOL T2Tenant::IsRegist() const { unsigned int T2Tenant::CheckRouteFromPool(T2TowerDoc* inDoc, unsigned int inScore) const { unsigned int checkRoute = 0; - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); - T2RouteNavigator *theNavi = inDoc->towerDoc_vf124(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); + T2RouteNavigator *theNavi = inDoc->GetRouteNavi(); POINT entrancePt = GetEntrancePt(); if (theNavi->CheckRoute(theFloorInfo->GetEntrancePt(1000), entrancePt, inScore)) checkRoute |= kTransportFlagLobbyLeft | kTransportFlagLobbyRight; - T2RegistedTenantDB *theDB = inDoc->towerDoc_vf174(); + T2RegistedTenantDB *theDB = inDoc->GetRegistedTenantDB(); T2Tenant *theEmptyParking = theDB->FindEmptyParking(); if (theEmptyParking) { if (theNavi->CheckRoute(theEmptyParking->GetExitPt(), entrancePt, inScore)) checkRoute |= kTransportFlagParking; } - T2TowerEvent *theEvent = inDoc->towerDoc_vf170()->GetTowerEvent(); - T2DateTime *theCurrentDateTime = inDoc->towerDoc_vf120(); + T2TowerEvent *theEvent = inDoc->GetWorldDef()->GetTowerEvent(); + T2DateTime *theCurrentDateTime = inDoc->GetNow(); theEmptyParking = theDB->GetFirstTenant(kTenantRegistID8); if (theEmptyParking && theEmptyParking->IsOpen()) { if (theNavi->CheckRoute(theEmptyParking->GetExitPt(), entrancePt, inScore)) @@ -1671,7 +1671,7 @@ BOOL T2Tenant::UpdateResidencialEstimate(T2TowerDoc* inDoc) { int senseOfNoise = ((T2TenantDef *) GetEquipDef())->GetSenseOfNoise(); if (senseOfNoise != 0) { - T2TrafficInfo *theTrafficInfo = inDoc->towerDoc_vf150(); + T2TrafficInfo *theTrafficInfo = inDoc->GetTrafficInfo(); if (theTrafficInfo) mEstimate -= senseOfNoise * theTrafficInfo->GetRange(GetEntrancePt()); } @@ -1679,7 +1679,7 @@ BOOL T2Tenant::UpdateResidencialEstimate(T2TowerDoc* inDoc) { if (GetPriceIndex() != 0) mEstimate += (GetPriceIndex() - 3) * -30; - mEstimate += inDoc->towerDoc_vf120()->CalcLapseYears(mBuildDay) * -1; + mEstimate += inDoc->GetNow()->CalcLapseYears(mBuildDay) * -1; } else { mEstimate = 1; } @@ -1697,7 +1697,7 @@ void T2Tenant::BreakoutEmergency(T2TowerDoc* inTowerDoc) { int result = GetEquipDef()->EmergencyProc(inTowerDoc, this); if (result) { SetDrawMode(result); - inTowerDoc->GetTowerMainView()->tmv_vf128(mArea); + inTowerDoc->GetMainView()->InvalUnitRect(mArea); } } } @@ -1712,7 +1712,7 @@ void T2Tenant::BurntDown(T2TowerDoc* inDoc) { GetEquipDef()->BurntDownProc(inDoc, this); mDrawMode = DrawMode1; - inDoc->GetTowerMainView()->tmv_vf128(mArea); + inDoc->GetMainView()->InvalUnitRect(mArea); } } @@ -1887,7 +1887,7 @@ void T2Tenant::SetMerchandise(int inCount, int* inArray) { void T2Tenant::SetRelatedTenant(T2TowerDoc* inDoc, unsigned int inRegistID) { if (!mRelatedTenantList) { - T2RegistedTenantDB *theDB = inDoc->towerDoc_vf174(); + T2RegistedTenantDB *theDB = inDoc->GetRegistedTenantDB(); mRelatedTenantList = theDB->GetList(inRegistID); } diff --git a/src/T2DLL/T2TenantArray.cpp b/src/T2DLL/T2TenantArray.cpp index 9dd23ee..b2a5823 100644 --- a/src/T2DLL/T2TenantArray.cpp +++ b/src/T2DLL/T2TenantArray.cpp @@ -33,7 +33,7 @@ T2Tenant* T2TenantArray::FindUnusedTenant() { for (int i = 0; i < kGroupSize; i++) { if (tenant->mUsed) { - if ((counter % 32) == startIndex || towerDoc->m180) + if ((counter % 32) == startIndex || towerDoc->mDebugStepRunEnabled) tenant->Idle(towerDoc); counter++; } diff --git a/src/T2DLL/T2TenantArray.h b/src/T2DLL/T2TenantArray.h index aef2cd0..a62d045 100644 --- a/src/T2DLL/T2TenantArray.h +++ b/src/T2DLL/T2TenantArray.h @@ -22,6 +22,8 @@ public: protected: friend class T2TenantArrayList; + friend class T2TowerDoc; + friend class T2TowerMainView; T2Tenant *mTenants; }; diff --git a/src/T2DLL/T2TenantDef.cpp b/src/T2DLL/T2TenantDef.cpp index 365a0bf..3cde569 100644 --- a/src/T2DLL/T2TenantDef.cpp +++ b/src/T2DLL/T2TenantDef.cpp @@ -57,8 +57,8 @@ T2TenantDef::T2TenantDef(DWORD type, T2PluginSpecifier& specifier, CResFile* res } m180 = 0; - m194 = (m154 == 0); - m198 = 1; + mDrawRoof = (m154 == 0); + mDrawFloor = true; mIsLoaded = true; } @@ -104,17 +104,17 @@ T2TenantDef::T2TenantDef(DWORD type, T2PluginSpecifier& specifier, CResFile* res pattern += mHeight * 100; if (tenant->IsFire()) pattern += 2; - else if (towerDoc->towerDoc_vf160()->IsSnow()) + else if (towerDoc->GetPaletteAnime()->IsSnow()) pattern += 1; } - UT2Coordinate::UnitToQD(tenantRect, towerDoc->towerDoc_vf108(), !includeRoofAndFloor); + UT2Coordinate::UnitToQD(tenantRect, towerDoc->GetZoomLevel(), !includeRoofAndFloor); int objectIndex = mImageObj->FindObject(objID, pattern); if (objectIndex >= 0) { - mImageObj->DrawObject(towerDoc->towerDoc_vf10C(), objectIndex, tenantRect, towerDoc->towerDoc_vf108()); + mImageObj->DrawObject(towerDoc->GetImage(), objectIndex, tenantRect, towerDoc->GetZoomLevel()); } else if (tenant->m58) { - towerDoc->towerDoc_vf10C()->FillRect(tenantRect, 1); + towerDoc->GetImage()->FillRect(tenantRect, 1); } else { CString err; #ifdef _MSC_VER @@ -153,7 +153,7 @@ T2TenantDef::T2TenantDef(DWORD type, T2PluginSpecifier& specifier, CResFile* res if (status == kStatus10) { BuildFinish(towerDoc, theEquip); - towerDoc->mTowerMainView->tmv_vf128(theEquip->mArea, true); + towerDoc->mTowerMainView->InvalUnitRect(theEquip->mArea, true); } } @@ -168,7 +168,7 @@ T2TenantDef::T2TenantDef(DWORD type, T2PluginSpecifier& specifier, CResFile* res } if (theTenant->GetDrawMode() != DrawMode0) - towerDoc->mTowerMainView->tmv_vf128(theTenant->mArea, false); + towerDoc->mTowerMainView->InvalUnitRect(theTenant->mArea, false); return result; } @@ -177,16 +177,20 @@ T2TenantDef::T2TenantDef(DWORD type, T2PluginSpecifier& specifier, CResFile* res return false; } -/*virtual*/ AREACHECKCODE T2TenantDef::AreaCheck(T2TowerDoc* towerDoc, RECT& rect, unsigned int a, BOOL flag) { +/*virtual*/ AREACHECKCODE T2TenantDef::AreaCheck(T2TowerDoc* towerDoc, RECT& rect, unsigned int a, BOOL inShowError) { if (GetCategory() != 100 && rect.top <= towerDoc->mWorldDef->mTopFloorLine) { - if (flag) + if (inShowError) { + // EN: Only Final item can be placed on the top floor of building. towerDoc->towerDoc_vf13C()->BuildErr(68, NULL); + } return AreaCheckCode_0; } if (rect.bottom > towerDoc->mWorldDef->mBottomFloorLine) { - if (flag) + if (inShowError) { + // EN: Can not place items beyond the edges of the floor below. towerDoc->towerDoc_vf13C()->BuildErr(2, NULL); + } return AreaCheckCode_0; } diff --git a/src/T2DLL/T2TenantDef.h b/src/T2DLL/T2TenantDef.h index 9f4b5e1..81ff79d 100644 --- a/src/T2DLL/T2TenantDef.h +++ b/src/T2DLL/T2TenantDef.h @@ -13,7 +13,7 @@ public: virtual unsigned int IdleProc(T2HaveOutViewObject*, T2TowerDoc*); virtual void DrawProc(T2HaveOutViewObject*, const RECT& inRect, T2TowerDoc*) const; virtual int CalcMentenanceCostProc(const T2HaveOutViewObject*) const; - virtual AREACHECKCODE AreaCheck(T2TowerDoc*, RECT& inRect, unsigned int, BOOL); + virtual AREACHECKCODE AreaCheck(T2TowerDoc*, RECT& inRect, unsigned int, BOOL inShowError); virtual void DrawPeople(T2TowerDoc*, T2Equip*); virtual BOOL EmergencyProc(T2TowerDoc*, T2Equip*); virtual int DrawData(int); @@ -62,8 +62,8 @@ public: int m188; T2TenantMemberTableDef *mEmployeeTableDef; T2TenantMemberTableDef *mCustomerTableDef; - int m194; - int m198; + BOOL mDrawRoof; + BOOL mDrawFloor; unsigned int mRegistID; unsigned int mDownFlag; int mSenseOfNoise; diff --git a/src/T2DLL/T2TenantMemberTableDef.cpp b/src/T2DLL/T2TenantMemberTableDef.cpp index 10c0b82..9ca80f4 100644 --- a/src/T2DLL/T2TenantMemberTableDef.cpp +++ b/src/T2DLL/T2TenantMemberTableDef.cpp @@ -134,7 +134,7 @@ BOOL T2TenantMemberTableDef::IsCollectFromPool(T2TowerDoc* towerDoc) const { T2DayParamDef::EDay theDay = T2DayParamDef::Day_0; T2DayParamDef::EWhether theWhether = T2DayParamDef::Whether_0; - T2DateTime *theNow = towerDoc->towerDoc_vf120(); + T2DateTime *theNow = towerDoc->GetNow(); if (theNow->IsHoliday(towerDoc)) theDay = T2DayParamDef::Day_1; diff --git a/src/T2DLL/T2Terrorist.cpp b/src/T2DLL/T2Terrorist.cpp index 9afd78d..b42e389 100644 --- a/src/T2DLL/T2Terrorist.cpp +++ b/src/T2DLL/T2Terrorist.cpp @@ -1,7 +1,7 @@ #include "CResFile.h" -#include "CT2App.h" #include "GlobalFunc.h" #include "LArray.h" +#include "T2.h" #include "T2CtrlPalette.h" #include "T2DateTime.h" #include "T2Dialog.h" @@ -57,7 +57,7 @@ T2Terrorist::T2Terrorist(T2TowerEvent* inTowerEvent, CResFile* inResFile, int in BOOL found = false; - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); RECT theIteratorArea; int theGroundLine = theFloorInfo->GetGroundLine(); @@ -77,7 +77,7 @@ T2Terrorist::T2Terrorist(T2TowerEvent* inTowerEvent, CResFile* inResFile, int in return false; SetupSound(); - inDoc->towerDoc_vf144(ViewMode_0); + inDoc->SetViewMode(kInView); inDoc->towerDoc_vf1A0(true); CString text, tempStr; @@ -96,7 +96,7 @@ T2Terrorist::T2Terrorist(T2TowerEvent* inTowerEvent, CResFile* inResFile, int in Sounds->Play("Terrorist:", SoundMask_10, SoundFlags_10 | SoundFlags_10000, NULL, PlayMode_0, 100); if (DoDialog(inDoc, 8300, 8300, 2, text) == 8303) { - inDoc->towerDoc_vf270(mRansomFee, kFundGroup2); + inDoc->DoPay(mRansomFee, kFundGroup2); Sounds->Play("Terrorist:ThankYou", SoundMask_10, SoundFlags_10 | SoundFlags_10000, NULL, PlayMode_0, 100); DWORD time = timeGetTime(); @@ -105,12 +105,12 @@ T2Terrorist::T2Terrorist(T2TowerEvent* inTowerEvent, CResFile* inResFile, int in inDoc->towerDoc_vf1A0(false); } else { - inDoc->towerDoc_vf2A8(25); + inDoc->SetDrawSpeed(25); inDoc->SetFireBurning(true); inDoc->towerDoc_vf2A0()->EnableIcon(false); - inDoc->GetTowerMainView()->tmv_vf154(); + inDoc->GetMainView()->HideToolSprite(); inDoc->towerDoc_vf2B0(true); - ((T2MainWindow *) AfxGetMainWnd())->mCtrlPalette->vf108(0); + T2_MAIN_WINDOW->mCtrlPalette->vf108(0); do { mBombHidePos.x = UT2Utils::Randomize(URect::Width(theIteratorArea)) + theIteratorArea.left; @@ -120,10 +120,10 @@ T2Terrorist::T2Terrorist(T2TowerEvent* inTowerEvent, CResFile* inResFile, int in mBombHideRoomID = theTenant->GetEquipID(); - inDoc->towerDoc_vf1B4(); - inDoc->GetTowerMainView()->tmv_vf120(); + inDoc->BreakoutEmergency(); + inDoc->GetMainView()->tmv_vf120(); - T2TowerMainView *theView = inDoc->GetTowerMainView(); + T2TowerMainView *theView = inDoc->GetMainView(); text = LoadStringTable(GetWorldModuleHandle(), 8300, 4); DoAlert(inDoc, text, 0); @@ -133,11 +133,11 @@ T2Terrorist::T2Terrorist(T2TowerEvent* inTowerEvent, CResFile* inResFile, int in mAttach = new T2FireAttach(this, 0, true); theView->AddAttachment(mAttach, NULL, true); - inDoc->towerDoc_vf2A8(25); + inDoc->SetDrawSpeed(25); - T2EquipPtrList *theList = inDoc->towerDoc_vf174()->GetList(kTenantRegistID5); + T2EquipPtrList *theList = inDoc->GetRegistedTenantDB()->GetList(kTenantRegistID5); if (theList) { - T2FloorPtrList *theFloorList = inDoc->towerDoc_vf124()->GetFloorPtrList(); + T2FloorPtrList *theFloorList = inDoc->GetRouteNavi()->GetFloorPtrList(); LArrayIterator floorIterator(*theFloorList); T2Tenant *theFloor; while (floorIterator.Next(&theFloor)) @@ -146,7 +146,7 @@ T2Terrorist::T2Terrorist(T2TowerEvent* inTowerEvent, CResFile* inResFile, int in T2Tenant *iteratorTenant; LArrayIterator tenantIterator(*theList); while (tenantIterator.Next(&iteratorTenant)) { - T2Tenant *theCurrFloor = inDoc->towerDoc_vf12C()->GetTenant(iteratorTenant->GetExitFloorID()); + T2Tenant *theCurrFloor = inDoc->GetFloorInfo()->GetTenant(iteratorTenant->GetExitFloorID()); if (theCurrFloor) { CRect area; theCurrFloor->GetEquipArea(area); @@ -221,11 +221,11 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag); /*virtual*/ int T2Terrorist::Exec(T2TowerDoc* inDoc) { int result = IsExclusive() ? 1 : 0; - T2DateTime *theNow = inDoc->towerDoc_vf120(); + T2DateTime *theNow = inDoc->GetNow(); unsigned int nowMinutes = theNow->GetRawMinutes(); if (mStatus == kTerroristStatus1) { - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); T2People *theSearcher; LArrayIterator theIteratorL(*mSearcherL); @@ -282,10 +282,10 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag); text += LoadStringTable(GetWorldModuleHandle(), 8300, 9); if (DoDialog(inDoc, 8300, 8300, 2, text) == 1) { - inDoc->towerDoc_vf270(mHigherRansomFee, kFundGroup2); + inDoc->DoPay(mHigherRansomFee, kFundGroup2); result = 3; } else { - inDoc->towerDoc_vf2A8(25); + inDoc->SetDrawSpeed(25); } } else if (nowMinutes == mEndTime) { Sounds->Stop("Terrorist:Tick"); @@ -309,7 +309,7 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag); for (int vDir = 0; vDir < 2; vDir++) { int v = (vDir == 0) ? vA : vF; if (v > 0 && v < GetWorldDef()->mGroundLine) { - theTenant = inDoc->towerDoc_vf12C()->GetTenant(v, h); + theTenant = inDoc->GetFloorInfo()->GetTenant(v, h); if (theTenant && !theTenant->IsFire() && !theTenant->IsFireproof()) theTenant->BurntDown(inDoc); @@ -337,15 +337,15 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag); break; } - T2TowerMainView *theMainView = inDoc->GetTowerMainView(); + T2TowerMainView *theMainView = inDoc->GetMainView(); CRect theBombArea; UT2Coordinate::MakeRect(theBombArea, mBombHidePos, 1, 1); - theMainView->tmv_vf15C(theBombArea); + theMainView->CenterOnRect(theBombArea); - if (inDoc->towerDoc_vf140() != ViewMode_1) + if (inDoc->GetViewMode() != kOutView) inDoc->towerDoc_vf284(); else - ((T2MainWindow *) AfxGetMainWnd())->mCtrlPalette->vf108(false); + T2_MAIN_WINDOW->mCtrlPalette->vf108(false); text = LoadStringTable(GetWorldModuleHandle(), 8300, 10); DoAlert(inDoc, text, 0); @@ -382,7 +382,7 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag) { CRect theEquipRect; CPoint theNextPt; - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); T2Tenant *theCurrFloor = theFloorInfo->GetTenant(inPeople->GetCurrEquipID()); CRect theSearchRect; @@ -449,7 +449,7 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag) { CRect theSilhouetteArea; inPeople->CalcWalkingSilhouetteArea(theSilhouetteArea); theFloorInfo->SetTenantDrawModeByRect(theSilhouetteArea, DrawMode1); - inDoc->GetTowerMainView()->tmv_vf128(theSilhouetteArea); + inDoc->GetMainView()->InvalUnitRect(theSilhouetteArea); if (theNextFloor) { theCurrFloor->Leave(inPeople); @@ -471,7 +471,7 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag) { } /*virtual*/ void T2Terrorist::StopEvent(T2TowerDoc* inDoc) { - T2TowerMainView *theMainView = inDoc->GetTowerMainView(); + T2TowerMainView *theMainView = inDoc->GetMainView(); if (theMainView && mAttach) { theMainView->RemoveAttachment(mAttach); delete mAttach; @@ -479,7 +479,7 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag) { } CRect theSilhouetteArea; - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); T2People *theSecurityMan; LArrayIterator theIteratorL(*mSearcherL); @@ -501,7 +501,7 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag) { theSecurityMan->CalcWalkingSilhouetteArea(theSilhouetteArea); theFloorInfo->SetTenantDrawModeByRect(theSilhouetteArea, DrawMode1); - theMainView->tmv_vf128(theSilhouetteArea); + theMainView->InvalUnitRect(theSilhouetteArea); } } @@ -526,7 +526,7 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag) { theSecurityMan->CalcWalkingSilhouetteArea(theSilhouetteArea); theFloorInfo->SetTenantDrawModeByRect(theSilhouetteArea, DrawMode1); - theMainView->tmv_vf128(theSilhouetteArea); + theMainView->InvalUnitRect(theSilhouetteArea); } } @@ -537,8 +537,8 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag) { inDoc->towerDoc_vf1A0(false); inDoc->SetFireBurning(false); - if (inDoc->GetTowerMainView()) - inDoc->GetTowerMainView()->tmv_vf150(); + if (inDoc->GetMainView()) + inDoc->GetMainView()->UnhideToolSprite(); if (inDoc->towerDoc_vf2A0()) inDoc->towerDoc_vf2A0()->EnableIcon(true); @@ -546,7 +546,7 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag) { } /*virtual*/ unsigned int T2Terrorist::DialogHook(T2EventDialog* inDialog, unsigned int inResult, T2TowerDoc* inDoc) { - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); T2Tenant *theTenant = theFloorInfo->GetTenantByPID('KEBI'); BOOL isMissing = (theTenant == NULL); @@ -556,9 +556,9 @@ static void MoveNextFloor(T2TowerDoc *inDoc, T2People *inPeople, BOOL inFlag) { break; if (mStatus == kTerroristStatus1) { - inResult = (inDoc->towerDoc_vf26C() >= mHigherRansomFee) ? inResult : 0; + inResult = (inDoc->GetCurrentFunds() >= mHigherRansomFee) ? inResult : 0; } else { - inResult = (inDoc->towerDoc_vf26C() >= mRansomFee) ? inResult : 0; + inResult = (inDoc->GetCurrentFunds() >= mRansomFee) ? inResult : 0; } if (inResult == 0) { diff --git a/src/T2DLL/T2ToolCallback.h b/src/T2DLL/T2ToolCallback.h index 752bec5..60b2515 100644 --- a/src/T2DLL/T2ToolCallback.h +++ b/src/T2DLL/T2ToolCallback.h @@ -3,5 +3,5 @@ class AFX_CLASS_EXPORT T2ToolCallback { public: - virtual void toolCallback_vf00(int unkParam1, int unkParam2) = 0; + virtual void toolCallback_vf00(int unkParam1, T2ToolIconItem *inItem) = 0; }; diff --git a/src/T2DLL/T2ToolDef.cpp b/src/T2DLL/T2ToolDef.cpp index 1a0d264..6ea6fa1 100644 --- a/src/T2DLL/T2ToolDef.cpp +++ b/src/T2DLL/T2ToolDef.cpp @@ -81,7 +81,7 @@ T2ToolDef::T2ToolDef(DWORD type, T2PluginSpecifier& specifier, CResFile* resFile if (mEC) delete mEC; if (mToolQuietUntil) - delete mToolQuietUntil; // what type is this? + delete mToolQuietUntil; if (mSubPluginList) delete mSubPluginList; } @@ -92,18 +92,18 @@ T2ToolDef::T2ToolDef(DWORD type, T2PluginSpecifier& specifier, CResFile* resFile return key; } -/*virtual*/ CURSORTYPE T2ToolDef::QueryCursor(T2TowerDoc*, POINT inPt, CString& outStr, RECT& outRect, POINT& outPt, int factor, unsigned int, int) { - outStr = "Csr"; +/*virtual*/ CURSORTYPE T2ToolDef::QueryCursor(T2TowerDoc* inDoc, POINT inPt, CString& outSpriteName, RECT& outRect, POINT& outPt, int inZoomLevel, unsigned int inValiation, int) { + outSpriteName = "Csr"; - inPt.x -= ((mWidth * UT2Coordinate::UnitHSize(factor)) / 2 - UT2Coordinate::UnitHSize(factor) / 2); - inPt.y -= ((mHeight * UT2Coordinate::UnitVSize(factor)) / 2 - UT2Coordinate::UnitVSize(factor) / 2); + inPt.x -= ((mWidth * UT2Coordinate::UnitHSize(inZoomLevel)) / 2 - UT2Coordinate::UnitHSize(inZoomLevel) / 2); + inPt.y -= ((mHeight * UT2Coordinate::UnitVSize(inZoomLevel)) / 2 - UT2Coordinate::UnitVSize(inZoomLevel) / 2); - UT2Coordinate::QDToUnit(inPt, factor); + UT2Coordinate::QDToUnit(inPt, inZoomLevel); SetRect(&outRect, inPt.x, inPt.y, inPt.x + mWidth, inPt.y + mHeight); outPt.x = outRect.left; outPt.y = outRect.top; - UT2Coordinate::UnitToQD(outRect, factor); + UT2Coordinate::UnitToQD(outRect, inZoomLevel); return CursorType_0; } diff --git a/src/T2DLL/T2ToolDef.h b/src/T2DLL/T2ToolDef.h index b954d82..bb42d77 100644 --- a/src/T2DLL/T2ToolDef.h +++ b/src/T2DLL/T2ToolDef.h @@ -26,9 +26,9 @@ enum { kTenantAttrIsConcat = 0x20000, kTenantAttr40000 = 0x40000, // 80000 - // 100000 - // 200000 - // 400000 + kTenantAttrOnlyGroundFloor = 0x100000, + kTenantAttrOnlyAboveGround = 0x200000, + kTenantAttrOnlyUnderground = 0x400000, kTenantAttrIsPeopleAnime = 0x800000, kTenantAttrIsPeopleAnime2 = 0x1000000, kTenantAttrIsNeedToilet = 0x2000000, @@ -69,7 +69,7 @@ public: return 0; } - virtual CURSORTYPE QueryCursor(T2TowerDoc*, POINT, CString&, RECT&, POINT&, int, unsigned int, int); + virtual CURSORTYPE QueryCursor(T2TowerDoc* inDoc, POINT inPt, CString& outSpriteName, RECT& outRect, POINT& outPt, int inZoomLevel, unsigned int inValiation, int); virtual unsigned int IdleProc(T2HaveOutViewObject*, T2TowerDoc*) { return 0; @@ -93,8 +93,8 @@ public: virtual void LoadExtraData(T2Archive&, T2TowerDoc*, T2HaveOutViewObject*) {} virtual void SaveExtraData(T2Archive&, T2HaveOutViewObject*) {} - virtual void Add(T2AdvertisePlugin* plugin); virtual void Add(CResourcePlugin* plugin); + virtual void Add(T2AdvertisePlugin* plugin); virtual PROCCODE DrawHitMask(T2TowerDoc*, T2HaveOutViewObject*) { return ProcCode_0; } @@ -115,6 +115,7 @@ protected: friend class T2Settlement; friend class T2TemplatePluginList; friend class T2ToolHelpWnd; + friend class T2TowerDoc; int mToolType; int mWidth; diff --git a/src/T2DLL/T2ToolWindow.cpp b/src/T2DLL/T2ToolWindow.cpp index 346f1e8..7e65ac6 100644 --- a/src/T2DLL/T2ToolWindow.cpp +++ b/src/T2DLL/T2ToolWindow.cpp @@ -1,4 +1,4 @@ -#include "CT2App.h" +#include "T2.h" #include "T2DLL.h" #include "T2ImageObj.h" #include "T2MainWindow.h" @@ -140,7 +140,7 @@ afx_msg int T2ToolWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { theItem->mToolDef = inToolDef; unsigned short mask = 1; - if (mDocument->mViewMode == ViewMode_1) + if (mDocument->mViewMode == kOutView) mask = 2; if (inSomeMask & mask) @@ -158,7 +158,7 @@ afx_msg int T2ToolWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { } /*virtual*/ void T2ToolWindow::AddIcon(const char* inName, unsigned short inSomeMask, char* inStr2, T2ToolCallback* inToolCallback) { - AddIcon(inName, inStr2, 0, 0, NULL, 0, inSomeMask, inToolCallback); + AddIcon(inName, inStr2, 0, kToolOption0, NULL, 0, inSomeMask, inToolCallback); } /*virtual*/ void T2ToolWindow::RemoveIcon(const char* inName, unsigned int inValiation) { @@ -377,7 +377,7 @@ afx_msg int T2ToolWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { theToolIconItem->m30 = flag; if (theToolIconItem->m24) { - if (theToolIconItem->mOption == 4 || theToolIconItem->mOption == 0) { + if (theToolIconItem->mOption == kToolOption4 || theToolIconItem->mOption == kToolOption0) { _D8[_118] = theToolIconItem; if (!flag) oldSelectedItem = theToolIconItem; @@ -388,7 +388,7 @@ afx_msg int T2ToolWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { for (unsigned short what = 1; what < 16; what++) { if ((what & inMask) && _D8[what]) { theToolIconItem = _D8[what]; - if (theToolIconItem->mOption == 4 || theToolIconItem->mOption == 0) { + if (theToolIconItem->mOption == kToolOption4 || theToolIconItem->mOption == kToolOption0) { if (theToolIconItem->m30 && !theToolIconItem->m18) { theToolIconItem->m24 = true; selectedItem = theToolIconItem; @@ -401,12 +401,12 @@ afx_msg int T2ToolWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { } } - if (oldSelectedItem && oldSelectedItem->mOption == 4) { + if (oldSelectedItem && oldSelectedItem->mOption == kToolOption4) { pos = mToolIconList->GetHeadPosition(); while (pos) { theToolIconItem = mToolIconList->GetNext(pos); - if (theToolIconItem->m30 && theToolIconItem->mOption == 4 && !theToolIconItem->m18) { + if (theToolIconItem->m30 && theToolIconItem->mOption == kToolOption4 && !theToolIconItem->m18) { theToolIconItem->m24 = true; selectedItem = theToolIconItem; oldSelectedItem->m24 = false; @@ -421,7 +421,7 @@ afx_msg int T2ToolWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { while (pos) { theToolIconItem = mToolIconList->GetNext(pos); - if (theToolIconItem->m30 && theToolIconItem->mOption == 0) { + if (theToolIconItem->m30 && theToolIconItem->mOption == kToolOption0) { theToolIconItem->m24 = true; selectedItem = theToolIconItem; oldSelectedItem->m24 = false; @@ -608,7 +608,7 @@ afx_msg void T2ToolWindow::OnClose() { if (!mDocument) return; - mDocument->towerDoc_vf198(2); + mDocument->towerDoc_vf198(kToolWindow); } /*virtual*/ BOOL T2ToolWindow::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { @@ -633,7 +633,7 @@ T2ToolIconItem::T2ToolIconItem() { mPlugin = NULL; mName = ""; mValiation = 0; - mOption = 0; + mOption = kToolOption0; mID = -1; m24 = false; mEnableCount = 0; diff --git a/src/T2DLL/T2ToolWindow.h b/src/T2DLL/T2ToolWindow.h index 7536377..368bad3 100644 --- a/src/T2DLL/T2ToolWindow.h +++ b/src/T2DLL/T2ToolWindow.h @@ -3,6 +3,19 @@ class T2ToolIconItem; +enum { + // General tools + kToolOption0 = 0, + // Tenants + kToolOption1 = 1, + // Movers + kToolOption2 = 2, + // OutObjs + kToolOption3 = 3, + // Categories + kToolOption4 = 4, +}; + class AFX_CLASS_EXPORT T2ToolWindow : public CFrameWnd { DECLARE_DYNCREATE(T2ToolWindow) DECLARE_MESSAGE_MAP() @@ -62,7 +75,9 @@ protected: afx_msg void OnDestroy(); afx_msg void OnClose(); - int _C0; + friend class T2TowerDoc; + + HINSTANCE mModule; T2TowerDoc *mDocument; T2WorldDef *mWorldDef; T2ToolIconList *mToolIconList; diff --git a/src/T2DLL/T2TowerEvent.cpp b/src/T2DLL/T2TowerEvent.cpp index 84dc878..11287d6 100644 --- a/src/T2DLL/T2TowerEvent.cpp +++ b/src/T2DLL/T2TowerEvent.cpp @@ -290,18 +290,18 @@ void T2TowerEvent::StopEvent() { int T2TowerEvent::Idle(T2TowerDoc* inDoc) { T2EventItem *theEvent; - T2DateTime *theNow = inDoc->towerDoc_vf120(); + T2DateTime *theNow = inDoc->GetNow(); int nowMinutes = theNow->GetRawMinutes(); - if ((nowMinutes == 0 && _8 != nowMinutes) || mLevel != inDoc->towerDoc_vf138()) { + if ((nowMinutes == 0 && _8 != nowMinutes) || mLevel != inDoc->GetLevel()) { #pragma var_order(day, eventIteratorWaiting, eventIteratorStandby, theLevelBit) - mLevel = inDoc->towerDoc_vf138(); + mLevel = inDoc->GetLevel(); unsigned int theLevelBit = (mLevel > 0) ? (1 << (mLevel - 1)) : 0; int day = theNow->CalcLapseDays(12) + 1; LArrayIterator eventIteratorStandby(mStandby); while (eventIteratorStandby.Next(&theEvent)) { - if (theEvent->_4 || ((theEvent->GetLevelBit() & theLevelBit) && theEvent->IsBeginDay(day))) { + if (theEvent->mForceStart || ((theEvent->GetLevelBit() & theLevelBit) && theEvent->IsBeginDay(day))) { mStandby.Remove(&theEvent); eventIteratorStandby.Reset(); StoreWaitSequence(theEvent); @@ -310,7 +310,7 @@ int T2TowerEvent::Idle(T2TowerDoc* inDoc) { LArrayIterator eventIteratorWaiting(mWaiting); while (eventIteratorWaiting.Next(&theEvent)) { - if (!theEvent->_4 && !(theEvent->GetLevelBit() & theLevelBit)) { + if (!theEvent->mForceStart && !(theEvent->GetLevelBit() & theLevelBit)) { mWaiting.Remove(&theEvent); eventIteratorWaiting.Reset(); mStandby.Add(&theEvent); @@ -488,12 +488,12 @@ void T2TowerEvent::DrawRubble(T2TowerDoc* inDoc, T2Tenant* inTenant) { CRect rect1, rect2; inTenant->GetEquipArea(rect1); - UT2Coordinate::UnitToQD(rect1, rect2, inDoc->towerDoc_vf108(), true); - rect2.bottom = rect2.top + UT2Coordinate::UnitVSize(inDoc->towerDoc_vf108()); + UT2Coordinate::UnitToQD(rect1, rect2, inDoc->GetZoomLevel(), true); + rect2.bottom = rect2.top + UT2Coordinate::UnitVSize(inDoc->GetZoomLevel()); for (int i = 0; i < rect1.Height(); i++) { - inDoc->mWorldDef->mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, rect2, inDoc->towerDoc_vf108()); - rect2.OffsetRect(0, UT2Coordinate::UnitVSize(inDoc->towerDoc_vf108())); + inDoc->mWorldDef->mImageObj->DrawObject(inDoc->GetImage(), objectID, rect2, inDoc->GetZoomLevel()); + rect2.OffsetRect(0, UT2Coordinate::UnitVSize(inDoc->GetZoomLevel())); } } } diff --git a/src/T2DLL/T2TowerMessage.cpp b/src/T2DLL/T2TowerMessage.cpp index c99ac63..3beea1d 100644 --- a/src/T2DLL/T2TowerMessage.cpp +++ b/src/T2DLL/T2TowerMessage.cpp @@ -24,7 +24,7 @@ T2TowerMessage::T2TowerMessage(HINSTANCE inModuleHandle, T2TowerDoc* inDoc) { mHasCapture = false; - inDoc->GetTowerMainView()->AddAttachment(this); + inDoc->GetMainView()->AddAttachment(this); } /*virtual*/ T2TowerMessage::~T2TowerMessage() { @@ -67,7 +67,7 @@ void T2TowerMessage::InfoBarMessage(const CString& inText, int inDelay, const ch void T2TowerMessage::SetInfoBarMsg(InfoBarMsgItem* inItem) { CString empty; CString *theString = inItem ? &inItem->mText : ∅ - mDocument->towerDoc_vf164(*theString); + mDocument->SetInfoBarText(*theString); if (inItem && inItem->mSoundID != "") Sounds->Play(inItem->mSoundID, SoundMask_10, SoundFlags_10, NULL, PlayMode_0, 100); @@ -109,7 +109,7 @@ void T2TowerMessage::EquipBalloonMessage(const CString& inText, POINT inPt) { } void T2TowerMessage::BuildErr(const CString& inText) { - POINT otherPt = mDocument->GetTowerMainView()->m7C; + POINT otherPt = mDocument->GetMainView()->m7C; (new T2Message)->ShowMessage(inText); } @@ -135,7 +135,7 @@ BOOL T2TowerMessage::GetBuildErrString(unsigned int inID, CString& outStr) { } void T2TowerMessage::ObjectBalloonMessage(const CString& inText, const RECT& inRect) { - T2TowerMainView *theView = mDocument->GetTowerMainView(); + T2TowerMainView *theView = mDocument->GetMainView(); CRect rect = inRect; UT2Coordinate::UnitToQD(rect, 0, true); @@ -257,7 +257,7 @@ void T2TowerMessage::SpendTime2() { CPoint pt; pt.x = LOWORD(pMsg->lParam); pt.y = HIWORD(pMsg->lParam); - pt += GetCurrentT2TowerDoc()->GetTowerMainView()->m64; + pt += GetCurrentT2TowerDoc()->GetMainView()->mScrollOffset; if (PtInRect(&mCaptureRect, pt)) { newExecuteHost = false; diff --git a/src/T2DLL/T2TrafficInfo.cpp b/src/T2DLL/T2TrafficInfo.cpp index 04722a4..2079015 100644 --- a/src/T2DLL/T2TrafficInfo.cpp +++ b/src/T2DLL/T2TrafficInfo.cpp @@ -70,13 +70,13 @@ void T2TrafficInfo::HourChanged(T2TowerDoc* inDoc) { int range = CalcRange(unt->x4); if (range != unt->range) { unt->range = range; - if (inDoc->towerDoc_vf140() == ViewMode_5) { + if (inDoc->GetViewMode() == kTransView) { RECT area; - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); CalcUnitArea(i, area); theFloorInfo->SetTenantDrawModeByRect(area, DrawMode3); - inDoc->GetTowerMainView()->tmv_vf128(area); + inDoc->GetMainView()->InvalUnitRect(area); } } } diff --git a/src/T2DLL/T2Transport.cpp b/src/T2DLL/T2Transport.cpp index a3e1ac3..67adf7a 100644 --- a/src/T2DLL/T2Transport.cpp +++ b/src/T2DLL/T2Transport.cpp @@ -149,7 +149,7 @@ BOOL T2Transport::ChkStoppage() const { BOOL result = false; if (mFlag) { - T2DateTime *theNow = DoGetTowerDoc()->towerDoc_vf120(); + T2DateTime *theNow = DoGetTowerDoc()->GetNow(); int nowMinutes = theNow->GetRawMinutes(); int diff = nowMinutes - mArriveTime; result = (diff >= 0 && diff < (_2C + 1)); @@ -269,7 +269,7 @@ CLink* T2Transport::LeaveFirst() { do { thePeople = (T2People *) LeaveFirst(); if (thePeople) - inDoc->towerDoc_vf130()->Enter(thePeople); + inDoc->GetPool()->Enter(thePeople); } while (thePeople); diff --git a/src/T2DLL/T2VisitVIP.cpp b/src/T2DLL/T2VisitVIP.cpp index c411321..0b190d9 100644 --- a/src/T2DLL/T2VisitVIP.cpp +++ b/src/T2DLL/T2VisitVIP.cpp @@ -72,10 +72,10 @@ T2VisitVIP::T2VisitVIP(T2TowerEvent* inTowerEvent, int inSubID, int inLevelBit, mPeopleID = 0; mTenantID = 0; - if (mGrade <= theWorldDef->mNumOfGradeDef && inDoc->towerDoc_vf138() == mGrade) { + if (mGrade <= theWorldDef->mNumOfGradeDef && inDoc->GetLevel() == mGrade) { GradeDef *theGrade = &theWorldDef->mGradeDef[mGrade - 1]; if ((theGrade->m0 & mVisitFlag) != 0 && (inDoc->mA0 & mVisitFlag) == 0) { - T2Pool *thePool = inDoc->towerDoc_vf130(); + T2Pool *thePool = inDoc->GetPool(); if (thePool && thePool->GetPopulation() > (theGrade->m4 / 2)) { T2Tenant *theTenant = NULL; CFilePlugin *thePlugin = NULL; @@ -113,7 +113,7 @@ T2VisitVIP::T2VisitVIP(T2TowerEvent* inTowerEvent, int inSubID, int inLevelBit, RECT rect; theTenant->GetEquipArea(rect); - int floorNum = inDoc->towerDoc_vf12C()->UnitToFloor(rect.top); + int floorNum = inDoc->GetFloorInfo()->UnitToFloor(rect.top); if (floorNum < 0) { text += 'B'; floorNum = 0 - floorNum; @@ -123,7 +123,7 @@ T2VisitVIP::T2VisitVIP(T2TowerEvent* inTowerEvent, int inSubID, int inLevelBit, // "階" - floor text += "\x8A\x4B"; - int roomNum = theTenant->GetRoomNumber(inDoc->towerDoc_vf12C()); + int roomNum = theTenant->GetRoomNumber(inDoc->GetFloorInfo()); if (roomNum < 0) { text += 'B'; roomNum = 0 - roomNum; @@ -289,14 +289,14 @@ BOOL T2VisitVIP::DoReception(T2TowerDoc* inDoc) { } else { // "不満な様子です。\n\n「" - I'm dissatisfied. str += "\x95\x73\x96\x9E\x82\xC8\x97\x6C\x8E\x71\x82\xC5\x82\xB7\x81\x42\x0A\x0A\x81\x75"; - T2Tenant *theTenant = inDoc->towerDoc_vf12C()->GetTenant(mTenantID); + T2Tenant *theTenant = inDoc->GetFloorInfo()->GetTenant(mTenantID); if (theTenant) { CString tmp; RECT rect; theTenant->GetEquipArea(rect); - int floorNum = inDoc->towerDoc_vf12C()->UnitToFloor(rect.top); + int floorNum = inDoc->GetFloorInfo()->UnitToFloor(rect.top); if (floorNum < 0) { str += 'B'; floorNum = 0 - floorNum; @@ -327,7 +327,7 @@ BOOL T2VisitVIP::DoReception(T2TowerDoc* inDoc) { delete theName; } - thePool = inDoc->towerDoc_vf130(); + thePool = inDoc->GetPool(); thePool->DeadVIP(thePeople); return true; @@ -336,7 +336,7 @@ BOOL T2VisitVIP::DoReception(T2TowerDoc* inDoc) { if (mCheckedIn) { T2DateTime *theNow = inDoc->mNow; if (theNow && theNow->GetRawMinutes() == 600) { - T2Tenant *theTenant = inDoc->towerDoc_vf12C()->GetTenant(mTenantID); + T2Tenant *theTenant = inDoc->GetFloorInfo()->GetTenant(mTenantID); if (theTenant && theTenant->IsBelongPeople(thePeople)) { theTenant->SetStatus(kTenantStatus34); mCheckedIn = false; @@ -362,21 +362,21 @@ BOOL T2VisitVIP::GetDestinationTennant(DWORD inPluginID, T2Tenant*& outTenant, C while ((theSpecifier = theT2PluginLoader->GetNext(pos))) { if (theSpecifier->mID == inPluginID) { - outPlugin = theTowerDoc->mTenantPluginsListOther->GetItem(theSpecifier->mID); + outPlugin = theTowerDoc->mTenantPlugins->GetItem(theSpecifier->mID); outSpecifier = theSpecifier; break; } } if (outPlugin) { - T2FloorInfo *theFloorInfo = theTowerDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = theTowerDoc->GetFloorInfo(); if (theFloorInfo) { T2Tenant *theTenant = theFloorInfo->GetTenantByPID(inPluginID); if (theTenant) { unsigned int registID = theTenant->GetRegistID(); if (registID == kTenantRegistID1) { theTenant = NULL; - T2RegistedTenantDB *theDB = theTowerDoc->towerDoc_vf174(); + T2RegistedTenantDB *theDB = theTowerDoc->GetRegistedTenantDB(); if (theDB) { T2EquipPtrList *theList = theDB->GetList(kTenantRegistID1); if (theList) { diff --git a/src/T2DLL/T2WorldDef.cpp b/src/T2DLL/T2WorldDef.cpp index f9dbfbd..63358f3 100644 --- a/src/T2DLL/T2WorldDef.cpp +++ b/src/T2DLL/T2WorldDef.cpp @@ -89,9 +89,9 @@ T2WorldDef::T2WorldDef(DWORD inType, T2PluginSpecifier& inSpecifier, CResFile* i *inResFile >> m148[3]; *inResFile >> m148[4]; *inResFile >> m15C; - *inResFile >> mDustOnThreshold; - *inResFile >> mToiletVar1; - *inResFile >> mToiletVar2; + *inResFile >> mMinimumLevelForDust; + *inResFile >> mMinimumLevelForToilet; + *inResFile >> mToiletDenomi; *inResFile >> a; memset(mCashAmount, 0, sizeof(mCashAmount)); @@ -215,7 +215,7 @@ T2ColdTableDef* T2WorldDef::MakeColdTableDef() { RECT destRect = srcRect; - mImage->CopyImage(*inDoc->towerDoc_vf10C(), srcRect, destRect); + mImage->CopyImage(*inDoc->GetImage(), srcRect, destRect); } /*virtual*/ void T2WorldDef::DrawBkgnd(unsigned int inImageIndex, const RECT& inDestRect, T2TowerDoc* inDoc) { @@ -227,9 +227,9 @@ T2ColdTableDef* T2WorldDef::MakeColdTableDef() { OffsetRect(&srcRect, 0, inImageIndex * height); RECT destRect = inDestRect; - UT2Coordinate::BkgndToQD(destRect, inDoc->towerDoc_vf108()); + UT2Coordinate::BkgndToQD(destRect, inDoc->GetZoomLevel()); - mSkyOffscreen->CopyImage(*inDoc->towerDoc_vf10C(), srcRect, destRect); + mSkyOffscreen->CopyImage(*inDoc->GetImage(), srcRect, destRect); } /*virtual*/ void T2WorldDef::DrawBkgnd(const RECT& inRect, T2TowerDoc* inDoc) { @@ -252,9 +252,9 @@ T2ColdTableDef* T2WorldDef::MakeColdTableDef() { srcRect.right *= mBGHUnit; RECT destRect; - UT2Coordinate::BkgndToQD(inRect, destRect, inDoc->towerDoc_vf108()); + UT2Coordinate::BkgndToQD(inRect, destRect, inDoc->GetZoomLevel()); - mSkyOffscreen->CopyImage(*inDoc->towerDoc_vf10C(), srcRect, destRect); + mSkyOffscreen->CopyImage(*inDoc->GetImage(), srcRect, destRect); } } @@ -266,13 +266,13 @@ T2ColdTableDef* T2WorldDef::MakeColdTableDef() { if (inRoofAndFloor & RoofAndFloor_Roof) { UT2Coordinate::UnitToQDRoof(unitRect, qdRect, inDoc->mZoomLevel); id = mImageObj->FindObject("Roof"); - mImageObj->DrawObject(inDoc->towerDoc_vf10C(), id, qdRect, inDoc->towerDoc_vf108()); + mImageObj->DrawObject(inDoc->GetImage(), id, qdRect, inDoc->GetZoomLevel()); } if (inRoofAndFloor & RoofAndFloor_Floor) { UT2Coordinate::UnitToQDFloor(unitRect, qdRect, inDoc->mZoomLevel); id = mImageObj->FindObject("Floor"); - mImageObj->DrawObject(inDoc->towerDoc_vf10C(), id, qdRect, inDoc->towerDoc_vf108()); + mImageObj->DrawObject(inDoc->GetImage(), id, qdRect, inDoc->GetZoomLevel()); } } @@ -291,9 +291,9 @@ T2ColdTableDef* T2WorldDef::MakeColdTableDef() { name2 = "R"; int numPattern = 0; - if (inDoc->towerDoc_vf140() == ViewMode_1) { + if (inDoc->GetViewMode() == kOutView) { numPattern = 1; - if (inDoc->towerDoc_vf160()->IsSnow()) + if (inDoc->GetPaletteAnime()->IsSnow()) numPattern = 2; } @@ -318,7 +318,7 @@ T2ColdTableDef* T2WorldDef::MakeColdTableDef() { 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()); + mImageObj->DrawObject(inDoc->GetImage(), objectID, rect, inDoc->GetZoomLevel()); objectID = mImageObj->FindObject("Side" + name2, numPattern); mImageObj->GetObjectSize(objectID, &size); @@ -339,28 +339,28 @@ T2ColdTableDef* T2WorldDef::MakeColdTableDef() { 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()); + mImageObj->DrawObject(inDoc->GetImage(), objectID, rect, inDoc->GetZoomLevel()); unitRect.top++; unitRect.bottom++; } - } else if (((T2TenantDef *) inEquip->GetEquipDef())->m198 && !((T2TenantDef *) inEquip->GetEquipDef())->m194) { + } else if (((T2TenantDef *) inEquip->GetEquipDef())->mDrawFloor && !((T2TenantDef *) inEquip->GetEquipDef())->mDrawRoof) { 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) { + mImageObj->DrawObject(inDoc->GetImage(), objectID, rect, inDoc->GetZoomLevel()); + } else if (!((T2TenantDef *) inEquip->GetEquipDef())->mDrawFloor && ((T2TenantDef *) inEquip->GetEquipDef())->mDrawRoof) { 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) { + mImageObj->DrawObject(inDoc->GetImage(), objectID, rect, inDoc->GetZoomLevel()); + } else if (((T2TenantDef *) inEquip->GetEquipDef())->mDrawFloor && ((T2TenantDef *) inEquip->GetEquipDef())->mDrawRoof) { 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()); + mImageObj->DrawObject(inDoc->GetImage(), objectID, rect, inDoc->GetZoomLevel()); unitRect.top++; unitRect.bottom++; @@ -370,8 +370,8 @@ T2ColdTableDef* T2WorldDef::MakeColdTableDef() { } /*virtual*/ void T2WorldDef::DrawCrane(T2TowerDoc* inDoc, const RECT& inRect) { - T2FloorInfo *floorInfo = inDoc->towerDoc_vf12C(); - T2BitImage *theViewImage = inDoc->GetTowerMainView()->m60; + T2FloorInfo *floorInfo = inDoc->GetFloorInfo(); + T2BitImage *theViewImage = inDoc->GetMainView()->mImage; int theZoomLevel = inDoc->mZoomLevel; RECT craneArea; @@ -400,7 +400,7 @@ T2ColdTableDef* T2WorldDef::MakeColdTableDef() { int count = 0; POINT *array = (POINT *) malloc(GetWidth() * sizeof(POINT) / m190.x); - T2FloorInfo *floorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *floorInfo = inDoc->GetFloorInfo(); RECT rect; SetRect(&rect, 0, 0, GetWidth(), mGroundLine); @@ -505,7 +505,7 @@ T2ColdTableDef* T2WorldDef::MakeColdTableDef() { rect.bottom = rect.top + 1; UT2Coordinate::UnitToQD(rect, inDoc->mZoomLevel, true); - mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objIndex, rect, inDoc->towerDoc_vf108()); + mImageObj->DrawObject(inDoc->GetImage(), objIndex, rect, inDoc->GetZoomLevel()); } } @@ -638,7 +638,7 @@ void T2WorldDef::DisposePalette() { DrawCalendar(inControl, *inDoc->mNow, inDoc); break; case 1002: - DrawFunds(inControl, inDoc->towerDoc_vf26C()); + DrawFunds(inControl, inDoc->GetCurrentFunds()); break; case 2000: DrawPauseButton(inControl); @@ -647,7 +647,7 @@ void T2WorldDef::DisposePalette() { DrawMessage(inControl); break; case 1003: - thePool = inDoc->towerDoc_vf130(); + thePool = inDoc->GetPool(); #line 755 _ASSERT(thePool != NULL); population = thePool->GetPopulation(); @@ -733,9 +733,9 @@ void T2WorldDef::DisposePalette() { if (newValue != inControl->GetData()) { inControl->SetData(newValue); if (newValue == 0) - inDoc->towerDoc_vf14C(-1); + inDoc->SetWalkRate(-1); else - inDoc->towerDoc_vf14C(7 - newValue); + inDoc->SetWalkRate(7 - newValue); } break; } @@ -781,9 +781,9 @@ void T2WorldDef::DisposePalette() { if (newValue != inControl->GetData()) { inControl->SetData(newValue); if (newValue == 0) - inDoc->towerDoc_vf14C(-1); + inDoc->SetWalkRate(-1); else - inDoc->towerDoc_vf14C(7 - newValue); + inDoc->SetWalkRate(7 - newValue); } break; } @@ -1315,26 +1315,26 @@ void T2WorldDef::DisposePalette() { strcpy(outStr, "\x8E\xC0\x8D\x73\x81\x5E\x92\xE2\x8E\x7E"); } -unsigned int T2WorldDef::GetToiletDenomi(unsigned int inVal) const { +unsigned int T2WorldDef::GetToiletDenomi(unsigned int inGameLevel) const { unsigned int result = 0; - if (mToiletVar1 > 0 && inVal >= mToiletVar1) - result = mToiletVar2; + if (mMinimumLevelForToilet > 0 && inGameLevel >= mMinimumLevelForToilet) + result = mToiletDenomi; return result; } -unsigned int T2WorldDef::GetColdDenomi(unsigned int inVal1, unsigned int inVal2) const { +unsigned int T2WorldDef::GetColdDenomi(unsigned int inGameLevel, unsigned int inMonth) const { unsigned int result = 0; if (mColdTableDef) - result = mColdTableDef->GetDenomi(inVal1, inVal2); + result = mColdTableDef->GetDenomi(inGameLevel, inMonth); return result; } -BOOL T2WorldDef::IsDustOn(unsigned int inVal) const { - return (mDustOnThreshold > 0) && (inVal >= mDustOnThreshold); +BOOL T2WorldDef::IsDustOn(unsigned int inGameLevel) const { + return (mMinimumLevelForDust > 0) && (inGameLevel >= mMinimumLevelForDust); } T2TowerVision* T2WorldDef::GetTowerVision() { @@ -1427,7 +1427,7 @@ BOOL T2WorldDef::IsBlackOut() { int result = 0; if (inDoc->mGameLevel <= mNumOfGradeDef) { - T2Pool *thePool = inDoc->towerDoc_vf130(); + T2Pool *thePool = inDoc->GetPool(); if (thePool) { GradeDef theDef = mGradeDef[inDoc->mGameLevel - 1]; int population = thePool->GetPopulation(); @@ -1450,8 +1450,8 @@ BOOL T2WorldDef::IsBlackOut() { } /*virtual*/ void T2WorldDef::CalcOptionObj(T2TowerDoc* inDoc, T2Equip* inEquip) { - T2TowerMainView *theView = inDoc->GetTowerMainView(); - T2FloorInfo *floorInfo = inDoc->towerDoc_vf12C(); + T2TowerMainView *theView = inDoc->GetMainView(); + T2FloorInfo *floorInfo = inDoc->GetFloorInfo(); if (inEquip) { RECT equipArea; @@ -1470,7 +1470,7 @@ BOOL T2WorldDef::IsBlackOut() { equipArea.left -= objectSize.cx; equipArea.right += objectSize.cx; - theView->tmv_vf128(equipArea, true); + theView->InvalUnitRect(equipArea, true); } } } @@ -1481,7 +1481,7 @@ BOOL T2WorldDef::IsBlackOut() { if (rect1.bottom > mGroundLine) rect1.bottom = mGroundLine; - T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C(); + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); CString name = "Side"; int objectID = mImageObj->FindObject(name + "L"); @@ -1522,7 +1522,7 @@ BOOL T2WorldDef::IsBlackOut() { 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()); + mImageObj->DrawObject(inDoc->GetImage(), objectID, rect, inDoc->GetZoomLevel()); } if (theFloorInfo->GetTenantID(theFloor->mArea.bottom - 1, theFloor->mArea.right) == 0) { @@ -1533,7 +1533,7 @@ BOOL T2WorldDef::IsBlackOut() { 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()); + mImageObj->DrawObject(inDoc->GetImage(), objectID, rect, inDoc->GetZoomLevel()); } } else { if (theFloorInfo->GetTenantID(theFloor->mArea.bottom - 1, theFloor->mArea.left - 1) == 0) { @@ -1549,7 +1549,7 @@ BOOL T2WorldDef::IsBlackOut() { 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()); + mImageObj->DrawObject(inDoc->GetImage(), objectID, workRect, inDoc->GetZoomLevel()); OffsetRect(&baseRect, 0, 1); } @@ -1558,7 +1558,7 @@ BOOL T2WorldDef::IsBlackOut() { baseRect.left = baseRect.right - tentObjectSize.cx; UT2Coordinate::UnitToQD(baseRect, workRect, inDoc->mZoomLevel, true); - mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, workRect, inDoc->towerDoc_vf108()); + mImageObj->DrawObject(inDoc->GetImage(), objectID, workRect, inDoc->GetZoomLevel()); } if (theFloorInfo->GetTenantID(theFloor->mArea.bottom - 1, theFloor->mArea.right) == 0) { @@ -1574,7 +1574,7 @@ BOOL T2WorldDef::IsBlackOut() { 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()); + mImageObj->DrawObject(inDoc->GetImage(), objectID, workRect, inDoc->GetZoomLevel()); OffsetRect(&baseRect, 0, 1); } @@ -1583,7 +1583,7 @@ BOOL T2WorldDef::IsBlackOut() { baseRect.right = baseRect.left + tentObjectSize.cx; UT2Coordinate::UnitToQD(baseRect, workRect, inDoc->mZoomLevel, true); - mImageObj->DrawObject(inDoc->towerDoc_vf10C(), objectID, workRect, inDoc->towerDoc_vf108()); + mImageObj->DrawObject(inDoc->GetImage(), objectID, workRect, inDoc->GetZoomLevel()); } } } diff --git a/src/T2DLL/T2WorldDef.h b/src/T2DLL/T2WorldDef.h index 6aa3ee6..d23bd97 100644 --- a/src/T2DLL/T2WorldDef.h +++ b/src/T2DLL/T2WorldDef.h @@ -84,9 +84,9 @@ public: } virtual unsigned long OptionProc(unsigned long, void*) { return 0; } - unsigned int GetToiletDenomi(unsigned int inVal) const; - unsigned int GetColdDenomi(unsigned int inVal1, unsigned int inVal2) const; - BOOL IsDustOn(unsigned int inVal) const; + unsigned int GetToiletDenomi(unsigned int inGameLevel) const; + unsigned int GetColdDenomi(unsigned int inGameLevel, unsigned int inMonth) const; + BOOL IsDustOn(unsigned int inGameLevel) const; T2TowerVision* GetTowerVision(); void SetLatestBuild(T2Equip* inEquip, BOOL inFlag); void SetLatestBuild(T2ToolDef* inToolDef, BOOL inFlag); @@ -155,6 +155,7 @@ protected: friend class T2Terrorist; friend class T2ToolDef; friend class T2ToolWindow; + friend class T2TowerDoc; friend class T2WorldPlugin; friend class T2VisitVIP; @@ -165,8 +166,8 @@ protected: POINT mInitPos; int mTopFloorLine; int mBottomFloorLine; - int m70; - int m74; + int m70; // starting level + int m74; // starting month int _78; int _7C; int _80; @@ -174,15 +175,15 @@ protected: GradeDef mGradeDef[8]; int m148[5]; char m15C[20]; - unsigned int mDustOnThreshold; - unsigned int mToiletVar1; - unsigned int mToiletVar2; + unsigned int mMinimumLevelForDust; + unsigned int mMinimumLevelForToilet; + unsigned int mToiletDenomi; int m17C; int mBGVUnit; int mBGHUnit; int mSkyVSize; int mSkyHSize; - POINT m190; + POINT m190; // crane size T2WordDefArray *mWordDefArray; T2BitImage *mSkyOffscreen; T2BitImage *m1A0; diff --git a/src/T2DLL/T2WorldPlugin.cpp b/src/T2DLL/T2WorldPlugin.cpp index afa7d1c..fc55a9c 100644 --- a/src/T2DLL/T2WorldPlugin.cpp +++ b/src/T2DLL/T2WorldPlugin.cpp @@ -90,7 +90,7 @@ void T2WorldPlugin::_DrawFunds(CWnd*, int) { int result = 0; if (inDoc->mGameLevel <= inWorldDef->mNumOfGradeDef) { - T2Pool *thePool = inDoc->towerDoc_vf130(); + T2Pool *thePool = inDoc->GetPool(); if (thePool) { GradeDef gradeDef = inWorldDef->mGradeDef[inDoc->mGameLevel - 1]; int population = thePool->GetPopulation(); diff --git a/src/T2DLL/TenantSearchDlg.cpp b/src/T2DLL/TenantSearchDlg.cpp index b0845c0..d2ec1bc 100644 --- a/src/T2DLL/TenantSearchDlg.cpp +++ b/src/T2DLL/TenantSearchDlg.cpp @@ -44,7 +44,7 @@ void TenantSearchDlg::DoFind() { return; T2Name *theName = (T2Name *) listBox->GetItemDataPtr(sel); - mDocument->towerDoc_vf238(theName); + mDocument->DoFind(theName); } void TenantSearchDlg::DoDelete() { diff --git a/src/T2DLL/WalkerDlg.cpp b/src/T2DLL/WalkerDlg.cpp index fdd7e63..4c2c842 100644 --- a/src/T2DLL/WalkerDlg.cpp +++ b/src/T2DLL/WalkerDlg.cpp @@ -1,4 +1,4 @@ -#include "CT2App.h" +#include "T2.h" #include "T2CtrlPalette.h" #include "T2DlgItem.h" #include "T2MainWindow.h" @@ -45,7 +45,7 @@ void WalkerDlg::Revert() { } void WalkerDlg::Save() { - T2CtrlPalette *theCtrlPalette = ((CT2App *) AfxGetApp())->mMainWindow->mCtrlPalette; + T2CtrlPalette *theCtrlPalette = T2_APP->mMainWindow->mCtrlPalette; if (!theCtrlPalette) return; @@ -59,13 +59,13 @@ void WalkerDlg::Save() { theSlider->SetData(value); if (mFC == 0) - mDocument->towerDoc_vf14C(-1); + mDocument->SetWalkRate(-1); else - mDocument->towerDoc_vf14C(mFC); + mDocument->SetWalkRate(mFC); } /*virtual*/ void WalkerDlg::OnT2Create() { - mFC = mDocument->towerDoc_vf148(); + mFC = mDocument->GetWalkRate(); if (mFC == -1) mFC = 0; diff --git a/src/T2FilePreview.cpp b/src/T2FilePreview.cpp index 9f6b616..95db5e3 100644 --- a/src/T2FilePreview.cpp +++ b/src/T2FilePreview.cpp @@ -1,2 +1,230 @@ +#define ATOI_KLUDGE #include "T2FilePreview.h" +#include <io.h> +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +T2FilePreview::T2FilePreview() { + mStr40 = ""; + mStr44 = ""; +} + +/*virtual*/ T2FilePreview::~T2FilePreview() { + +} + +BEGIN_MESSAGE_MAP(T2FilePreview, CWnd) + ON_WM_PAINT() +END_MESSAGE_MAP() + +void T2FilePreview::SetFile(const char *path) { + mStr40 = path; + + int fd = _open(mStr40, 0); + if (fd != -1) { + char magic[4]; + _read(fd, magic, 4); + + if (!memcmp(magic, "T200", 4) || !memcmp(magic, "002T", 4)) { + mStr44 = "READY"; + + unsigned char len; + _read(fd, &len, 1); + + char *str = (char *) malloc(len + 1); + _read(fd, str, len); + str[len] = 0; + + mStr44 += str; + free(str); + } else { + // "ERRORThe Tower2.0のファイルではありません" + mStr44 = "ERROR\x01The Tower2.0\x82\xCC\x83\x74\x83\x40\x83\x43\x83\x8B\x82\xC5\x82\xCD\x82\xA0\x82\xE8\x82\xDC\x82\xB9\x82\xF1\x01"; + } + + _close(fd); + } else { + // "ERRORファイルがありません" + mStr44 = "ERROR\x01\x83\x74\x83\x40\x83\x43\x83\x8B\x82\xAA\x82\xA0\x82\xE8\x82\xDC\x82\xB9\x82\xF1\x01"; + } + + InvalidateRect(NULL); +} + +void T2FilePreview::OnPaint() { +#pragma var_order(clr2, clr3, innerRect, clr1, font2, font1, save, pen1, pen2, paintDC, clientRect, logFont) + CPaintDC paintDC(this); + int save = paintDC.SaveDC(); + paintDC.SetBkMode(TRANSPARENT); + + CFont font1, font2; + LOGFONT logFont; + GetParent()->GetFont()->GetLogFont(&logFont); + font1.CreateFontIndirect(&logFont); + logFont.lfWeight = FW_BOLD; + font2.CreateFontIndirect(&logFont); + + COLORREF clr1 = GetSysColor(COLOR_BTNTEXT); + COLORREF clr2 = GetSysColor(COLOR_BTNHIGHLIGHT); + COLORREF clr3 = GetSysColor(COLOR_BTNSHADOW); + + CPen pen1, pen2; + pen1.CreatePen(PS_SOLID, 0, clr1); + pen2.CreatePen(PS_SOLID, 0, clr2); + + CRect clientRect; + GetClientRect(clientRect); + + paintDC.DrawEdge(clientRect, EDGE_SUNKEN, BF_RECT); + + CRect innerRect = clientRect; + innerRect.DeflateRect(3, 3, 3, 3); + + if (mStr44 != "") { +#pragma var_order(tok, str) + char *str = (char *) malloc(mStr44.GetLength() + 1); + strcpy(str, mStr44); + + char *tok = strtok(str, "\x01"); + if (!strcmp(tok, "READY")) { +#pragma var_order(line2, height, pt, line1) + int height = abs(logFont.lfHeight); + CPoint pt = innerRect.TopLeft(); + + paintDC.SelectObject(&font2); + + paintDC.SetTextColor(clr2); + paintDC.TextOut(pt.x + 1, pt.y + 1, "\x8C\x9A\x90\xDD\x92\x6E"); + + paintDC.SetTextColor(clr1); + paintDC.TextOut(pt.x, pt.y, "\x8C\x9A\x90\xDD\x92\x6E"); + + pt.y += height; + + paintDC.SelectObject(&font1); + tok = strtok(NULL, "\x01"); + paintDC.TextOut(pt.x + height, pt.y, tok); + + pt.y += height + 1; + + paintDC.SelectObject(&pen2); + paintDC.MoveTo(pt.x + height + 1, pt.y + 1); + paintDC.LineTo(innerRect.right - height + 1, pt.y + 1); + paintDC.SelectObject(&pen1); + paintDC.MoveTo(pt.x + height, pt.y); + paintDC.LineTo(innerRect.right - height, pt.y); + + pt.y += 6; + + paintDC.SelectObject(&font2); + + paintDC.SetTextColor(clr2); + paintDC.TextOut(pt.x + 1, pt.y + 1, "\x83\x4F\x83\x8C\x81\x5B\x83\x68"); + + paintDC.SetTextColor(clr1); + paintDC.TextOut(pt.x, pt.y, "\x83\x4F\x83\x8C\x81\x5B\x83\x68"); + + pt.y += height; + + paintDC.SelectObject(&font1); + tok = strtok(NULL, "\x01"); + + CString line1, line2; + if (tok) { +#pragma var_order(i, count) + int count = atoi(tok); + for (int i = 0; i < count; i++) { + // ☆ + line1 += "\x81\x99"; + // ★ + line2 += "\x81\x9A"; + } + } + + paintDC.SetTextColor(RGB(255, 255, 0)); + paintDC.TextOut(pt.x + height, pt.y, line2); + paintDC.SetTextColor(RGB(0, 0, 0)); + paintDC.TextOut(pt.x + height, pt.y, line1); + + pt.y += height + 1; + + paintDC.SelectObject(&pen2); + paintDC.MoveTo(pt.x + height + 1, pt.y + 1); + paintDC.LineTo(innerRect.right - height + 1, pt.y + 1); + paintDC.SelectObject(&pen1); + paintDC.MoveTo(pt.x + height, pt.y); + paintDC.LineTo(innerRect.right - height, pt.y); + + pt.y += 6; + + paintDC.SelectObject(&font2); + + paintDC.SetTextColor(clr2); + paintDC.TextOut(pt.x + 1, pt.y + 1, "\x8E\x91\x8B\xE0"); + + paintDC.SetTextColor(clr1); + paintDC.TextOut(pt.x, pt.y, "\x8E\x91\x8B\xE0"); + + pt.y += height; + + paintDC.SelectObject(&font1); + tok = strtok(NULL, "\x01"); + paintDC.TextOut(pt.x + height, pt.y, tok); + + pt.y += height + 1; + + paintDC.SelectObject(&pen2); + paintDC.MoveTo(pt.x + height + 1, pt.y + 1); + paintDC.LineTo(innerRect.right - height + 1, pt.y + 1); + paintDC.SelectObject(&pen1); + paintDC.MoveTo(pt.x + height, pt.y); + paintDC.LineTo(innerRect.right - height, pt.y); + + pt.y += 6; + + paintDC.SelectObject(&font2); + + paintDC.SetTextColor(clr2); + paintDC.TextOut(pt.x + 1, pt.y + 1, "\x90\x6C\x8C\xFB"); + + paintDC.SetTextColor(clr1); + paintDC.TextOut(pt.x, pt.y, "\x90\x6C\x8C\xFB"); + + pt.y += height; + + paintDC.SelectObject(&font1); + tok = strtok(NULL, "\x01"); + paintDC.TextOut(pt.x + height, pt.y, tok); + + pt.y += height + 1; + + paintDC.SelectObject(&pen2); + paintDC.MoveTo(pt.x + height + 1, pt.y + 1); + paintDC.LineTo(innerRect.right - height + 1, pt.y + 1); + paintDC.SelectObject(&pen1); + paintDC.MoveTo(pt.x + height, pt.y); + paintDC.LineTo(innerRect.right - height, pt.y); + + } else if (!strcmp(tok, "ERROR")) { + tok = strtok(NULL, "\x01"); + + paintDC.SelectObject(&font1); + + innerRect.OffsetRect(1, 1); + paintDC.SetTextColor(clr2); + paintDC.DrawText(tok, innerRect, DT_WORDBREAK); + + innerRect.OffsetRect(-1, -1); + paintDC.SetTextColor(clr3); + paintDC.DrawText(tok, innerRect, DT_WORDBREAK); + } + + free(str); + } + + paintDC.RestoreDC(save); +} diff --git a/src/T2FilePreview.h b/src/T2FilePreview.h index fcaf1ff..dce5513 100644 --- a/src/T2FilePreview.h +++ b/src/T2FilePreview.h @@ -1,3 +1,18 @@ #pragma once #include "common.h" +class T2FilePreview : public CWnd { + DECLARE_MESSAGE_MAP() + +public: + T2FilePreview(); + ~T2FilePreview(); + + void SetFile(const char *path); + +protected: + void OnPaint(); + + CString mStr40; + CString mStr44; +}; diff --git a/src/T2GraphWindow.cpp b/src/T2GraphWindow.cpp index 5e076b1..b1a8d14 100644 --- a/src/T2GraphWindow.cpp +++ b/src/T2GraphWindow.cpp @@ -1,2 +1,146 @@ +#include "GlobalFunc.h" #include "T2GraphWindow.h" +#include "T2HUnknown.h" +#include "T2TowerDoc.h" +#include "T2WorldDef.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#line 16 +IMPLEMENT_DYNCREATE(T2GraphWindow, CFrameWnd) + +T2GraphWindow::T2GraphWindow() { + mDocument = NULL; +} + +T2GraphWindow::~T2GraphWindow() { +} + +BEGIN_MESSAGE_MAP(T2GraphWindow, CFrameWnd) + ON_WM_ERASEBKGND() + ON_WM_HSCROLL() + ON_WM_SIZE() + ON_WM_QUERYNEWPALETTE() +END_MESSAGE_MAP() + +BOOL T2GraphWindow::OnEraseBkgnd(CDC *pDC) { +#pragma var_order(pen4, rect2, brush, i, pen2, save, pen3, font, newSave, newDC, x, y, pen1, clientRect, position, bitmap) + if (!mDocument || !mDocument->mWorldDef) + return CFrameWnd::OnQueryNewPalette(); + + int save = pDC->SaveDC(); + pDC->SelectPalette(mDocument->mWorldDef->GetPalette(), false); + pDC->RealizePalette(); + + CDC newDC; + newDC.CreateCompatibleDC(pDC); + int newSave = newDC.SaveDC(); + newDC.SelectPalette(mDocument->mWorldDef->GetPalette(), false); + newDC.RealizePalette(); + + CRect clientRect; + GetClientRect(clientRect); + + HBITMAP bitmap = Create256DIBitmap(newDC.m_hDC, clientRect.Width(), clientRect.Height()); + SelectObject(newDC.m_hDC, bitmap); + + CBrush brush; + + brush.CreateSysColorBrush(COLOR_BTNFACE); + newDC.FillRect(clientRect, &brush); + brush.DeleteObject(); + + brush.CreateSolidBrush(PALETTERGB(255, 255, 255)); + + CRect rect2 = clientRect; + rect2.top += 16; + rect2.left += 1; + rect2.right -= 1; + rect2.bottom -= 1; + newDC.FillRect(rect2, &brush); + + CPen pen1; + pen1.CreatePen(PS_SOLID, 0, GetSysColor(COLOR_BTNHIGHLIGHT)); + + CPen pen2; + pen2.CreatePen(PS_SOLID, 0, GetSysColor(COLOR_BTNSHADOW)); + + CPen pen3; + pen3.CreatePen(PS_SOLID, 0, PALETTERGB(0, 0, 0)); + + newDC.SelectObject(pen2); + newDC.MoveTo(0, 16); + newDC.LineTo(clientRect.right, 16); + + newDC.SelectObject(pen3); + newDC.MoveTo(0, 17); + newDC.LineTo(clientRect.right, 17); + + CFont font; + font.CreateFont(-12, 0, 0, 0, FW_NORMAL, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, DRAFT_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); + newDC.SelectObject(font); + newDC.SetBkMode(TRANSPARENT); + + newDC.Draw3dRect(10, 4, 28, 9, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); + newDC.TextOut(39, 2, "\x8E\x91\x8B\xE0"); + + newDC.Draw3dRect(80, 4, 28, 9, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); + newDC.TextOut(109, 2, "\x90\x6C\x8C\xFB"); + + CPen pen4; + pen4.CreatePen(PS_SOLID, 0, PALETTERGB(255, 0, 0)); + newDC.SelectObject(pen4); + + int position = mDocument->_170->GetFirst(); + int x = mDocument->_170->GetLength() - 1; + int y; + int i = 0; + while (position >= 0) { + y = clientRect.bottom - 4 - (mDocument->_170->GetNext(position) / 1000); + if (i == 0) + newDC.MoveTo(x, y); + else + newDC.LineTo(x, y); + x--; + i++; + } + + pDC->BitBlt(0, 0, clientRect.Width(), clientRect.Height(), &newDC, 0, 0, SRCCOPY); + + newDC.RestoreDC(newSave); + newDC.DeleteDC(); + DeleteObject(bitmap); + + pDC->RestoreDC(save); + + return true; +} + +void T2GraphWindow::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) { +} + +void T2GraphWindow::OnSize(UINT nType, int cx, int cy) { + CFrameWnd::OnSize(nType, cx, cy); +} + +BOOL T2GraphWindow::OnQueryNewPalette() { + if (!mDocument || !mDocument->mWorldDef) + return CFrameWnd::OnQueryNewPalette(); + + CDC *pDC = GetDC(); + pDC->SaveDC(); + pDC->SelectPalette(mDocument->mWorldDef->GetPalette(), false); + pDC->RealizePalette(); + pDC->RestoreDC(-1); + ReleaseDC(pDC); + + return true; +} + +void T2GraphWindow::SetDocument(T2TowerDoc *inDoc) { + mDocument = inDoc; +} diff --git a/src/T2GraphWindow.h b/src/T2GraphWindow.h index fcaf1ff..4286e73 100644 --- a/src/T2GraphWindow.h +++ b/src/T2GraphWindow.h @@ -1,3 +1,20 @@ #pragma once #include "common.h" +class T2GraphWindow : public CFrameWnd { + DECLARE_DYNCREATE(T2GraphWindow) + DECLARE_MESSAGE_MAP() + +public: + T2GraphWindow(); + virtual ~T2GraphWindow(); + void SetDocument(T2TowerDoc *inDoc); + +protected: + BOOL OnEraseBkgnd(CDC *pDC); + void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar); + void OnSize(UINT nType, int cx, int cy); + BOOL OnQueryNewPalette(); + + T2TowerDoc *mDocument; +}; diff --git a/src/T2HUnknown.cpp b/src/T2HUnknown.cpp new file mode 100644 index 0000000..2ca8ab6 --- /dev/null +++ b/src/T2HUnknown.cpp @@ -0,0 +1,49 @@ +#include "T2HUnknown.h" + +T2HUnknown::T2HUnknown(int capacity) { + mData = (int *) malloc(sizeof(int) * capacity); + mLength = 0; + mCapacity = capacity; +} + +T2HUnknown::~T2HUnknown() { + free(mData); +} + +int T2HUnknown::GetLength() const { + return mLength; +} + +void T2HUnknown::AddValue(int value) { + if (mLength == mCapacity) { + mLength--; + memmove(mData, mData + 1, (mCapacity - 1) * sizeof(int)); + } + + mData[mLength] = value; + mLength++; +} + +int T2HUnknown::GetFirst() const { + if (mLength == 0) + return -1; + return 0; +} + +int T2HUnknown::GetNext(int &position) const { + if (position == -1 || position == mLength) { + position = -1; + return 0; + } + + int value = mData[position]; + position++; + if (position == mLength) + position = -1; + return value; +} + +void T2HUnknown::SetAll(int value) { + for (int i = 0; i < mCapacity; i++) + mData[i] = value; +} diff --git a/src/T2HUnknown.h b/src/T2HUnknown.h new file mode 100644 index 0000000..5c6bc09 --- /dev/null +++ b/src/T2HUnknown.h @@ -0,0 +1,18 @@ +#pragma once +#include "common.h" + +class T2HUnknown { +public: + T2HUnknown(int capacity); + ~T2HUnknown(); + int GetLength() const; + void AddValue(int value); + int GetFirst() const; + int GetNext(int &position) const; + void SetAll(int value); + +protected: + int *mData; + int mLength; + int mCapacity; +}; diff --git a/src/T2MWControl.cpp b/src/T2MWControl.cpp index a6527f1..205827e 100644 --- a/src/T2MWControl.cpp +++ b/src/T2MWControl.cpp @@ -2,6 +2,12 @@ #include "T2TowerDoc.h" #include "T2WorldDef.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + #line 19 IMPLEMENT_DYNCREATE(T2MWControl, CWnd) @@ -30,8 +36,10 @@ END_MESSAGE_MAP() } afx_msg BOOL T2MWControl::OnEraseBkgnd(CDC* pDC) { - if (mWorldDef) - mWorldDef->DrawCtrl(mDocument, this); + if (!mWorldDef) + return true; + + mWorldDef->DrawCtrl(mDocument, this); return true; } @@ -60,7 +68,8 @@ afx_msg void T2MWControl::OnLButtonUp(UINT nFlags, CPoint point) { afx_msg void T2MWControl::OnMouseMove(UINT nFlags, CPoint point) { if (mWorldDef) { - HCURSOR cursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW); + CWinApp *theApp = AfxGetApp(); + HCURSOR cursor = theApp->LoadStandardCursor(IDC_ARROW); if (cursor) SetCursor(cursor); diff --git a/src/T2MainWindow.cpp b/src/T2MainWindow.cpp index 2874e91..096859a 100644 --- a/src/T2MainWindow.cpp +++ b/src/T2MainWindow.cpp @@ -1,4 +1,8 @@ -#include "CT2App.h" +#include "DbgEventList.h" +#include "DbgIPS.h" +#include "DbgStepRun.h" +#include "T2.h" +#include "T2CtrlPalette.h" #include "T2DLL.h" #include "T2MainWindow.h" #include "T2MsgWindow.h" @@ -9,6 +13,12 @@ #include "T2WorldDef.h" #include "UT2Coordinate.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + #line 22 IMPLEMENT_DYNCREATE(T2MainWindow, CFrameWnd) @@ -28,7 +38,7 @@ BEGIN_MESSAGE_MAP(T2MainWindow, CFrameWnd) END_MESSAGE_MAP() T2MainWindow::T2MainWindow() { - _EC = 0; + _EC = true; _F0 = 0; mSoundPlayer = NULL; mDirectSound = NULL; @@ -36,7 +46,7 @@ T2MainWindow::T2MainWindow() { mMsgWindow = NULL; mCtrlPalette = NULL; - ((CT2App *) AfxGetApp())->mMainWindow = this; + T2_APP->mMainWindow = this; } /*virtual*/ T2MainWindow::~T2MainWindow() { @@ -70,14 +80,14 @@ void T2MainWindow::InitSound() { return; } - DSBUFFERDESC bufferDesc; - memset(&bufferDesc, 0, sizeof(DSBUFFERDESC)); - bufferDesc.dwSize = sizeof(DSBUFFERDESC); - bufferDesc.dwFlags = DSBCAPS_PRIMARYBUFFER; + DSBUFFERDESC bufferdesc; + memset(&bufferdesc, 0, sizeof(DSBUFFERDESC)); + bufferdesc.dwSize = sizeof(DSBUFFERDESC); + bufferdesc.dwFlags = DSBCAPS_PRIMARYBUFFER; LPDIRECTSOUNDBUFFER buffer = NULL; - if (mDirectSound->CreateSoundBuffer(&bufferDesc, &buffer, NULL) != S_OL) { + if (mDirectSound->CreateSoundBuffer(&bufferdesc, &buffer, NULL) != S_OK) { DeinitSound(); } #endif @@ -93,61 +103,81 @@ void T2MainWindow::DeinitSound() { } /*virtual*/ BOOL T2MainWindow::PreCreateWindow(CREATESTRUCT& cs) { - cs.style |= WS_TABSTOP | WS_GROUP | WS_VSCROLL; + cs.style |= WS_HSCROLL | WS_VSCROLL | WS_CLIPCHILDREN; return CFrameWnd::PreCreateWindow(cs); } afx_msg int T2MainWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { #line 123 - // mDbgStepRun = DEBUG_NEW DbgStepRun; - // mDbgIPS = DEBUG_NEW DbgIPS; + mDbgStepRun = new DbgStepRun(this); + mDbgIPS = new DbgIPS(this); if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; InitSound(); #line 130 - mSoundPlayer = DEBUG_NEW T2SoundPlayer(this, mDirectSound); + mSoundPlayer = new T2SoundPlayer(this, mDirectSound); - SetWindowRgn(CreateRectRgn(100, 100, 100, 100), true); + HRGN rgn = CreateRectRgn(100, 100, 100, 100); + SetWindowRgn(rgn, true); return 0; } afx_msg void T2MainWindow::OnDestroy() { gT2App->mMainWindow = NULL; - // ffCalledFromDestroy(); + ffDestroy(); CFrameWnd::OnDestroy(); - // mDbgStepRun->DestroyWindow(); - // delete mDbgStepRun; - // mDbgIPS->DestroyWindow(); - // delete mDbgIPS; + mDbgStepRun->DestroyWindow(); + delete mDbgStepRun; + mDbgIPS->DestroyWindow(); + delete mDbgIPS; } void T2MainWindow::Setup() { RECT windowRect; GetWindowRect(&windowRect); - SetWindowRgn(CreateRectRgn(0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top), true); + + int mainWindowWidth = windowRect.right - windowRect.left; + int mainWindowHeight = windowRect.bottom - windowRect.top; + HRGN rgn = CreateRectRgn(0, 0, mainWindowWidth, mainWindowHeight); + SetWindowRgn(NULL, true); mWndClassA = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); RECT rect; SetRect(&rect, 100, 100, 300, 300); - mToolWindow = ((CT2App *) AfxGetApp())->mToolWindow; + mToolWindow = T2_APP->mToolWindow; mToolWindow->Create(mWndClassA, "Tools", WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_VISIBLE | WS_POPUP, rect, this, NULL, WS_EX_TOOLWINDOW); mWndClassB = AfxRegisterWndClass(0, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); SetRect(&rect, 0, 0, 520, 50); - // ... - // more stuff here. +#line 194 + mMsgWindow = new T2MsgWindow; + mMsgWindow->Create(mWndClassB, "Information", WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_VISIBLE | WS_POPUP, rect, this, NULL, WS_EX_TOOLWINDOW); + + SetRect(&rect, 500, 100, 600, 150); +#line 198 + mCtrlPalette = new T2CtrlPalette; + mCtrlPalette->Create(mWndClassB, "Control", WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_VISIBLE | WS_POPUP, rect, this, NULL, WS_EX_TOOLWINDOW); + + mWndClassC = AfxRegisterWndClass(0, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); + + GetDesktopWindow()->GetClientRect(&rect); + rect.top = rect.bottom - 200; + rect.left = rect.right - 300; } void T2MainWindow::Teardown() { - delete mToolWindow; - delete mMsgWindow; - delete mCtrlPalette; + if (mToolWindow) + mToolWindow->DestroyWindow(); + if (mMsgWindow) + mMsgWindow->DestroyWindow(); + if (mCtrlPalette) + mCtrlPalette->DestroyWindow(); mToolWindow = NULL; mMsgWindow = NULL; @@ -164,7 +194,7 @@ void T2MainWindow::Teardown() { afx_msg void T2MainWindow::OnSize(UINT nType, int cx, int cy) { T2TowerMainView *theView = (T2TowerMainView *) GetActiveView(); - T2TowerDoc *theTowerDoc = (T2TowerDoc *) GetActiveDocument(); + T2TowerDoc *theDocument = (T2TowerDoc *) GetActiveDocument(); if (!_EC) { CFrameWnd::OnSize(nType, cx, cy); @@ -183,34 +213,35 @@ afx_msg void T2MainWindow::OnSize(UINT nType, int cx, int cy) { } void T2MainWindow::x414445() { + int width, height; T2TowerMainView *theView = (T2TowerMainView *) GetActiveView(); - T2TowerDoc *theTowerDoc = (T2TowerDoc *) GetActiveDocument(); + T2TowerDoc *theDocument = (T2TowerDoc *) GetActiveDocument(); x4144FA(); - CRect rect; - GetWindowRect(rect); - int width = rect.Width(); - int height = rect.Height(); + CRect mainWindowRect; + GetWindowRect(mainWindowRect); + width = mainWindowRect.Width(); + height = mainWindowRect.Height(); - if (width && height && theTowerDoc && theView && theTowerDoc->mWorldDef) { - theView->tmv_vf138(theTowerDoc->mWorldDef->mInitPos, 0x102); + if (width && height && theDocument && theView && theDocument->mWorldDef) { + theView->tmv_vf138(theDocument->mWorldDef->mInitPos, kScroll2 | kScrollOpt2); _F0 = 1; theView->ShowWindow(SW_SHOW); } } void T2MainWindow::x4144FA() { - T2TowerDoc *theTowerDoc = (T2TowerDoc *) GetActiveDocument(); + T2TowerDoc *theDocument = (T2TowerDoc *) GetActiveDocument(); T2TowerMainView *theView = (T2TowerMainView *) GetActiveView(); - if (theTowerDoc && theView && theTowerDoc->mWorldDef) { + if (theDocument && theView && theDocument->mWorldDef) { RECT clientRect; - GetClientRect(&clientRect); + theView->GetClientRect(&clientRect); RECT unitRect; - SetRect(&unitRect, 0, 0, theTowerDoc->mWorldDef->GetWidth(), theTowerDoc->mWorldDef->GetHeight()); - UT2Coordinate::UnitToQD(unitRect, theTowerDoc->mZoomLevel, true); + SetRect(&unitRect, 0, 0, theDocument->mWorldDef->GetWidth(), theDocument->mWorldDef->GetHeight()); + UT2Coordinate::UnitToQD(unitRect, theDocument->mZoomLevel, true); SCROLLINFO info; info.cbSize = sizeof(SCROLLINFO); @@ -230,9 +261,10 @@ void T2MainWindow::x4144FA() { } afx_msg void T2MainWindow::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { - T2TowerDoc *theTowerDoc = (T2TowerDoc *) GetActiveDocument(); + T2TowerDoc *theDocument = (T2TowerDoc *) GetActiveDocument(); - if (theTowerDoc) { + if (theDocument) { +#pragma var_order(scrollLimit, activeClientRect, activeView, myClientRect, clientRect, origScrollPos, scrollPos, theView) RECT clientRect; GetClientRect(&clientRect); @@ -245,10 +277,10 @@ afx_msg void T2MainWindow::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrol scrollPos = scrollLimit; break; case SB_LINEDOWN: - scrollPos += UT2Coordinate::UnitVSize(theTowerDoc->mZoomLevel); + scrollPos += UT2Coordinate::UnitVSize(theDocument->mZoomLevel); break; case SB_LINEUP: - scrollPos -= UT2Coordinate::UnitVSize(theTowerDoc->mZoomLevel); + scrollPos -= UT2Coordinate::UnitVSize(theDocument->mZoomLevel); break; case SB_PAGEDOWN: scrollPos += clientRect.bottom / 2; @@ -283,21 +315,22 @@ afx_msg void T2MainWindow::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrol myClientRect.top = activeClientRect.top; - ScrollWindow(0, scrollPos - origScrollPos, myClientRect, myClientRect); + ScrollWindow(0, origScrollPos - scrollPos, myClientRect, myClientRect); UpdateWindow(); T2TowerMainView *theView = (T2TowerMainView *) GetActiveView(); if (theView) { - theView->tmv_vf130(scrollPos); + theView->SetScrollV(scrollPos); theView->tmv_vf120(); } } } afx_msg void T2MainWindow::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { - T2TowerDoc *theTowerDoc = (T2TowerDoc *) GetActiveDocument(); + T2TowerDoc *theDocument = (T2TowerDoc *) GetActiveDocument(); - if (theTowerDoc) { + if (theDocument) { +#pragma var_order(scrollLimit, activeClientRect, activeView, myClientRect, clientRect, origScrollPos, scrollPos, theView) RECT clientRect; GetClientRect(&clientRect); @@ -310,10 +343,10 @@ afx_msg void T2MainWindow::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrol scrollPos = scrollLimit; break; case SB_LINERIGHT: - scrollPos += UT2Coordinate::UnitHSize(theTowerDoc->mZoomLevel); + scrollPos += UT2Coordinate::UnitHSize(theDocument->mZoomLevel); break; case SB_LINELEFT: - scrollPos -= UT2Coordinate::UnitHSize(theTowerDoc->mZoomLevel); + scrollPos -= UT2Coordinate::UnitHSize(theDocument->mZoomLevel); break; case SB_PAGERIGHT: scrollPos += clientRect.right / 2; @@ -346,23 +379,24 @@ afx_msg void T2MainWindow::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrol activeView->GetClientRect(activeClientRect); activeView->MapWindowPoints(this, activeClientRect); - myClientRect.top = activeClientRect.top; + myClientRect.left = activeClientRect.left; - ScrollWindow(scrollPos - origScrollPos, 0, myClientRect, myClientRect); + ScrollWindow(origScrollPos - scrollPos, 0, myClientRect, myClientRect); UpdateWindow(); T2TowerMainView *theView = (T2TowerMainView *) GetActiveView(); if (theView) { - theView->tmv_vf134(scrollPos); + theView->SetScrollH(scrollPos); theView->tmv_vf120(); } } } afx_msg BOOL T2MainWindow::OnEraseBkgnd(CDC* pDC) { - T2TowerDoc *theTowerDoc = (T2TowerDoc *) GetActiveDocument(); +#pragma var_order(shadowPen, bigFont, theView, brush, save, highlightPen, theDocument, clientRect, smallFont) + T2TowerDoc *theDocument = (T2TowerDoc *) GetActiveDocument(); - if (!theTowerDoc || !theTowerDoc->mWorldDef || !theTowerDoc->Get22C()) { + if (!theDocument || !theDocument->mWorldDef || !theDocument->Get22C()) { CRect clientRect; GetClientRect(clientRect); @@ -384,10 +418,10 @@ afx_msg BOOL T2MainWindow::OnEraseBkgnd(CDC* pDC) { CPen highlightPen(PS_SOLID, 0, GetSysColor(COLOR_BTNHIGHLIGHT)); CFont bigFont; - bigFont.CreateFont(-14, 0, 900, 900, FW_BOLD, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY, FIXED_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); + bigFont.CreateFont(-14, 0, 900, 900, FW_BOLD, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_LH_ANGLES | CLIP_TT_ALWAYS, DRAFT_QUALITY, FIXED_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); CFont smallFont; - smallFont.CreateFont(-14, 0, 0, 0, FW_BOLD, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY, FIXED_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); + smallFont.CreateFont(-14, 0, 0, 0, FW_BOLD, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_LH_ANGLES | CLIP_TT_ALWAYS, DRAFT_QUALITY, FIXED_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); pDC->SelectObject(shadowPen); pDC->MoveTo(clientRect.right, 0); @@ -398,16 +432,17 @@ afx_msg BOOL T2MainWindow::OnEraseBkgnd(CDC* pDC) { CView *theView = GetActiveView(); - if (_F0 && theTowerDoc && theView) { + if (_F0 && theDocument && theView) { +#pragma var_order(scrollInfoV, hRange, height, scrollInfoH, viewRect, str, textPos, x, y, i, textLen, anotherRect, showAllNumbers, vRange, theTowerMainView) CRect viewRect; theView->GetClientRect(viewRect); theView->MapWindowPoints(this, viewRect); T2TowerMainView *theTowerMainView = (T2TowerMainView *) theView; - viewRect.left += theTowerMainView->m84; - viewRect.right += theTowerMainView->m84; - viewRect.top += theTowerMainView->m88; - viewRect.bottom += theTowerMainView->m88; + viewRect.left += theTowerMainView->mImageOrigin.x; + viewRect.right += theTowerMainView->mImageOrigin.x; + viewRect.top += theTowerMainView->mImageOrigin.y; + viewRect.bottom += theTowerMainView->mImageOrigin.y; pDC->SelectObject(shadowPen); pDC->MoveTo(viewRect.left - 1, 0); @@ -433,6 +468,7 @@ afx_msg BOOL T2MainWindow::OnEraseBkgnd(CDC* pDC) { int y; char str[4]; POINT textPos; + int textLen; for (i = 0; i < 10; i++) { x = viewRect.left + (hRange * i) / 10; @@ -476,7 +512,7 @@ afx_msg BOOL T2MainWindow::OnEraseBkgnd(CDC* pDC) { pDC->SetWindowOrg(0, scrollInfoV.nPos); int vRange = scrollInfoV.nMax - scrollInfoV.nMin; - int height = theTowerDoc->mWorldDef->GetHeight(); + int height = theDocument->mWorldDef->GetHeight(); pDC->SelectObject(bigFont); @@ -493,41 +529,40 @@ afx_msg BOOL T2MainWindow::OnEraseBkgnd(CDC* pDC) { pDC->LineTo(16, y); } - BOOL showAllNumbers = (theTowerDoc->towerDoc_vf108() == 0); + BOOL showAllNumbers = (theDocument->GetZoomLevel() == 0); for (i = 0; i <= height; i++) { y = viewRect.top + (vRange * i) / height; anotherRect.SetRect(0, y, 14, viewRect.top + (vRange * (i + 1)) / height); - int number = theTowerDoc->mWorldDef->mGroundLine - i; - BOOL show = showAllNumbers; + int number = theDocument->mWorldDef->mGroundLine - i; + BOOL isShow = showAllNumbers; if (number > 1 && (number % 5 == 0)) - show = true; + isShow = true; if (number == 1) - show = true; + isShow = true; if (number < 1 && ((number - 1) % 5 == 0)) - show = true; + isShow = true; - if (show) { + if (isShow) { if (number >= 1) wsprintf(str, "%d", number); else - wsprintf(str, "B%d", 1 - number); - - int textLen = strlen(str); + wsprintf(str, "B%d", -number + 1); + textLen = strlen(str); textPos.x = 2; - textPos.y = ((anotherRect.top + anotherRect.bottom) / 2) - (pDC->GetTextExtent(str, 2).cx / 2); + textPos.y = ((anotherRect.top + anotherRect.bottom) / 2) + (pDC->GetTextExtent(str, textLen).cx / 2); pDC->SetTextColor(GetSysColor(COLOR_BTNHIGHLIGHT)); - pDC->TextOut(textPos.x + 1, textPos.y + 1, str, 2); + pDC->TextOut(textPos.x + 1, textPos.y + 1, str, textLen); pDC->SetTextColor(GetSysColor(COLOR_BTNSHADOW)); - pDC->TextOut(textPos.x - 1, textPos.y - 1, str, 2); + pDC->TextOut(textPos.x - 1, textPos.y - 1, str, textLen); pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT)); - pDC->TextOut(textPos.x, textPos.y, str, 2); + pDC->TextOut(textPos.x, textPos.y, str, textLen); } } } @@ -543,40 +578,41 @@ afx_msg void T2MainWindow::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimi afx_msg void T2MainWindow::OnActivateApp(BOOL bActive, HTASK hTask) { CWnd::OnActivateApp(bActive, hTask); - T2TowerDoc *theTowerDoc = (T2TowerDoc *) GetActiveDocument(); + T2TowerDoc *theDocument = (T2TowerDoc *) GetActiveDocument(); - if (theTowerDoc && theTowerDoc->mWorldDef) { + if (theDocument && theDocument->mWorldDef) { CDC *pDC = GetDC(); pDC->SaveDC(); - pDC->SelectPalette(theTowerDoc->mWorldDef->GetPalette(), false); + pDC->SelectPalette(theDocument->mWorldDef->GetPalette(), false); pDC->RealizePalette(); pDC->RestoreDC(-1); ReleaseDC(pDC); InvalidateRect(NULL); - T2TowerMainView *theTowerMainView = theTowerDoc->GetTowerMainView(); + T2TowerMainView *theTowerMainView = theDocument->GetMainView(); if (theTowerMainView) theTowerMainView->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN | RDW_ERASENOW); - DWORD processID; - GetWindowThreadProcessId(this, &processID); + DWORD thisProcessId; + GetWindowThreadProcessId(*this, &thisProcessId); - CWnd *window = GetDesktopWindow()->GetWindow(GW_CHILD); - while (window) { - DWORD checkProcessID; - GetWindowThreadProcessId(window, &checkProcessID); + CWnd *wnd = GetDesktopWindow()->GetWindow(GW_CHILD); + while (wnd) { + DWORD checkProcessId; + GetWindowThreadProcessId(*wnd, &checkProcessId); - if (processID == checkProcessID) - window->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN | RDW_ERASENOW); + if (thisProcessId == checkProcessId) + wnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN | RDW_ERASENOW); - window = window->GetWindow(GW_HWNDNEXT); + wnd = wnd->GetWindow(GW_HWNDNEXT); } } } afx_msg void T2MainWindow::OnCmdDebugEvent() { - // TODO: DbgEventList + DbgEventList dlg(NULL); + dlg.DoModal(); } afx_msg void T2MainWindow::OnUpdateCmdDebugEvent(CCmdUI *pCmdUI) { @@ -584,18 +620,18 @@ afx_msg void T2MainWindow::OnUpdateCmdDebugEvent(CCmdUI *pCmdUI) { } afx_msg void T2MainWindow::OnClose() { - T2TowerDoc *theTowerDoc = (T2TowerDoc *) GetActiveDocument(); + T2TowerDoc *theDocument = (T2TowerDoc *) GetActiveDocument(); - if (theTowerDoc->towerDoc_vf1A4()) + if (theDocument->towerDoc_vf1A4()) return; CFrameWnd::OnClose(); } afx_msg void T2MainWindow::OnCmdDebugMode() { - HMENU oldMenu = GetMenu(this); - HMENU newMenu = LoadMenu(AfxGetInstanceHandle(), 130); + HMENU oldMenu = ::GetMenu(*this); + HMENU newMenu = LoadMenu(AfxGetInstanceHandle(), MAKEINTRESOURCE(130)); m_hMenuDefault = newMenu; - SetMenu(this, newMenu); + ::SetMenu(*this, newMenu); DestroyMenu(oldMenu); } diff --git a/src/T2MainWindow.h b/src/T2MainWindow.h index b84d81f..eedd250 100644 --- a/src/T2MainWindow.h +++ b/src/T2MainWindow.h @@ -1,6 +1,8 @@ #pragma once #include "common.h" +#define T2_MAIN_WINDOW ((T2MainWindow *) AfxGetMainWnd()) + class T2MainWindow : public CFrameWnd { DECLARE_DYNCREATE(T2MainWindow) DECLARE_MESSAGE_MAP() @@ -27,7 +29,7 @@ public: CString mWndClassC; DbgStepRun *mDbgStepRun; DbgIPS *mDbgIPS; - int _EC; + BOOL _EC; int _F0; protected: diff --git a/src/T2MsgWindow.cpp b/src/T2MsgWindow.cpp index 1394f19..d63d054 100644 --- a/src/T2MsgWindow.cpp +++ b/src/T2MsgWindow.cpp @@ -1,2 +1,159 @@ +#include "T2DlgItemAnimation.h" +#include "T2ImageObj.h" #include "T2MsgWindow.h" +#include "T2MWControl.h" +#include "T2TowerDoc.h" +#include "T2WorldDef.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#line 19 +IMPLEMENT_DYNCREATE(T2MsgWindow, CFrameWnd) + +T2MsgWindow::T2MsgWindow() { +#line 23 + mClockControl = new T2MWControl; + mCalendarControl = new T2MWControl; + mFundsControl = new T2MWControl; + +#line 30 + mPopulationControl = new T2MWControl; + mMessageControl = new T2MWControl; + + mDocument = NULL; + mWorldDef = NULL; + mIsSetUp = false; +} + +/*virtual*/ T2MsgWindow::~T2MsgWindow() { + delete mClockControl; + delete mCalendarControl; + delete mFundsControl; + delete mPopulationControl; + delete mMessageControl; +} + +BEGIN_MESSAGE_MAP(T2MsgWindow, CFrameWnd) + ON_WM_QUERYNEWPALETTE() + ON_WM_ERASEBKGND() + ON_WM_CREATE() + ON_WM_CLOSE() +END_MESSAGE_MAP() + +void T2MsgWindow::SetDocument(T2TowerDoc *inDoc) { + mDocument = inDoc; + mWorldDef = inDoc->mWorldDef; + + mWndClass = AfxRegisterWndClass(CS_NOCLOSE, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); + + RECT rect; + + mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Clock", 0), rect); + mClockControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1000); + + mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Calendar", 0), rect); + mCalendarControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1001); + + mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Funds", 0), rect); + mFundsControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1002); + + mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Population", 0), rect); + mPopulationControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1003); + + mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Message", 0), rect); + mMessageControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1004); + + mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Grade", 0), rect); +#line 80 + mGradeControl = new T2DlgItemAnimation(mDocument, NULL, mWorldDef->GetPalette()); + + mGradeControl->Create("", WS_CLIPCHILDREN | WS_VISIBLE | WS_CHILD, rect, this, 1005); + + mClockControl->Setup(inDoc); + mCalendarControl->Setup(inDoc); + mFundsControl->Setup(inDoc); + mPopulationControl->Setup(inDoc); + mMessageControl->Setup(inDoc); + + mToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX); + mToolTip.AddTool(mClockControl); + mToolTip.AddTool(mCalendarControl); + mToolTip.AddTool(mFundsControl); + mToolTip.AddTool(mPopulationControl); + mToolTip.AddTool(mMessageControl); + mToolTip.Activate(true); + + mIsSetUp = true; + InvalidateRect(NULL); +} + +int T2MsgWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { + if (CFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + RECT windowRect, clientRect; + GetWindowRect(&windowRect); + GetClientRect(&clientRect); + + SetWindowPos(NULL, + 0, + 0, + (windowRect.right - windowRect.left) - clientRect.right + 512, + (windowRect.bottom - windowRect.top) - clientRect.bottom + 44, + SWP_NOMOVE | SWP_NOZORDER + ); + return 0; +} + +BOOL T2MsgWindow::OnQueryNewPalette() { + return CFrameWnd::OnQueryNewPalette(); +} + +BOOL T2MsgWindow::OnEraseBkgnd(CDC *pDC) { + if (!mDocument) + return CFrameWnd::OnEraseBkgnd(pDC); + + pDC->SaveDC(); + pDC->SelectPalette(mWorldDef->GetPalette(), false); + + int objInd = mWorldDef->mImageObj->FindObject("MsgWnd"); + + RECT rect; + SetRect(&rect, 0, 0, 513, 45); + mWorldDef->mImageObj->DrawObject(pDC, objInd, rect); + + pDC->RealizePalette(); + pDC->RestoreDC(-1); + + return true; +} + +/*virtual*/ BOOL T2MsgWindow::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT *pResult) { + LPNMTTDISPINFO msg = (LPNMTTDISPINFO) lParam; + int id = ::GetDlgCtrlID((HWND) msg->hdr.idFrom); + + if (msg->hdr.code == TTN_GETDISPINFO && (id >= 1000) && (id <= 1003)) { + mWorldDef->GetToolTipText(mDocument, (T2MWControl *) GetDlgItem(id), msg); + return true; + } + + return CWnd::OnNotify(wParam, lParam, pResult); +} + +void T2MsgWindow::OnClose() { + if (!mDocument) + return; + + mDocument->towerDoc_vf198(kMessageWindow); +} + +/*virtual*/ BOOL T2MsgWindow::PreTranslateMessage(MSG *pMsg) { + if (mIsSetUp) + mToolTip.RelayEvent(pMsg); + + return CFrameWnd::PreTranslateMessage(pMsg); +} diff --git a/src/T2MsgWindow.h b/src/T2MsgWindow.h index fcaf1ff..0a703d6 100644 --- a/src/T2MsgWindow.h +++ b/src/T2MsgWindow.h @@ -1,3 +1,33 @@ #pragma once #include "common.h" +class T2MsgWindow : public CFrameWnd { + DECLARE_DYNCREATE(T2MsgWindow) + DECLARE_MESSAGE_MAP() + +public: + T2MsgWindow(); + virtual ~T2MsgWindow(); + void SetDocument(T2TowerDoc *inDoc); + virtual BOOL PreTranslateMessage(MSG *pMsg); + +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg BOOL OnQueryNewPalette(); + afx_msg BOOL OnEraseBkgnd(CDC *pDC); + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT *pResult); + afx_msg void OnClose(); + +protected: + CString mWndClass; + T2MWControl *mClockControl; + T2MWControl *mCalendarControl; + T2MWControl *mFundsControl; + T2MWControl *mPopulationControl; + T2MWControl *mMessageControl; + T2DlgItemAnimation *mGradeControl; + T2TowerDoc *mDocument; + T2WorldDef *mWorldDef; + CToolTipCtrl mToolTip; + BOOL mIsSetUp; +}; diff --git a/src/T2NewDlg.cpp b/src/T2NewDlg.cpp index 3f8284d..c08afe1 100644 --- a/src/T2NewDlg.cpp +++ b/src/T2NewDlg.cpp @@ -1,2 +1,767 @@ +#include "GlobalFunc.h" +#include "T2BitImage.h" #include "T2NewDlg.h" +#include "T2NewDlgTmp.h" +#include "T2PluginLoader.h" +#include "T2PluginSpecifier.h" +#include "T2TowerDoc.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#line 20 +IMPLEMENT_DYNCREATE(T2NewDlg, CFrameWnd) + +T2NewDlg::T2NewDlg() { + HRSRC rsrc = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(100), "PALETTE"); + HGLOBAL theHandle = LoadResource(AfxGetApp()->m_hInstance, rsrc); + void *resData = LockResource(theHandle); + + LOGPALETTE *theLogPalette = ConvACTPalette((ACTPALETTEENTRY *) resData); + mPalette.CreatePalette(theLogPalette); + + int i; + + mPal1 = (short *) malloc(sizeof(short) * 256); + for (i = 0; i < 256; i++) + mPal1[i] = i; + + mPal2 = (short *) malloc(sizeof(short) * 256); + for (i = 0; i < 256; i++) { + int r = theLogPalette->palPalEntry[i].peRed; + int g = theLogPalette->palPalEntry[i].peGreen; + int b = theLogPalette->palPalEntry[i].peBlue; + int index = mPalette.GetNearestPaletteIndex(RGB(r, g, b)); + + if (theLogPalette->palPalEntry[index].peRed == 1 && theLogPalette->palPalEntry[index].peGreen == 1 && theLogPalette->palPalEntry[index].peBlue == 1) + index = 255; + + mPal2[i] = index; + } + + free(theLogPalette); + + mBitmap.LoadBitmap(170); + mBrush.CreatePatternBrush(&mBitmap); + + mPlugins = NULL; + mScrollOffset = 0; + mSelectedPlugin = 0; +} + +/*virtual*/ T2NewDlg::~T2NewDlg() { + if (mPlugins) { + for (int i = 0; i < mPluginCount; i++) { + delete mPlugins[i].preview; + delete mPlugins[i].icon; + delete mPlugins[i].mStr8; + delete mPlugins[i].mStr18; + } + free(mPlugins); + } + + free(mPal1); + free(mPal2); + + mBrush.DeleteObject(); + mBitmap.DeleteObject(); +} + +BEGIN_MESSAGE_MAP(T2NewDlg, CFrameWnd) + ON_WM_CLOSE() + ON_WM_TIMER() + ON_WM_CREATE() + ON_WM_QUERYNEWPALETTE() + ON_WM_ERASEBKGND() + ON_WM_KEYDOWN() + ON_COMMAND(IDOK, OnCommandOK) + ON_COMMAND(IDCANCEL, OnCommandCancel) + ON_COMMAND(106, OnCommand106) + ON_COMMAND(107, OnCommand107) +END_MESSAGE_MAP() + +void T2NewDlg::Setup(T2TowerDoc *inDoc, T2PluginLoader *inPluginLoader, BOOL inShowCancelButton) { + mDocument = inDoc; + mPluginLoader = inPluginLoader; + mShowCancelButton = inShowCancelButton; + + POSITION pos; + T2PluginSpecifier *specifier; + + mPluginLoader->SetTypeFilter(pos, 'WdPl'); + mPluginCount = 0; + + while ((specifier = mPluginLoader->GetNext(pos))) + mPluginCount++; + + mPlugins = (PluginRecord *) malloc(mPluginCount * sizeof(PluginRecord)); + + mPluginLoader->SetTypeFilter(pos, 'WdPl'); + int index = 0; + + while ((specifier = mPluginLoader->GetNext(pos))) { + mPluginLoader->LoadPlugin(specifier); + +#line 112 + mPlugins[index].preview = new T2BitImage(specifier->mInstance, 20000, true); + mPlugins[index].icon = new T2BitImage(specifier->mInstance, 20001, true); + mPlugins[index].mStr8 = new CString(specifier->mPluginName); + + char *buf = (char *) malloc(10000); + strcpy(buf, "NO TEXT"); + LoadString(specifier->mInstance, 20000, buf, 10000); + +#line 118 + mPlugins[index].mStr18 = new CString(strtok(buf, "|")); + mPlugins[index].mStrC = new CString(strtok(NULL, "\r\n")); + mPlugins[index].mStr10 = new CString(strtok(NULL, "\r\n")); + + free(buf); + + mPluginLoader->UnloadPlugin(specifier); + index++; + } + + CRect rect; + SetRect(&rect, 100, 100, 300, 300); + Create("#32770", "\x8C\x9A\x90\xDD\x92\x6E\x91\x49\x91\xF0", WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_POPUP, rect, AfxGetMainWnd(), NULL, WS_EX_DLGMODALFRAME); + + SetTimer(1, 100, NULL); +} + +/*virtual*/ BOOL T2NewDlg::PreCreateWindow(CREATESTRUCT &cs) { + return CFrameWnd::PreCreateWindow(cs); +} + +T2PluginSpecifier *T2NewDlg::GetSelectedPlugin() { + POSITION pos; + T2PluginSpecifier *specifier; + int index = mSelectedPlugin; + + mPluginLoader->SetTypeFilter(pos, 'WdPl'); + + while ((specifier = mPluginLoader->GetNext(pos))) { + if (index == 0) + break; + index--; + } + + return specifier; +} + +void T2NewDlg::OnClose() { + OnCommandCancel(); +} + +void T2NewDlg::OnTimer(UINT nIDEvent) { + if (nIDEvent == 1) { + KillTimer(1); + ShowWindow(SW_SHOW); + + CWnd *mainWindow = AfxGetMainWnd(); + if (mainWindow) + mainWindow->EnableWindow(false); + + EnableWindow(true); + mButton1.SetFocus(); + } +} + +int T2NewDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) { +#pragma var_order(rect2, rect1, rect6, size, rect3, rect5, logFont, newDlgTmp, rect4) + if (CFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + T2NewDlgTmp newDlgTmp(this); + newDlgTmp.Create(166); + + CRect rect1, rect2, rect3, rect4; + newDlgTmp.GetWindowRect(rect1); + newDlgTmp.mStatic.GetWindowRect(rect3); + + CSize size; + size.cx = 468; + size.cy = 314; + rect1.right += (size.cx - rect3.Width()); + rect1.bottom += (size.cy - rect3.Height()); + + GetDesktopWindow()->GetClientRect(rect2); + SetWindowPos( + NULL, + (rect2.Width() - rect1.Width()) / 2, + (rect2.Height() - rect1.Height()) / 2, + rect1.Width(), + rect1.Height(), + SWP_NOZORDER + ); + + LOGFONT logFont; + newDlgTmp.GetFont()->GetLogFont(&logFont); + mFont.CreateFontIndirectA(&logFont); + SetFont(&mFont); + + GetClientRect(rect3); + newDlgTmp.GetClientRect(rect4); + + CRect rect5, rect6; + if (mShowCancelButton) { + newDlgTmp.mOKButton.GetWindowRect(rect5); + newDlgTmp.ScreenToClient(rect5); + rect5.OffsetRect(rect3.right - rect4.right, rect3.bottom - rect4.bottom); + mButton1.Create("\x82\x6E\x82\x6A", BS_DEFPUSHBUTTON | WS_CHILD, rect5, this, IDOK); + mButton1.SetFont(&mFont); + mButton1.ShowWindow(SW_SHOW); + + newDlgTmp.mCancelButton.GetWindowRect(rect5); + newDlgTmp.ScreenToClient(rect5); + rect5.OffsetRect(rect3.right - rect4.right, rect3.bottom - rect4.bottom); + mButton2.Create("\x8E\xE6\x8F\xC1\x82\xB5", WS_CHILD, rect5, this, IDCANCEL); + mButton2.SetFont(&mFont); + mButton2.ShowWindow(SW_SHOW); + } else { + newDlgTmp.mCancelButton.GetWindowRect(rect5); + newDlgTmp.ScreenToClient(rect5); + rect5.OffsetRect(rect3.right - rect4.right, rect3.bottom - rect4.bottom); + mButton1.Create("\x82\x6E\x82\x6A", BS_DEFPUSHBUTTON | WS_CHILD, rect5, this, IDOK); + mButton1.SetFont(&mFont); + mButton1.ShowWindow(SW_SHOW); + } + + newDlgTmp.mStatic.GetWindowRect(rect5); + newDlgTmp.ScreenToClient(rect5); + + rect6 = rect5; + + rect5.OffsetRect(rect3.right - rect4.right, rect3.bottom - rect4.bottom); + rect5.left = rect5.right - 18; + rect5.top = rect5.bottom - 68; + + mButton4.Create(NULL, BS_ICON | WS_CHILD, rect5, this, 107); + mButton4.SetFont(&mFont); + mButton4.ShowWindow(SW_SHOW); + mButton4.SetIcon(AfxGetApp()->LoadIcon(169)); + + if (mPluginCount <= 6) + mButton4.EnableWindow(false); + + mRect1.top = rect5.top; + mRect1.right = rect5.left; + mRect1.bottom = rect5.bottom; + + mRect2.top = rect6.top; + mRect2.left = rect6.left; + mRect2.bottom = rect5.top - 15; + mRect2.right = rect5.right; + + newDlgTmp.mStatic.GetWindowRect(rect5); + newDlgTmp.ScreenToClient(rect5); + + rect6 = rect5; + + rect5.OffsetRect(rect3.right - rect4.right, rect3.bottom - rect4.bottom); + rect5.top = rect5.bottom - 68; + rect5.left = rect6.left; + rect5.right = rect5.left + 18; + + mButton3.Create(NULL, BS_ICON | WS_CHILD, rect5, this, 106); + mButton3.SetFont(&mFont); + mButton3.ShowWindow(SW_SHOW); + mButton3.SetIcon(AfxGetApp()->LoadIcon(168)); + + mButton3.EnableWindow(false); + + mRect1.left = rect5.right; + + GetClientRect(mRect3); + + newDlgTmp.DestroyWindow(); + + return 0; +} + +BOOL T2NewDlg::OnQueryNewPalette() { + CDC *pDC = GetDC(); + int save = pDC->SaveDC(); + + pDC->SelectPalette(&mPalette, false); + pDC->RealizePalette(); + + pDC->RestoreDC(save); + ReleaseDC(pDC); + return true; +} + +void T2NewDlg::OnCommandOK() { + mDocument->towerDoc_vfCC(GetSelectedPlugin(), false); + DestroyWindow(); +} + +void T2NewDlg::OnCommandCancel() { +} + +void T2NewDlg::OnCommand106() { + GoLeft(); +} + +void T2NewDlg::OnCommand107() { + GoRight(); +} + +BOOL T2NewDlg::OnEraseBkgnd(CDC *pDC) { +#pragma var_order(brush3, bitmap, newSave2, pen2, newSave, pen3, brush1, save, newDC, index, pen1, maxPlugin, brush2) + int save = pDC->SaveDC(); + pDC->SelectPalette(&mPalette, false); + pDC->RealizePalette(); + + CBitmap bitmap; + bitmap.CreateCompatibleBitmap(pDC, mRect3.Width(), mRect3.Height()); + + CDC newDC; + newDC.CreateCompatibleDC(pDC); + int newSave = newDC.SaveDC(); + + newDC.SelectObject(bitmap); + newDC.SelectPalette(&mPalette, false); + newDC.RealizePalette(); + newDC.SetStretchBltMode(COLORONCOLOR); + + CBrush brush1, brush2, brush3; + brush1.CreateSysColorBrush(COLOR_BTNFACE); + brush2.CreateSolidBrush(PALETTERGB(255, 255, 255)); + brush3.CreateSolidBrush(PALETTERGB(200, 0, 0)); + + CPen pen1, pen2, pen3; + pen1.CreatePen(PS_SOLID, 0, GetSysColor(COLOR_BTNHIGHLIGHT)); + pen2.CreatePen(PS_SOLID, 0, GetSysColor(COLOR_BTNSHADOW)); + pen3.CreatePen(PS_SOLID, 0, PALETTERGB(0, 0, 0)); + + newDC.FillRect(mRect3, &brush1); + + newDC.SelectObject(brush2); + newDC.SelectObject(pen3); + newDC.Rectangle(mRect1.left + 1, mRect1.top + 1, mRect1.right - 1, mRect1.bottom - 1); + + newDC.SelectObject(pen2); + newDC.MoveTo(mRect1.right - 1, mRect1.top); + newDC.LineTo(mRect1.left, mRect1.top); + newDC.LineTo(mRect1.left, mRect1.bottom); + + newDC.SelectObject(pen1); + newDC.MoveTo(mRect1.left, mRect1.bottom - 1); + newDC.LineTo(mRect1.right - 1, mRect1.bottom - 1); + newDC.LineTo(mRect1.right - 1, mRect1.top); + + int maxPlugin = min(mScrollOffset + 6, mPluginCount); + for (int index = mScrollOffset; index < maxPlugin; index++) { + int x = (index - mScrollOffset) * 70 + mRect1.left + 2; + + CRect rect1; + rect1.SetRect(x, mRect1.top + 2, x + 70, mRect1.bottom - 2); + + if (index == mSelectedPlugin) { + CRect rect2; + rect2.top = rect1.CenterPoint().y - mPlugins[index].icon->mBitmap.header.biHeight / 2; + rect2.left = rect1.CenterPoint().x - mPlugins[index].icon->mBitmap.header.biWidth / 2; + rect2.bottom = rect2.top + mPlugins[index].icon->mBitmap.header.biHeight; + rect2.right = rect2.left + mPlugins[index].icon->mBitmap.header.biWidth; + + CRect rect3 = rect2; + rect3.top -= 2; + rect3.left -= 2; + rect3.bottom += 2; + rect3.right += 2; + + newDC.FillRect(rect3, &brush3); + + memcpy(&mPlugins[index].icon->mBitmap.palette, mPal1, sizeof(short) * 256); + StretchDIBits( + newDC.m_hDC, + rect2.left, + rect2.bottom - 1, + rect2.Width(), + -rect2.Height(), + 0, + 0, + mPlugins[index].icon->mBitmap.header.biWidth, + mPlugins[index].icon->mBitmap.header.biHeight, + mPlugins[index].icon->mData, + (const BITMAPINFO *) &mPlugins[index].icon->mBitmap, + DIB_PAL_COLORS, + SRCCOPY + ); + } else { + CRect rect2; + rect2.top = rect1.CenterPoint().y - 25; + rect2.left = rect1.CenterPoint().x - 25; + rect2.bottom = rect2.top + 50; + rect2.right = rect2.left + 50; + + memcpy(&mPlugins[index].icon->mBitmap.palette, mPal2, sizeof(short) * 256); + + newDC.SelectObject(mBrush); + StretchDIBits( + newDC.m_hDC, + rect2.left, + rect2.bottom - 1, + rect2.Width(), + -rect2.Height(), + 0, + 0, + mPlugins[index].icon->mBitmap.header.biWidth, + mPlugins[index].icon->mBitmap.header.biHeight, + mPlugins[index].icon->mData, + (const BITMAPINFO *) &mPlugins[index].icon->mBitmap, + DIB_PAL_COLORS, + 0xCA0749 + ); + } + } + + int newSave2 = newDC.SaveDC(); + newDC.SetViewportOrg(mRect2.TopLeft()); + newDC.SetViewportExt(mRect2.Width(), mRect2.Height()); + DrawWorldPreview(&newDC); + newDC.RestoreDC(newSave2); + + pDC->BitBlt(0, 0, mRect3.Width(), mRect3.Height(), &newDC, 0, 0, SRCCOPY); + + newDC.RestoreDC(newSave); + + pDC->RestoreDC(save); + return true; +} + +void T2NewDlg::GoLeft() { +#pragma var_order(bitmap, newSave, brush, save, newDC, i, left, pDC) + if (mSelectedPlugin <= 0) + return; + + mSelectedPlugin--; + if (mSelectedPlugin < mScrollOffset) + mScrollOffset = mSelectedPlugin; + + if (mSelectedPlugin == 0) { + mButton3.EnableWindow(false); + SetFocus(); + } else { + mButton3.EnableWindow(true); + } + + if (mSelectedPlugin < (mPluginCount - 1)) + mButton4.EnableWindow(true); + + InvalidateRect(mRect1); + UpdateWindow(); + + CDC *pDC = GetDC(); + int save = pDC->SaveDC(); + + CBrush brush; + brush.CreateSysColorBrush(COLOR_BTNFACE); + + CBitmap bitmap; + bitmap.CreateCompatibleBitmap(pDC, mRect3.Width(), mRect3.Height()); + + CDC newDC; + newDC.CreateCompatibleDC(pDC); + int newSave = newDC.SaveDC(); + + newDC.SelectObject(bitmap); + newDC.SelectPalette(&mPalette, false); + newDC.RealizePalette(); + newDC.SetStretchBltMode(COLORONCOLOR); + + DrawWorldPreview(&newDC); + + int left = mRect2.left; + for (int i = 1; i <= 10; i++) { + int right = mRect2.left + ((mRect3.right - mRect2.left) * i) / 10; + pDC->BitBlt(right, mRect2.top, mRect2.Width(), mRect2.Height(), pDC, left, mRect2.top, SRCCOPY); + + left = right; + pDC->BitBlt(mRect2.left, mRect2.top, right - mRect2.left, mRect2.Height(), &newDC, 0, 0, SRCCOPY); + + if (right >= mRect2.right) { + CRect rect; + rect.SetRect(mRect2.right, mRect2.top, mRect3.right, mRect2.bottom); + pDC->FillRect(rect, &brush); + } + + Sleep(30); + } + + newDC.RestoreDC(newSave); + + pDC->RestoreDC(save); + ReleaseDC(pDC); +} + +void T2NewDlg::GoRight() { +#pragma var_order(bitmap, newSave, brush, save, newDC, i, pDC) + if (mSelectedPlugin >= (mPluginCount - 1)) + return; + + mSelectedPlugin++; + if (mSelectedPlugin >= (mScrollOffset + 6)) + mScrollOffset = mSelectedPlugin - 5; + + if (mSelectedPlugin != 0) + mButton3.EnableWindow(true); + + if (mSelectedPlugin < (mPluginCount - 1)) { + mButton4.EnableWindow(true); + } else { + mButton4.EnableWindow(false); + SetFocus(); + } + + InvalidateRect(mRect1); + UpdateWindow(); + + CDC *pDC = GetDC(); + int save = pDC->SaveDC(); + + CBrush brush; + brush.CreateSysColorBrush(COLOR_BTNFACE); + + CBitmap bitmap; + bitmap.CreateCompatibleBitmap(pDC, mRect3.Width(), mRect3.Height()); + + CDC newDC; + newDC.CreateCompatibleDC(pDC); + int newSave = newDC.SaveDC(); + + newDC.SelectObject(bitmap); + newDC.SelectPalette(&mPalette, false); + newDC.RealizePalette(); + newDC.SetStretchBltMode(COLORONCOLOR); + + DrawWorldPreview(&newDC); + + for (int i = 1; i <= 10; i++) { + int x = mRect3.right - ((mRect3.right - mRect2.left) * i) / 10; + pDC->BitBlt(x, mRect2.top, mRect2.Width(), mRect2.Height(), &newDC, 0, 0, SRCCOPY); + + x += mRect2.Width(); + + if (x < mRect3.right) { + CRect rect; + rect.SetRect(x, mRect2.top, mRect3.right, mRect2.bottom); + pDC->FillRect(rect, &brush); + } + + Sleep(30); + } + + newDC.RestoreDC(newSave); + + pDC->RestoreDC(save); + ReleaseDC(pDC); +} + +/*virtual*/ BOOL T2NewDlg::PreTranslateMessage(MSG *pMsg) { + if (pMsg->message == WM_KEYDOWN) { + BOOL shift = (GetAsyncKeyState(VK_SHIFT) < 0); + BOOL control = (GetAsyncKeyState(VK_CONTROL) < 0); + + if (pMsg->wParam == VK_LEFT && !shift && !control) { + GoLeft(); + return true; + } + if (pMsg->wParam == VK_RIGHT && !shift && !control) { + GoRight(); + return true; + } + } + + return CFrameWnd::PreTranslateMessage(pMsg); +} + +void T2NewDlg::DrawWorldPreview(CDC *pDC) { +#pragma var_order(pt2, clr1, str, brush3, rect1, pen2, clr2, rect3, pen3, brush1, font, previewWidth, rect2, clr3, save, x, previewHeight, pen4, pen1, pt, brush2) + CRect rect1 = mRect2; + rect1.OffsetRect(-rect1.left, -rect1.top); + + int save = pDC->SaveDC(); + + CBrush brush1, brush2, brush3; + brush1.CreateSysColorBrush(COLOR_BTNFACE); + brush2.CreateSolidBrush(PALETTERGB(255, 255, 255)); + brush3.CreateSolidBrush(PALETTERGB(200, 0, 0)); + + CPen pen1, pen2, pen3, pen4; + pen1.CreatePen(PS_SOLID, 0, GetSysColor(COLOR_BTNHIGHLIGHT)); + pen2.CreatePen(PS_SOLID, 0, GetSysColor(COLOR_BTNSHADOW)); + pen3.CreatePen(PS_SOLID, 0, PALETTERGB(0, 0, 0)); + pen4.CreatePen(PS_SOLID, 0, GetSysColor(COLOR_BTNTEXT)); + + COLORREF clr1 = GetSysColor(COLOR_BTNHIGHLIGHT); + COLORREF clr2 = GetSysColor(COLOR_BTNSHADOW); + COLORREF clr3 = GetSysColor(COLOR_BTNTEXT); + + pDC->FillRect(rect1, &brush1); + + pDC->SelectObject(pen1); + + pDC->MoveTo(rect1.right - 1, rect1.top); + pDC->LineTo(rect1.left, rect1.top); + pDC->LineTo(rect1.left, rect1.bottom); + + pDC->MoveTo(rect1.right - 1, rect1.top + 1); + pDC->LineTo(rect1.left + 1, rect1.top + 1); + pDC->LineTo(rect1.left + 1, rect1.bottom); + + pDC->SelectObject(pen2); + + pDC->MoveTo(rect1.right - 1, rect1.top + 1); + pDC->LineTo(rect1.right - 1, rect1.bottom - 1); + pDC->LineTo(rect1.left - 1, rect1.bottom - 1); + + pDC->MoveTo(rect1.right - 2, rect1.top + 2); + pDC->LineTo(rect1.right - 2, rect1.bottom - 2); + pDC->LineTo(rect1.left, rect1.bottom - 2); + + CRect rect2; + int previewWidth = mPlugins[mSelectedPlugin].preview->mBitmap.header.biWidth; + int previewHeight = mPlugins[mSelectedPlugin].preview->mBitmap.header.biHeight; + + rect2.top = (rect1.Height() - previewHeight) / 2; + rect2.left = rect2.top - rect1.top; + rect2.bottom = rect2.top + previewHeight; + rect2.right = rect2.left + previewWidth; + + pDC->SelectObject(pen2); + + pDC->MoveTo(rect2.right, rect2.top - 1); + pDC->LineTo(rect2.left - 1, rect2.top - 1); + pDC->LineTo(rect2.left - 1, rect2.bottom + 1); + + pDC->SelectObject(pen1); + + pDC->MoveTo(rect2.right, rect2.top); + pDC->LineTo(rect2.right, rect2.bottom); + pDC->LineTo(rect2.left - 2, rect2.bottom); + + StretchDIBits( + pDC->m_hDC, + rect2.left, + rect2.bottom - 1, + rect2.Width(), + -rect2.Height(), + 0, + 0, + previewWidth, + previewHeight, + mPlugins[mSelectedPlugin].preview->mData, + (const BITMAPINFO *) &mPlugins[mSelectedPlugin].preview->mBitmap, + DIB_PAL_COLORS, + SRCCOPY + ); + + CPoint pt; + pt.x = rect2.right + (rect2.left - rect1.left); + pt.y = rect2.left; + + pDC->SetBkMode(TRANSPARENT); + + CFont font; + font.CreateFont(-24, 0, 0, 0, FW_BOLD, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x82\x6F\x83\x53\x83\x56\x83\x62\x83\x4E"); + + CString str = *mPlugins[mSelectedPlugin].mStr8; + + pDC->SelectObject(font); + + pDC->SetTextColor(clr1); + pDC->TextOut(pt.x - 1, pt.y - 1, str); + pDC->SetTextColor(clr2); + pDC->TextOut(pt.x + 1, pt.y + 1, str); + pDC->SetTextColor(clr3); + pDC->TextOut(pt.x, pt.y, str); + + font.Detach(); + font.CreateFont(-14, 0, 0, 0, FW_BOLD, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x82\x6F\x83\x53\x83\x56\x83\x62\x83\x4E"); + pDC->SelectObject(&font)->DeleteObject(); + + pt.y += 38; + pt.x += 12; + + CPoint pt2 = pt; + + str = "\x8F\x89\x8A\xFA\x8E\x91\x8B\xE0"; + pDC->SetTextColor(clr1); + pDC->TextOut(pt.x + 1, pt.y + 1, str); + pDC->SetTextColor(clr3); + pDC->TextOut(pt.x, pt.y, str); + + pt.y += 23; + + str = "\x8D\x82\x82\xB3\x90\xA7\x8C\xC0"; + pDC->SetTextColor(clr1); + pDC->TextOut(pt.x + 1, pt.y + 1, str); + pDC->SetTextColor(clr3); + pDC->TextOut(pt.x, pt.y, str); + + pt.y += 23; + + str = "\x89\xF0\x90\xE0"; + pDC->SetTextColor(clr1); + pDC->TextOut(pt.x + 1, pt.y + 1, str); + pDC->SetTextColor(clr3); + pDC->TextOut(pt.x, pt.y, str); + + CRect rect3; + rect3.left = pt.x + 15; + rect3.top = pt.y + 20; + rect3.right = rect1.right - (rect2.left - rect1.left); + rect3.bottom = rect1.bottom - (rect2.left - rect1.left); + + pt = pt2; + + pt.x += pDC->GetTextExtent("\x81\x97\x81\x97\x81\x97\x81\x97").cx + 3; + + pt2 = pt; + + int x = rect1.right - (rect2.left - rect1.left); + + pDC->SelectObject(pen4); + pDC->MoveTo(pt.x, pt.y + 14); + pDC->LineTo(x, pt.y + 14); + + pDC->SelectObject(pen1); + pDC->MoveTo(pt.x + 1, pt.y + 15); + pDC->LineTo(x + 1, pt.y + 15); + + pt.y += 23; + + pDC->SelectObject(pen4); + pDC->MoveTo(pt.x, pt.y + 14); + pDC->LineTo(x, pt.y + 14); + + pDC->SelectObject(pen1); + pDC->MoveTo(pt.x + 1, pt.y + 15); + pDC->LineTo(x + 1, pt.y + 15); + + font.Detach(); + font.CreateFont(-14, 0, 0, 0, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x82\x6F\x83\x53\x83\x56\x83\x62\x83\x4E"); + pDC->SelectObject(&font)->DeleteObject(); + + pDC->SetTextColor(clr3); + + pt = pt2; + pt.x = x; + + str.Format("%d\x96\x9C\x89\x7E", mPlugins[mSelectedPlugin].mStrC); + pDC->TextOut(pt.x - pDC->GetTextExtent(str).cx, pt.y, str); + + pt.y += 23; + + str.Format("%d\x8A\x4B", mPlugins[mSelectedPlugin].mStr10); + pDC->TextOut(pt.x - pDC->GetTextExtent(str).cx, pt.y, str); + + pDC->DrawText(*mPlugins[mSelectedPlugin].mStr18, rect3, DT_WORDBREAK); + + pDC->RestoreDC(save); +} diff --git a/src/T2NewDlg.h b/src/T2NewDlg.h index fcaf1ff..5412231 100644 --- a/src/T2NewDlg.h +++ b/src/T2NewDlg.h @@ -1,3 +1,62 @@ #pragma once #include "common.h" +struct PluginRecord { + T2BitImage *preview; + T2BitImage *icon; + CString *mStr8; + CString *mStrC; + CString *mStr10; + void *_14; + CString *mStr18; +}; + +class T2NewDlg : public CFrameWnd { + DECLARE_DYNCREATE(T2NewDlg) + DECLARE_MESSAGE_MAP() + +public: + T2NewDlg(); + virtual ~T2NewDlg(); + virtual BOOL PreTranslateMessage(MSG *pMsg); + void Setup(T2TowerDoc *inDoc, T2PluginLoader *inPluginLoader, BOOL inShowCancelButton); + T2PluginSpecifier *GetSelectedPlugin(); + +protected: + virtual BOOL PreCreateWindow(CREATESTRUCT &cs); + + afx_msg void OnClose(); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg BOOL OnQueryNewPalette(); + afx_msg void OnCommandOK(); + afx_msg void OnCommandCancel(); + afx_msg void OnCommand106(); + afx_msg void OnCommand107(); + afx_msg BOOL OnEraseBkgnd(CDC *pDC); + void GoLeft(); + void GoRight(); + void DrawWorldPreview(CDC *pDC); + + T2PluginLoader *mPluginLoader; + BOOL mShowCancelButton; + T2TowerDoc *mDocument; + CFont mFont; + CPalette mPalette; + short *mPal1; + short *mPal2; + CBitmap mBitmap; + CBrush mBrush; + PluginRecord *mPlugins; + int mPluginCount; + int mScrollOffset; + int _100; + int mSelectedPlugin; + CRect mRect1; + CRect mRect2; + CRect mRect3; + CButton mButton1; + CButton mButton2; + CButton mButton3; + CButton mButton4; +}; diff --git a/src/T2NewDlgTmp.cpp b/src/T2NewDlgTmp.cpp index 1c8b940..af5b407 100644 --- a/src/T2NewDlgTmp.cpp +++ b/src/T2NewDlgTmp.cpp @@ -1,2 +1,22 @@ #include "T2NewDlgTmp.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +T2NewDlgTmp::T2NewDlgTmp(CWnd *pParentWnd) + : CDialog(166, pParentWnd) +{ +} + +/*virtual*/ void T2NewDlgTmp::DoDataExchange(CDataExchange *pDX) { + CWnd::DoDataExchange(pDX); + DDX_Control(pDX, 1, mOKButton); + DDX_Control(pDX, 2, mCancelButton); + DDX_Control(pDX, 1018, mStatic); +} + +BEGIN_MESSAGE_MAP(T2NewDlgTmp, CDialog) +END_MESSAGE_MAP() diff --git a/src/T2NewDlgTmp.h b/src/T2NewDlgTmp.h index fcaf1ff..9c82334 100644 --- a/src/T2NewDlgTmp.h +++ b/src/T2NewDlgTmp.h @@ -1,3 +1,16 @@ #pragma once #include "common.h" +class T2NewDlgTmp : public CDialog { + DECLARE_MESSAGE_MAP() + +public: + T2NewDlgTmp(CWnd *pParentWnd); + + CButton mOKButton; + CButton mCancelButton; + CStatic mStatic; + +protected: + virtual void DoDataExchange(CDataExchange *pDX); +}; diff --git a/src/T2OpenFileDialog.cpp b/src/T2OpenFileDialog.cpp index 4fef5f2..5aa86f8 100644 --- a/src/T2OpenFileDialog.cpp +++ b/src/T2OpenFileDialog.cpp @@ -1,2 +1,30 @@ #include "T2OpenFileDialog.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +IMPLEMENT_DYNAMIC(T2OpenFileDialog, CFileDialog) + +T2OpenFileDialog::T2OpenFileDialog(BOOL bOpenFileDialog, const CHAR *lpszDefExt, const CHAR *lpszFileName, + DWORD dwFlags, const CHAR *lpszFilter, CWnd *pParentWnd) + : CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd) +{ +} + +BEGIN_MESSAGE_MAP(T2OpenFileDialog, CCommonDialog) + ON_WM_CLOSE() +END_MESSAGE_MAP() + +/*virtual*/ BOOL T2OpenFileDialog::OnInitDialog() { + return true; +} + +/*virtual*/ void T2OpenFileDialog::OnFileNameChange() { +} + +void T2OpenFileDialog::OnClose() { + CWnd::OnClose(); +} diff --git a/src/T2OpenFileDialog.h b/src/T2OpenFileDialog.h index fcaf1ff..0fcca2f 100644 --- a/src/T2OpenFileDialog.h +++ b/src/T2OpenFileDialog.h @@ -1,3 +1,20 @@ #pragma once #include "common.h" +#include "T2FilePreview.h" +#include <AFXEXT.H> +class T2OpenFileDialog : public CFileDialog { + DECLARE_DYNAMIC(T2OpenFileDialog) + DECLARE_MESSAGE_MAP() + +public: + T2OpenFileDialog(BOOL bOpenFileDialog, const CHAR *lpszDefExt, const CHAR *lpszFileName, DWORD dwFlags, + const CHAR *lpszFilter, CWnd *pParentWnd); + virtual BOOL OnInitDialog(); + +protected: + virtual void OnFileNameChange(); + afx_msg void OnClose(); + + T2FilePreview mFilePreview; +}; diff --git a/src/T2OpenSelectDlg.cpp b/src/T2OpenSelectDlg.cpp index 1a86321..e0e2d99 100644 --- a/src/T2OpenSelectDlg.cpp +++ b/src/T2OpenSelectDlg.cpp @@ -1,2 +1,167 @@ +#include "Bitmap.h" +#include "GlobalFunc.h" +#include "T2.h" +#include "T2BitImage.h" +#include "T2DLL.h" +#include "T2ImageObj.h" #include "T2OpenSelectDlg.h" +#include "T2TowerDoc.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +static CWnd *unknownWindow; + +T2OpenSelectDlg::T2OpenSelectDlg(T2TowerDoc *inDoc) { + mTowerDoc = inDoc; + +#line 29 + mBitmap = new Bitmap; + mBitmap->LoadFile("T2S.dat"); + + mDeleteOnClose = true; +} + +/*virtual*/ T2OpenSelectDlg::~T2OpenSelectDlg() { + delete mBitmap; + + if (mImageObj) + delete mImageObj; + if (mImage) + delete mImage; + + free(mPal1); + free(mPal2); +} + +void T2OpenSelectDlg::Setup() { + CBitmap theBitmap; + CBrush theBrush; + + HRSRC resource = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(174), "PALETTE"); + HGLOBAL theHandle = LoadResource(AfxGetApp()->m_hInstance, resource); + void *resData = LockResource(theHandle); + + LOGPALETTE *theLogPalette = ConvACTPalette((ACTPALETTEENTRY *) resData); + mPalette2.CreatePalette(theLogPalette); + + int i; + + mPal1 = (short *) malloc(sizeof(short) * 256); + for (i = 0; i < 256; i++) + mPal1[i] = i; + + mPal2 = (short *) malloc(sizeof(short) * 256); + for (i = 0; i < 256; i++) { + int r = theLogPalette->palPalEntry[i].peRed; + int g = theLogPalette->palPalEntry[i].peGreen; + int b = theLogPalette->palPalEntry[i].peBlue; + int index = mPalette2.GetNearestPaletteIndex(RGB(r, g, b)); + + if (theLogPalette->palPalEntry[index].peRed == 1 && theLogPalette->palPalEntry[index].peGreen == 1 && theLogPalette->palPalEntry[index].peBlue == 1) + index = 255; + + mPal2[i] = index; + } + + free(theLogPalette); + + theBitmap.LoadBitmap(170); + theBrush.CreatePatternBrush(&theBitmap); +} + +int T2OpenSelectDlg::ShowOpenSelectDialog() { + Setup(); + + CRect rect; + GetDesktopWindow()->GetWindowRect(rect); + + HINSTANCE instance = AfxGetInstanceHandle(); + + T2DLGTEMPLATE tmpl; + tmpl.pt = rect.CenterPoint(); + tmpl.moduleHandle = instance; + tmpl.resID = 1000; + + T2TowerDoc *theDoc = NULL; + +#line 137 + mImageObj = new T2ImageObj; + mImage = new T2BitImage(instance, 172, true); + mImageObj->AddObject(instance, 172, mImage); + + Realize(this, &tmpl, theDoc, mImageObj, &mPalette2, true, NULL, 0, false); + + if (gT2App->mStrE0 != "") { + PostMessage(WM_COMMAND, 103); + } else { + ShowWindow(SW_SHOW); + SetActiveWindow(); + } + + return 0; +} + +/*virtual*/ void T2OpenSelectDlg::ListenToMessage(unsigned int msg, void *data) { +} + +/*virtual*/ BOOL T2OpenSelectDlg::OnT2DialogCommand(WPARAM inWParam, LPARAM inLParam) { + BOOL result = true; + WORD code = HIWORD(inWParam); + WORD id = LOWORD(inWParam); + + if (id == 101 && code == 0) { + ShowWindow(SW_HIDE); + mTowerDoc->LoadsWorldPlugin(); + DoClose(id); + } else if (id == 102 && code == 0) { + ShowWindow(SW_HIDE); + T2_APP->OnCmdOpen(); + DoClose(id); + } else if (id == 100 && code == 0) { + PostQuitMessage(0); + DoClose(id); + } else if (id == 103 && code == 0) { + GetCurrentT2TowerDoc()->SetPathName(gT2App->mStrE0); + GetCurrentT2TowerDoc()->OnOpenDocument(gT2App->mStrE0); + gT2App->mStrE0 = ""; + DoClose(id); + } + + return result; +} + +/*virtual*/ BOOL T2OpenSelectDlg::OnT2EraseBkgnd(CDC *pDC) { +#pragma var_order(paletteH, result, dc, hdc, palette) + unknownWindow = GetActiveWindow(); + + SetFocus(); + SetActiveWindow(); + + BOOL result = true; + + CPaintDC dc(this); + HDC hdc = dc; + HPALETTE paletteH = mBitmap->CreatePalette(); + CPalette palette; + + SelectPalette(dc, paletteH, false); + RealizePalette(dc); + + mBitmap->Draw(hdc, 0, 0); + + SelectPalette(hdc, palette, false); + DeleteObject(paletteH); + + return result; +} + +/*virtual*/ void T2OpenSelectDlg::vfF4() { + OnClose(); +} + +/*virtual*/ void T2OpenSelectDlg::vfF8(int unk1, int unk2) { +} diff --git a/src/T2OpenSelectDlg.h b/src/T2OpenSelectDlg.h index fcaf1ff..e65486a 100644 --- a/src/T2OpenSelectDlg.h +++ b/src/T2OpenSelectDlg.h @@ -1,3 +1,31 @@ #pragma once #include "common.h" +#include "T2Dialog.h" +class Bitmap; + +class T2OpenSelectDlg : public T2Dialog { +public: + T2OpenSelectDlg(T2TowerDoc *inDoc); + virtual ~T2OpenSelectDlg(); + + void Setup(); + int ShowOpenSelectDialog(); + virtual void ListenToMessage(unsigned int msg, void *data); + +protected: + virtual BOOL OnT2DialogCommand(WPARAM inWParam, LPARAM inLParam); + virtual BOOL OnT2EraseBkgnd(CDC *pDC); + virtual void vfF4(); + virtual void vfF8(int unk1, int unk2); + + CPalette mPalette1; + T2TowerDoc *mTowerDoc; + CPalette mPalette2; + T2BitImage *mImage; + T2ImageObj *mImageObj; + int _114; + short *mPal1; + short *mPal2; + Bitmap *mBitmap; +}; diff --git a/src/T2OpenningWindow.cpp b/src/T2OpenningWindow.cpp index d16135f..ee1cb40 100644 --- a/src/T2OpenningWindow.cpp +++ b/src/T2OpenningWindow.cpp @@ -1,2 +1,144 @@ +#include "Bitmap.h" +#include "T2.h" #include "T2OpenningWindow.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#line 27 +IMPLEMENT_DYNCREATE(T2OpenningWindow, CFrameWnd) + +T2OpenningWindow::T2OpenningWindow() { + _CC = 1; + +#line 32 + mBitmap = new Bitmap; + if (!mBitmap->LoadFile("T2.dat")) { + delete mBitmap; + mBitmap = NULL; + } +} + +/*virtual*/ T2OpenningWindow::~T2OpenningWindow() { + if (mBitmap) + delete mBitmap; +} + +BEGIN_MESSAGE_MAP(T2OpenningWindow, CFrameWnd) + ON_WM_PAINT() + ON_WM_LBUTTONDOWN() + ON_WM_ERASEBKGND() +END_MESSAGE_MAP() + +void T2OpenningWindow::ShowOpenningWindow() { + CString text; + + mWndClass = AfxRegisterWndClass(0, NULL, (HBRUSH) GetStockObject(BLACK_BRUSH)); + + RECT windowRect; + windowRect.left = 0; + windowRect.top = 0; + windowRect.right = 640; + windowRect.bottom = 480; + + Create(mWndClass, text, WS_MAXIMIZE | WS_POPUP, windowRect, AfxGetMainWnd(), NULL, WS_EX_TOPMOST); + + RECT rect; + ::GetWindowRect(::GetDesktopWindow(), &rect); + MoveWindow(-5, -5, rect.right + 10, rect.bottom + 10); + ShowWindow(SW_SHOW); + SetActiveWindow(); + + PlaySound(MAKEINTRESOURCE(1), AfxGetInstanceHandle(), SND_ASYNC | SND_NOWAIT | SND_RESOURCE); + T2_APP->app_vfB4(); + + DWORD startTick = GetTickCount(); + while (labs(GetTickCount() - startTick) < 2000) + T2_APP->app_vfB4(); + + if (mBitmap) + _CC = 0; + + InvalidateRect(NULL); + + startTick = GetTickCount(); + while (labs(GetTickCount() - startTick) < 3000) + T2_APP->app_vfB4(); + + ShowWindow(SW_HIDE); + DestroyWindow(); +} + +void T2OpenningWindow::OnPaint() { +#pragma var_order(rect, centerY, dc, centerX) + CPaintDC dc(this); + + RECT rect; + ::GetWindowRect(::GetDesktopWindow(), &rect); + int centerX = rect.right / 2; + int centerY = rect.bottom / 2; + + if (_CC == 0) { +#pragma var_order(paletteH, width, height, hdc, palette) + HDC hdc = dc; + HPALETTE paletteH = mBitmap->CreatePalette(); + CPalette palette; + + SelectPalette(dc, paletteH, false); + RealizePalette(dc); + + int width = mBitmap->GetWidth(); + int height = mBitmap->GetHeight(); + mBitmap->Draw(hdc, centerX - width / 2, centerY - height / 2); + + SelectPalette(hdc, palette, false); + DeleteObject(paletteH); + } + + if (_CC == 1) { + CDC newDC; + + CBitmap bitmap; + bitmap.LoadBitmap(175); + + newDC.CreateCompatibleDC(&dc); + newDC.SelectObject(&bitmap); + dc.SelectPalette(&mPalette, false); + dc.RealizePalette(); + dc.BitBlt(centerX - 240, centerY - 188, 480, 376, &newDC, 0, 0, SRCCOPY); + } +} + +void T2OpenningWindow::OnLButtonDown(UINT nFlags, CPoint point) { + CWnd::OnLButtonDown(nFlags, point); +} + +BOOL T2OpenningWindow::OnEraseBkgnd(CDC *pDC) { +#pragma var_order(brush, pen, clientRect, windowRect) + CBrush brush; + brush.CreateSolidBrush(PALETTERGB(204, 204, 204)); + + CRect clientRect; + GetClientRect(clientRect); + + CPen pen; + pen.CreatePen(PS_SOLID, 0, PALETTERGB(255, 0, 0)); + + CRect windowRect; + GetWindowRect(windowRect); + + pDC->SelectObject(pen); + + pDC->MoveTo(windowRect.right, windowRect.top); + pDC->LineTo(windowRect.left - 1, windowRect.top); + pDC->LineTo(windowRect.left - 1, windowRect.bottom); + + pDC->MoveTo(windowRect.right, windowRect.top); + pDC->LineTo(windowRect.right, windowRect.bottom); + pDC->LineTo(windowRect.left, windowRect.bottom); + + return CFrameWnd::OnEraseBkgnd(pDC); +} diff --git a/src/T2OpenningWindow.h b/src/T2OpenningWindow.h index fcaf1ff..7695cbc 100644 --- a/src/T2OpenningWindow.h +++ b/src/T2OpenningWindow.h @@ -1,3 +1,25 @@ #pragma once #include "common.h" +class Bitmap; + +class T2OpenningWindow : public CFrameWnd { + DECLARE_DYNCREATE(T2OpenningWindow) + DECLARE_MESSAGE_MAP() + +public: + T2OpenningWindow(); + virtual ~T2OpenningWindow(); + void ShowOpenningWindow(); + +protected: + void OnPaint(); + void OnLButtonDown(UINT nFlags, CPoint point); + BOOL OnEraseBkgnd(CDC *pDC); + + Bitmap *mBitmap; + CPalette mPalette; + int _CC; + int _D0; + CString mWndClass; +}; diff --git a/src/T2PoolView.cpp b/src/T2PoolView.cpp index 13cfae6..f02934a 100644 --- a/src/T2PoolView.cpp +++ b/src/T2PoolView.cpp @@ -1,2 +1,209 @@ +#include "T2PeopleDemandList.h" +#include "T2PeopleTimeZoneList.h" +#include "T2PeopleType.h" +#include "T2PeopleTypeArray.h" +#include "T2Pool.h" #include "T2PoolView.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#line 17 +IMPLEMENT_DYNCREATE(T2PoolView, CFrameWnd) + +T2PoolView::T2PoolView() { + mPool = NULL; +} + +T2PoolView::~T2PoolView() { +} + +BEGIN_MESSAGE_MAP(T2PoolView, CFrameWnd) + ON_WM_ERASEBKGND() + ON_WM_VSCROLL() + ON_WM_LBUTTONDOWN() +END_MESSAGE_MAP() + +void T2PoolView::SetPool(T2Pool *inPool) { + mPool = inPool; + InvalidateRect(NULL); +} + +BOOL T2PoolView::OnEraseBkgnd(CDC *pDC) { + Draw(pDC, NULL, NULL, NULL, NULL); + return true; +} + +void T2PoolView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) { + int minPos, maxPos; + GetScrollRange(SB_VERT, &minPos, &maxPos); + + int pos = GetScrollPos(SB_VERT); + switch (nSBCode) { + case SB_THUMBPOSITION: + case SB_THUMBTRACK: + pos = nPos; + break; + } + + SetScrollPos(SB_VERT, pos); + InvalidateRect(NULL); +} + +void T2PoolView::OnLButtonDown(UINT nFlags, CPoint point) { + T2PeopleTimeZoneList *peopleTimeZoneList = NULL;; + T2PeopleTypeArray *peopleTypeArray = NULL; + int weirdUnusedVariable = 0; // arbitrary name chosen to fit in + CDC *pDC = GetDC(); + + Draw(pDC, &point, &peopleTimeZoneList, &peopleTypeArray, &weirdUnusedVariable); + + if (peopleTimeZoneList && !peopleTypeArray && !weirdUnusedVariable) + peopleTimeZoneList->_20 = !peopleTimeZoneList->_20; + if (peopleTimeZoneList && peopleTypeArray && !weirdUnusedVariable) + peopleTypeArray->m20 = !peopleTypeArray->m20; + + ReleaseDC(pDC); + InvalidateRect(NULL); +} + +void T2PoolView::Draw(CDC *pDC, CPoint *inPt, T2PeopleTimeZoneList **outTimeZoneList, T2PeopleTypeArray **outPeopleTypeArray, int *outUnknown) { +#pragma var_order(peopleTimeZoneList, peopleDemandListIterator, peopleDemandList, str, font, save, totalPopulation, x, height, y, rect, pt, brush) + if (!mPool) + return; + + CPoint pt; + if (inPt) { + pt = *inPt; + } else { + pt.x = 0; + pt.y = 0; + } + + int save = pDC->SaveDC(); + + CRect rect; + GetClientRect(rect); + + pDC->SetTextColor(RGB(0, 0, 0)); + pDC->SetBkColor(RGB(255, 255, 255)); + + CBrush brush; + brush.CreateStockObject(WHITE_BRUSH); + if (!inPt) + pDC->FillRect(rect, &brush); + + CFont font; + font.CreateFont(-12, 0, 0, 0, FW_NORMAL, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, DRAFT_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); + + pDC->SelectObject(&font); + int height = pDC->GetTextExtent("A").cy + 1; + + int x = 4; + int y = -GetScrollPos(SB_VERT); + + CString str; + + T2PeopleDemandList *peopleDemandList = mPool->mDemandList; + LArrayIterator peopleDemandListIterator(*peopleDemandList); + + T2PeopleTimeZoneList *peopleTimeZoneList; + int totalPopulation = 0; + + while (peopleDemandListIterator.Next(&peopleTimeZoneList)) { +#pragma var_order(demandStartY, peopleTypeArray, demandTotal, peopleTimeZoneListIterator) + int demandStartY = y; + int demandTotal = 0; + + LArrayIterator peopleTimeZoneListIterator(*peopleTimeZoneList); + T2PeopleTypeArray *peopleTypeArray; + + while (peopleTimeZoneListIterator.Next(&peopleTypeArray)) { +#pragma var_order(peopleType, timeZoneStartY, peopleTypeArrayIterator, timeZoneTotal) + int timeZoneStartY = y; + int timeZoneTotal = 0; + + LArrayIterator peopleTypeArrayIterator(*peopleTypeArray); + T2PeopleType peopleType; + + while (peopleTypeArrayIterator.Next(&peopleType)) { + int peopleStartY = y; + + timeZoneTotal++; + demandTotal++; + totalPopulation++; + + if (peopleTypeArray->m20) { + str.Format( + " Sh=%-3d Dm=%-3d Tz=%-3d Lf=%-3d Et=%-3d", + peopleType.GetSilhouetteType(), + peopleType.GetDemandType(), + peopleType.GetTimeZoneType(), + peopleType.mLife, + peopleType.mEconoType + ); + + pDC->SetTextColor(RGB(0, 0, 0)); + pDC->SetBkColor(RGB(255, 255, 255)); + + pDC->TextOut(x, y, str); + y += height; + } + + if (peopleStartY <= pt.y && pt.y < y && outUnknown) + *outUnknown = 0; + } + + if (peopleTimeZoneList->_20) { + str.Format(" TimeZone total : %d", timeZoneTotal); + if (peopleTypeArray->m20) { + pDC->SetTextColor(RGB(255, 255, 255)); + pDC->SetBkColor(RGB(0, 0, 0)); + } else { + pDC->SetTextColor(RGB(0, 0, 0)); + pDC->SetBkColor(RGB(255, 255, 255)); + } + + pDC->TextOut(x, y, str); + y += height; + } + + if (timeZoneStartY <= pt.y && pt.y < y && outPeopleTypeArray) + *outPeopleTypeArray = peopleTypeArray; + } + + str.Format(" Demand total : %d", demandTotal); + if (peopleTimeZoneList->_20) { + pDC->SetTextColor(RGB(255, 255, 255)); + pDC->SetBkColor(RGB(0, 0, 0)); + } else { + pDC->SetTextColor(RGB(0, 0, 0)); + pDC->SetBkColor(RGB(255, 255, 255)); + } + + pDC->TextOut(x, y, str); + y += height; + + if (demandStartY <= pt.y && pt.y < y && outTimeZoneList) + *outTimeZoneList = peopleTimeZoneList; + } + + pDC->SetTextColor(RGB(255, 255, 255)); + pDC->SetBkColor(RGB(0, 0, 0)); + + str.Format("Total population : %d", totalPopulation); + pDC->TextOut(x, y, str); + + y += height; + + height = y + GetScrollPos(SB_VERT) - rect.Height(); + if (height > 0) + SetScrollRange(SB_VERT, 0, height); + else + SetScrollRange(SB_VERT, 0, 0); + + pDC->RestoreDC(save); +} diff --git a/src/T2PoolView.h b/src/T2PoolView.h index fcaf1ff..7b24545 100644 --- a/src/T2PoolView.h +++ b/src/T2PoolView.h @@ -1,3 +1,20 @@ #pragma once #include "common.h" +class T2PoolView : public CFrameWnd { + DECLARE_DYNCREATE(T2PoolView) + DECLARE_MESSAGE_MAP() + +public: + T2PoolView(); + virtual ~T2PoolView(); + void SetPool(T2Pool *inPool); + +protected: + afx_msg BOOL OnEraseBkgnd(CDC *pDC); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + void Draw(CDC *pDC, CPoint *inPt, T2PeopleTimeZoneList **outTimeZoneList, T2PeopleTypeArray **outPeopleTypeArray, int *outUnknown); + + T2Pool *mPool; +}; diff --git a/src/T2SysInfoDlg.cpp b/src/T2SysInfoDlg.cpp index b77a596..04377a6 100644 --- a/src/T2SysInfoDlg.cpp +++ b/src/T2SysInfoDlg.cpp @@ -1,2 +1,109 @@ +#include "T2PluginLoader.h" +#include "T2PluginSpecifier.h" #include "T2SysInfoDlg.h" +#include "T2TowerDoc.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +T2SysInfoDlg::T2SysInfoDlg(CWnd *pParentWnd) + : CDialog(159, pParentWnd) +{ +} + +/*virtual*/ void T2SysInfoDlg::DoDataExchange(CDataExchange *pDX) { + CWnd::DoDataExchange(pDX); + DDX_Control(pDX, 1009, mUsedMemory); + DDX_Control(pDX, 1008, mFreeMemory); + DDX_Control(pDX, 1007, mPluginList); +} + +BEGIN_MESSAGE_MAP(T2SysInfoDlg, CDialog) + ON_NOTIFY(LVN_COLUMNCLICK, 1007, OnColumnClick) +END_MESSAGE_MAP() + +void T2SysInfoDlg::SetDocument(T2TowerDoc *inDoc) { + mDocument = inDoc; +} + +BOOL T2SysInfoDlg::OnInitDialog() { + CDialog::OnInitDialog(); + + MEMORYSTATUS theGlobalMemStats; + theGlobalMemStats.dwLength = sizeof(theGlobalMemStats); + GlobalMemoryStatus(&theGlobalMemStats); + + CString str; + + str.Format("%d", theGlobalMemStats.dwAvailPageFile >> 10); + mFreeMemory.SetWindowText(str); + + str.Format("%d", (theGlobalMemStats.dwTotalVirtual - theGlobalMemStats.dwAvailVirtual) >> 10); + mUsedMemory.SetWindowText(str); + + RECT rect; + mPluginList.GetClientRect(&rect); + int width = rect.right; + + mPluginList.InsertColumn(0, "Name", LVCFMT_LEFT, (width * 6) / 20); + mPluginList.InsertColumn(1, "Type", LVCFMT_LEFT, (width * 3) / 20); + mPluginList.InsertColumn(2, "Lv", LVCFMT_LEFT, width / 20); + mPluginList.InsertColumn(3, "Stat", LVCFMT_LEFT, (width * 3) / 20); + mPluginList.InsertColumn(4, "File", LVCFMT_LEFT, width); + + POSITION pos; + T2PluginSpecifier *specifier; + mDocument->mT2PluginLoader->SetTypeFilter(pos, 0); + + while ((specifier = mDocument->mT2PluginLoader->GetNext(pos))) { + int index = mPluginList.InsertItem(0, specifier->mPluginName); + + CString text; + text = (char) ((specifier->mType >> 24) & 0xFF); + text += (char) ((specifier->mType >> 16) & 0xFF); + text += (char) ((specifier->mType >> 8) & 0xFF); + text += (char) (specifier->mType & 0xFF); + mPluginList.SetItemText(index, 1, text); + + text.Format("%d", specifier->mGameLevel); + mPluginList.SetItemText(index, 2, text); + + CString stat; + if (specifier->mIsLoaded) + stat = "Loaded"; + mPluginList.SetItemText(index, 3, stat); + + mPluginList.SetItemText(index, 4, specifier->mPath); + + mPluginList.SetItemData(index, (DWORD) specifier); + } + + return true; +} + +int CALLBACK doCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { + T2PluginSpecifier *specifierL = (T2PluginSpecifier *) lParam1; + T2PluginSpecifier *specifierR = (T2PluginSpecifier *) lParam2; + int compare = 0; + + if (lParamSort == 0) + compare = strcmp(specifierL->mPluginName, specifierR->mPluginName); + else if (lParamSort == 1) + compare = specifierL->mType - specifierR->mType; + else if (lParamSort == 2) + compare = specifierR->mIsLoaded - specifierL->mIsLoaded; + else if (lParamSort == 3) + compare = strcmp(specifierL->mPath, specifierR->mPath); + + return compare; +} + +void T2SysInfoDlg::OnColumnClick(NMHDR *pHdr, LRESULT *pResult) { + NMLISTVIEW *pnmv = (NMLISTVIEW *) pHdr; + + mPluginList.SortItems(doCompare, pnmv->iSubItem); + *pResult = 0; +} diff --git a/src/T2SysInfoDlg.h b/src/T2SysInfoDlg.h index fcaf1ff..e8d8d49 100644 --- a/src/T2SysInfoDlg.h +++ b/src/T2SysInfoDlg.h @@ -1,3 +1,20 @@ #pragma once #include "common.h" +class T2SysInfoDlg : public CDialog { + DECLARE_MESSAGE_MAP() + +public: + T2SysInfoDlg(CWnd *pParentWnd); + void SetDocument(T2TowerDoc *inDoc); + virtual BOOL OnInitDialog(); + +protected: + virtual void DoDataExchange(CDataExchange *pDX); + afx_msg void OnColumnClick(NMHDR *pHdr, LRESULT *pResult); + + CStatic mUsedMemory; + CStatic mFreeMemory; + CListCtrl mPluginList; + T2TowerDoc *mDocument; +}; diff --git a/src/T2TowerDoc.cpp b/src/T2TowerDoc.cpp new file mode 100644 index 0000000..f9bcf5f --- /dev/null +++ b/src/T2TowerDoc.cpp @@ -0,0 +1,4419 @@ +#include "CFilePluginList.h" +#include "CObjectQueue.h" +#include "CPluginInfoArray.h" +#include "CPluginInfo.h" +#include "DbgIPS.h" +#include "DbgPeopleView.h" +#include "DbgStepRun.h" +#include "GlobalFunc.h" +#include "T2.h" +#include "T2AdvertisePlugin.h" +#include "T2Archive.h" +#include "T2ArrowWnd.h" +#include "T2BitImage.h" +#include "T2CtrlPalette.h" +#include "T2DateTime.h" +#include "T2Dialog.h" +#include "T2DlgItemAnimation.h" +#include "T2DlgItemProgress.h" +#include "T2DlgItemText.h" +#include "T2DLL.h" +#include "T2FInfoAreaIterator.h" +#include "T2FInfoPtIterator.h" +#include "T2FloorInfo.h" +#include "T2HallEventPlugin.h" +#include "T2MainWindow.h" +#include "T2Mover.h" +#include "T2MoverArray.h" +#include "T2MoverArrayList.h" +#include "T2MoverDef.h" +#include "T2MoverPlugin.h" +#include "T2MoviePlugin.h" +#include "T2MoviePluginList.h" +#include "T2MsgWindow.h" +#include "T2MWControl.h" +#include "T2Name.h" +#include "T2NameList.h" +#include "T2OpenSelectDlg.h" +#include "T2OptionPluginList.h" +#include "T2OuterObjDef.h" +#include "T2OuterObjList.h" +#include "T2OuterObjPlugin.h" +#include "T2OutObj.h" +#include "T2OutObjArray.h" +#include "T2OutObjArrayList.h" +#include "T2PaletteAnime.h" +#include "T2People.h" +#include "T2PeopleArray.h" +#include "T2PeopleArrayList.h" +#include "T2PeopleDef.h" +#include "T2PeopleLoader.h" +#include "T2PluginInfoTable.h" +#include "T2PluginLoader.h" +#include "T2PluginSpecifier.h" +#include "T2Pool.h" +#include "T2PoolView.h" +#include "T2RegistedTenantDB.h" +#include "T2Request.h" +#include "T2RequestArrayList.h" +#include "T2RouteNavigator.h" +#include "T2SearchDialog.h" +#include "T2SettingDialog.h" +#include "T2Settlement.h" +#include "T2SilhouetteDef.h" +#include "T2SoundPlayer.h" +#include "T2StewardDialog.h" +#include "T2SysInfoDlg.h" +#include "T2TemplatePluginDB.h" +#include "T2TemplatePluginList.h" +#include "T2Tenant.h" +#include "T2TenantArray.h" +#include "T2TenantArrayList.h" +#include "T2TenantDef.h" +#include "T2TenantPlugin.h" +#include "T2ToolWindow.h" +#include "T2TowerDoc.h" +#include "T2TowerEvent.h" +#include "T2TowerMainView.h" +#include "T2TowerMessage.h" +#include "T2TrafficInfo.h" +#include "T2TreasureDialog.h" +#include "T2UnitInfo.h" +#include "T2WorldDef.h" +#include "T2WorldPlugin.h" +#include "T2WorldSelectDlg.h" +#include "UT2BkgndInfo.h" +#include "UT2Coordinate.h" +#include "UT2Utils.h" + +IMPLEMENT_DYNCREATE(T2TowerDoc, CDocument) + +BEGIN_MESSAGE_MAP(T2TowerDoc, CDocument) + ON_COMMAND(0x8009, OnSystemInformation) + ON_UPDATE_COMMAND_UI(0x800A, OnUpdateDebugStepRun) + ON_COMMAND(0x800A, OnDebugStepRun) + ON_UPDATE_COMMAND_UI(0x8010, OnUpdateDebugIdleSpeedMeasuring) + ON_COMMAND(0x8010, OnDebugIdleSpeedMeasuring) + ON_UPDATE_COMMAND_UI(0x8011, OnUpdateDebugAllLoadMeasuring) + ON_COMMAND(0x8011, OnDebugAllLoadMeasuring) + ON_UPDATE_COMMAND_UI(0x8012, OnUpdateDebugPool) + ON_COMMAND(0x8012, OnDebugPool) + ON_UPDATE_COMMAND_UI(0x8013, OnUpdateDebugDisplayIPS) + ON_COMMAND(0x8013, OnDebugDisplayIPS) + ON_UPDATE_COMMAND_UI(0x8014, OnUpdateDebugPeople) + ON_COMMAND(0x8014, OnDebugPeople) + ON_COMMAND(0x8015, OnDebugGradeUp) + ON_COMMAND(0x8016, OnDebugGradeDown) + ON_COMMAND(0x8019, OnPause) + ON_UPDATE_COMMAND_UI(0x8019, OnUpdatePause) + ON_COMMAND(0x801A, OnSetting) + ON_UPDATE_COMMAND_UI(0x801A, OnUpdateSetting) + ON_COMMAND(0x801B, OnHideElevatorRoom) + ON_UPDATE_COMMAND_UI(0x801B, OnUpdateHideElevatorRoom) + ON_COMMAND(0x8022, OnFavorite) + ON_UPDATE_COMMAND_UI(0x8022, OnUpdateFavorite) + ON_COMMAND(0x801F, OnHideControlWindow) + ON_UPDATE_COMMAND_UI(0x801F, OnUpdateHideControlWindow) + ON_COMMAND(0x8020, OnHideMessageWindow) + ON_UPDATE_COMMAND_UI(0x8020, OnUpdateHideMessageWindow) + ON_COMMAND(0x8021, OnHideToolWindow) + ON_UPDATE_COMMAND_UI(0x8021, OnUpdateHideToolWindow) +END_MESSAGE_MAP() + +T2TowerDoc::T2TowerDoc() { + g_TowerDoc = this; + gT2App->_E4 = 1; + m228 = 1; + _22C = false; + mNewDocFlag = true; + m208 = 0; + mTowerMainView = NULL; + mDestroyCallbackData = NULL; + mDestroyCallback = NULL; + + mWorldPluginID = 0; + mToolPaletteID = 1000; + + mWorldDef = NULL; + + mIsStuffLoadedFlag = false; + + _B0 = true; + mLastRequestedCursor = 256; + mCurrentCursorIndex = -1; + + _1F8 = 0; + mFundsOnClick = 0; + + mT2PluginLoader = T2_APP->mPluginLoader; + T2_APP->mDocument = this; + + m20C = 0; + + HDC hdc = GetDC(NULL); + if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) + mIsPaletteMode = true; + else + mIsPaletteMode = false; + ReleaseDC(NULL, hdc); + + mTowerMessage = NULL; +} + +/*virtual*/ T2TowerDoc::~T2TowerDoc() { + gT2App->_E4 = 0; + + if (mDestroyCallbackData && mDestroyCallback) { + mDestroyCallback(mDestroyCallbackData); + mDestroyCallbackData = NULL; + } + + towerDoc_vfD4(false); +} + +/*virtual*/ void T2TowerDoc::towerDoc_vfC8() { + mSoundPlayer = NULL; + mNameDB = NULL; + mWorldPluginSpecifier = mT2PluginLoader->FindPlugin(mWorldPluginID, 'WdPl'); + + if (!mWorldPluginSpecifier) { + if (m228) { + T2OpenSelectDlg *dlg = new T2OpenSelectDlg(this); + dlg->ShowOpenSelectDialog(); + } else { + LoadsWorldPlugin(); + } + } else { + towerDoc_vfCC(mWorldPluginSpecifier, true); + } +} + +/*virtual*/ void T2TowerDoc::towerDoc_vfCC(T2PluginSpecifier *inWorldPluginSpec, BOOL inIsExistingFile) { + T2MainWindow *theMainWindow = T2_MAIN_WINDOW; + if (theMainWindow) + theMainWindow->EnableWindow(); + + if (!mWorldPluginSpecifier) { + mWorldPluginSpecifier = inWorldPluginSpec; + mWorldPluginID = mWorldPluginSpecifier->mID; + } + +#line 187 + _ASSERT(mWorldPluginSpecifier != NULL); + + mWorldPlugin = (T2WorldPlugin *) T2PluginLoader::LoadPlugin(mWorldPluginSpecifier); + mWorldDef = mWorldPlugin->LoadT2WorldDef(); + + mToolPaletteSpecifier = mT2PluginLoader->FindPlugin(mToolPaletteID, 'TOPL'); +#line 192 + _ASSERT(mToolPaletteSpecifier != NULL); + + T2_APP->mToolWindow = NULL; + + m218 = 0; + m21C = 0; + mGameLevel = mWorldDef->m70; + _1F4 = 1; + m9C = 0; + mA0 = 0; + mZoomLevel = 0; + mDrawSpeed = 25; + _94 = 0; + mViewMode = kInView; + mPause = false; + m204 = 0; + mNow = new T2DateTime(1, mWorldDef->m74, 7, 0, 0); + mFloorDef = NULL; + mDragMask = NULL; + mDebugStepRunEnabled = false; + mDisplayIPS = false; + m1C4 = NULL; + mPeopleArrayList = NULL; + mTrafficInfo = NULL; + mSearchRangeFrom = NULL; + m1F0 = 0; + mElevTransparent = false; + mWalkRate = 1; + _224 = 0; + mObjectQueue = new CObjectQueue; + mCraneCount = 0; + mCranePosArray = NULL; + mBC = 0; + mC0 = 0; + mRegistedTenantDB = new T2RegistedTenantDB; + m1A0 = NULL; + _1A4 = NULL; + _1A8 = 0; + _1AC = 0; + + mFloorInfo = new T2FloorInfo(mWorldDef); + mWorldDef->InitializeFloorInfo(mFloorInfo); + + m1CC = 0; + mRouteNavigator = new T2RouteNavigator(mFloorInfo); + mPaletteUpdated = false; + + mIsDustOn = mWorldDef->IsDustOn(mGameLevel); + mToiletDenomi = mWorldDef->GetToiletDenomi(mGameLevel); + mColdDenomi = mWorldDef->GetColdDenomi(mGameLevel, mNow->GetMonth()); + + mPaletteAnime = new T2PaletteAnime(mWorldDef, mNow); + + mTenantPlugins = new CFilePluginList('TnPl'); + mMoverPlugins = new CFilePluginList('MvPl'); + mOuterObjPlugins = new CFilePluginList('OoPl'); + mMoviePluginList = new T2MoviePluginList; + mHallEventPlugins = new CFilePluginList('HePl'); + mAdvertisePlugins = new CFilePluginList('AdPl'); + + mTenantTemplates = new T2TemplatePluginList('TnDf'); + mMoverTemplates = new T2TemplatePluginList('MvDf'); + mOuterObjTemplates = new T2TemplatePluginList('OODf'); + if (mWorldDef->IsUseMatterObject()) + mMatterTemplates = new T2TemplatePluginList('MtDf'); + else + mMatterTemplates = NULL; + mPeopleTemplates = new T2TemplatePluginList('PPDf'); + mSilhouetteTemplates = new T2TemplatePluginList('SlDf'); + + mTemplatePluginDB = new T2TemplatePluginDB; + mTemplatePluginDB->Add(mTenantTemplates); + mTemplatePluginDB->Add(mMoverTemplates); + mTemplatePluginDB->Add(mOuterObjTemplates); + if (mWorldDef->IsUseMatterObject()) + mTemplatePluginDB->Add(mMatterTemplates); + mTemplatePluginDB->Add(mPeopleTemplates); + mTemplatePluginDB->Add(mSilhouetteTemplates); + + mOuterObjList = new T2OuterObjList; + mPeopleArrayList = new T2PeopleArrayList; + mPeopleArrayList->SetWalkPeople(mWalkRate); + + mOptionPluginList = new T2OptionPluginList; + + mNameDB = new T2NameList; + + T2PeopleLoader::Load(mWorldPluginSpecifier, mTemplatePluginDB); + + towerDoc_vfD0(); + + LoadOptionPlugins(); + if (!inIsExistingFile) + SelectPlugins(false); + + CreatePool(); + + RECT theBkgndRect; + SetRect(&theBkgndRect, 0, 0, mWorldDef->GetWidth(), mWorldDef->GetHeight()); + mBkgndInfo = UT2BkgndInfo::SetupBkgndInfo(theBkgndRect, mWorldDef->mGroundLine); + mWorldDef->InitializeBkgndInfo(mBkgndInfo); + + InitSound(T2_APP->mMainWindow->mSoundPlayer); + + mWorldDef->InitializeDocument(this); + mWorldDef->InitTowerEvent(this); + + RECT theFloorArea; + mFloorInfo->GetFloorArea(theFloorArea); + mTrafficInfo = new T2TrafficInfo(theFloorArea, 100, 500, 1000, 4); + + mSettlement = new T2Settlement(this, mWorldDef->GetInitialFunds()); + + T2_APP->mMainWindow->Setup(); + + T2ToolWindow *theToolPalette = T2_APP->mMainWindow->mToolWindow; + theToolPalette->SetDocument(this); + + T2MsgWindow *messageWindow = T2_APP->mMainWindow->mMsgWindow; + messageWindow->SetDocument(this); + + T2CtrlPalette *controlPalette = T2_APP->mMainWindow->mCtrlPalette; + controlPalette->SetDocument(this); + controlPalette->vf100(mViewMode); + + T2_APP->mMainWindow->InvalidateRect(NULL); + + mIsStuffLoadedFlag = true; + m228 = 0; + + CRect mainWindowArea; + T2_APP->mMainWindow->GetWindowRect(mainWindowArea); + T2_APP->mMainWindow->x414445(); + + m188 = mTowerMainView->mScrollOffset; + + if (!mTowerMessage) + mTowerMessage = new T2TowerMessage(AfxGetInstanceHandle(), this); + + SetupGradeAnimation(); +} + +void T2TowerDoc::xUnkNameSelectWorld(T2PluginSpecifier *inWorldPluginSpec) { + towerDoc_vfCC(inWorldPluginSpec, false); + x41CFEB(); +} + +void T2TowerDoc::x41CFEB() { + mPaletteAnime->MinuteChanged(mNow); + mPaletteAnime->ChangeSE(); + mPaletteAnime->DoAnimatePalette(); + _22C = true; + + UpdateAllViews(NULL); + + T2MainWindow *theMainWindow = T2_MAIN_WINDOW; + if (theMainWindow) + theMainWindow->InvalidateRect(NULL); +} + +/*virtual*/ void T2TowerDoc::towerDoc_vfD0() { + T2ToolWindow *toolWindow = T2_APP->mToolWindow; + toolWindow = (T2ToolWindow *) T2PluginLoader::LoadPlugin(mToolPaletteSpecifier); + T2_APP->mToolWindow = toolWindow; + + toolWindow->mModule = mToolPaletteSpecifier->mInstance; + toolWindow->SetDocument(this); + + toolWindow->AddIcon( + "ToolDestruct", + 3, + // 撤去ツール + // テナント、移動設備、看板を撤去します。 + "\x93\x50\x8B\x8E\x83\x63\x81\x5B\x83\x8B\n\x83\x65\x83\x69\x83\x93\x83\x67\x81\x41\x88\xDA\x93\xAE\x90\xDD\x94\xF5\x81\x41\x8A\xC5\x94\xC2\x82\xF0\x93\x50\x8B\x8E\x82\xB5\x82\xDC\x82\xB7\x81\x42", + this); + + toolWindow->AddIcon( + "ToolFinger", + 1, + // エレベータ伸縮ツール + // エレベータの機械室をドラッグして伸縮します。 + "\x83\x47\x83\x8C\x83\x78\x81\x5B\x83\x5E\x90\x4C\x8F\x6B\x83\x63\x81\x5B\x83\x8B\n\x83\x47\x83\x8C\x83\x78\x81\x5B\x83\x5E\x82\xCC\x8B\x40\x8A\x42\x8E\xBA\x82\xF0\x83\x68\x83\x89\x83\x62\x83\x4F\x82\xB5\x82\xC4\x90\x4C\x8F\x6B\x82\xB5\x82\xDC\x82\xB7\x81\x42", + this); + + toolWindow->AddIcon( + "ToolInfo", + 3, + // 情報ツール + // テナント、移動設備、人をクリックすると情報ウィンドウが表示されます。 + "\x8F\xEE\x95\xF1\x83\x63\x81\x5B\x83\x8B\n\x83\x65\x83\x69\x83\x93\x83\x67\x81\x41\x88\xDA\x93\xAE\x90\xDD\x94\xF5\x81\x41\x90\x6C\x82\xF0\x83\x4E\x83\x8A\x83\x62\x83\x4E\x82\xB7\x82\xE9\x82\xC6\x8F\xEE\x95\xF1\x83\x45\x83\x42\x83\x93\x83\x68\x83\x45\x82\xAA\x95\x5C\x8E\xA6\x82\xB3\x82\xEA\x82\xDC\x82\xB7\x81\x42", + this); + + toolWindow->AddIcon( + "ToolZoom", + 3, + // ズームツール + // ゲーム画面を拡大縮小します。 + // 左クリックで拡大、右クリックで縮小します。 + "\x83\x59\x81\x5B\x83\x80\x83\x63\x81\x5B\x83\x8B\n\x83\x51\x81\x5B\x83\x80\x89\xE6\x96\xCA\x82\xF0\x8A\x67\x91\xE5\x8F\x6B\x8F\xAC\x82\xB5\x82\xDC\x82\xB7\x81\x42\n\x8D\xB6\x83\x4E\x83\x8A\x83\x62\x83\x4E\x82\xC5\x8A\x67\x91\xE5\x81\x41\x89\x45\x83\x4E\x83\x8A\x83\x62\x83\x4E\x82\xC5\x8F\x6B\x8F\xAC\x82\xB5\x82\xDC\x82\xB7\x81\x42", + this); + + toolWindow->AddIcon( + "ToolHand", + 3, + // スクロールツール + // 画面を自由にスクロールできます。 + "\x83\x58\x83\x4E\x83\x8D\x81\x5B\x83\x8B\x83\x63\x81\x5B\x83\x8B\n\x89\xE6\x96\xCA\x82\xF0\x8E\xA9\x97\x52\x82\xC9\x83\x58\x83\x4E\x83\x8D\x81\x5B\x83\x8B\x82\xC5\x82\xAB\x82\xDC\x82\xB7\x81\x42", + this); + + toolWindow->AddIcon( + "ToolMic", + 1, + // インタビューツール + // 歩いている人の意見を聞くことができます。 + "\x83\x43\x83\x93\x83\x5E\x83\x72\x83\x85\x81\x5B\x83\x63\x81\x5B\x83\x8B\n\x95\xE0\x82\xA2\x82\xC4\x82\xA2\x82\xE9\x90\x6C\x82\xCC\x88\xD3\x8C\xA9\x82\xF0\x95\xB7\x82\xAD\x82\xB1\x82\xC6\x82\xAA\x82\xC5\x82\xAB\x82\xDC\x82\xB7\x81\x42", + this); + + toolWindow->AddIcon( + "ToolRoot", + 1, + // 集客範囲表示ツール + // クリックしたテナントが人を呼べる範囲を表示します。 + "\x8F\x57\x8B\x71\x94\xCD\x88\xCD\x95\x5C\x8E\xA6\x83\x63\x81\x5B\x83\x8B\n\x83\x4E\x83\x8A\x83\x62\x83\x4E\x82\xB5\x82\xBD\x83\x65\x83\x69\x83\x93\x83\x67\x82\xAA\x90\x6C\x82\xF0\x8C\xC4\x82\xD7\x82\xE9\x94\xCD\x88\xCD\x82\xF0\x95\x5C\x8E\xA6\x82\xB5\x82\xDC\x82\xB7\x81\x42", + this); +} + +void T2TowerDoc::LoadOptionPlugins() { + T2PluginSpecifier *specifier; + POSITION pos; + + mT2PluginLoader->SetTypeFilter(pos, 'OPPL'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if (specifier->mAttrib == 0 || specifier->mAttrib == mWorldPluginSpecifier->mID) { + T2OptionPlugin *plugin = (T2OptionPlugin *) T2PluginLoader::LoadPlugin(specifier); + mOptionPluginList->Add(plugin); + } + } + + mOptionPluginList->DispatchEvent(kInitOptionEvent, this, NULL); +} + +/*virtual*/ void T2TowerDoc::towerDoc_vfD4(BOOL inResetMainWindow) { + _22C = false; + + if (mIsStuffLoadedFlag) { + mIsStuffLoadedFlag = false; + mOptionPluginList->DispatchEvent(kDestroyOptionEvent, this, NULL); + + if (inResetMainWindow) { + T2_MAIN_WINDOW->Teardown(); + mSoundPlayer->DeleteSoundAll(); + } + + mWorldDef->ClearCranePos(this); + + delete mPool; + T2PeopleLoader::Unload(mTemplatePluginDB); + + delete mTenantPlugins; + delete mMoverPlugins; + delete mOuterObjPlugins; + delete mMoviePluginList; + delete mHallEventPlugins; + delete mAdvertisePlugins; + delete mTenantTemplates; + delete mMoverTemplates; + delete mOuterObjTemplates; + if (mMatterTemplates) + delete mMatterTemplates; + delete mPeopleTemplates; + delete mSilhouetteTemplates; + delete mTemplatePluginDB; + delete mObjectQueue; + delete mOuterObjList; + delete mNameDB; + delete mTrafficInfo; + delete mSettlement; + delete mOptionPluginList; + UT2BkgndInfo::DisposeBkgndInfo(mBkgndInfo); + delete mRouteNavigator; + delete mFloorInfo; + + T2PluginSpecifier *specifier; + POSITION pos; + + mT2PluginLoader->SetTypeFilter(pos, 0); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if (specifier->mIsLoaded) + T2PluginLoader::UnloadPlugin(specifier); + } + + delete mRegistedTenantDB; + delete mNow; + + mSprite.AllClear(); + + if (mPeopleArrayList) + delete mPeopleArrayList; + + mWorldDef = NULL; + + UpdateAllViews(NULL); + + if (inResetMainWindow) + T2_APP->mMainWindow->InvalidateRect(NULL); + } +} + +/*virtual*/ BOOL T2TowerDoc::OnNewDocument() { + if (!CDocument::OnNewDocument()) + return false; + + towerDoc_vfD4(true); + mWorldPluginID = 0; + mNewDocFlag = true; + towerDoc_vfC8(); + + return true; +} + +/*virtual*/ BOOL T2TowerDoc::OnOpenDocument(LPCTSTR lpszPathName) { + mErrorFlag = false; + + if (!towerDoc_vf2BC(lpszPathName)) { + MessageBox(NULL, "File load error", "ERROR", MB_OK); + mErrorFlag = true; + return false; + } + + return true; +} + +/*virtual*/ BOOL T2TowerDoc::towerDoc_vf2BC(const char *inPath) { + BOOL loaded = true; + int viewMode = kInView; + + mNewDocFlag = false; + + T2Archive stream; + if (stream.OpenAsReadMode(inPath)) { + DWORD magic; + stream >> magic; + + if (magic == 'T200') { + stream.BeginCompressedStream(); + BOOL foundWorldPlugin = true; + + stream >> mWorldPluginID; + if (!mT2PluginLoader->FindPlugin(mWorldPluginID, 'WdPl')) + foundWorldPlugin = false; + + if (foundWorldPlugin) { + towerDoc_vfD4(true); + mTowerMainView->tmv_vf110(); + towerDoc_vfC8(); + _22C = false; + + try { +#pragma var_order(i, installedPlugins, mustCheckError, uc, queueVar, checkError, pluginInfoArray, s, theFloorArea, pluginInfo, us, scrollX, desktopRect, numPlugins, ctrlPalette, scrollY, pluginIterator, desktopWindow, pt2, anotherRect, pt1, missingPlugins) + int i; + short s; + unsigned short us; + unsigned char uc; + + stream >> s; + mGameLevel = s; + stream >> s; + m9C = s; + + stream >> mA0; + + stream >> s; + mZoomLevel = s; + + stream >> uc; + if (uc) + mPause = true; + else + mPause = false; + + stream >> s; // drawSpeed on Mac + stream >> s; // field 0x8C on Mac + + stream >> s; + viewMode = s; + + stream >> uc; // field 0x92 on Mac + stream >> uc; // field 0x93 on Mac + stream >> uc; // soundplayer pausedFlag on Mac + + // soundplayer priority on flags on Mac + for (i = 0; i < 7; i++) + stream >> uc; + + delete mNow; + mNow = new T2DateTime(stream); + + SelectPlugins(false); + + int numPlugins; + stream >> numPlugins; + + CPluginInfoArray *pluginInfoArray = new CPluginInfoArray(false); + CPluginInfo *pluginInfo; + + for (i = 0; i < numPlugins; i++) { + pluginInfo = CPluginInfo::ReadPluginInfo(stream); + pluginInfoArray->Add(&pluginInfo); + } + + BOOL mustCheckError = false; + BOOL checkError = false; + + LArray *missingPlugins = new CPluginInfoArray(true); + CPluginInfoArray *installedPlugins = MakePluginInfoArray(); + + LArrayIterator pluginIterator(*pluginInfoArray); + while (pluginIterator.Next(&pluginInfo)) { + DWORD id = pluginInfo->GetID(); + BOOL found = false; + + LArrayIterator iteratorCheck(*installedPlugins); + CPluginInfo *thePluginCheck; + + while (iteratorCheck.Next(&thePluginCheck)) { + if (id == thePluginCheck->GetID()) { + found = true; + break; + } + } + + if (!found) + missingPlugins->Add(&pluginInfo); + } + + if (missingPlugins->GetCount() > 0) { + TRACE("\r\nPlugin Check Error !\r\n"); + + checkError = true; + + CPluginInfo *errorPlugin; + LArrayIterator iterator(*missingPlugins); + + while (iterator.Next(&errorPlugin)) { + if (errorPlugin->mMustItem) { + mustCheckError = true; + break; + } + } + + if (mustCheckError) { + TRACE("\r\nPlugin Must Check Error !\r\n"); + + T2Dialog dialog; + + CRect rect; + AfxGetMainWnd()->GetWindowRect(rect); + + T2DLGTEMPLATE theTmpl; + theTmpl.pt = rect.CenterPoint(); + theTmpl.moduleHandle = AfxGetApp()->m_hInstance; + theTmpl.resID = 1110; + + dialog.Realize(this, &theTmpl, this, NULL, NULL, true, NULL, 0, true); + + T2PluginInfoTable *pluginInfoTable = (T2PluginInfoTable *) dialog.GetDlgItem(102); + if (pluginInfoTable) { + CPluginInfo *errorPlugin; + LArrayIterator iterator(*missingPlugins); + + while (iterator.Next(&errorPlugin)) { + if (errorPlugin->mMustItem) + pluginInfoTable->Add(errorPlugin); + } + } + + int code = dialog.DoModal(); + throw -10000; + } + } + + if (checkError) { + T2Dialog dialog; + + CRect rect; + AfxGetMainWnd()->GetWindowRect(rect); + + T2DLGTEMPLATE theTmpl; + theTmpl.pt = rect.CenterPoint(); + theTmpl.moduleHandle = AfxGetApp()->m_hInstance; + theTmpl.resID = 1111; + + dialog.Realize(this, &theTmpl, this, NULL, NULL, true, NULL, 0, true); + + T2PluginInfoTable *pluginInfoTable = (T2PluginInfoTable *) dialog.GetDlgItem(102); + if (pluginInfoTable) { + CPluginInfo *errorPlugin; + LArrayIterator iterator(*missingPlugins); + + while (iterator.Next(&errorPlugin)) + pluginInfoTable->Add(errorPlugin); + } + + int code = dialog.DoModal(); + if (code == IDOK) + throw -10000; + } + + delete missingPlugins; + delete installedPlugins; + delete pluginInfoArray; + + mPeopleArrayList->Read(stream, this); + mFloorInfo->Read(stream, this); + + short queueVar; + stream >> queueVar; + + if (queueVar > 0) { + unsigned int queueLen; + stream >> queueLen; + + for (unsigned int index = 0; index < queueLen; index++) { + stream >> s; + T2Tenant *theTenant = mFloorInfo->GetTenant(s); + if (theTenant) + mObjectQueue->AddItem(theTenant); + } + } + + stream >> uc; + mElevTransparent = (uc != 0); + + stream >> s; + mWalkRate = s; + + LoadPool(stream); + + delete mRouteNavigator; + mRouteNavigator = new T2RouteNavigator(mFloorInfo); + + RECT theFloorArea; + mFloorInfo->GetFloorArea(theFloorArea); + mTrafficInfo = new T2TrafficInfo(theFloorArea, 100, 500, 1000, 4); + mTrafficInfo->Read(stream); + + mSettlement = new T2Settlement(this, stream); + mMoviePluginList->Read(stream); + mWorldDef->ReadTowerEvent(stream); + + CRect desktopRect; + CWnd *desktopWindow = CWnd::GetDesktopWindow(); + if (desktopWindow) + desktopWindow->GetWindowRect(&desktopRect); + + CRect anotherRect; + CPoint pt1, pt2; + stream.ReadSRect(anotherRect); + + pt1 = anotherRect.TopLeft(); + pt2 = anotherRect.BottomRight(); + if (desktopRect.PtInRect(pt1) && desktopRect.PtInRect(pt2)) + AfxGetMainWnd()->MoveWindow(&anotherRect); + + int scrollX, scrollY; + stream >> scrollY; + m188.y = scrollY; + stream >> scrollX; + m188.x = scrollX; + + // tool window bounds + stream.ReadSRect(anotherRect); + anotherRect.right = anotherRect.left + 92; + anotherRect.bottom = anotherRect.top + 359; + + pt1 = anotherRect.TopLeft(); + pt2 = anotherRect.BottomRight(); + if (desktopRect.PtInRect(pt1) && desktopRect.PtInRect(pt2)) + T2_APP->mToolWindow->MoveWindow(&anotherRect); + + // message window bounds + stream.ReadSRect(anotherRect); + anotherRect.right = anotherRect.left + 523; + anotherRect.bottom = anotherRect.top + 70; + + pt1 = anotherRect.TopLeft(); + pt2 = anotherRect.BottomRight(); + if (desktopRect.PtInRect(pt1) && desktopRect.PtInRect(pt2)) + T2_MAIN_WINDOW->mMsgWindow->MoveWindow(&anotherRect); + + // control window bounds + stream.ReadSRect(anotherRect); + anotherRect.right = anotherRect.left + 133; + anotherRect.bottom = anotherRect.top + 76; + + T2CtrlPalette *ctrlPalette = T2_APP->mMainWindow->mCtrlPalette; + pt1 = anotherRect.TopLeft(); + pt2 = anotherRect.BottomRight(); + if (desktopRect.PtInRect(pt1) && desktopRect.PtInRect(pt2)) + ctrlPalette->MoveWindow(&anotherRect); + + SetViewMode(mViewMode); + + // calendar window bounds - Mac only + stream.ReadSRect(anotherRect); + + // sub-window visibility flags - Mac only + stream >> uc; + stream >> uc; + stream >> uc; + stream >> uc; + + stream >> us; + mSearchRangeFrom = (us == 0) ? NULL : mFloorInfo->GetTenant(us); + + mNameDB->Read(stream); + mWorldDef->ReadStatisticsProc(this, stream); + } catch (int err) { + loaded = false; + } + } else { + loaded = false; + } + + stream.EndCompressedStream(); + } else { + loaded = false; + } + + stream.Close(); + } else { + loaded = false; + } + + if (loaded) { +#pragma var_order(theTenantArrayList, theMoverDef, theOutObjArrayList, theMover, theOutObjArray, theIterator, theMoverArray, theTenantArray, theMoverArrayList, theTenant, theOutObj, theTenantDef) + SelectPlugins(false); + + T2TenantArrayList *theTenantArrayList = mFloorInfo->GetTenantArrayList(); + LArrayIterator *theIterator = new LArrayIterator(*theTenantArrayList); + T2TenantArray *theTenantArray; + T2Tenant *theTenant; + T2TenantDef *theTenantDef; + + while (theIterator->Next(&theTenantArray)) { + for (int index = 0; index < T2TenantArray::kGroupSize; index++) { + theTenant = &theTenantArray->mTenants[index]; + if (theTenant->IsUsed()) { + LArrayIterator templateIterator(*mTenantTemplates); + + while (templateIterator.Next(&theTenantDef)) { + if (theTenantDef->GetEquipType() == theTenant->GetEquipType()) { + theTenant->SetToolDef(theTenantDef); + break; + } + } + + if (!theTenant->GetToolDef()) { + CRect tmp; + theTenant->Destruct(this, tmp); + } + } + } + } + + delete theIterator; + + T2MoverArrayList *theMoverArrayList = mFloorInfo->GetMoverArrayList(); + theIterator = new LArrayIterator(*theMoverArrayList); + T2MoverArray *theMoverArray; + T2Mover *theMover; + T2MoverDef *theMoverDef; + + while (theIterator->Next(&theMoverArray)) { + for (int index = 0; index < T2MoverArray::kGroupSize; index++) { + theMover = &theMoverArray->mMover[index]; + if (theMover->IsUsed()) { + LArrayIterator templateIterator(*mMoverTemplates); + + while (templateIterator.Next(&theMoverDef)) { + if (theMoverDef->GetEquipType() == theMover->GetEquipType()) { + theMover->SetToolDef(theMoverDef); + break; + } + } + + if (!theMover->GetToolDef()) { + CRect tmp; + theMover->Destruct(this, tmp); + } + } + } + } + + delete theIterator; + + T2OutObjArrayList *theOutObjArrayList = mFloorInfo->GetOutObjArrayList(); + theIterator = new LArrayIterator(*theOutObjArrayList); + T2OutObjArray *theOutObjArray; + T2OutObj *theOutObj; + + while (theIterator->Next(&theOutObjArray)) { + for (int index = 0; index < T2OutObjArray::kGroupSize; index++) { + theOutObj = &theOutObjArray->mOutObj[index]; + if (theOutObj->IsUsed()) { + mOuterObjList->Add(&theOutObj); + theOutObj->_3C = theOutObj->mOutObjArea; + } + } + } + + delete theIterator; + } + + BOOL pausedFlag = false; + if (mPause) + pausedFlag = true; + + x429A9A(pausedFlag); + x429B01(pausedFlag); + + SetViewMode(viewMode); + mWorldDef->DayChanged(this); + + if (loaded) + x41CFEB(); + + return loaded; +} + +/*virtual*/ BOOL T2TowerDoc::OnSaveDocument(LPCTSTR lpszPathName) { + if (!towerDoc_vf2C0(lpszPathName)) + MessageBox(NULL, "File save error", "ERROR", MB_OK); + + return true; +} + +/*virtual*/ BOOL T2TowerDoc::towerDoc_vf2C0(const char *inPath) { +#pragma var_order(thePluginInfoArray, uc, stream, queueVar, s, magic, thePluginInfo, us, pluginIterator, i, scrollPos, windowPlacement, dummyRect) + T2Archive stream; + if (!stream.OpenAsWriteMode(inPath)) + return false; + + short s; + unsigned char uc; + unsigned short us; + + DWORD magic = 'T200'; + stream << magic; + + stream.BeginCompressedStream(); + + stream << mWorldPluginSpecifier->mID; + + s = mGameLevel; + stream << s; + + s = m9C; + stream << s; + + stream << mA0; + + s = mZoomLevel; + stream << s; + + uc = 0; + s = 0; + stream << uc; + stream << s; + stream << s; + + s = mViewMode; + stream << s; + + stream << uc; + stream << uc; + stream << uc; + + for (int i = 0; i < 7; i++) + stream << uc; + + mNow->Write(stream); + + CPluginInfoArray *thePluginInfoArray = MakePluginInfoArray(); + stream << thePluginInfoArray->GetCount(); + + LArrayIterator pluginIterator(*thePluginInfoArray); + CPluginInfo *thePluginInfo; + + while (pluginIterator.Next(&thePluginInfo)) + thePluginInfo->Write(stream); + + mPeopleArrayList->Write(stream); + mFloorInfo->Write(stream); + + short queueVar = 0; + if (mObjectQueue) { + queueVar = 1; + stream << queueVar; + stream << mObjectQueue->GetItemCount(); + + POSITION pos = mObjectQueue->GetHeadPosition(); + while (pos) { + POSITION prevPos = pos; + T2Tenant *theTenant = (T2Tenant *) mObjectQueue->GetNext(pos); + s = theTenant->GetEquipID(); + stream << s; + } + } else { + stream << queueVar; + } + + uc = mElevTransparent != 0; + stream << uc; + + stream << (short) mWalkRate; + + mPool->Write(stream); + mTrafficInfo->Write(stream); + mSettlement->Write(stream); + mMoviePluginList->Write(stream); + mWorldDef->WriteTowerEvent(stream); + + WINDOWPLACEMENT windowPlacement; + + AfxGetMainWnd()->GetWindowPlacement(&windowPlacement); + stream.WriteSRect(windowPlacement.rcNormalPosition); + + POINT scrollPos = mTowerMainView->mScrollOffset; + stream << (int) scrollPos.y; + stream << (int) scrollPos.x; + + T2_APP->mToolWindow->GetWindowPlacement(&windowPlacement); + windowPlacement.rcNormalPosition.right = windowPlacement.rcNormalPosition.left + 88; + windowPlacement.rcNormalPosition.bottom = windowPlacement.rcNormalPosition.top + 353; + stream.WriteSRect(windowPlacement.rcNormalPosition); + + T2_MAIN_WINDOW->mMsgWindow->GetWindowPlacement(&windowPlacement); + windowPlacement.rcNormalPosition.right = windowPlacement.rcNormalPosition.left + 513; + windowPlacement.rcNormalPosition.bottom = windowPlacement.rcNormalPosition.top + 45; + stream.WriteSRect(windowPlacement.rcNormalPosition); + + T2_APP->mMainWindow->mCtrlPalette->GetWindowPlacement(&windowPlacement); + windowPlacement.rcNormalPosition.right = windowPlacement.rcNormalPosition.left + 150; + windowPlacement.rcNormalPosition.bottom = windowPlacement.rcNormalPosition.top + 58; + stream.WriteSRect(windowPlacement.rcNormalPosition); + + RECT dummyRect; + dummyRect.left = 0; + dummyRect.top = 0; + dummyRect.right = 0; + dummyRect.bottom = 0; + stream.WriteSRect(dummyRect); + + uc = 1; + stream << uc; + stream << uc; + stream << uc; + stream << uc; + + us = (mSearchRangeFrom == NULL) ? 0 : mSearchRangeFrom->GetEquipID(); + stream << us; + + mNameDB->Write(stream); + mWorldDef->WriteStatisticsProc(this, stream); + + stream.EndCompressedStream(); + stream.Close(); + + return true; +} + +void T2TowerDoc::OnSystemInformation() { + T2SysInfoDlg dlg(NULL); + dlg.SetDocument(this); + dlg.DoModal(); +} + +/*virtual*/ int T2TowerDoc::GetZoomLevel() const { + return mZoomLevel; +} + +/*virtual*/ void T2TowerDoc::DrawBkgnd(const RECT &inRect) { + RECT bkgndRect, updateRect; + bkgndRect.left = 0; + bkgndRect.top = 0; + bkgndRect.right = mBkgndInfo->hRange; + bkgndRect.bottom = mBkgndInfo->vRange; + + IntersectRect(&updateRect, &inRect, &bkgndRect); + + if (updateRect.left < 0 || updateRect.right > mBkgndInfo->hRange || updateRect.top < 0 || updateRect.bottom > mBkgndInfo->vRange) { + OutputDebugString("Backgound update rect is invalid!!\n"); + return; + } + + if (!IsRectEmpty(&inRect)) + mWorldDef->DrawBkgnd(inRect, this); +} + +/*virtual*/ void T2TowerDoc::towerDoc_vfF0(const RECT &inRect1, const RECT &inRect2) { + RECT rect; + UnionRect(&rect, &inRect1, &inRect2); + towerDoc_vfD8(inRect1, inRect2); +} + +/*virtual*/ void T2TowerDoc::DrawBuilding(const RECT &inRect1, const RECT &inRect2) { + RECT rect; + UnionRect(&rect, &inRect1, &inRect2); + + if (mViewMode == kOutView) + DrawOutView(rect, inRect2); + else + DrawInView(rect, inRect2); + + mWorldDef->DrawCrane(this, rect); +} + +/*virtual*/ void T2TowerDoc::DrawInView(const RECT &inRect1, const RECT &inRect2) { + DrawRequestAll(inRect1); + mPeopleArrayList->DrawSearchedPerson(this); + DrawMoverAll(inRect1); +} + +/*virtual*/ void T2TowerDoc::DrawOutView(const RECT &inRect1, const RECT &inRect2) { + DrawTenantOutViewAll(inRect1); +} + +/*virtual*/ void T2TowerDoc::towerDoc_vfD8(const RECT &inRect1, const RECT &inRect2) { + if (!IsRectEmpty(&inRect2)) { + RECT rect; + UnionRect(&rect, &inRect1, &inRect2); + towerDoc_vfFC(rect); + } else { + towerDoc_vfF8(inRect1); + } +} + +/*virtual*/ void T2TowerDoc::towerDoc_vfFC(const RECT &inRect) { + RECT drawRect = inRect; + + if (mViewMode == kOutView) { + drawRect.bottom = mFloorInfo->GetGroundLine(); + InsetRect(&drawRect, -mFloorInfo->GetEntranceWidth(), 0); + } + + int topFloorLine = mWorldDef->mTopFloorLine; + T2FInfoAreaIterator iterator(*mFloorInfo, drawRect); + T2Tenant *theTenant; + + while (iterator.NextTenant(theTenant)) { + if (theTenant) { + RECT rect; + theTenant->GetEquipArea(rect); + + ROOFANDFLOOR roofAndFloor; + if (((T2TenantDef *) theTenant->GetToolDef())->mDrawRoof) { + if (((T2TenantDef *) theTenant->GetToolDef())->mDrawFloor) + roofAndFloor = RoofAndFloor_Both; + else + roofAndFloor = RoofAndFloor_Roof; + } else { + if (((T2TenantDef *) theTenant->GetToolDef())->mDrawFloor) + roofAndFloor = RoofAndFloor_Floor; + else + roofAndFloor = RoofAndFloor_None; + } + + T2Tenant *theFloor = NULL; + + if (theTenant->IsFloor()) { + if (theTenant->IsBuildFinish()) { + iterator.GetTenantRect(rect); + if (mViewMode != kOutView) + mWorldDef->DrawRoofAndFloor(rect, this, roofAndFloor); + theTenant->Draw(this, rect); + } else { + mWorldDef->DrawBuild(theTenant, this); + } + + theFloor = theTenant; + } else { + if (theTenant->IsBuildFinish()) { + if (mViewMode != kOutView) + mWorldDef->DrawRoofAndFloor(rect, this, roofAndFloor); + theTenant->Draw(this, rect); + } else { + mWorldDef->DrawBuild(theTenant, this); + } + + theFloor = mFloorInfo->GetTenant(theTenant->GetFloorID(-1)); + } + + theTenant->ClearDrawMode(); + } + } +} + +/*virtual*/ void T2TowerDoc::towerDoc_vfF8(const RECT &inRect) { + RECT drawRect = inRect; + + if (mViewMode == kOutView) { + drawRect.bottom = mFloorInfo->GetGroundLine(); + InsetRect(&drawRect, -mFloorInfo->GetEntranceWidth(), 0); + } + + int topFloorLine = mWorldDef->mTopFloorLine; + T2FInfoAreaIterator iterator(*mFloorInfo, drawRect); + T2Tenant *theTenant; + unsigned int floorID = 0; + + while (iterator.NextTenant(theTenant)) { + if (theTenant) { + RECT rect; + + ROOFANDFLOOR roofAndFloor; + if (((T2TenantDef *) theTenant->GetToolDef())->mDrawRoof) { + if (((T2TenantDef *) theTenant->GetToolDef())->mDrawFloor) + roofAndFloor = RoofAndFloor_Both; + else + roofAndFloor = RoofAndFloor_Roof; + } else { + if (((T2TenantDef *) theTenant->GetToolDef())->mDrawFloor) + roofAndFloor = RoofAndFloor_Floor; + else + roofAndFloor = RoofAndFloor_None; + } + + if (theTenant->IsNeedDraw()) { + if (theTenant->IsBuildFinish()) { + theTenant->GetEquipArea(rect); + if (theTenant->IsFloor()) + iterator.GetTenantRect(rect); + + if (mViewMode != kOutView) + mWorldDef->DrawRoofAndFloor(rect, this, roofAndFloor); + + theTenant->Draw(this, rect); + } else { + mWorldDef->DrawBuild(theTenant, this); + } + + theTenant->ClearDrawMode(); + } else if (theTenant->IsFloor() && theTenant->GetEquipID() == floorID) { + theTenant->GetEquipArea(rect); + iterator.GetTenantRect(rect); + + if (mViewMode != kOutView) + mWorldDef->DrawRoofAndFloor(rect, this, roofAndFloor); + + theTenant->Draw(this, rect); + theTenant->ClearDrawMode(); + } + } + } +} + +/*virtual*/ void T2TowerDoc::towerDoc_vf100(const RECT &inRect) { + mWorldDef->DrawOptionObj(this, inRect); +} + +/*virtual*/ void T2TowerDoc::DrawRequestAll(const RECT &inRect) { + T2FInfoAreaIterator iterator(*mFloorInfo, inRect); + T2Request *theReq; + + while (iterator.NextRequest(theReq)) { + RECT rect, requestArea; + theReq->CalcArea(requestArea); + if (IntersectRect(&rect, &requestArea, &inRect)) + theReq->Draw(this, rect); + } +} + +/*virtual*/ void T2TowerDoc::DrawMoverAll(const RECT &inRect) { + T2MoverArrayList *theMoverArrayList = mFloorInfo->GetMoverArrayList(); + if (theMoverArrayList) + theMoverArrayList->DrawMoverAll(this, inRect); +} + +/*virtual*/ void T2TowerDoc::DrawTenantOutViewAll(const RECT &inRect) { + RECT rect; + LArrayIterator iterator(*mOuterObjList); + T2OutObj *theOutObj; + + while (iterator.Next(&theOutObj)) { + if (IntersectRect(&rect, &inRect, &theOutObj->_3C)) { + CRect rectCopy = inRect; + theOutObj->Draw(this, rectCopy); + } + } +} + +/*virtual*/ int T2TowerDoc::HitTest(POINT inPt, HitTestResult &outObj, BOOL inSkipPeople, BOOL inSkipOuterObj) { + int theHitType = kHitNull; + outObj.obj = NULL; + + T2BitImage *theImage = mTowerMainView->mImage; + theImage->SetOrigin(mTowerMainView->mScrollOffset.x, mTowerMainView->mScrollOffset.y); + theImage->SetClipRect(NULL); + theImage->Clear(254); + + POINT pt = inPt; + UT2Coordinate::QDToUnit(pt, mZoomLevel); + + theHitType = HitTestLayer(theImage, inPt, outObj, T2Sprite::ELayer_2); + if (theHitType == kHitNull && !inSkipOuterObj) { + LArrayIterator iterator(*mOuterObjList); + T2OutObj *theOuterObj; + + while (theHitType == kHitNull && iterator.Next(&theOuterObj)) { + theOuterObj->DrawHitMask(this); + if (theImage->GetPixel(inPt) != 254) { + theHitType = kHitOutObj; + outObj.obj = theOuterObj; + } + } + } + + if (theHitType == kHitNull) { + LArrayIterator arrayListIter(*mFloorInfo->GetMoverArrayList()); + T2MoverArray *theMoverArray; + + while (theHitType == kHitNull && arrayListIter.Next(&theMoverArray)) { + for (int i = 0; theHitType == kHitNull && i < T2MoverArray::kGroupSize; i++) { + T2Mover *theMover = &theMoverArray->mMover[i]; + if (theMover->IsUsed()) { + theMover->DrawHitMask(this); + if (theImage->GetPixel(inPt) != 254) { + theHitType = kHitMover; + outObj.obj = theMover; + } + } + } + } + } + + if (theHitType == kHitNull && !inSkipPeople) { + RECT visibleRect; + mTowerMainView->GetVisibleUnitRect(visibleRect); + + T2FInfoAreaIterator iterator(*mFloorInfo, visibleRect); + T2Request *theRequest; + + while (theHitType == kHitNull && iterator.NextRequest(theRequest)) { + theRequest->DrawHitMask(this); + if (theImage->GetPixel(inPt) != 254) { + T2People *thePeople = theRequest->FindPeople(pt.x); +#line 1414 + _ASSERT(thePeople != NULL); + + theHitType = kHitPeople; + outObj.obj = thePeople; + } + } + } + + if (theHitType == kHitNull && !inSkipPeople) { + LArrayIterator arrayListIter(*mPeopleArrayList); + T2PeopleArray *thePeopleArray; + + while (theHitType == kHitNull && arrayListIter.Next(&thePeopleArray)) { + for (int i = 0; theHitType == kHitNull && i < T2PeopleArray::kGroupSize; i++) { + T2People *thePeople = &thePeopleArray->mPeople[i]; + if (thePeople->IsUsed() && thePeople->IsWalk()) { + thePeople->DrawHitMask(this); + if (theImage->GetPixel(inPt) != 254) { + theHitType = kHitPeople; + outObj.obj = thePeople; + } + } + } + } + } + + if (theHitType == kHitNull) { + RECT visibleRect; + mTowerMainView->GetVisibleUnitRect(visibleRect); + + T2FInfoAreaIterator iterator(*mFloorInfo, visibleRect); + T2Tenant *theTenant; + + while (theHitType == kHitNull && iterator.NextTenant(theTenant)) { + if (theTenant && !theTenant->IsFloor()) { + theTenant->DrawHitMask(this); + if (theImage->GetPixel(inPt) != 254) { + theHitType = kHitTenant; + if (theTenant->GetStatus() >= kTenantStatus10) + outObj.obj = theTenant; + } + } + } + } + + if (theHitType == kHitNull) { + RECT visibleRect; + mTowerMainView->GetVisibleUnitRect(visibleRect); + + T2FInfoAreaIterator iterator(*mFloorInfo, visibleRect); + T2Tenant *theTenant; + + while (theHitType == kHitNull && iterator.NextTenant(theTenant)) { + if (theTenant && theTenant->IsFloor()) { + theTenant->DrawHitMask(this); + if (theImage->GetPixel(inPt) != 254) { + theHitType = kHitTenant; + outObj.obj = theTenant; + } + } + } + } + + if (theHitType == kHitNull) + theHitType = HitTestLayer(theImage, inPt, outObj, T2Sprite::ELayer_1); + + if (theHitType == kHitNull) { + CRect bkgndRect; + mTowerMainView->GetClientRect(bkgndRect); + bkgndRect.OffsetRect(mTowerMainView->mScrollOffset); + + UT2Coordinate::QDToBkgnd(bkgndRect, mZoomLevel); + bkgndRect.right += 1; + bkgndRect.bottom += 1; + + for (int y = bkgndRect.top; theHitType == kHitNull && y < bkgndRect.bottom; y++) { + for (int x = bkgndRect.left; theHitType == kHitNull && x < bkgndRect.right; x++) { + unsigned int bkgndInfo = UT2BkgndInfo::GetBkgndInfo(mBkgndInfo, y, x); + + RECT bkgndInfoRect; + SetRect(&bkgndInfoRect, x, y, x + 1, y + 1); + mWorldDef->DrawBkgnd(bkgndInfo, bkgndInfoRect, this); + + if (theImage->GetPixel(inPt) != 254) { + theHitType = kHitBkgndInfo; + outObj.bkgndInfo = bkgndInfo; + } + } + } + } + + if (theHitType == kHitNull) + theHitType = HitTestLayer(theImage, inPt, outObj, T2Sprite::ELayer_0); + + theImage->SetOrigin(0, 0); + mTowerMainView->Invalidate(true); + mTowerMainView->tmv_vf11C(); + + return theHitType; +} + +int T2TowerDoc::HitTestLayer(T2BitImage *inImage, POINT inPt, HitTestResult &outObj, int inLayer) { + POSITION pos = mSprite.GetHeadPosition(); + while (pos) { + T2SpriteObj *obj = mSprite.GetNext(pos); + if (obj->mLayer == inLayer) { + mSprite.DrawSprite(inImage, obj, mZoomLevel); + if (inImage->GetPixel(inPt) != 254) { + outObj.spriteObj = obj; + return kHitSpriteObj; + } + } + } + + return kHitNull; +} + +/*virtual*/ T2BitImage *T2TowerDoc::GetImage() const { + return mTowerMainView->mImage; +} + +/*virtual*/ T2TowerMainView *T2TowerDoc::GetMainView() const { + return mTowerMainView; +} + +/*virtual*/ T2DateTime *T2TowerDoc::GetNow() const { + return mNow; +} + +/*virtual*/ T2RouteNavigator *T2TowerDoc::GetRouteNavi() const { + return mRouteNavigator; +} + +/*virtual*/ T2TemplatePluginList *T2TowerDoc::GetSilhouetteTemplates() { + return mSilhouetteTemplates; +} + +static int cursors[16] = { + 194, 184, + 187, 188, + 193, 183, + 195, 195, + 189, 190, + 185, 185, + 192, 192, + 210, 210 +}; + +/*virtual*/ void T2TowerDoc::SetCursorType(int inCursor, BOOL inIsPressed) { + HCURSOR theCursorH = NULL; + CT2App *theApp = T2_APP; + UINT id; + + if (inCursor == kCursorNoChange) + inCursor = mLastRequestedCursor; + else + mLastRequestedCursor = inCursor; + + if (inCursor < kCursorDefault) { + inCursor *= 2; + if (inIsPressed) + inCursor++; + + id = cursors[inCursor]; + theCursorH = theApp->LoadCursor(id); + } else if (inCursor == kCursorDefault) { + theCursorH = theApp->LoadStandardCursor(IDC_ARROW); + } + + if (mCurrentCursorIndex != inCursor) { + mCurrentCursorIndex = inCursor; + + if (inCursor == kCursorDefault) { + theCursorH = theApp->LoadStandardCursor(IDC_ARROW); + } else { + id = cursors[inCursor]; + theCursorH = theApp->LoadCursor(id); + } + + if (theCursorH) { + SetClassLong(mTowerMainView->m_hWnd, GCL_HCURSOR, (LONG) theCursorH); + SetCursor(theCursorH); + } + } +} + +/*virtual*/ void T2TowerDoc::Serialize(CArchive &ar) { + if (ar.IsStoring()) { + } else { + } +} + +/*virtual*/ void T2TowerDoc::InitSound(T2SoundPlayer *inSoundPlayer) { + mSoundPlayer = inSoundPlayer; + Sounds = mSoundPlayer; + + LoadSoundForPlugin(mWorldDef); + + T2TemplatePlugin *thePlugin; + LArrayIterator *theIterator; + + theIterator = new LArrayIterator(*mTenantTemplates); + while (theIterator->Next(&thePlugin)) + LoadSoundForPlugin(thePlugin); + delete theIterator; + + theIterator = new LArrayIterator(*mMoverTemplates); + while (theIterator->Next(&thePlugin)) + LoadSoundForPlugin(thePlugin); + delete theIterator; +} + +void T2TowerDoc::LoadSoundForPlugin(T2TemplatePlugin *inPlugin) { + if (mSoundPlayer) + inPlugin->LoadSound(this); +} + +/*virtual*/ void T2TowerDoc::CreatePool() { + if (mWorldDef) { + T2PoolDef *thePoolDef = mWorldDef->mPoolDef; + if (thePoolDef) { + T2TemplatePluginList *theList = mTemplatePluginDB->GetTemplatePluginList('PPDf'); + unsigned int theHour = mNow->Get24Hour(); + mPool = new T2Pool( + thePoolDef, + mWorldDef->GetSeasonParamDef(), + theList, + mPeopleArrayList, + mGameLevel, + mNow->GetMonth(), + mNow->Get24Hour(), + mWorldDef); + } + } +} + +/*virtual*/ void T2TowerDoc::LoadPool(T2Archive &inArchive) { + if (mWorldDef) { + T2PoolDef *thePoolDef = mWorldDef->mPoolDef; + if (thePoolDef) { + T2TemplatePluginList *theList = mTemplatePluginDB->GetTemplatePluginList('PPDf'); + unsigned int theHour = mNow->Get24Hour(); + mPool = new T2Pool( + inArchive, + thePoolDef, + mWorldDef->GetSeasonParamDef(), + theList, + mPeopleArrayList, + mWorldDef); + } + } +} + +/*virtual*/ void T2TowerDoc::SetViewMode(int inViewMode) { + if (mViewMode != inViewMode) { + if (mWorldDef) + mWorldDef->ViewModeChanged(this, (VIEWMODE) inViewMode); + + T2MainWindow *theMainWindow = T2_MAIN_WINDOW; + if (theMainWindow) { + T2CtrlPalette *theCtrlPalette = theMainWindow->mCtrlPalette; + if (theCtrlPalette) + theCtrlPalette->vf100(inViewMode); + } + + GetWorldDef()->GetTowerEvent()->ViewModeChanged(this, (VIEWMODE) inViewMode); + + mViewMode = inViewMode; + + mSearchRangeFrom = NULL; + + T2ToolWindow *theToolWindow = T2_APP->mToolWindow; + + unsigned short theIconSet; + if (mViewMode == kOutView) + theIconSet = 2; + else + theIconSet = 1; + theToolWindow->EnableIcon(theIconSet); + + mTowerMainView->Invalidate(false); + mTowerMainView->tmv_vf120(); + } +} + +/*virtual*/ void T2TowerDoc::SelectPlugins(BOOL inIsGradeUp) { +#pragma var_order(rect, pos2, pos3, theItemNameText, tmpl, thePluginTypeText, specifier, theToolWindow, numPlugins, str, pos1, theProgress, pos, theDialog) + mOptionPluginList->DispatchEvent(kSelectPluginsOptionEvent, this, NULL); + + T2ToolWindow *theToolWindow = T2_APP->mToolWindow; + + towerDoc_vf290(true); + + POSITION pos; + T2PluginSpecifier *specifier; + int numPlugins = 0; + + mT2PluginLoader->SetTypeFilter(pos, 'TnPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mTenantPlugins->GetItem(specifier->mID) && + (!specifier->mSecretItem || (specifier->mSecretItem & (m9C != 0))) + ) + numPlugins++; + } + + mT2PluginLoader->SetTypeFilter(pos, 'MvPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mMoverPlugins->GetItem(specifier->mID) && + (!specifier->mSecretItem || (specifier->mSecretItem & (m9C != 0))) + ) + numPlugins++; + } + + mT2PluginLoader->SetTypeFilter(pos, 'OoPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mOuterObjPlugins->GetItem(specifier->mID) && + (!specifier->mSecretItem || (specifier->mSecretItem & (m9C != 0))) + ) + numPlugins++; + } + + mT2PluginLoader->SetTypeFilter(pos, 'MoPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mMoviePluginList->GetItem(specifier->mID) + ) + numPlugins++; + } + + mT2PluginLoader->SetTypeFilter(pos, 'HePl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mHallEventPlugins->GetItem(specifier->mID) + ) + numPlugins++; + } + + mT2PluginLoader->SetTypeFilter(pos, 'AdPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mAdvertisePlugins->GetItem(specifier->mID) + ) + numPlugins++; + } + + CRect rect; + AfxGetMainWnd()->GetWindowRect(rect); + + T2DLGTEMPLATE tmpl; + tmpl.pt = rect.CenterPoint(); + tmpl.moduleHandle = GetWorldModuleHandle(); + if (!inIsGradeUp) + tmpl.resID = 9100; + else + tmpl.resID = 9101; + + T2Dialog *theDialog = new T2Dialog; + theDialog->mDeleteOnClose = true; + theDialog->Realize(this, &tmpl, this, NULL, NULL, true, NULL, 0, true); + T2_APP->app_vfB4(); + + if (inIsGradeUp) { + T2DlgItemAnimation *theGradeUpAnimation = (T2DlgItemAnimation *) theDialog->GetDlgItem(104); + mWorldDef->SetupGradeUpAnimation(theGradeUpAnimation, mGameLevel); + + CString message; + mWorldDef->GetGradeUpMessage(mGameLevel, message); + ((T2DlgItem *) theDialog->GetDlgItem(105))->SetDescriptor(message); + + mSoundPlayer->Play("GradeUp", SoundMask_10, SoundFlags_10, NULL, PlayMode_2, 100); + + DWORD v = timeGetTime(); + while ((timeGetTime() - v) < 3000) + T2_APP->app_vfB4(); + } + + CString str; + T2DlgItemText *theItemNameText = (T2DlgItemText *) theDialog->GetDlgItem(101); + T2DlgItemText *thePluginTypeText = (T2DlgItemText *) theDialog->GetDlgItem(102); + T2DlgItemProgress *theProgress = (T2DlgItemProgress *) theDialog->GetDlgItem(103); + + theProgress->SetRange(0, numPlugins); + theProgress->SetPos(0); + theProgress->SetStep(1); + + // "テナント" + thePluginTypeText->SetDescriptor("\x83\x65\x83\x69\x83\x93\x83\x67"); + + T2_APP->app_vfB4(); + + mT2PluginLoader->SetTypeFilter(pos, 'TnPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mTenantPlugins->GetItem(specifier->mID) && + (!specifier->mSecretItem || (specifier->mSecretItem & (m9C != 0))) + ) + { + theItemNameText->SetDescriptor(specifier->mPluginName); + theProgress->StepIt(); + T2_APP->app_vfB4(); + + T2TenantPlugin *theTenantPlugin = (T2TenantPlugin *) mT2PluginLoader->LoadPlugin(specifier); + mTenantPlugins->Add(theTenantPlugin); + theTenantPlugin->LoadAllTemplatePlugin(mWorldDef, mTemplatePluginDB); + + T2TenantDef *def = (T2TenantDef *) theTenantPlugin->GetTemplatePlugin(); + mTenantTemplates->Regist(def); + + if (def->IsFloor()) + mFloorDef = def; + + if (!def->RequierToolIcon(theToolWindow)) + theToolWindow->AddIcon(def->mStr48, NULL, 0, kToolOption1, def, 0, 1, this); + theToolWindow->AddIcon("Category", NULL, def->mCategoryNo, kToolOption4, def, 0, 1, this); + + LoadSoundForPlugin(def); + T2PeopleLoader::Load(specifier, mTemplatePluginDB); + } + } + +#line 1996 + _ASSERT(mFloorDef != NULL); + + // "移動設備" + thePluginTypeText->SetDescriptor("\x88\xDA\x93\xAE\x90\xDD\x94\xF5"); + + T2_APP->app_vfB4(); + + mT2PluginLoader->SetTypeFilter(pos, 'MvPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mMoverPlugins->GetItem(specifier->mID) && + (!specifier->mSecretItem || (specifier->mSecretItem & (m9C != 0))) + ) + { + theItemNameText->SetDescriptor(specifier->mPluginName); + theProgress->StepIt(); + T2_APP->app_vfB4(); + + T2MoverPlugin *theMoverPlugin = (T2MoverPlugin *) mT2PluginLoader->LoadPlugin(specifier); + mMoverPlugins->Add(theMoverPlugin); + theMoverPlugin->LoadAllTemplatePlugin(mWorldDef, mTemplatePluginDB); + + T2MoverDef *def = (T2MoverDef *) theMoverPlugin->GetTemplatePlugin(); + mMoverTemplates->Regist(def); + + if (!def->RequierToolIcon(theToolWindow)) + theToolWindow->AddIcon(def->mStr48, NULL, 0, kToolOption2, def, 0, 1, this); + theToolWindow->AddIcon("Category", NULL, def->mCategoryNo, kToolOption4, def, 0, 1, this); + + LoadSoundForPlugin(def); + T2PeopleLoader::Load(specifier, mTemplatePluginDB); + } + } + + // "外観" + thePluginTypeText->SetDescriptor("\x8A\x4F\x8A\xCF"); + + T2_APP->app_vfB4(); + + mT2PluginLoader->SetTypeFilter(pos, 'OoPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mOuterObjPlugins->GetItem(specifier->mID) && + (!specifier->mSecretItem || (specifier->mSecretItem & (m9C != 0))) + ) + { + theItemNameText->SetDescriptor(specifier->mPluginName); + theProgress->StepIt(); + T2_APP->app_vfB4(); + + T2OuterObjPlugin *theOuterObjPlugin = (T2OuterObjPlugin *) mT2PluginLoader->LoadPlugin(specifier); + mOuterObjPlugins->Add(theOuterObjPlugin); + theOuterObjPlugin->LoadAllTemplatePlugin(mWorldDef, mTemplatePluginDB); + + T2OuterObjDef *def = (T2OuterObjDef *) theOuterObjPlugin->GetTemplatePlugin(); + mOuterObjTemplates->Regist(def); + + if (!def->RequierToolIcon(theToolWindow)) + theToolWindow->AddIcon(def->mStr48, NULL, 0, kToolOption3, def, 0, 2, this); + theToolWindow->AddIcon("Category", NULL, def->mCategoryNo, kToolOption4, def, 0, 2, this); + + LoadSoundForPlugin(def); + T2PeopleLoader::Load(specifier, mTemplatePluginDB); + } + } + + // "ムービー" + thePluginTypeText->SetDescriptor("\x83\x80\x81\x5B\x83\x72\x81\x5B"); + + T2_APP->app_vfB4(); + + mT2PluginLoader->SetTypeFilter(pos, 'MoPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mMoviePluginList->GetItem(specifier->mID) + ) + { + theItemNameText->SetDescriptor(specifier->mPluginName); + theProgress->StepIt(); + T2_APP->app_vfB4(); + + T2MoviePlugin *theMoviePlugin = new T2MoviePlugin('MoPl', *specifier); + theMoviePlugin->LoadSelf(); + mMoviePluginList->Add(theMoviePlugin); + + theMoviePlugin->UnfoldPluginSelf(); + T2PeopleLoader::Load(specifier, mTemplatePluginDB); + } + } + + // "イベント" + thePluginTypeText->SetDescriptor("\x83\x43\x83\x78\x83\x93\x83\x67"); + + T2_APP->app_vfB4(); + + mT2PluginLoader->SetTypeFilter(pos, 'HePl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mHallEventPlugins->GetItem(specifier->mID) + ) + { + theItemNameText->SetDescriptor(specifier->mPluginName); + theProgress->StepIt(); + T2_APP->app_vfB4(); + + T2HallEventPlugin *theHallEventPlugin = new T2HallEventPlugin('HePl', *specifier); + theHallEventPlugin->LoadSelf(); + mHallEventPlugins->Add(theHallEventPlugin); + + theHallEventPlugin->UnfoldPluginSelf(); + T2PeopleLoader::Load(specifier, mTemplatePluginDB); + } + } + + // "広告" + thePluginTypeText->SetDescriptor("\x8D\x4C\x8D\x90"); + + T2_APP->app_vfB4(); + + mT2PluginLoader->SetTypeFilter(pos, 'AdPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mAdvertisePlugins->GetItem(specifier->mID) + ) + { + theItemNameText->SetDescriptor(specifier->mPluginName); + theProgress->StepIt(); + T2_APP->app_vfB4(); + + T2AdvertisePlugin *theAdvertisePlugin = new T2AdvertisePlugin('AdPl', *specifier); + theAdvertisePlugin->LoadSelf(); + mAdvertisePlugins->Add(theAdvertisePlugin); + + theAdvertisePlugin->UnfoldPluginSelf(); + T2PeopleLoader::Load(specifier, mTemplatePluginDB); + } + } + + if (!inIsGradeUp) { + int id; + if (mViewMode == kOutView) { + id = theToolWindow->GetID("ToolInfo", 0); + } else { + // "フロア" + id = theToolWindow->GetID("\x83\x74\x83\x8D\x83\x41", 1); + } + theToolWindow->SetSel(id); + } + + POSITION pos1 = mTenantPlugins->GetHeadPosition(); + while (pos1) { + T2TenantPlugin *theTenantPlugin = (T2TenantPlugin *) mTenantPlugins->GetNext(pos1); + T2TenantDef *def = (T2TenantDef *) theTenantPlugin->GetTemplatePlugin(); + if (def) { + DWORD subPluginType = def->GetSubPluginType(); + if (subPluginType == 'MoPl') { + POSITION pluginPos = mMoviePluginList->GetHeadPosition(); + while (pluginPos) { + CResourcePlugin *thePlugin = (CResourcePlugin *) mMoviePluginList->GetNext(pluginPos); + if (thePlugin->GetType() == subPluginType) + def->Add(thePlugin); + } + } + } + } + + POSITION pos2 = mTenantPlugins->GetHeadPosition(); + while (pos2) { + T2TenantPlugin *theTenantPlugin = (T2TenantPlugin *) mTenantPlugins->GetNext(pos2); + T2TenantDef *def = (T2TenantDef *) theTenantPlugin->GetTemplatePlugin(); + if (def) { + DWORD subPluginType = def->GetSubPluginType(); + if (subPluginType == 'HePl') { + POSITION pluginPos = mHallEventPlugins->GetHeadPosition(); + while (pluginPos) { + CResourcePlugin *thePlugin = (CResourcePlugin *) mHallEventPlugins->GetNext(pluginPos); + if (thePlugin->GetType() == subPluginType) + def->Add(thePlugin); + } + } + } + } + + POSITION pos3 = mOuterObjPlugins->GetHeadPosition(); + while (pos3) { + T2OuterObjPlugin *theOuterObjPlugin = (T2OuterObjPlugin *) mOuterObjPlugins->GetNext(pos3); + T2OuterObjDef *theOuterObjDef = (T2OuterObjDef *) theOuterObjPlugin->GetTemplatePlugin(); + if (theOuterObjDef) { + DWORD subPluginType = theOuterObjDef->GetSubPluginType(); + if (subPluginType != 0) { + POSITION pluginPos = mAdvertisePlugins->GetHeadPosition(); + while (pluginPos) { + T2AdvertisePlugin *thePlugin = (T2AdvertisePlugin *) mAdvertisePlugins->GetNext(pluginPos); + if (thePlugin->GetSubType() == subPluginType) + theOuterObjDef->Add(thePlugin); + } + } + } + } + + _1F4 = 0; + theDialog->DestroyWindow(); + SetupGradeAnimation(); + towerDoc_vf294(); +} + +/*virtual*/ void T2TowerDoc::towerDoc_vfC0(int) { +#pragma var_order(var8, varC, counter, var14, oldLevel) + if (!mWorldPluginID || !mTowerMainView) + return; + + DWORD varC = timeGetTime(); + if (m218 == 0) + m218 = varC; + if (varC > m218) + m21C += varC - m218; + if (m21C > 1000) + m21C = 1000; + + int counter = 0; + DWORD var14 = timeGetTime(); + + while (m21C > mDrawSpeed) { + if ((counter++ % 2) == 0) { + MSG msg; + if (PeekMessage(&msg, NULL, 0, 0, 0)) { + if (msg.message == WM_QUIT) + return; + + if (msg.message != WM_PAINT) { + m21C = 0; + break; + } + } + } + + if ((timeGetTime() - var14) > 1000) { + m21C = 0; + break; + } + + mTowerMessage->SpendTime2(); + + if (!mPause) + towerDoc_vfC4(); + + if (m21C >= mDrawSpeed) + m21C -= mDrawSpeed; + + if (m208) + break; + } + + DWORD var8 = GetTickCount(); + if ((var8 - mC0) > 20) { + mBC = (mBC >= 7) ? 0 : (mBC + 1); + mC0 = var8; + } + + if (!gT2App->_E4) + return; + + mTowerMainView->tmv_vf120(); + m218 = varC; + + int oldLevel = mGameLevel; + if (oldLevel != CheckGameLevel()) { + mBC = 0; + mC0 = GetTickCount(); + SelectPlugins(true); + + mPool->GameLevelChanged(mGameLevel); + mIsDustOn = mWorldDef->IsDustOn(mGameLevel); + mToiletDenomi = mWorldDef->GetToiletDenomi(mGameLevel); + mColdDenomi = mWorldDef->GetColdDenomi(mGameLevel, mNow->GetMonth()); + } +} + +/*virtual*/ void T2TowerDoc::towerDoc_vfC4() { + if (m20C) { + m210++; + if ((time(NULL) - m20C) >= 5) { + m20C = 0; + + CString str; + str.Format("%.2f Idles/sec.", m210 / 5.0f); + + MessageBox(NULL, str, "RESULT", MB_OK); + } + + if (m214) + mTowerMainView->Invalidate(false); + } + + DispatchOptionEvent(kIdleOptionEvent, NULL); + + unsigned int theOldDay = mNow->GetDay(); + unsigned int theOldHour = mNow->GetHour(); + if (mNow->IsIncDateTime()) { + InvalClock(); + if (mNow->GetHour() != theOldHour) { + mPool->IncHour(mNow); + mTrafficInfo->HourChanged(this); + + unsigned int theNewDay = mNow->GetDay(); + if (theNewDay != theOldDay) { + InvalCalender(); + mWorldDef->DayChanged(this); + mColdDenomi = mWorldDef->GetColdDenomi(mGameLevel, mNow->GetMonth()); + + if (theNewDay == 1) { + mSettlement->Update(); + mFloorInfo->CalcMentenanceCost(this); + } + } + } + + if (mPool->IsChangePopulation()) + InvalPopulation(); + + if ((mNow->GetMinutes() == 0) && (mNow->GetHour() % 3) == 0) { + } + + mPaletteAnime->MinuteChanged(mNow); + } + + // this might be a bool + int idleResult = mWorldDef->IdleProc(this); + + if (m1CC) { + m1CC++; + if (m1CC == 256) + m1CC = 0; + } + + mPeopleArrayList->DispatchIdle(this); + + static DWORD var4479B0; + DWORD ticks = GetTickCount(); + if (ticks < var4479B0 || ticks >= (var4479B0 + 100)) { + var4479B0 = ticks; + CycleOutlinePalette(); + } + + mFloorInfo->GetRequestArrayList()->DispatchIdle(this); + mFloorInfo->GetMoverArrayList()->DispatchIdle(this); + + if (idleResult == 0) { + mFloorInfo->GetTenantArrayList()->DispatchIdle(this); + mFloorInfo->GetOutObjArrayList()->DispatchIdle(this); + + m204++; + if (m204 >= 40) { + m204 = 0; + if (mOuterObjTemplates) + mOuterObjTemplates->DispatchIdle(this); + if (mMoverTemplates) + mMoverTemplates->DispatchIdle(this); + if (mTenantTemplates) + mTenantTemplates->DispatchIdle(this); + } + + CheckBuildQueue(); + } + + if (mPaletteAnime->IsSETime()) + mPaletteAnime->ChangeSE(); + mPaletteAnime->DoAnimatePalette(); + + mTowerMessage->SpendTime(); + + static DWORD var4479B4 = 0; + static DWORD var4479B8 = 0; + + var4479B4++; + if (var4479B8 == 0) + var4479B8 = GetTickCount(); + + DWORD endTicks = GetTickCount(); + if ((endTicks - var4479B8) >= 550) { + if (mDisplayIPS) { + char buf[12]; + sprintf(buf, "%.2f", (var4479B4 * 1000.0f) / (endTicks - var4479B8)); + T2_MAIN_WINDOW->mDbgIPS->GetDlgItem(1019)->SetWindowText(buf); + } + var4479B4 = 0; + var4479B8 = endTicks; + } + + SetModifiedFlag(); +} + +/*virtual*/ void T2TowerDoc::DoDestruct(const CPoint &inPt) { +#pragma var_order(ptC, result, theHit, var18, pt20, var24) + POINT pt20 = inPt; + POINT ptC = inPt; + UT2Coordinate::QDToUnit(pt20, mZoomLevel); + + T2DrawableObject *var18 = NULL; + BOOL var24 = false; + + HitTestResult result; + int theHit = HitTest(inPt, result, true, mViewMode != kOutView); + if (!result.obj) + return; + + if (mViewMode == kOutView) { + if (theHit == kHitOutObj) { + var24 = DestructOutObj(inPt, pt20, (T2OutObj *) result.obj); + if (var24) + var18 = result.obj; + } + } else { + if (theHit == kHitMover) { + var24 = DestructMover(inPt, pt20, (T2Mover *) result.obj); + if (var24) + var18 = result.obj; + } + + if (theHit == kHitTenant) { + var24 = DestructTenant(inPt, pt20, (T2Tenant *) result.obj, false); + if (var24) + var18 = result.obj; + } + } + + if (var24 && mWorldDef && var18) { + if (theHit == kHitOutObj) + mWorldDef->SetLatestBuild(((T2OutObj *) var18)->GetToolDef(), false); + else + mWorldDef->SetLatestBuild((T2Equip *) var18, false); + } +} + +/*virtual*/ BOOL T2TowerDoc::DestructTenant(POINT inPt1, POINT inPt2, T2Tenant *inTenant, BOOL inSkipSounds) { + if (inTenant->IsFloor() && !OutsideAreaCheck(inTenant, true)) + return false; + + if (!inTenant->IsBuildFinish()) { + // EN: Can not remove the item under construction until it is completed. + towerDoc_vf13C()->BuildErr(52, NULL); + + if (!inSkipSounds) + mSoundPlayer->Play("No", SoundMask_20, SoundFlags_20, &inPt2, PlayMode_2, 100); + return false; + } + + T2Name *theName = mNameDB->Search(inTenant); + RECT destructRect = {0, 0, 0, 0}; + PROCCODE result = inTenant->DoDestruct(this, inPt1, destructRect); + + if (result == ProcCode_1 && theName) { + mNameDB->RemoveName(theName); + delete theName; + } + + if (!IsRectEmpty(&destructRect)) { + CalcCraneUpdateRect(destructRect); + mTowerMainView->InvalUnitRect(destructRect, true); + } + + if (!inSkipSounds) { + if (result == ProcCode_1) + mSoundPlayer->Play("Destroy", SoundMask_20, SoundFlags_20, &inPt2, PlayMode_2, 100); + else + mSoundPlayer->Play("No", SoundMask_20, SoundFlags_20, &inPt2, PlayMode_2, 100); + } + + return true; +} + +BOOL T2TowerDoc::OutsideAreaCheck(T2Tenant *inTenant, BOOL inShowError) { + RECT rect; + inTenant->GetEquipArea(rect); + + for (int v = rect.top; v < rect.bottom; v++) { + for (int h = rect.left; h < rect.right; h++) { + if (mFloorInfo->GetOutObjID(v, h) != 0) { + if (inShowError) { + // EN: Can not remove this floor because an outside item is placed. + towerDoc_vf13C()->BuildErr(69 /*nice*/, NULL); + } + return false; + } + } + } + + return true; +} + +void T2TowerDoc::CalcCraneUpdateRect(RECT &ioRect) { + RECT rect; + RECT craneArea; + int i; + + rect.top = rect.left = 0; + rect.right = mWorldDef->m190.x; + rect.bottom = mWorldDef->m190.y; + + for (i = 0; i < mCraneCount; i++) { + craneArea = rect; + OffsetRect(&craneArea, mCranePosArray[i].x, mCranePosArray[i].y); + UnionRect(&ioRect, &craneArea, &ioRect); + } + + mWorldDef->CalcCranePos(this); + + for (i = 0; i < mCraneCount; i++) { + craneArea = rect; + OffsetRect(&craneArea, mCranePosArray[i].x, mCranePosArray[i].y); + UnionRect(&ioRect, &craneArea, &ioRect); + } +} + +/*virtual*/ BOOL T2TowerDoc::DestructMover(POINT inPt1, POINT inPt2, T2Mover *inMover) { + RECT destructRect = {0, 0, 0, 0}; + + if (inMover->DoDestruct(this, inPt1, destructRect) == ProcCode_1) { + mSoundPlayer->Play("Destroy", SoundMask_20, SoundFlags_20, &inPt2, PlayMode_2, 100); + mTowerMainView->InvalUnitRect(destructRect, true); + return true; + } + + return true; +} + +/*virtual*/ BOOL T2TowerDoc::DestructOutObj(POINT inPt1, POINT inPt2, T2OutObj *inOutObj) { + CRect rect; + + if (inOutObj->DoDestruct(this, 0, inPt1, inPt2, rect) == ProcCode_1) { + mOuterObjList->RemoveItemsAt(1, mOuterObjList->FetchIndexOf(&inOutObj)); + + mSoundPlayer->Play("Destroy", SoundMask_20, SoundFlags_20, &inPt2, PlayMode_2, 100); + mTowerMainView->InvalUnitRect(rect, true); + + CalcCraneUpdateRect(rect); + mTowerMainView->InvalUnitRect(rect, true); + + return true; + } + + return false; +} + +/*virtual*/ BOOL T2TowerDoc::DoClickByTenantTool(CRect inRect, T2TenantDef *inDef, unsigned int inValiation) { +#pragma var_order(rect, clickResult, result) + if (!inDef) + return false; + + _200 = 0; + + RECT rect = inRect; + mFundsOnClick = GetCurrentFunds(); + _1A4 = NULL; + + int clickResult = 0; + clickResult = inDef->ClickProc(this, &rect, inValiation); + + _1BC = inRect.TopLeft(); + m1A0 = inDef; + mValiation = inValiation; + + CalcDragMask(inRect); + BOOL result = towerDoc_vf248(rect); + mTowerMainView->tmv_vf120(); + + if (!clickResult) { + free(mDragMask); + mDragMask = NULL; + } + + return result; +} + +/*virtual*/ void T2TowerDoc::DoDragByTenantTool(CRect inRect) { +#pragma var_order(buildArea, pt) + // TODO: name me + CPoint pt = inRect.TopLeft(); + + RECT buildArea; + mWorldDef->GetBuildArea(buildArea); + + pt.x = min(pt.x, buildArea.right); + pt.x = max(pt.x, buildArea.left); + + pt.y = min(pt.y, buildArea.bottom); + pt.y = max(pt.y, buildArea.top); + + if (mDragMask) { +#pragma var_order(rect, pt2) + CRect rect; + POINT pt2; + pt2.y = _1BC.y; + if (_1BC.x <= pt.x) { + for (pt2.x = _1BC.x; pt2.x <= pt.x; pt2.x += inRect.Width()) { + if (mDragMask[pt2.x].x0 == kDm1) + break; + + rect.top = pt2.y; + rect.left = pt2.x; + rect.bottom = pt2.y + inRect.Height(); + rect.right = pt2.x + inRect.Width(); + + towerDoc_vf248(rect); + } + } else { + for (pt2.x = _1BC.x; pt2.x >= pt.x; pt2.x -= inRect.Width()) { + if (mDragMask[pt2.x].x0 == kDm1) + break; + + rect.top = pt2.y; + rect.left = pt2.x; + rect.bottom = pt2.y + inRect.Height(); + rect.right = pt2.x + inRect.Width(); + + towerDoc_vf248(rect); + } + } + + mTowerMainView->tmv_vf120(); + } +} + +/*virtual*/ void T2TowerDoc::DoReleaseByTenantTool(CRect inRect) { + CPoint centerPt = inRect.CenterPoint(); + + if (_200 > 0) { + if (m1A0 && !m1A0->IsFloor()) + mSoundPlayer->Play("Build2", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_2, 100); + else if (m1A0 && m1A0->IsFloor()) + mSoundPlayer->Play("Build", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_2, 100); + + RECT craneUpdateRect = {0, 0, 0, 0}; + CalcCraneUpdateRect(craneUpdateRect); + mTowerMainView->InvalUnitRect(craneUpdateRect, true); + } + + int moneySpent = mFundsOnClick - GetCurrentFunds(); + if (inRect.top >= mWorldDef->mGroundLine && !m1A0->IsFloor() && moneySpent >= 65) { + T2TreasureStatus status; + if (mWorldDef->CheckTreasure(this, &status)) { + T2TreasureDialog::ShowTreasureDialog(this, &status); + int winnings = status._0; + DoPay(-winnings, kFundGroup4); + } + } + + if (mDragMask) { + free(mDragMask); + mDragMask = NULL; + } +} + +/*virtual*/ void T2TowerDoc::CalcDragMask(CRect inRect) { + RECT buildArea; + mWorldDef->GetBuildArea(buildArea); + + int width = mWorldDef->GetWidth(); + mDragMask = (DragMask *) malloc(width * sizeof(DragMask)); + + int i; + for (i = 0; i < width; i++) { + mDragMask[i].x0 = kDm1; + mDragMask[i].x4 = 0; + SetRectEmpty(&mDragMask[i].rect); + } + + int funds = GetCurrentFunds(); + CalcDragMaskPoint(inRect, funds, mDragMask, 0, false); + + if (mDragMask[inRect.left].x0 == kDm0) { + CRect rect = inRect; + + for (i = inRect.left + inRect.Width(); i < width; i += inRect.Width()) { + rect.left = i; + rect.right = i + inRect.Width(); + if (CalcDragMaskPoint(rect, funds, mDragMask, 2, false) != kDm0) + break; + } + + funds = mDragMask[inRect.left].x4; + for (i = inRect.left - m1A0->mWidth; i >= 0; i -= inRect.Width()) { + rect.left = i; + rect.right = i + inRect.Width(); + if (CalcDragMaskPoint(rect, funds, mDragMask, 1, false) != kDm0) + break; + } + } +} + +/*virtual*/ int T2TowerDoc::CalcDragMaskPoint(CRect &ioRect, int &ioFunds, DragMask *inArray, int inMode, BOOL inShowError) { + int h = ioRect.left; + + if (ioFunds < 0) + return true; + if (inArray && inArray[h].x0 == kDm2) + return true; + + RECT area = ioRect; + unsigned int valiation; + if (!m1A0->IsFloor()) { + if (area.bottom == mWorldDef->mGroundLine) + valiation = 1; + else + valiation = 0; + } else { + valiation = mValiation; + } + + int cost = 0; + BOOL success = CheckTenantArea(area, m1A0, inShowError, false); + if (success && success) { + RECT rect2 = area; + + BOOL isSkyBridge = false; + CProgramPlugin *thePlugin = m1A0->GetPlugin(); + isSkyBridge = (thePlugin && thePlugin->GetID() == 'SKYB'); + + if (!isSkyBridge) { + success = mFloorDef->AreaCheck( + this, + rect2, + valiation | + (!m1A0->IsFloor() ? 0x10000 : 0) | + ((inMode == 1) ? 0x1000 : 0) | + ((inMode == 2) ? 0x100 : 0), + inShowError + ) == AreaCheckCode_1; + } + + if (success) + cost += mFloorDef->CalcPayment(this, rect2, valiation); + + if (success && !m1A0->IsFloor()) { + success = (m1A0->AreaCheck(this, area, mValiation, inShowError) == AreaCheckCode_1); + cost += m1A0->CalcPayment(this, area, mValiation); + } + + if (success) { + if (ioFunds >= cost) { + ioFunds -= cost; + ioRect = area; + + if (inArray) { + for (int i = area.left; i < area.right; i++) { + if (inArray[i].x0 != kDm0) + inArray[i].x0 = kDm2; + } + + inArray[h].x0 = kDm0; + inArray[h].x4 = ioFunds; + inArray[h].rect = area; + } + } else { + success = false; + if (inShowError) { + // EN: Shortage of construction money. + towerDoc_vf13C()->BuildErr(10, NULL); + } + } + } + } + + if (inArray) + return inArray[h].x0; + return success ? kDm0 : kDm1; +} + +/*virtual*/ BOOL T2TowerDoc::CheckTenantArea(const RECT &inRect, T2TenantDef *inTenantDef, BOOL inShowErr, BOOL inUnkFlag) { + RECT buildArea; + mWorldDef->GetBuildArea(buildArea); + + if (inRect.top < buildArea.top || inRect.bottom > buildArea.bottom || inRect.left < buildArea.left || inRect.right > buildArea.right) { + if (inShowErr) { + // EN: Can not place items here. + towerDoc_vf13C()->BuildErr(8, NULL); + } + return false; + } + + if (!mFloorInfo->IsAreaBuildable(inRect)) { + if (inShowErr) { + // EN: Can not place items here. + towerDoc_vf13C()->BuildErr(8, NULL); + } + return false; + } + + if (!inUnkFlag) { + if (!m1A0->IsFloor()) { + if (m1A0->IsSetAttribute(kTenantAttrOnlyGroundFloor)) { + if (inRect.bottom != mWorldDef->mGroundLine) { + if (inShowErr) { + // EN: This item can only be placed on the lobby floor. + towerDoc_vf13C()->BuildErr(23, NULL); + } + return false; + } + } else { + if (mWorldDef->mGroundLine > inRect.top && inRect.bottom > (mWorldDef->mGroundLine - mWorldDef->GetLobbyHeight())) { + if (inShowErr) { + // EN: Can not place this item on the lobby floor. + towerDoc_vf13C()->BuildErr(24, NULL); + } + return false; + } + } + + if (m1A0->IsSetAttribute(kTenantAttrOnlyAboveGround)) { + if (inRect.bottom > mWorldDef->mGroundLine) { + if (inShowErr) { + // EN: Can not place this item underground. + towerDoc_vf13C()->BuildErr(6, NULL); + } + return false; + } + } + + if (m1A0->IsSetAttribute(kTenantAttrOnlyUnderground)) { + if (inRect.top < mWorldDef->mGroundLine) { + if (inShowErr) { + // EN: Can not place this item above ground. + towerDoc_vf13C()->BuildErr(7, NULL); + } + return false; + } + } + } + + BOOL isBuildingFloor = m1A0->IsFloor(); + + POSITION pos = mObjectQueue->GetHeadPosition(); + while (pos) { + RECT tmp; + T2Equip *equip = (T2Equip *) mObjectQueue->GetNext(pos); + if (IntersectRect(&tmp, &inRect, &equip->mArea)) { + if (inShowErr) { + // EN: Can not place items where something else already exists. + towerDoc_vf13C()->BuildErr(9, NULL); + } + return false; + } + } + + for (int v = inRect.top; v < inRect.bottom; v++) { + for (int h = inRect.left; h < inRect.right; h++) { + T2Tenant *theTenant = mFloorInfo->GetTenant(v, h); + if (theTenant && (isBuildingFloor || !theTenant->IsFloor())) { + if (inShowErr) { + // EN: Can not place items where something else already exists. + towerDoc_vf13C()->BuildErr(9, NULL); + } + return false; + } + } + } + } + + return true; +} + +/*virtual*/ BOOL T2TowerDoc::towerDoc_vf248(CRect inRect) { + BOOL result = true; + + int cost2 = 0; + int beginH = inRect.left; + CPoint centerPt = inRect.CenterPoint(); + + if (mDragMask[beginH].x0 == kDm3) + result = false; + + if (result && m1A0->GetMaxBuildCount() != 0) { + if (m1A0->GetCurBuildCount() >= m1A0->GetMaxBuildCount()) { + if (_B0) { + // EN: Can not make additional placement of this item. + towerDoc_vf13C()->BuildErr(11, NULL); + } + result = false; + } + } + + if (result) { + int funds = GetCurrentFunds(); + CalcDragMaskPoint(inRect, funds, NULL, 0, _B0); + if (mDragMask[beginH].x0 != kDm0) + result = false; + } + + CRect rect = inRect; + if (result) { + if (!CheckTenantArea(rect, m1A0, false, false)) + result = false; + } + + if (result) { + int cost = 0; + int h, v; + + if (!m1A0->IsFloor()) { + for (v = rect.top; v < rect.bottom; v++) { + BOOL isLobby; + if (rect.bottom == mWorldDef->mGroundLine) + isLobby = true; + else + isLobby = false; + + for (h = rect.left; h < rect.right; h++) { + if (!mFloorInfo->GetTenant(v, h)) { + RECT newTenantRect; + newTenantRect.top = v; + newTenantRect.left = h; + newTenantRect.bottom = v + 1; + + for (; h < rect.right; h++) { + if (mFloorInfo->GetTenant(v, h)) + break; + } + + newTenantRect.right = h; + + mFloorDef->AreaCheck(this, newTenantRect, 3, false); + cost += mFloorDef->CalcPayment(this, newTenantRect, 0); + + h = newTenantRect.right; + + T2Tenant *theTenant = AssignNewTenant(mFloorDef, newTenantRect, (isLobby == 1)); + theTenant->StartBuild(); + mFloorInfo->FillTenantID(theTenant->mArea, theTenant->mEquipID); + theTenant->GetEquipDef()->BuildFinish(this, theTenant); + + mTowerMainView->InvalUnitRect(newTenantRect, true); + mTowerMainView->tmv_vf120(); + } + } + } + } + + if (_1A4 && !_1A4->IsFloor()) + _1A4 = NULL; + + if (!_1A4) { + _1A4 = AssignNewTenant(m1A0, rect, mValiation); + TenantAdded(_1A4); + cost += m1A0->CalcPayment(this, rect, mValiation); + } + + BOOL isFloor = false; + if (!_1A4->IsFloor()) { + mSoundPlayer->Play("Build1", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_2, 100); + mObjectQueue->AddItem(_1A4); + CheckBuildQueue(); + } else { + mSoundPlayer->Play("BuildFloor", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_0, 100); + + RECT origArea = _1A4->mArea; + if (rect.left < _1A4->mArea.left) + _1A4->mArea.left = rect.left; + if (_1A4->mArea.right < rect.right) + _1A4->mArea.right = rect.right; + + mFloorDef->AreaCheck(this, _1A4->mArea, mValiation, false); + + if (!EqualRect(&origArea, &_1A4->mArea) || EqualRect(&rect, &_1A4->mArea)) { + if (!EqualRect(&origArea, &_1A4->mArea)) + cost += mFloorDef->CalcPayment(this, _1A4->mArea, mValiation); + + mFloorDef->OptionProc(this, _1A4, NULL); + mFloorInfo->FillTenantID(_1A4->mArea, _1A4->mEquipID); + _1A4->StartBuild(); + _1A4->GetEquipDef()->BuildFinish(this, _1A4); + + isFloor = true; + } + } + + if (isFloor) + mTowerMainView->InvalUnitRect(_1A4->mArea, true); + + DoPay(cost, kFundGroup1); + DoPay(-cost2, kFundGroup4); + + mWorldDef->SetLatestBuild(_1A4, true); + + for (h = inRect.left; h < inRect.right; h++) + mDragMask[h].x0 = kDm3; + + InvalFunds(); + _200++; + } else { + if (_200 == 0) { + CPoint pt = inRect.CenterPoint(); + mSoundPlayer->Play("No", SoundMask_20, SoundFlags_20, &pt, PlayMode_2, 100); + _200--; + } + } + + return result; +} + +/*virtual*/ T2Tenant *T2TowerDoc::AssignNewTenant(T2TenantDef *inTenantDef, RECT &inRect, unsigned int inValiation) { + T2Tenant *theTenant = mFloorInfo->FindUnusedTenant(); + theTenant->InitTenant(inTenantDef, inRect, inValiation); + return theTenant; +} + +/*virtual*/ void T2TowerDoc::CheckBuildQueue() { + POSITION position = mObjectQueue->GetHeadPosition(); + while (position) { + POSITION oldPosition = position; + T2Tenant *tenant = (T2Tenant *) mObjectQueue->GetNext(position); + BOOL isWait = false; + + for (int v = tenant->mArea.top; v < tenant->mArea.bottom; v++) { + for (int h = tenant->mArea.left; h < tenant->mArea.right; h++) { + T2Tenant *otherTenant = mFloorInfo->GetTenant(v, h); + if (otherTenant && otherTenant->IsFloor()) { + if (!otherTenant->IsBuildFinish()) { + isWait = true; + break; + } + h = otherTenant->mArea.right - 1; + } + } + } + + if (!isWait) { + T2Tenant *theFloor = mFloorInfo->GetTenant(tenant->mArea.top, tenant->mArea.left); + tenant->SetFloorID(mFloorInfo); + mFloorInfo->FillTenantID(tenant->mArea, tenant->mEquipID); + + tenant->StartBuild(); + + RECT updateRect = tenant->mArea; + if (tenant->mArea.right < theFloor->mArea.right) { + updateRect.right = theFloor->mArea.right; + theFloor->SetDrawMode(DrawMode3); + } + mTowerMainView->InvalUnitRect(updateRect, true); + + mObjectQueue->RemoveItem(oldPosition); + position = mObjectQueue->GetHeadPosition(); + } + } +} + +/*virtual*/ BOOL T2TowerDoc::DoClickByMoverTool(CRect inRect, T2MoverDef *inDef, unsigned int inValiation, BOOL inIsFromMouseMove) { + if (!inDef) + return false; + + int cost = 0; + + RECT moverRect = inRect; + +#line 3246 + _ASSERT(!inDef->ClickProc(this, &moverRect, inValiation)); + + if (!mFloorInfo->IsAreaBuildable(moverRect)) + return false; + + AREACHECKCODE theAreaCheck = inDef->AreaCheck(this, moverRect, 0, !inIsFromMouseMove); + if (theAreaCheck == AreaCheckCode_0) + return false; + if (theAreaCheck == AreaCheckCode_0) + return false; + + if (theAreaCheck == AreaCheckCode_1) { + moverRect.top -= inDef->mAddSize.top; + moverRect.left -= inDef->mAddSize.left; + moverRect.bottom -= inDef->mAddSize.bottom; + moverRect.right -= inDef->mAddSize.right; + } + + CRect requiredSpace = moverRect; + requiredSpace.left -= T2MoverDef::GetRequiredRequestSpace(); + requiredSpace.right += T2MoverDef::GetRequiredRequestSpace(); + + CRect checkSpace, buildArea; + mFloorInfo->GetBuildArea(buildArea); + checkSpace.IntersectRect(buildArea, requiredSpace); + + if (checkSpace != requiredSpace || !mFloorInfo->IsAllTenant(requiredSpace)) { + if (!inIsFromMouseMove) { + if (inDef->IsStair()) { + // EN: can not be placed there. + towerDoc_vf13C()->BuildErr(41, inDef); + } else { + // EN: Can not place elevator system there. + towerDoc_vf13C()->BuildErr(42, NULL); + } + } + return false; + } + + T2FInfoAreaIterator iter(*mFloorInfo, requiredSpace); + T2UnitInfo *theUnitInfo; + while (iter.Next(theUnitInfo)) { + unsigned int theTenantID = theUnitInfo->GetTenantID(); + if (theTenantID != 0) { + T2Tenant *theTenant = mFloorInfo->GetTenant(theTenantID); + if (theTenant && theTenant->IsSetAttribute(kTenantAttr40000)) { + if (!inIsFromMouseMove) { + // EN: Can not place a transit system on the Sky Bridge. + towerDoc_vf13C()->BuildErr(72, NULL); + } + return false; + } + } + } + + if (!mFloorInfo->IsEnoughSideSpace(inRect)) { + if (!inIsFromMouseMove) { + if (inDef->IsStair()) { + // EN: requires space on both sides. + towerDoc_vf13C()->BuildErr(32, inDef); + } else { + // EN: The elevator item requires space on both sides. + towerDoc_vf13C()->BuildErr(33, NULL); + } + } + return false; + } + + BOOL finish = true; + + if (theAreaCheck == AreaCheckCode_1) { + cost = inDef->CalcPayment(this, moverRect, 0); + if (cost > GetCurrentFunds()) { + if (!inIsFromMouseMove) { + // EN: Shortage of construction money. + towerDoc_vf13C()->BuildErr(10, NULL); + } + return false; + } + + if (!inIsFromMouseMove) { + mFloorInfo->FinishBuildFloor(this, requiredSpace); + finish = towerDoc_vf258(moverRect, inDef); + } + } else if (theAreaCheck == AreaCheckCode_2) { + cost = inDef->m194; + if (cost == 0) + cost = inDef->CalcPayment(this, moverRect, 0); + + if (cost > GetCurrentFunds()) { + if (!inIsFromMouseMove) { + // EN: Shortage of construction money. + towerDoc_vf13C()->BuildErr(10, NULL); + } + return false; + } + + if (!inIsFromMouseMove) { + mFloorInfo->FinishBuildFloor(this, requiredSpace); + finish = towerDoc_vf25C(moverRect, inDef); + } + } + + if (!inIsFromMouseMove && finish) { + DoPay(cost, kFundGroup1); + mWorldDef->SetLatestBuild(inDef, true); + } + + return true; +} + +/*virtual*/ void T2TowerDoc::DoDragByMoverTool(CRect inRect) { + // empty +} + +/*virtual*/ void T2TowerDoc::DoReleaseByMoverTool(CRect inRect) { + // empty +} + +/*virtual*/ BOOL T2TowerDoc::towerDoc_vf258(const RECT &inRect, T2MoverDef *inMoverDef) { + if (!inMoverDef) + return false; + + CRect cRect = inRect; + CPoint centerPt = cRect.CenterPoint(); + + RECT moverArea = inRect; + + BOOL didBuildMover = false; + PROCCODE result = inMoverDef->DoBuildProc(this, moverArea, 0); + + if (result == ProcCode_1) { + mSoundPlayer->Play("Build", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_2, 100); + didBuildMover = true; + } + + if (result == ProcCode_0) { + T2Mover *theMover = mFloorInfo->FindUnusedMover(); + theMover->InitMover(inMoverDef, moverArea, 0); + mFloorInfo->FillMoverID(theMover->mArea, theMover->mEquipID); + theMover->GetEquipDef()->BuildFinish(this, theMover); + moverArea = theMover->mArea; + } + + mTowerMainView->InvalUnitRect(moverArea); + mTowerMainView->tmv_vf120(); + return didBuildMover; +} + +/*virtual*/ BOOL T2TowerDoc::towerDoc_vf25C(const RECT &inRect, T2MoverDef *inMoverDef) { + if (!inMoverDef) + return false; + + CRect buildRect = inRect; + CPoint centerPt = buildRect.CenterPoint(); + + RECT moverArea = inRect; + + T2FInfoAreaIterator iter(*mFloorInfo, inRect); + T2UnitInfo *unitInfo; + T2Mover *theMover; + while (iter.Next(unitInfo)) { + unsigned int theMoverID = unitInfo->GetMoverID(); + if (theMoverID != 0) { + theMover = mFloorInfo->GetMover(theMoverID); + if (theMover->GetEquipType() == inMoverDef->GetEquipType()) + break; + } + } + + if (inMoverDef->AddModuleProc(this, theMover, &moverArea) == ProcCode_1) { + mSoundPlayer->Play("Build1", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_2, 100); + return true; + } + + return false; +} + +/*virtual*/ BOOL T2TowerDoc::DoClickByFingerTool(CPoint inPt) { + CPoint pt = inPt; + UT2Coordinate::QDToUnit(pt, mZoomLevel); + + T2Mover *theMover = mFloorInfo->GetMover(pt.y, pt.x); + m1C4 = theMover; + if (theMover) { + if (theMover->GetPartFromPoint(this, inPt, NULL)) + return theMover->GetEquipDef()->FingerToolProc(this, theMover, inPt, MouseEvent_0); + } + + T2Tenant *theTenant = mFloorInfo->GetTenant(pt.y, pt.x); + m1C4 = theTenant; + if (theTenant) { + if (theTenant->GetPartFromPoint(this, inPt, NULL)) + return theTenant->GetEquipDef()->FingerToolProc(this, theTenant, inPt, MouseEvent_0); + } + + return false; +} + +/*virtual*/ BOOL T2TowerDoc::towerDoc_vf23C(CPoint inPt) { + CPoint pt = inPt; + UT2Coordinate::QDToUnit(pt, mZoomLevel); + + if (pt.x < 0) + return false; + if (pt.x >= mFloorInfo->GetHRange()) + return false; + + if (pt.y < 0) + return false; + if (pt.y >= mFloorInfo->GetVRange()) + return false; + + T2Mover *theMover = mFloorInfo->GetMover(pt.y, pt.x); + if (theMover) { + T2MoverDef *theMoverDef = (T2MoverDef *) theMover->GetEquipDef(); + if (theMoverDef) { + PARTCODE part = theMoverDef->GetPartFromPoint(this, theMover, inPt, NULL); + if (part == PartCode_1 || part == PartCode_3) + return true; + } + } + + return false; +} + +/*virtual*/ void T2TowerDoc::DoDragByFingerTool(CPoint inPt) { + m1C4->GetEquipDef()->FingerToolProc(this, m1C4, inPt, MouseEvent_1); +} + +/*virtual*/ void T2TowerDoc::DoReleaseByFingerTool(CPoint inPt) { + m1C4->GetEquipDef()->FingerToolProc(this, m1C4, inPt, MouseEvent_2); + m1C4 = NULL; +} + +/*virtual*/ void T2TowerDoc::DoClickByOutObjTool(CRect inRect, T2OuterObjDef *inDef, unsigned int inValiation) { + towerDoc_vf260(inRect, inDef); +} + +/*virtual*/ void T2TowerDoc::DoDragByOutObjTool(CRect inRect) { + // empty +} + +/*virtual*/ void T2TowerDoc::DoReleaseByOutObjTool(CRect inRect) { + // empty +} + +/*virtual*/ void T2TowerDoc::DoGetInfo(CPoint inPt) { + HitTestResult result; + int theHit = HitTest(inPt, result, false, mViewMode != kOutView); + + if (!result.obj) + return; + + if (theHit != kHitBkgndInfo && theHit != kHitSpriteObj) { + if (mViewMode != kOutView || (mViewMode == kOutView && theHit == kHitOutObj)) { + if (theHit == kHitMover) + ((T2Mover *) result.obj)->ShowInfoDialog(this, inPt); + else + ((T2Equip *) result.obj)->ShowInfoDialog(this); + } + } +} + +/*virtual*/ void T2TowerDoc::towerDoc_vf228(CPoint inPt) { + // empty +} + +/*virtual*/ void T2TowerDoc::DoInterview(CPoint inPt) { + CPoint pt = inPt; + UT2Coordinate::QDToUnit(pt, mZoomLevel); + + T2People *thePeople = mFloorInfo->FindPeople(pt.y, pt.x); + if (thePeople) + thePeople->Interview(this); +} + +/*virtual*/ void T2TowerDoc::DoSearchRangeTool(CPoint inPt) { + CPoint pt = inPt; + UT2Coordinate::QDToUnit(pt, mZoomLevel); + + T2Tenant *theClickTenant = mFloorInfo->GetTenant(pt.y, pt.x); + if (theClickTenant && !theClickTenant->IsFloor()) + SetSearchRangeFrom(theClickTenant); +} + +/*virtual*/ void T2TowerDoc::towerDoc_vf260(const RECT &inRect, T2OuterObjDef *inOuterObjDef) { + CRect rect = inRect; + CPoint centerPt = rect.CenterPoint(); + + if (inOuterObjDef->AreaCheck(this, rect, 0, true) == AreaCheckCode_1) { + mSoundPlayer->Play("Build", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_2, 100); + + T2OutObj *theOutObj = mFloorInfo->FindUnusedOutObj(); + inOuterObjDef->InitObject(theOutObj); + theOutObj->_3C = rect; + + mOuterObjList->Add(&theOutObj); + mFloorInfo->FillOutObjID(rect, theOutObj->mID); + + mTowerMainView->InvalUnitRect(rect, true); + mWorldDef->SetLatestBuild(inOuterObjDef, true); + + DoPay(inOuterObjDef->mPrice[0], kFundGroup1); + theOutObj->InitOutObj(inOuterObjDef, rect, mValiation); + } +} + +/*virtual*/ BOOL T2TowerDoc::towerDoc_vf288(RECT &ioRect, int &ioCost) { + int cost = ioCost, x, y; + RECT rect; + RECT origRect = ioRect; + + for (y = ioRect.top; y < ioRect.bottom; y++) { + for (x = ioRect.left; x < ioRect.right; x++) { + if (mFloorInfo->GetTenant(y, x) == 0) { + rect.top = y; + rect.bottom = y + 1; + rect.left = x; + + for (; x < ioRect.right; x++) { + if (mFloorInfo->GetTenant(y, x)) + break; + } + + rect.right = x; + + if (!CheckTenantArea(rect, mFloorDef, false, true)) + return false; + if (!mWorldDef->TenantAreaCheck(this, rect, false)) + return false; + if (mFloorDef->AreaCheck(this, rect, 0, false) != AreaCheckCode_1) + return false; + + cost += mFloorDef->CalcPayment(this, rect, 0); + if (cost > GetCurrentFunds()) + return false; + + UnionRect(&ioRect, &ioRect, &rect); + } + } + } + + ioCost = cost; + return true; +} + +/*virtual*/ void T2TowerDoc::FillFloor(const RECT &inRect) { + RECT rect; + int x, y; + + for (y = inRect.top; y < inRect.bottom; y++) { + for (x = inRect.left; x < inRect.right; x++) { + if (mFloorInfo->GetTenantID(y, x) == 0) { + rect.top = y; + rect.bottom = y + 1; + rect.left = x; + + for (; x < inRect.right; x++) { + if (mFloorInfo->GetTenant(y, x)) + break; + } + + rect.right = x; + + T2Tenant *theTenant = AssignNewTenant(mFloorDef, rect, 0); + theTenant->SetStatus(kTenantStatus1); + + mFloorInfo->FillTenantID(theTenant->mArea, theTenant->mEquipID); + theTenant->GetEquipDef()->BuildFinish(this, theTenant); + theTenant->Idle(this); + + CalcCraneUpdateRect(rect); + mTowerMainView->InvalUnitRect(rect, true); + } + } + } + + mFloorInfo->FinishBuildFloor(this, inRect); +} + +/*virtual*/ void T2TowerDoc::towerDoc_vf298() { + if (!m1CC) + m1CC = 1; +} + +/*virtual*/ void T2TowerDoc::BreakoutEmergency() { + mFloorInfo->GetTenantArrayList()->BreakoutEmergency(this); + mFloorInfo->GetRequestArrayList()->BreakoutEmergency(this); + mPeopleArrayList->BreakoutEmergency(this); +} + +void T2TowerDoc::OnUpdateDebugStepRun(CCmdUI *pCmdUI) { + pCmdUI->SetCheck(mDebugStepRunEnabled != FALSE); +} + +void T2TowerDoc::OnDebugStepRun() { + mDebugStepRunEnabled = !mDebugStepRunEnabled; + + T2_APP->app_vfA4(!mDebugStepRunEnabled); + T2_MAIN_WINDOW->mDbgStepRun->ShowWindow(mDebugStepRunEnabled ? SW_SHOW : SW_HIDE); +} + +void T2TowerDoc::InvalClock() { + T2MsgWindow *msgWindow = T2_MAIN_WINDOW->mMsgWindow; + msgWindow->GetDlgItem(1000)->InvalidateRect(NULL); +} + +void T2TowerDoc::InvalCalender() { + T2MsgWindow *msgWindow = T2_MAIN_WINDOW->mMsgWindow; + msgWindow->GetDlgItem(1001)->InvalidateRect(NULL); +} + +void T2TowerDoc::InvalFunds() { + T2MsgWindow *msgWindow = T2_MAIN_WINDOW->mMsgWindow; + msgWindow->GetDlgItem(1002)->InvalidateRect(NULL); +} + +void T2TowerDoc::InvalPopulation() { + T2MsgWindow *msgWindow = T2_MAIN_WINDOW->mMsgWindow; + msgWindow->GetDlgItem(1003)->InvalidateRect(NULL); +} + +void T2TowerDoc::SetupGradeAnimation() { + T2MsgWindow *msgWindow = T2_MAIN_WINDOW->mMsgWindow; + if (msgWindow) { + T2DlgItemAnimation *theAnimation = (T2DlgItemAnimation *) msgWindow->GetDlgItem(1005); + theAnimation->SetAnimation(mWorldDef->mModuleHandle, mWorldDef->m148[mGameLevel - 1], 0); + theAnimation->SetAnimationParam(100, 0); + } +} + +void T2TowerDoc::x42670C() { + // empty +} + +void T2TowerDoc::x426717() { + // empty +} + +void T2TowerDoc::CycleOutlinePalette() { + static int sMode = 0; + static int sCounter = 0; + + PALETTEENTRY colors[2]; + + if (sMode == 0) { + colors[0].peRed = 1; + colors[0].peGreen = 1; + colors[0].peBlue = 1; + colors[0].peFlags = PC_RESERVED; + colors[1].peRed = 255; + colors[1].peGreen = 255; + colors[1].peBlue = 255; + colors[1].peFlags = PC_RESERVED; + + sCounter++; + if (sCounter == 2) + sCounter = 0; + } else if (sMode == 1) { + int i = ((sCounter + 1) * 254) / 3; + colors[0].peRed = i + 1; + colors[0].peGreen = i + 1; + colors[0].peBlue = i + 1; + colors[0].peFlags = PC_RESERVED; + colors[1].peRed = 255 - i; + colors[1].peGreen = 255 - i; + colors[1].peBlue = 255 - i; + colors[1].peFlags = PC_RESERVED; + + sCounter++; + if (sCounter == 2) + sCounter = 0; + } else if (sMode == 2) { + colors[0].peRed = 255; + colors[0].peGreen = 255; + colors[0].peBlue = 255; + colors[0].peFlags = PC_RESERVED; + colors[1].peRed = 1; + colors[1].peGreen = 1; + colors[1].peBlue = 1; + colors[1].peFlags = PC_RESERVED; + + sCounter++; + if (sCounter == 2) + sCounter = 0; + } else if (sMode == 3) { + int i = ((sCounter + 1) * 254) / 3; + colors[0].peRed = 255 - i; + colors[0].peGreen = 255 - i; + colors[0].peBlue = 255 - i; + colors[0].peFlags = PC_RESERVED; + colors[1].peRed = i + 1; + colors[1].peGreen = i + 1; + colors[1].peBlue = i + 1; + colors[1].peFlags = PC_RESERVED; + + sCounter++; + if (sCounter == 2) + sCounter = 0; + } + + if (sCounter == 0) { + sMode++; + if (sMode == 4) + sMode = 0; + } + + UpdatePalette(253, 2, colors); +} + +/*virtual*/ void T2TowerDoc::UpdatePalette(int startIndex, int count, PALETTEENTRY *entries) { + if (mIsPaletteMode) { + mWorldDef->GetPalette()->AnimatePalette(startIndex, count, entries); + } else { + mWorldDef->GetPalette()->SetPaletteEntries(startIndex, count, entries); + mPaletteUpdated = true; + } +} + +/*virtual*/ void T2TowerDoc::DoPayTool(int inCost, short inFundGroup, T2ToolDef *inToolDef) { + if (inCost == 0) + return; + + mSettlement->DoPayTool(inCost, inFundGroup, inToolDef); + InvalFunds(); +} + +/*virtual*/ void T2TowerDoc::DoPayTool(int inCost, short inFundGroup, T2ToolDef *inToolDef, const char *inMessage, int inLimitLength, int inLimitType) { + if (inCost == 0) + return; + + mSettlement->DoPayTool(inCost, inFundGroup, inToolDef); + mSettlement->EmitPayToolMessage(this, inToolDef, inMessage, inLimitLength, inLimitType); + InvalFunds(); +} + +/*virtual*/ void T2TowerDoc::DoPay(int inCost, short inFundGroup) { + if (inCost == 0) + return; + + mSettlement->DoPay(inCost, inFundGroup); + InvalFunds(); +} + +/*virtual*/ void T2TowerDoc::CallbackZoomIn(POINT inPt) { + mTowerMainView->DoZoomIn(inPt); + x42670C(); +} + +/*virtual*/ void T2TowerDoc::CallbackZoomOut() { + mTowerMainView->DoZoomOut(); + x42670C(); +} + +/*virtual*/ void T2TowerDoc::CallbackInView() { + SetViewMode(kInView); + mTowerMainView->Invalidate(true); + + T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); +} + +/*virtual*/ void T2TowerDoc::CallbackOutView() { + SetViewMode(kOutView); + mTowerMainView->Invalidate(true); + + T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); +} + +/*virtual*/ void T2TowerDoc::CallbackPriceView() { + SetViewMode(kPriceView); + mTowerMainView->Invalidate(true); + + T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); +} + +/*virtual*/ void T2TowerDoc::CallbackMaintView() { + SetViewMode(kMaintView); + mTowerMainView->Invalidate(true); + + T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); +} + +/*virtual*/ void T2TowerDoc::CallbackTransView() { + SetViewMode(kTransView); + mTowerMainView->Invalidate(true); + + T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); +} + +/*virtual*/ void T2TowerDoc::CallbackEvalView() { + SetViewMode(kEvalView); + mTowerMainView->Invalidate(true); + + T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); +} + +/*virtual*/ void T2TowerDoc::CallbackPause(BOOL inPause) { + towerDoc_vf290(inPause); + x429B01(inPause); +} + +/*virtual*/ void T2TowerDoc::CallbackCalendar() { +} + +/*virtual*/ void T2TowerDoc::CallbackFunds() { +} + +/*virtual*/ void T2TowerDoc::CallbackPopulation() { +} + +void T2TowerDoc::OnUpdateDebugIdleSpeedMeasuring(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +void T2TowerDoc::OnDebugIdleSpeedMeasuring() { + m20C = time(NULL); + + time_t t; +retry: + t = time(NULL); + if (t == m20C) + goto retry; + + m20C = t; + m210 = 0; + m214 = 0; +} + +void T2TowerDoc::OnUpdateDebugAllLoadMeasuring(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +void T2TowerDoc::OnDebugAllLoadMeasuring() { + m20C = time(NULL); + + time_t t; + retry: + t = time(NULL); + if (t == m20C) + goto retry; + + m20C = t; + m210 = 0; + m214 = 1; +} + +/*virtual*/ void T2TowerDoc::towerDoc_vf290(BOOL inPause) { + if (inPause) { + mPause++; + } else if (mPause > 0) { + mPause--; + } else { +#line 4043 + _ASSERT(!1); + } + + TRACE("\x81\x9FPAUSE COUNTER = %d\n", mPause); +} + +void T2TowerDoc::OnUpdateDebugPool(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +void T2TowerDoc::OnDebugPool() { + CString wndClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); + + RECT theRect; + SetRect(&theRect, 300, 80, 500, 400); + + T2PoolView *thePoolView = new T2PoolView; + thePoolView->Create(wndClass, "Pool", WS_THICKFRAME | WS_POPUPWINDOW | WS_VSCROLL | WS_CAPTION | WS_CLIPCHILDREN | WS_VISIBLE, theRect, AfxGetMainWnd(), NULL, WS_EX_TOOLWINDOW); + thePoolView->SetPool(mPool); +} + +void T2TowerDoc::OnUpdateDebugDisplayIPS(CCmdUI *pCmdUI) { + pCmdUI->Enable(); + pCmdUI->SetCheck(mDisplayIPS); +} + +void T2TowerDoc::OnDebugDisplayIPS() { + mDisplayIPS = !mDisplayIPS; + T2_MAIN_WINDOW->mDbgIPS->ShowWindow(mDisplayIPS ? SW_SHOW : SW_HIDE); +} + +/*virtual*/ void T2TowerDoc::LoadsWorldPlugin() { + mWorldPluginSpecifier = mT2PluginLoader->FindPlugin(mWorldPluginID, 'WdPl'); + if (!mWorldPluginSpecifier) { + T2WorldSelectDlg *dlg = new T2WorldSelectDlg; + dlg->ShowWorldSelectDlg(this, mT2PluginLoader, false); + } else { + towerDoc_vfCC(mWorldPluginSpecifier, false); + } +} + +void T2TowerDoc::OnDebugPeople() { + CString wndClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); + + RECT theRect; + SetRect(&theRect, 200, 80, 600, 400); + + DbgPeopleView *thePeopleView = new DbgPeopleView; + thePeopleView->SetPeople(mPeopleArrayList); + thePeopleView->Create(wndClass, "People link", WS_THICKFRAME | WS_POPUPWINDOW | WS_VSCROLL | WS_CAPTION | WS_CLIPCHILDREN | WS_VISIBLE, theRect, AfxGetMainWnd(), NULL, WS_EX_TOOLWINDOW); +} + +void T2TowerDoc::OnUpdateDebugPeople(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +void T2TowerDoc::UpdateAllTenant() { + CRect rect; + mTowerMainView->GetVisibleUnitRect(rect); + mFloorInfo->SetTenantDrawModeByRect(rect, DrawMode3); + mTowerMainView->Invalidate(false); + mTowerMainView->tmv_vf120(); +} + +/*virtual*/ BOOL T2TowerDoc::IsRectInView(const RECT &inRect) { + CRect theRect, viewRect, intersect; + + theRect = inRect; + UT2Coordinate::UnitToQD(theRect, mZoomLevel); + + mTowerMainView->GetClientRect(viewRect); + viewRect.OffsetRect(mTowerMainView->mScrollOffset); + return intersect.IntersectRect(theRect, viewRect); +} + +/*virtual*/ void T2TowerDoc::SetWalkRate(int inWalkRate) { + mWalkRate = inWalkRate; + mPeopleArrayList->SetWalkPeople(mWalkRate); + UpdateAllTenant(); +} + +/*virtual*/ void T2TowerDoc::AddFavoritePeople(T2People *inPeople) { + if (inPeople) { +#line 4141 + _ASSERT(!inPeople->IsFavorite()); + + CString roomName, peopleDefaultName, name; + unsigned int theTenantID = (inPeople->GetWorkTenant() > 1) ? inPeople->GetWorkTenant() : (inPeople->GetHomeTenant() > 1) ? inPeople->GetHomeTenant() : 1; + T2Tenant *theTenant = GetFloorInfo()->GetTenantArrayList()->GetTenantByID(theTenantID); + + if (theTenant) { + int roomNumber = theTenant->GetRoomNumber(GetFloorInfo()); + UT2Utils::GetRoomNumberString(roomNumber, roomName); + roomName += "\x8D\x86\x8E\xBA"; + } else { + roomName = "\x83\x65\x83\x69\x83\x93\x83\x67\x82\xC8\x82\xB5"; + } + + T2Name *theName = mNameDB->Search(inPeople); + if (theName) { + unsigned int id; + theName->GetName(peopleDefaultName, id); + } else { +#line 4165 + _ASSERT(inPeople->GetMatterDef() != NULL); + _ASSERT(((T2PeopleDef *) inPeople->GetMatterDef())->GetSilhouetteDef() != NULL); + ((T2PeopleDef *) inPeople->GetMatterDef())->GetSilhouetteDef()->GetName(peopleDefaultName); + } + + name = roomName + "\x81\x40" + peopleDefaultName; + + int index = 2; + while (mNameDB->Search(name) || mNameDB->Search(name, true)) { + CString indexStr; + indexStr.Format("%d", index++); + name = roomName + "\x81\x40" + peopleDefaultName + " " + indexStr; + } + + T2Name *newName = new T2Name(name, inPeople, true); + mNameDB->Add(newName); + inPeople->SetFavorite(true); + _1E4 = true; + } +} + +/*virtual*/ void T2TowerDoc::AddFavoriteTenant(T2Tenant *inTenant) { + if (inTenant) { +#line 4192 + _ASSERT(!inTenant->IsFavorite()); + + CString roomName, tenantDefaultName, name; + + int RoomNum = inTenant->GetRoomNumber(GetFloorInfo()); + UT2Utils::GetRoomNumberString(RoomNum, roomName); + roomName += "\x8D\x86\x8E\xBA"; + + T2Name *theName = mNameDB->Search(inTenant); + if (theName) { + unsigned int id; + theName->GetName(tenantDefaultName, id); + } else { + inTenant->GetTypicalName(tenantDefaultName); + } + + name = roomName + "\x81\x40" + tenantDefaultName; + + int index = 2; + while (mNameDB->Search(name) || mNameDB->Search(name, true)) { + CString indexStr; + indexStr.Format("%d", index++); + name = roomName + "\x81\x40" + tenantDefaultName + " " + indexStr; + } + + T2Name *newName = new T2Name(name, inTenant, true); + mNameDB->Add(newName); + inTenant->SetFavorite(true); + _1E4 = true; + } +} + +/*virtual*/ void T2TowerDoc::RemoveFavoritePeople(const char *inName, BOOL inFlag) { + T2Name *theName = mNameDB->Search(inName, true); + if (theName) { + mNameDB->RemoveName(theName); + + T2People *thePeople = mPeopleArrayList->FindPeople(theName->GetID()); + thePeople->SetFavorite(false); + + if (inFlag) + return; + + _1E4 = true; + } +} + +/*virtual*/ void T2TowerDoc::RemoveFavoriteTenant(const char *inName, BOOL inFlag) { + T2Name *theName = mNameDB->Search(inName, true); + if (theName) { + mNameDB->RemoveName(theName); + + T2Tenant *theTenant = mFloorInfo->GetTenantArrayList()->GetTenantByID(theName->GetID()); + theTenant->SetFavorite(false); + + if (inFlag) + return; + + _1E4 = true; + } +} + +/*virtual*/ void T2TowerDoc::RemoveFavoritePeople(T2People *inPeople, BOOL inFlag) { + T2Name *theName = mNameDB->Search(inPeople, true); + if (theName) { + mNameDB->RemoveName(theName); + + T2People *thePeople = mPeopleArrayList->FindPeople(theName->GetID()); + thePeople->SetFavorite(false); + + if (inFlag) + return; + + _1E4 = true; + } +} + +/*virtual*/ void T2TowerDoc::RemoveFavoriteTenant(T2Tenant *inTenant, BOOL inFlag) { + T2Name *theName = mNameDB->Search(inTenant, true); + if (theName) { + mNameDB->RemoveName(theName); + + T2Tenant *theTenant = mFloorInfo->GetTenantArrayList()->GetTenantByID(theName->GetID()); + theTenant->SetFavorite(false); + + if (inFlag) + return; + + _1E4 = true; + } +} + +/*virtual*/ void T2TowerDoc::towerDoc_vf1D4() { + // empty +} + +/*virtual*/ void T2TowerDoc::towerDoc_vf1D8() { + // empty +} + +/*virtual*/ BOOL T2TowerDoc::IsToiletFlagOn() const { + BOOL isFlagOn = false; + + if (mToiletDenomi > 0) + isFlagOn = (UT2Utils::Randomize(mToiletDenomi) == 0); + + return isFlagOn; +} + +int T2TowerDoc::CheckGameLevel() { + if (m1F0 == 0 && mWorldDef) + m1F0 = mWorldDef->CheckGameLevelProc(this); + + if (m1F0 == 10005) + mGameLevel++; + else if (m1F0 == 10006) + mGameLevel--; + + m1F0 = 0; + return mGameLevel; +} + +void T2TowerDoc::OnDebugGradeUp() { + m1F0 = 10005; +} + +void T2TowerDoc::OnDebugGradeDown() { + m1F0 = 10006; +} + +/*virtual*/ void T2TowerDoc::TenantAdded(T2Tenant *inTenant) { + mRegistedTenantDB->AddItem(inTenant); +} + +/*virtual*/ void T2TowerDoc::TenantRemoved(T2Tenant *inTenant) { + mRegistedTenantDB->RemoveItem(inTenant); + mFloorInfo->GetTenantArrayList()->TenantRemoved(inTenant->GetEquipID()); + mPeopleArrayList->TenantRemoved(inTenant->GetEquipID()); +} + +CPluginInfoArray *T2TowerDoc::MakePluginInfoArray() { + CPluginInfoArray *theArray = new CPluginInfoArray; +#line 4366 + _ASSERT(theArray != NULL); + + CPluginInfo *worldPluginInfo = mWorldPlugin->GetPluginInfo(); + theArray->Add(&worldPluginInfo); + + _MakePluginInfoArray(theArray, mTenantPlugins); + _MakePluginInfoArray(theArray, mMoverPlugins); + _MakePluginInfoArray(theArray, mOuterObjPlugins); + _MakePluginInfoArray(theArray, mMoviePluginList); + _MakePluginInfoArray(theArray, mHallEventPlugins); + + return theArray; +} + +void T2TowerDoc::_MakePluginInfoArray(CPluginInfoArray *inResultArray, CFilePluginList *inPluginArray) { + POSITION position = inPluginArray->GetHeadPosition(); + while (position) { + CFilePlugin *plugin = inPluginArray->GetNext(position); + if (plugin->GetGameLevel() <= mGameLevel) { + CPluginInfo *info = plugin->GetPluginInfo(); + inResultArray->Add(&info); + } + } +} + +/*virtual*/ void T2TowerDoc::towerDoc_vf184(int inFlags) { +#pragma var_order(var14, var18, theToolWindow, specifier, theToolWindow2, numPlugins, str, pos) + if (!(inFlags & _98)) + return; + + T2ToolWindow *theToolWindow = T2_APP->mToolWindow; + T2ToolWindow *theToolWindow2 = T2_APP->mToolWindow; + + int var14 = 0; + T2TemplatePluginList *var18 = NULL; + int numPlugins = 0; + CString str; + + POSITION pos; + T2PluginSpecifier *specifier; + + mT2PluginLoader->SetTypeFilter(pos, 'TnPl'); + var18 = mTenantTemplates; + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + (specifier->mSecretItem & inFlags) && + !mTenantPlugins->GetItem(specifier->mID) + ) + numPlugins++; + } + + mT2PluginLoader->SetTypeFilter(pos, 'TnPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + (specifier->mSecretItem & inFlags) && + !mTenantPlugins->GetItem(specifier->mID) + ) + { + T2TenantPlugin *theTenantPlugin = (T2TenantPlugin *) mT2PluginLoader->LoadPlugin(specifier); + mTenantPlugins->Add(theTenantPlugin); + theTenantPlugin->LoadAllTemplatePlugin(mWorldDef, mTemplatePluginDB); + + T2TenantDef *def = (T2TenantDef *) theTenantPlugin->GetTemplatePlugin(); + theTenantPlugin->GetName(str); + mTenantTemplates->Regist(def); + + if (def->IsFloor()) + mFloorDef = def; + + if (!def->RequierToolIcon(theToolWindow2)) + theToolWindow2->AddIcon(def->mStr48, NULL, 0, kToolOption1, def, 0, 1, this); + theToolWindow2->AddIcon("Category", NULL, def->mCategoryNo, kToolOption4, def, 0, 1, this); + + LoadSoundForPlugin(def); + T2PeopleLoader::Load(specifier, mTemplatePluginDB); + } + } + + mT2PluginLoader->SetTypeFilter(pos, 'MvPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mMoverPlugins->GetItem(specifier->mID) + ) + numPlugins++; + } + + mT2PluginLoader->SetTypeFilter(pos, 'MvPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mMoverPlugins->GetItem(specifier->mID) + ) + { + T2MoverPlugin *theMoverPlugin = (T2MoverPlugin *) mT2PluginLoader->LoadPlugin(specifier); + mMoverPlugins->Add(theMoverPlugin); + theMoverPlugin->LoadAllTemplatePlugin(mWorldDef, mTemplatePluginDB); + + T2MoverDef *def = (T2MoverDef *) theMoverPlugin->GetTemplatePlugin(); + theMoverPlugin->GetName(str); + mMoverTemplates->Regist(def); + + if (!def->RequierToolIcon(theToolWindow2)) + theToolWindow2->AddIcon(def->mStr48, NULL, 0, kToolOption2, def, 0, 1, this); + theToolWindow2->AddIcon("Category", NULL, def->mCategoryNo, kToolOption4, def, 0, 1, this); + + LoadSoundForPlugin(def); + T2PeopleLoader::Load(specifier, mTemplatePluginDB); + } + } + + mT2PluginLoader->SetTypeFilter(pos, 'OoPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mOuterObjPlugins->GetItem(specifier->mID) + ) + numPlugins++; + } + + mT2PluginLoader->SetTypeFilter(pos, 'OoPl'); + while ((specifier = mT2PluginLoader->GetNext(pos))) { + if ( + (mWorldPlugin->GetAttrib() & specifier->mAttrib) && + (specifier->mGameLevel <= mGameLevel) && + !mOuterObjPlugins->GetItem(specifier->mID) + ) + { + T2OuterObjPlugin *theOuterObjPlugin = (T2OuterObjPlugin *) mT2PluginLoader->LoadPlugin(specifier); + mOuterObjPlugins->Add(theOuterObjPlugin); + theOuterObjPlugin->LoadAllTemplatePlugin(mWorldDef, mTemplatePluginDB); + + T2OuterObjDef *def = (T2OuterObjDef *) theOuterObjPlugin->GetTemplatePlugin(); + theOuterObjPlugin->GetName(str); + mOuterObjTemplates->Regist(def); + + if (!def->RequierToolIcon(theToolWindow2)) + theToolWindow2->AddIcon(def->mStr48, NULL, 0, kToolOption3, def, 0, 2, this); + theToolWindow2->AddIcon("Category", NULL, def->mCategoryNo, kToolOption4, def, 0, 2, this); + + LoadSoundForPlugin(def); + T2PeopleLoader::Load(specifier, mTemplatePluginDB); + } + } + + m9C |= inFlags; +} + +/*virtual*/ BOOL T2TowerDoc::SetElevTransparent(BOOL inTransparent) { + BOOL oldValue = mElevTransparent; + mElevTransparent = inTransparent; + + mTowerMainView->Invalidate(false); + mTowerMainView->tmv_vf120(); + + return oldValue; +} + +/*virtual*/ BOOL T2TowerDoc::towerDoc_vf2B0(BOOL inValue) { + BOOL oldValue = _1FC; + if (inValue != _1FC) + _1FC = inValue; + return oldValue; +} + +/*virtual*/ void T2TowerDoc::FinalEventOccur() { + if (mGameLevel == mWorldDef->mNumOfGradeDef) + mA0 |= mWorldDef->mGradeDef[mGameLevel - 1].m0; +} + +/*virtual*/ void T2TowerDoc::SetSearchRangeFrom(T2Tenant *inTenant) { + mViewMode = ViewMode_6; + mSearchRangeFrom = inTenant; + + mTowerMainView->Invalidate(true); + T2_APP->mMainWindow->mCtrlPalette->vf100(kInView); + T2_APP->mMainWindow->mCtrlPalette->vf104(kInView); +} + +/*virtual*/ void T2TowerDoc::towerDoc_vf194() { + mViewMode = kInView; + mSearchRangeFrom = NULL; + + mTowerMainView->Invalidate(true); + T2_APP->mMainWindow->mCtrlPalette->vf100(mViewMode); + T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); +} + +/*virtual*/ void T2TowerDoc::DoRenumberTenant() { + CRect rect; + mFloorInfo->GetBuildArea(rect); + + for (int v = rect.top; v < rect.bottom; v++) { + CPoint rightPt; + rightPt.x = rect.right - 1; + rightPt.y = v; + + T2FInfoPtIterator iterator(*mFloorInfo, rightPt); + int number = 0; + T2Tenant *tenant = NULL; + + while (iterator.LeftTenant(tenant)) { + if (tenant->IsFloor()) + continue; + + number++; + tenant->SetTenantNumber(number); + } + + mFloorInfo->SetTenantNumber(v, number); + } + + towerDoc_vf280(); +} + +/*virtual*/ int T2TowerDoc::GetNextTenantNumber(int inV) { + return mFloorInfo->GetNextTenantNumber(inV); +} + +/*virtual*/ void T2TowerDoc::towerDoc_vf280() { + // empty +} + +/*virtual*/ void T2TowerDoc::towerDoc_vf1A0(BOOL inPause) { + if (inPause) { + _1F8++; + if (_1F8 != 1) + return; + } else if (_1F8 != 0) { + _1F8--; + if (_1F8 != 0) + return; + } else { + return; + } + + T2ToolWindow *theToolWindow = T2_APP->mToolWindow; + unsigned int isEnabled; + + if (inPause) { + theToolWindow->EnableIcon(false); + isEnabled = MF_BYPOSITION | MF_GRAYED; + } else { + theToolWindow->EnableIcon(true); + isEnabled = MF_BYPOSITION; + } + + T2MainWindow *theMain = T2_MAIN_WINDOW; + CMenu *theMenu = theMain->GetMenu(); + + unsigned int numItems = theMenu->GetMenuItemCount(); + for (unsigned int i = 0; i < numItems; i++) + theMenu->EnableMenuItem(i, isEnabled); + + theMain->DrawMenuBar(); +} + +/*virtual*/ void T2TowerDoc::towerDoc_vf198(unsigned short inWindowType) { + T2MainWindow *theMain = T2_MAIN_WINDOW; + CMenu *theMainMenu = theMain->GetMenu(); + if (!theMainMenu) + return; + + CString label; + CWnd *theWnd; + unsigned int id; + + switch (inWindowType) { + case kControlWindow: + id = 0x801F; + theWnd = T2_APP->mMainWindow->mCtrlPalette; + // "コントロールパレット" + label = "\x83\x52\x83\x93\x83\x67\x83\x8D\x81\x5B\x83\x8B\x83\x70\x83\x8C\x83\x62\x83\x67"; + break; + case kMessageWindow: + id = 0x8020; + theWnd = T2_APP->mMainWindow->mMsgWindow; + // "情報バー" + label = "\x8F\xEE\x95\xF1\x83\x6F\x81\x5B"; + break; + case kToolWindow: + id = 0x8021; + theWnd = T2_APP->mMainWindow->mToolWindow; + // "ツールパレット" + label = "\x83\x63\x81\x5B\x83\x8B\x83\x70\x83\x8C\x83\x62\x83\x67"; + break; + } + + if (theMainMenu->GetMenuState(id, 0) & MFS_CHECKED) { + // "を表示" + label += "\x82\xF0\x95\x5C\x8E\xA6"; + theMainMenu->ModifyMenu(id, 0, id, label); + theMainMenu->CheckMenuItem(id, MFS_UNCHECKED); + theWnd->ShowWindow(SW_HIDE); + } else { + // "を隠す" + label += "\x82\xF0\x89\x42\x82\xB7"; + theMainMenu->ModifyMenu(id, 0, id, label); + theMainMenu->CheckMenuItem(id, MFS_CHECKED); + theWnd->ShowWindow(SW_SHOW); + } +} + +void T2TowerDoc::OnPause() { + T2CtrlPalette *ctrlPalette = T2_APP->mMainWindow->mCtrlPalette; + if (!ctrlPalette) + return; + + T2MWControl *pauseCtrl = ctrlPalette->mPauseControl; + if (!pauseCtrl) + return; + + BOOL isPaused = false; + if (pauseCtrl->GetData() == 0) + isPaused = true; + + towerDoc_vf290(isPaused); + x429A9A(isPaused); + x429B01(isPaused); +} + +void T2TowerDoc::OnUpdatePause(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +void T2TowerDoc::OnSetting() { + T2SettingDialog *theDialog = new T2SettingDialog(this); + short dialogResult = theDialog->DoModal(); +} + +void T2TowerDoc::OnUpdateSetting(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +void T2TowerDoc::OnHideElevatorRoom() { + T2MainWindow *theMain = T2_MAIN_WINDOW; + CMenu *theMainMenu = theMain->GetMenu(); + // "エレベータ機械室" + CString label = "\x83\x47\x83\x8C\x83\x78\x81\x5B\x83\x5E\x8B\x40\x8A\x42\x8E\xBA"; + + if (mElevTransparent) { + // "非表示" + label += "\x94\xF1\x95\x5C\x8E\xA6"; + mElevTransparent = false; + } else { + // "表示" + label += "\x95\x5C\x8E\xA6"; + mElevTransparent = true; + } + + theMainMenu->ModifyMenu(0x801B, 0, 0x801B, label); + mTowerMainView->Invalidate(true); + mTowerMainView->tmv_vf120(); +} + +void T2TowerDoc::OnUpdateHideElevatorRoom(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +void T2TowerDoc::OnFavorite() { + T2SearchDialog *theDialog = new T2SearchDialog(this); + short dialogResult = theDialog->DoModal(); +} + +void T2TowerDoc::OnUpdateFavorite(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +void T2TowerDoc::OnHideControlWindow() { + towerDoc_vf198(kControlWindow); +} + +void T2TowerDoc::OnUpdateHideControlWindow(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +void T2TowerDoc::OnHideMessageWindow() { + towerDoc_vf198(kMessageWindow); +} + +void T2TowerDoc::OnUpdateHideMessageWindow(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +void T2TowerDoc::OnHideToolWindow() { + towerDoc_vf198(kToolWindow); +} + +void T2TowerDoc::OnUpdateHideToolWindow(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +/*virtual*/ T2ToolWindow *T2TowerDoc::towerDoc_vf2A0() { + if (gT2App->mMainWindow && gT2App->mMainWindow->mToolWindow) + return gT2App->mMainWindow->mToolWindow; + + return NULL; +} + +/*virtual*/ void T2TowerDoc::toolCallback_vf00(int unkParam1, T2ToolIconItem *inItem) { + if (inItem->mName == "ToolRoot") { + if (inItem->m24) + towerDoc_vf194(); + } else if (mSearchRangeFrom) { + towerDoc_vf194(); + } +} + +/*virtual*/ void T2TowerDoc::DoFind(T2Name *inName) { + if (!inName) + return; + + RECT rect; + BOOL found = false; + + switch (inName->GetType()) { + case kTenantNameType: { + T2Tenant *theTenant = mFloorInfo->GetTenant(inName->GetID()); + if (theTenant) { + theTenant->GetEquipArea(rect); +#line 5031 + _ASSERT(GetMainView() != NULL); + GetMainView()->CenterOnRect(&rect); + found = true; + } + break; + } + + case kMoverNameType: { + T2Mover *theMover = mFloorInfo->GetMover(inName->GetID()); + if (theMover) { + theMover->GetEquipArea(rect); +#line 5043 + _ASSERT(GetMainView() != NULL); + GetMainView()->CenterOnRect(&rect); + found = true; + } + break; + } + + case kPeopleNameType: { +#line 5068 + _ASSERT(mPeopleArrayList != NULL); + T2People *thePeople = mPeopleArrayList->FindPeople(inName->GetID()); + if (thePeople) + found = x4295F1(thePeople, rect); + break; + } + } + + if (found) { + CPoint leftPt(rect.left, rect.top); + UT2Coordinate::UnitToQD(leftPt, GetZoomLevel()); + + CPoint rightPt(rect.right, rect.top); + UT2Coordinate::UnitToQD(rightPt, GetZoomLevel()); + + leftPt.x += (rightPt.x - leftPt.x) / 2; + + T2TowerMainView *theMainView = GetMainView(); + leftPt -= theMainView->mScrollOffset; + + T2ArrowWnd *arrow = new T2ArrowWnd; + arrow->Show(leftPt.x, leftPt.y, this); + } +} + +BOOL T2TowerDoc::x4295F1(T2People *inPeople, RECT &outRect) { + BOOL isFound = false; + BOOL isFail = false; + CString text; + + switch (inPeople->GetStatus()) { + case kStatus1: { + T2Name *theName = mNameDB->Search(inPeople); + if (theName) { + unsigned int id; + theName->GetName(text, id); + } else { + inPeople->GetName(text); + } + // "は今、ビル内にいません。" + // is not in the building now. + text += "\x82\xCD\x8D\xA1\x81\x41\x83\x72\x83\x8B\x93\xE0\x82\xC9\x82\xA2\x82\xDC\x82\xB9\x82\xF1\x81\x42"; + isFail = true; + break; + } + + case kStatus11: { + T2Tenant *theTenant = GetFloorInfo()->GetTenant(inPeople->GetCurTenantID()); + if (theTenant) { + theTenant->GetEquipArea(outRect); +#line 5117 + _ASSERT(GetMainView() != NULL); + GetMainView()->CenterOnRect(&outRect); + isFound = true; + } + break; + } + + case kStatus8: { + T2Mover *theMover = GetFloorInfo()->GetMover(inPeople->GetCurrEquipID()); + if (theMover) { + T2MoverModule *theModule = theMover->FindPeople(inPeople); + if (theModule) { + int moduleID; + if (theMover->CalcModuleRect(theModule, outRect, moduleID)) { +#line 5132 + _ASSERT(GetMainView() != NULL); + GetMainView()->CenterOnRect(&outRect); + isFound = true; + } else { + T2Name *theName = mNameDB->Search(inPeople); + if (theName) { + unsigned int id; + theName->GetName(text, id); + } else { + inPeople->GetName(text); + } + // "は今、移動設備内にいます。" + // is now in the mobile facility. + text += "\x82\xCD\x8D\xA1\x81\x41\x88\xDA\x93\xAE\x90\xDD\x94\xF5\x93\xE0\x82\xC9\x82\xA2\x82\xDC\x82\xB7\x81\x42"; + isFail = true; + } + } + } + break; + } + + case kStatus6: + case kStatus7: + case kStatus9: + UT2Coordinate::MakeRect( + outRect, + inPeople->GetCurPosition(), + inPeople->IsFatSilhouette() ? 2 : 1, + 1); +#line 5160 + _ASSERT(GetMainView() != NULL); + GetMainView()->CenterOnRect(&outRect); + isFound = true; + break; + + default: { + int theFloor = GetFloorInfo()->UnitToFloor(inPeople->GetCurPosition().y); + T2Tenant *theTenant = GetFloorInfo()->GetTenant(inPeople->GetCurTenantID()); + CString numStr; + + T2Name *theName = mNameDB->Search(inPeople); + if (theName) { + unsigned int id; + theName->GetName(text, id); + } else { + inPeople->GetName(text); + } + + // "は今、" - is now + text += "\x82\xCD\x8D\xA1\x81\x41"; + + UT2Utils::GetRoomNumberString(theFloor, numStr); + text += numStr; + + // "階フロアを移動中です" - moving between floors + text += "\x8A\x4B\x83\x74\x83\x8D\x83\x41\x82\xF0\x88\xDA\x93\xAE\x92\x86\x82\xC5\x82\xB7"; + + isFail = true; + } + } + + if (isFail) { + T2WorldDef *theWorldDef = GetWorldDef(); + T2StewardDialog *theStewardDialog = new T2StewardDialog(this, theWorldDef->mModuleHandle, text, 0); + } + + return isFound; +} + +void T2TowerDoc::x429A9A(BOOL inPause) { + T2CtrlPalette *theCtrlPalette = T2_APP->mMainWindow->mCtrlPalette; + if (!theCtrlPalette) + return; + + T2MWControl *thePauseButton = theCtrlPalette->mPauseControl; + if (!thePauseButton) + return; + + if (inPause) + thePauseButton->SetData(100); + else + thePauseButton->SetData(0); +} + +void T2TowerDoc::x429B01(BOOL inPause) { + T2MainWindow *theMainWindow = T2_MAIN_WINDOW; + if (!theMainWindow) + return; + + CMenu *theMainMenu = theMainWindow->GetMenu(); + if (!theMainMenu) + return; + + if (inPause) { + // "再生" - play + theMainMenu->ModifyMenu(0x8019, 0, 0x8019, "\x8D\xC4\x90\xB6"); + } else { + // "一時停止" - pause + theMainMenu->ModifyMenu(0x8019, 0, 0x8019, "\x88\xEA\x8E\x9E\x92\xE2\x8E\x7E"); + } +} + +/*virtual*/ void T2TowerDoc::SetInfoBarText(const char *inText) { + T2MainWindow *theMainWindow = T2_MAIN_WINDOW; + if (theMainWindow) { + T2MsgWindow *theMsgWindow = theMainWindow->mMsgWindow; + if (theMsgWindow) { + theMsgWindow->GetDlgItem(1004)->SetWindowText(inText); + theMsgWindow->GetDlgItem(1004)->InvalidateRect(NULL); + } + } +} + +/*virtual*/ BOOL T2TowerDoc::IsColdFlagOn() const { + BOOL isFlagOn = false; + + if (mColdDenomi > 0) + isFlagOn = (UT2Utils::Randomize(mColdDenomi) == 0); + + return isFlagOn; +} diff --git a/src/T2TowerDoc.h b/src/T2TowerDoc.h index e657d47..9371bce 100644 --- a/src/T2TowerDoc.h +++ b/src/T2TowerDoc.h @@ -1,198 +1,306 @@ #pragma once #include "common.h" #include "T2MsgWindowCallback.h" +#include "T2Settlement.h" #include "T2Sprite.h" #include "T2ToolCallback.h" +#include "T2TowerMainView.h" enum { - kTowerDocWindowType0 = 0, - kTowerDocWindowType1, - kTowerDocWindowType2 + kControlWindow, + kMessageWindow, + kToolWindow +}; + +// The type of entity found when performing a hit test +enum { + kHitNull, + kHitBkgndInfo, + kHitTenant, + kHitMover, + kHitPeople, + kHitOutObj, + kHitSpriteObj +}; + +union HitTestResult { + T2DrawableObject *obj; + T2SpriteObj *spriteObj; + unsigned int bkgndInfo; +}; + +enum { + // Leave the cursor as-is + kCursorNoChange = -1, + // Destruct (193, 184) + kCursorDestruct = 0, + // Finger (187, 188) + kCursorFinger = 1, + // Info (193, 183) + kCursorInfo = 2, + // Zoom (195, 195) + kCursorZoom = 3, + // Hand (189, 190) + kCursorHand = 4, + // Mic (185, 185) + kCursorMic = 5, + // Search range (192, 192) + kCursorSearchRange = 6, + // No symbol (210, 210) + kCursorNo = 7, + // Use IDC_ARROW + kCursorDefault = 0x100 +}; + +class T2HUnknown; + +typedef void (*TowerDocDestroyCallback)(void *); + +enum { + kDm0 = 0, + kDm1, + kDm2, + kDm3 +}; + +struct DragMask { + int x0; + int x4; + RECT rect; }; class T2TowerDoc : public CDocument, public T2MsgWindowCallback, public T2ToolCallback { + DECLARE_DYNCREATE(T2TowerDoc) + DECLARE_MESSAGE_MAP() + public: - virtual int IsDustOn() const; - virtual void LoadsWorldPlugin(); + T2TowerDoc(); + virtual ~T2TowerDoc(); + virtual void Serialize(CArchive &ar); + + // is this one properly placed??? + virtual BOOL IsDustOn() const { return mIsDustOn; } + virtual void LoadsWorldPlugin(); // new file? // C0 - virtual void towerDoc_vfC0(); + virtual void towerDoc_vfC0(int); virtual void towerDoc_vfC4(); + virtual void towerDoc_vfC8(); - virtual void towerDoc_vfCC(); + virtual void towerDoc_vfCC(T2PluginSpecifier *inWorldPluginSpec, BOOL inIsExistingFile); + void xUnkNameSelectWorld(T2PluginSpecifier *inWorldPluginSpec); + void x41CFEB(); // D0 virtual void towerDoc_vfD0(); - virtual void towerDoc_vfD4(); - virtual void towerDoc_vfD8(); - virtual void towerDoc_vfDC(); + void LoadOptionPlugins(); + virtual void towerDoc_vfD4(BOOL inResetMainWindow); + virtual BOOL OnNewDocument(); + virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); + virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); + + virtual void towerDoc_vfD8(const RECT &inRect1, const RECT &inRect2); + virtual void DrawRequestAll(const RECT &inRect); // E0 - virtual void towerDoc_vfE0(); - virtual void towerDoc_vfE4(); - virtual void towerDoc_vfE8(); - virtual void towerDoc_vfEC(); + virtual void DrawMoverAll(const RECT &inRect); + virtual void DrawInView(const RECT &inRect1, const RECT &inRect2); + virtual void DrawOutView(const RECT &inRect1, const RECT &inRect2); + virtual void DrawBuilding(const RECT &inRect1, const RECT &inRect2); // F0 - virtual void towerDoc_vfF0(); - virtual void towerDoc_vfF4(); - virtual void towerDoc_vfF8(); - virtual void towerDoc_vfFC(); + virtual void towerDoc_vfF0(const RECT &inRect1, const RECT &inRect2); + virtual void DrawBkgnd(const RECT &inRect); + virtual void towerDoc_vfF8(const RECT &inRect); + virtual void towerDoc_vfFC(const RECT &inRect); // 100 - virtual void towerDoc_vf100(); - virtual void towerDoc_vf104(); - virtual int towerDoc_vf108() const; // get zoom level - virtual T2BitImage *towerDoc_vf10C() const; + virtual void towerDoc_vf100(const RECT &inRect); + virtual void DrawTenantOutViewAll(const RECT &inRect); + virtual int GetZoomLevel() const; + void SetZoomLevel(int inZoom) { mZoomLevel = inZoom; } + virtual T2BitImage *GetImage() const; // 110 - virtual T2TowerMainView *GetTowerMainView(); // GetMainView ref: Mac ver asserts - virtual void towerDoc_vf114(); - virtual void towerDoc_vf118(); - virtual void towerDoc_vf11C(int startIndex, int count, PALETTEENTRY *entries); // updates palette + virtual T2TowerMainView *GetMainView() const; + virtual void SelectPlugins(BOOL inIsGradeUp); + virtual void InitSound(T2SoundPlayer *inSoundPlayer); + void LoadSoundForPlugin(T2TemplatePlugin *inPlugin); + virtual void UpdatePalette(int startIndex, int count, PALETTEENTRY *entries); // updates palette // 120 - virtual T2DateTime *towerDoc_vf120() const; - virtual T2RouteNavigator *towerDoc_vf124(); // GetRouteNavi() - virtual T2TemplatePluginList *towerDoc_vf128(); - virtual T2FloorInfo *towerDoc_vf12C() const; + virtual T2DateTime *GetNow() const; + virtual T2RouteNavigator *GetRouteNavi() const; + virtual T2TemplatePluginList *GetSilhouetteTemplates(); + virtual T2FloorInfo *GetFloorInfo() const { return mFloorInfo; } // 130 - virtual T2Pool *towerDoc_vf130(); // GetPool - virtual T2SoundPlayer *towerDoc_vf134(); - virtual int towerDoc_vf138() const; // game level? - virtual T2TowerMessage *towerDoc_vf13C(); + virtual T2Pool *GetPool() const { return mPool; } + virtual T2SoundPlayer *GetSoundPlayer() const { return mSoundPlayer; } + virtual int GetLevel() const { return mGameLevel; } + virtual T2TowerMessage *towerDoc_vf13C() { return mTowerMessage; } // 140 - virtual int towerDoc_vf140(); // get view mode? - virtual void towerDoc_vf144(int); - virtual int towerDoc_vf148() const; // get walk rate? - virtual void towerDoc_vf14C(int walkRate); + virtual int GetViewMode() const { return mViewMode; } + virtual void SetViewMode(int inViewMode); + virtual int GetWalkRate() const { return mWalkRate; } + virtual void SetWalkRate(int inWalkRate); // 150 - virtual T2TrafficInfo *towerDoc_vf150() const; - virtual BOOL towerDoc_vf154(); // IsToiletFlagOn? - virtual void towerDoc_vf158(); - virtual int towerDoc_vf15C(const RECT &rect); // returns bool maybe? + virtual T2TrafficInfo *GetTrafficInfo() const { return mTrafficInfo; } + virtual BOOL IsToiletFlagOn() const; + virtual BOOL IsColdFlagOn() const; + int CheckGameLevel(); + void UpdateAllTenant(); + virtual BOOL IsRectInView(const RECT &inRect); // 160 - virtual T2PaletteAnime *towerDoc_vf160() const; - virtual void towerDoc_vf164(const char *inText); // sets infobar message - virtual void towerDoc_vf168(); - virtual BOOL towerDoc_vf16C() const; // GetElevTransparent + virtual T2PaletteAnime *GetPaletteAnime() const { return mPaletteAnime; } + virtual void SetInfoBarText(const char *inText); + virtual void towerDoc_vf168(const RECT &inRect) { + mTowerMainView->CenterOnRectAndZoom(inRect); + } + virtual BOOL GetElevTransparent() const { return mElevTransparent; } // 170 - virtual T2WorldDef *towerDoc_vf170(); - virtual T2RegistedTenantDB *towerDoc_vf174(); - virtual T2TemplatePluginList *towerDoc_vf178(); // get tenant templates - virtual T2TemplatePluginList *towerDoc_vf17C(); // get mover templates + virtual T2WorldDef *GetWorldDef() const { return mWorldDef; } + virtual T2RegistedTenantDB *GetRegistedTenantDB() const { return mRegistedTenantDB; } + virtual T2TemplatePluginList *GetTenantTemplates() const { return mTenantTemplates; } + virtual T2TemplatePluginList *GetMoverTemplates() const { return mMoverTemplates; } // 180 - virtual T2TemplatePluginList *towerDoc_vf180(); // get outobj templates - virtual void towerDoc_vf184(); - virtual void towerDoc_vf188(); - virtual T2Tenant *towerDoc_vf18C(); + virtual T2TemplatePluginList *GetOuterObjTemplates() const { return mOuterObjTemplates; } + CPluginInfoArray *MakePluginInfoArray(); + void _MakePluginInfoArray(CPluginInfoArray *inResultArray, CFilePluginList *inPluginArray); + virtual void towerDoc_vf184(int inFlags); + virtual void FinalEventOccur(); + virtual T2Tenant *GetSearchRangeFrom() const { return mSearchRangeFrom; } // 190 - virtual void towerDoc_vf190(); + virtual void SetSearchRangeFrom(T2Tenant *inTenant); virtual void towerDoc_vf194(); - virtual void towerDoc_vf198(int); - virtual void towerDoc_vf19C(); + virtual void towerDoc_vf198(unsigned short inWindowType); + virtual void SetCursorType(int inCursor, BOOL inIsPressed); // 1A0 - virtual void towerDoc_vf1A0(int); - virtual BOOL towerDoc_vf1A4() const; // called from T2MainWindow::OnClose - virtual void towerDoc_vf1A8(); - virtual void towerDoc_vf1AC(); + virtual void towerDoc_vf1A0(BOOL inPause); + virtual BOOL towerDoc_vf1A4() const { return _1F8 != 0; } + virtual void *towerDoc_vf1A8() const { return mDestroyCallbackData; } + virtual void towerDoc_vf1AC(void *inData) { mDestroyCallbackData = inData; } // 1B0 - virtual void towerDoc_vf1B0(); - virtual void towerDoc_vf1B4(); - virtual void towerDoc_vf1B8(T2People *); - virtual void towerDoc_vf1BC(); + virtual void towerDoc_vf1B0(TowerDocDestroyCallback inFunc) { mDestroyCallback = inFunc; } + virtual void BreakoutEmergency(); + virtual void AddFavoritePeople(T2People *inPeople); + virtual void AddFavoriteTenant(T2Tenant *inTenant); // 1C0 - virtual void towerDoc_vf1C0(); - virtual void towerDoc_vf1C4(T2People *, BOOL); - virtual void towerDoc_vf1C8(); - virtual void towerDoc_vf1CC(T2Tenant *, BOOL); + virtual void RemoveFavoritePeople(const char *inName, BOOL inFlag); + virtual void RemoveFavoritePeople(T2People *inPeople, BOOL inFlag); + virtual void RemoveFavoriteTenant(const char *inName, BOOL inFlag); + virtual void RemoveFavoriteTenant(T2Tenant *inTenant, BOOL inFlag); // 1D0 - virtual void towerDoc_vf1D0(); + virtual void towerDoc_vf1D0(int unk1, int unk2) {} virtual void towerDoc_vf1D4(); virtual void towerDoc_vf1D8(); - virtual void towerDoc_vf1DC(); + virtual void CreatePool(); // 1E0 - virtual void towerDoc_vf1E0(); - virtual void towerDoc_vf1E4(); - virtual void towerDoc_vf1E8(); - virtual void towerDoc_vf1EC(); + virtual void LoadPool(T2Archive &inArchive); + virtual void DoDestruct(const CPoint &inPt); + virtual BOOL DestructTenant(POINT inPt1, POINT inPt2, T2Tenant *inTenant, BOOL inSkipSounds); + BOOL OutsideAreaCheck(T2Tenant *inTenant, BOOL inShowError); + void CalcCraneUpdateRect(RECT &ioRect); + virtual BOOL DestructMover(POINT inPt1, POINT inPt2, T2Mover *inMover); // 1F0 - virtual void towerDoc_vf1F0(); - virtual void towerDoc_vf1F4(); - virtual void towerDoc_vf1F8(); - virtual void towerDoc_vf1FC(); + virtual BOOL DestructOutObj(POINT inPt1, POINT inPt2, T2OutObj *inOutObj); + virtual BOOL DoClickByTenantTool(CRect inRect, T2TenantDef *inDef, unsigned int inValiation); + virtual void DoDragByTenantTool(CRect inRect); + virtual void DoReleaseByTenantTool(CRect inRect); // 200 - virtual void towerDoc_vf200(); - virtual void towerDoc_vf204(); - virtual void towerDoc_vf208(); - virtual void towerDoc_vf20C(); + virtual BOOL DoClickByMoverTool(CRect inRect, T2MoverDef *inDef, unsigned int inValiation, BOOL inIsFromMouseMove); + virtual void DoDragByMoverTool(CRect inRect); + virtual void DoReleaseByMoverTool(CRect inRect); + virtual void DoClickByOutObjTool(CRect inRect, T2OuterObjDef *inDef, unsigned int inValiation); // 210 - virtual void towerDoc_vf210(); - virtual void towerDoc_vf214(); - virtual void towerDoc_vf218(); - virtual void towerDoc_vf21C(); + virtual void DoDragByOutObjTool(CRect inRect); + virtual void DoReleaseByOutObjTool(CRect inRect); + virtual BOOL DoClickByFingerTool(CPoint inPt); + virtual void DoDragByFingerTool(CPoint inPt); // 220 - virtual void towerDoc_vf220(); - virtual void towerDoc_vf224(); - virtual void towerDoc_vf228(); - virtual void towerDoc_vf22C(); + virtual void DoReleaseByFingerTool(CPoint inPt); + virtual void DoGetInfo(CPoint inPt); + virtual void towerDoc_vf228(CPoint inPt); + virtual void DoInterview(CPoint inPt); // 230 - virtual void towerDoc_vf230(); - virtual void towerDoc_vf234(); - virtual void towerDoc_vf238(T2Name *); // find tenant from search dialog - virtual void towerDoc_vf23C(); + virtual void DoSearchRangeTool(CPoint inPt); + virtual void DoRenumberTenant(); + virtual void DoFind(T2Name *inName); + BOOL x4295F1(T2People *inPeople, RECT &outRect); + virtual BOOL towerDoc_vf23C(CPoint inPt); // 240 - virtual void towerDoc_vf240(); - virtual void towerDoc_vf244(); - virtual void towerDoc_vf248(); - virtual void towerDoc_vf24C(); + virtual void CalcDragMask(CRect inRect); + virtual int CalcDragMaskPoint(CRect &ioRect, int &ioFunds, DragMask *inArray, int inMode, BOOL inShowError); // CalcDragMaskPoint + virtual BOOL towerDoc_vf248(CRect inRect); + virtual T2Tenant *AssignNewTenant(T2TenantDef *inTenantDef, RECT &inRect, unsigned int inValiation); // 250 - virtual void towerDoc_vf250(); - virtual void towerDoc_vf254(); - virtual void towerDoc_vf258(); - virtual void towerDoc_vf25C(); + virtual void CheckBuildQueue(); + virtual BOOL CheckTenantArea(const RECT &inRect, T2TenantDef *inTenantDef, BOOL inShowErr, BOOL inUnkFlag); + virtual BOOL towerDoc_vf258(const RECT &inRect, T2MoverDef *inMoverDef); + virtual BOOL towerDoc_vf25C(const RECT &inRect, T2MoverDef *inMoverDef); // 260 - virtual void towerDoc_vf260(); - virtual void towerDoc_vf264(); - virtual void towerDoc_vf268(T2Tenant *inTenant); // TenantRemoved - virtual int towerDoc_vf26C() const; // GetCurrentFunds? + virtual void towerDoc_vf260(const RECT &inRect, T2OuterObjDef *inOuterObjDef); + virtual void TenantAdded(T2Tenant *inTenant); + virtual void TenantRemoved(T2Tenant *inTenant); + virtual int GetCurrentFunds() const { return mSettlement->GetCurrentFunds(); } // 270 - virtual void towerDoc_vf270(int, short); // DoPay - virtual void towerDoc_vf274(); - virtual void DoPayTool(int cost, short unk, T2ToolDef *toolDef); - virtual int towerDoc_vf27C(int inV); // GetNextTenantNumber + virtual void DoPay(int inCost, short inFundGroup); + virtual void DoPayTool(int inCost, short inFundGroup, T2ToolDef *inToolDef, const char *inMessage, int inLimitLength, int inLimitType); + virtual void DoPayTool(int inCost, short inFundGroup, T2ToolDef *toolDef); + virtual int GetNextTenantNumber(int inV); // 280 - virtual void towerDoc_vf280(); - virtual void towerDoc_vf284(); - virtual void towerDoc_vf288(); - virtual void towerDoc_vf28C(); + virtual void towerDoc_vf280(); // empty: RecreateFavoriteMenus? + virtual void towerDoc_vf284() { UpdateAllTenant(); } + virtual BOOL towerDoc_vf288(RECT &ioRect, int &ioCost); + virtual void FillFloor(const RECT &inRect); // 290 - virtual void towerDoc_vf290(int pauseVal); - virtual void towerDoc_vf294(); + virtual void towerDoc_vf290(BOOL inPause); + virtual void towerDoc_vf294() { towerDoc_vf290(false); } virtual void towerDoc_vf298(); - virtual void towerDoc_vf29C(); + virtual int HitTest(POINT inPt, HitTestResult &outObj, BOOL inSkipPeople, BOOL inSkipOuterObj); + int HitTestLayer(T2BitImage *inImage, POINT inPt, HitTestResult &outObj, int inLayer); // 2A0 virtual T2ToolWindow *towerDoc_vf2A0(); - virtual int towerDoc_vf2A4() const; // get speed - virtual void towerDoc_vf2A8(int); // SetDrawSpeed - virtual void towerDoc_vf2AC(); + virtual int GetDrawSpeed() const { return mDrawSpeed; } + virtual int SetDrawSpeed(int inVal) { + int oldVal = mDrawSpeed; + mDrawSpeed = inVal; + return oldVal; + } + virtual BOOL SetElevTransparent(BOOL inTransparent); // 2B0 - virtual void towerDoc_vf2B0(BOOL); // SetVolatile maybe? - virtual void towerDoc_vf2B4(); - virtual void towerDoc_vf2B8(); - virtual void towerDoc_vf2BC(); + virtual BOOL towerDoc_vf2B0(BOOL inValue); // SetVolatile maybe? + virtual int towerDoc_vf2B4() const { return _1FC; } + virtual void CallbackZoomIn(POINT inPt); + virtual void CallbackZoomOut(); + virtual void CallbackInView(); + virtual void CallbackOutView(); + virtual void CallbackPriceView(); + virtual void CallbackMaintView(); + virtual void CallbackTransView(); + virtual void CallbackEvalView(); + virtual void CallbackPause(BOOL inPause); + virtual void CallbackCalendar(); + virtual void CallbackFunds(); + virtual void CallbackPopulation(); + virtual BOOL towerDoc_vf2BC(const char *inPath); // 2C0 - virtual void towerDoc_vf2C0(); + virtual BOOL towerDoc_vf2C0(const char *inPath); + virtual void toolCallback_vf00(int unkParam1, T2ToolIconItem *inItem); - // this might be SetVolatile actually + void x429A9A(BOOL inPause); + void x429B01(BOOL inPause); + + // this might be SetVolatile actually void SetFireBurning(BOOL flag) { m208 = flag; } - int Get22C() { return _22C; } + int Get228() { return m228; } + BOOL Get22C() const { return _22C; } T2PluginLoader *mT2PluginLoader; T2WorldPlugin *mWorldPlugin; T2PluginSpecifier *mWorldPluginSpecifier; - T2PluginSpecifier *mToPluginSpecifier; + T2PluginSpecifier *mToolPaletteSpecifier; DWORD mWorldPluginID; - DWORD mToPluginID; + DWORD mToolPaletteID; T2WorldDef *mWorldDef; int _78; int _7C; int mZoomLevel; - int _84; + // the current funds when the player clicked to begin building a tenant + int mFundsOnClick; BOOL mPause; int mGameLevel; int _90; @@ -203,9 +311,9 @@ public: int mViewMode; int _A8; int _AC; - int _B0; - int _B4; - int _B8; + BOOL _B0; + int mLastRequestedCursor; + int mCurrentCursorIndex; int mBC; DWORD mC0; T2DateTime *mNow; @@ -216,12 +324,12 @@ public: T2TrafficInfo *mTrafficInfo; T2Sprite mSprite; T2SoundPlayer *mSoundPlayer; - CFilePluginList *mTenantPluginsListOther; - CFilePluginList *mMoverPluginsListOther; - CFilePluginList *mOoPluginsListOther; + CFilePluginList *mTenantPlugins; + CFilePluginList *mMoverPlugins; + CFilePluginList *mOuterObjPlugins; T2MoviePluginList *mMoviePluginList; - CFilePluginList *mHePluginsListOther; - CFilePluginList *mAdPluginsListOther; + CFilePluginList *mHallEventPlugins; + CFilePluginList *mAdvertisePlugins; T2TemplatePluginList *mTenantTemplates; T2TemplatePluginList *mMoverTemplates; T2TemplatePluginList *mMatterTemplates; @@ -236,43 +344,42 @@ public: T2PeopleArrayList *mPeopleArrayList; T2Pool *mPool; T2RegistedTenantDB *mRegistedTenantDB; - int _15C; + T2TenantDef *mFloorDef; T2RouteNavigator *mRouteNavigator; - T2Equip *mSearchRangeFrom; + T2Tenant *mSearchRangeFrom; int mCraneCount; POINT *mCranePosArray; - int _170; + T2HUnknown *_170; int _174; T2PaletteAnime *mPaletteAnime; - int _17C; - int m180; - int m184; - int _188; - int _18C; + BOOL mPaletteUpdated; + BOOL mDebugStepRunEnabled; + BOOL mDisplayIPS; + POINT m188; BOOL mErrorFlag; BOOL mNewDocFlag; BOOL mIsStuffLoadedFlag; T2TowerMainView *mTowerMainView; T2TenantDef *m1A0; - int _1A4; + T2Tenant *_1A4; int _1A8; int _1AC; - int _1B0; - int _1B4; + unsigned int mValiation; + DragMask *mDragMask; CObjectQueue *mObjectQueue; - int _1BC; - int _1C0; + POINT _1BC; T2Equip *m1C4; - int _1C8; + // does the system support palettes? + BOOL mIsPaletteMode; int m1CC; BOOL mElevTransparent; - int isDustOn; - int mToiletDenomi; + BOOL mIsDustOn; + unsigned int mToiletDenomi; unsigned int mColdDenomi; int mWalkRate; - int _1E4; - int _1E8; - int _1EC; + BOOL _1E4; + void *mDestroyCallbackData; + TowerDocDestroyCallback mDestroyCallback; int m1F0; int _1F4; int _1F8; @@ -280,13 +387,52 @@ public: int _200; int m204; int m208; - int m20C; + time_t m20C; int m210; int m214; - int m218; - unsigned int m21C; - unsigned int m220; // speed? + DWORD m218; + DWORD m21C; + unsigned int mDrawSpeed; int _224; int m228; - int _22C; + BOOL _22C; + +protected: + afx_msg void OnSystemInformation(); + afx_msg void OnUpdateDebugStepRun(CCmdUI *pCmdUI); + afx_msg void OnDebugStepRun(); + void InvalClock(); + void InvalCalender(); + void InvalFunds(); + void InvalPopulation(); + void SetupGradeAnimation(); + void x42670C(); + void x426717(); + void CycleOutlinePalette(); + afx_msg void OnUpdateDebugIdleSpeedMeasuring(CCmdUI *pCmdUI); + afx_msg void OnDebugIdleSpeedMeasuring(); + afx_msg void OnUpdateDebugAllLoadMeasuring(CCmdUI *pCmdUI); + afx_msg void OnDebugAllLoadMeasuring(); + afx_msg void OnUpdateDebugPool(CCmdUI *pCmdUI); + afx_msg void OnDebugPool(); + afx_msg void OnUpdateDebugDisplayIPS(CCmdUI *pCmdUI); + afx_msg void OnDebugDisplayIPS(); + afx_msg void OnUpdateDebugPeople(CCmdUI *pCmdUI); + afx_msg void OnDebugPeople(); + afx_msg void OnDebugGradeUp(); + afx_msg void OnDebugGradeDown(); + afx_msg void OnPause(); + afx_msg void OnUpdatePause(CCmdUI *pCmdUI); + afx_msg void OnSetting(); + afx_msg void OnUpdateSetting(CCmdUI *pCmdUI); + afx_msg void OnHideElevatorRoom(); + afx_msg void OnUpdateHideElevatorRoom(CCmdUI *pCmdUI); + afx_msg void OnFavorite(); + afx_msg void OnUpdateFavorite(CCmdUI *pCmdUI); + afx_msg void OnHideControlWindow(); + afx_msg void OnUpdateHideControlWindow(CCmdUI *pCmdUI); + afx_msg void OnHideMessageWindow(); + afx_msg void OnUpdateHideMessageWindow(CCmdUI *pCmdUI); + afx_msg void OnHideToolWindow(); + afx_msg void OnUpdateHideToolWindow(CCmdUI *pCmdUI); }; diff --git a/src/T2TowerMainView.cpp b/src/T2TowerMainView.cpp new file mode 100644 index 0000000..87508af --- /dev/null +++ b/src/T2TowerMainView.cpp @@ -0,0 +1,1738 @@ +#include "DbgEquipInfo.h" +#include "GlobalFunc.h" +#include "T2.h" +#include "T2BitImage.h" +#include "T2CrossEquipArray.h" +#include "T2DLL.h" +#include "T2FInfoAreaIterator.h" +#include "T2FloorInfo.h" +#include "T2MainWindow.h" +#include "T2Mover.h" +#include "T2MoverArray.h" +#include "T2MoverArrayList.h" +#include "T2Request.h" +#include "T2Tenant.h" +#include "T2TenantArray.h" +#include "T2TenantArrayList.h" +#include "T2ToolDef.h" +#include "T2ToolWindow.h" +#include "T2TowerDoc.h" +#include "T2TowerMainView.h" +#include "T2WorldDef.h" +#include "URect.h" +#include "UT2BkgndInfo.h" +#include "UT2Coordinate.h" +#include "UT2Utils.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#line 24 +IMPLEMENT_DYNCREATE(T2TowerMainView, CView) + +BEGIN_MESSAGE_MAP(T2TowerMainView, CView) + ON_WM_CREATE() + ON_WM_SIZE() + ON_COMMAND(0x8006, OnDebugNormalDisplay) + ON_UPDATE_COMMAND_UI(0x8006, OnUpdateDebugNormalDisplay) + ON_COMMAND(0x8008, OnDebugBkgndInfo) + ON_UPDATE_COMMAND_UI(0x8008, OnUpdateDebugBkgndInfo) + ON_COMMAND(0x8007, OnDebugFloorInfoTenant) + ON_UPDATE_COMMAND_UI(0x8007, OnUpdateDebugFloorInfoTenant) + ON_WM_LBUTTONDOWN() + ON_WM_MOUSEMOVE() + ON_WM_LBUTTONUP() + ON_UPDATE_COMMAND_UI(0x800B, OnUpdateDebugGrid) + ON_COMMAND(0x800B, OnDebugGrid) + ON_UPDATE_COMMAND_UI(0x800C, OnUpdateDebugFloorInfoMover) + ON_COMMAND(0x800C, OnDebugFloorInfoMover) + ON_WM_RBUTTONDOWN() + ON_COMMAND(0x800E, OnDebugFloorInfoRequest) + ON_UPDATE_COMMAND_UI(0x800E, OnUpdateDebugFloorInfoRequest) + ON_UPDATE_COMMAND_UI(0x800F, OnUpdateDebugDisplaySpeedMeasuring) + ON_COMMAND(0x800F, OnDebugDisplaySpeedMeasuring) + ON_UPDATE_COMMAND_UI(0x8017, OnUpdateDebugOffscreenSpeedMeasuring) + ON_COMMAND(0x8017, OnDebugOffscreenSpeedMeasuring) + ON_WM_RBUTTONUP() + ON_WM_TIMER() + ON_WM_DESTROY() + ON_COMMAND_RANGE(10000, 10010, OnCommand10000to10010) +END_MESSAGE_MAP() + +T2TowerMainView::T2TowerMainView() { + mImage = NULL; + SetRectEmpty(&mWorldBounds); + SetRectEmpty(&mVisibleArea); + ClearUpdateRect(); + mScrollOffset.x = 0; + mScrollOffset.y = 0; + mActiveTool = kTool0_Null; + mDebugMode = 0; + mDbgEquipID = 0; + mSkipOffscreenDraw = false; + mIsDebugGrid = false; + mActiveToolDef = NULL; + _108.x = -1; + _108.y = -1; + mImageOrigin.x = 0; + mImageOrigin.y = 0; + mPressedButtons = 0; + mHideToolSpriteCount = 0; + mDC = false; + mAnotherToolVar = kAnotherToolVar0; + SetRectEmpty(&m6C); + _EC = 0; + mToolSpriteIndex = -1; +} + +/*virtual*/ T2TowerMainView::~T2TowerMainView() { + if (mImage) + delete mImage; +} + +/*virtual*/ void T2TowerMainView::tmv_vf110() { + SetRectEmpty(&mWorldBounds); + SetRectEmpty(&mVisibleArea); + ClearUpdateRect(); + mScrollOffset.x = 0; + mScrollOffset.y = 0; + mActiveTool = kTool0_Null; + mDebugMode = 0; + mDbgEquipID = 0; + mSkipOffscreenDraw = false; + mIsDebugGrid = false; + mActiveToolDef = NULL; + _108.x = -1; + _108.y = -1; + mImageOrigin.x = 0; + mImageOrigin.y = 0; + mPressedButtons = 0; + mHideToolSpriteCount = 0; + mDC = false; + mAnotherToolVar = kAnotherToolVar0; + SetRectEmpty(&m6C); + _EC = 0; + mToolSpriteIndex = -1; +} + +/*virtual*/ BOOL T2TowerMainView::PreCreateWindow(CREATESTRUCT &cs) { + cs.dwExStyle |= WS_EX_CLIENTEDGE; + cs.style &= ~WS_VISIBLE; + return CView::PreCreateWindow(cs); +} + +/*virtual*/ void T2TowerMainView::OnDraw(CDC *pDC) { +#pragma var_order(brush, save, h, v, theDoc, interiorRect, clientRect, bgRect, mysteryRect) + T2TowerDoc *theDoc = GetTowerDoc(); +#line 142 + ASSERT_VALID(theDoc); + + CBrush brush; + brush.CreateStockObject(GRAY_BRUSH); + + CRect clientRect; + GetClientRect(clientRect); + + CRect bgRect; + if (!theDoc->mIsStuffLoadedFlag || !theDoc->Get22C()) { + pDC->FillRect(clientRect, &brush); + return; + } + + int h = mDocument->mWorldDef->GetWidth() - 1; + int v = mDocument->mWorldDef->GetHeight() - 1; + UT2Coordinate::UnitToQD(v, h, mDocument->mZoomLevel); + + if (mImageOrigin.x != 0) { + bgRect = clientRect; + bgRect.right = mImageOrigin.x; + pDC->FillRect(bgRect, &brush); + + bgRect = clientRect; + bgRect.left = mImageOrigin.x + h; + pDC->FillRect(bgRect, &brush); + } + + if (mImageOrigin.y != 0) { + bgRect = clientRect; + bgRect.bottom = mImageOrigin.y; + pDC->FillRect(bgRect, &brush); + + bgRect = clientRect; + bgRect.top = mImageOrigin.y + v; + pDC->FillRect(bgRect, &brush); + } + + if (!theDoc->mWorldDef) + return; + + int save = pDC->SaveDC(); + + RECT mysteryRect; + mysteryRect.left = 0; + mysteryRect.top = 0; + mysteryRect.right = mysteryRect.left + mImage->mBitmap.header.biWidth; + mysteryRect.bottom = mysteryRect.top + mImage->mBitmap.header.biHeight; + + RECT interiorRect; + GetClientRect(&interiorRect); + + x42B484(pDC, interiorRect); + pDC->RestoreDC(save); +} + +/*virtual*/ void T2TowerMainView::AssertValid() const { + CView::AssertValid(); +} + +/*virtual*/ void T2TowerMainView::Dump(CDumpContext &dc) const { + CView::Dump(dc); +} + +/*virtual*/ T2TowerDoc *T2TowerMainView::GetTowerDoc() { +#line 223 + ASSERT_KINDOF(T2TowerDoc, m_pDocument); + return (T2TowerDoc *) m_pDocument; +} + +int T2TowerMainView::OnCreate(LPCREATESTRUCT lpcs) { + if (CView::OnCreate(lpcs) == -1) + return -1; + + mDocument = GetTowerDoc(); + mDocument->mTowerMainView = this; + SetRect(&mWorldBounds, 0, 0, 100, 100); + AdjustWorldBounds(); + + ShowWindow(SW_HIDE); + SetTimer(12345, 100, NULL); + SetClassLong(m_hWnd, GCL_HBRBACKGROUND, 0); + + return 0; +} + +void T2TowerMainView::OnDestroy() { + mDocument->mTowerMainView = NULL; + CView::OnDestroy(); + KillTimer(12345); +} + +void T2TowerMainView::AdjustWorldBounds() { + if (!mDocument->mWorldDef) + return; + + if (mImage) + delete mImage; + + RECT rect; + GetClientRect(&rect); + + CRect worldRect; + worldRect.SetRect(0, 0, mDocument->mWorldDef->GetWidth() - 1, mDocument->mWorldDef->GetHeight() - 1); + UT2Coordinate::UnitToQD(worldRect, mDocument->mZoomLevel, true); + + if (rect.right > worldRect.right) + rect.right = worldRect.right; + if (rect.bottom > worldRect.bottom) + rect.bottom = worldRect.bottom; + +#line 282 + mImage = new T2BitImage(rect); + + mUpdateRect1 = mVisibleArea; + mUpdateRect2 = mVisibleArea; +} + +void T2TowerMainView::ClearUpdateRect() { + SetRectEmpty(&mUpdateRect1); + SetRectEmpty(&mUpdateRect2); +} + +void T2TowerMainView::x42AC1B() { + if (!mDocument->mWorldDef) + return; + + GetClientRect(&mVisibleArea); + OffsetRect(&mVisibleArea, mScrollOffset.x, mScrollOffset.y); + UT2Coordinate::QDToUnit(mVisibleArea, mDocument->GetZoomLevel()); + IntersectRect(&mVisibleArea, &mWorldBounds, &mVisibleArea); +} + +void T2TowerMainView::OnSize(UINT nType, int cx, int cy) { + CWnd::OnSize(nType, cx, cy); + AdjustWorldBounds(); +} + +/*virtual*/ void T2TowerMainView::tmv_vf120() { + if (!mDocument->mWorldDef || !mDocument->Get22C()) + return; + + mDocument->mSprite.GetUpdateRect(&mSpriteUpdateRect, mDocument->mZoomLevel); + UT2Coordinate::QDToUnit(mSpriteUpdateRect, mDocument->mZoomLevel); + UT2Coordinate::UnitToQD(mSpriteUpdateRect, mDocument->mZoomLevel, true); + + RECT rect1, rect2; + rect1 = mSpriteUpdateRect; + + UT2Coordinate::UnitToQD(mUpdateRect1, rect2, mDocument->mZoomLevel, true); + UnionRect(&rect1, &rect1, &rect2); + + UT2Coordinate::UnitToQD(mUpdateRect2, rect2, mDocument->mZoomLevel, true); + UnionRect(&rect1, &rect1, &rect2); + + UT2Coordinate::QDToUnit(rect1, mDocument->mZoomLevel); + + UT2Coordinate::QDToUnit(mSpriteUpdateRect, rect2, mDocument->mZoomLevel); + UnionRect(&mUpdateRect1, &mUpdateRect1, &rect2); + UnionRect(&mUpdateRect2, &mUpdateRect2, &rect2); + UnionRect(&mUpdateRect2, &mUpdateRect2, &mUpdateRect1); + + if (!IsRectEmpty(&rect1)) { + tmv_vf11C(); + if (mIsDebugGrid) + DrawDebugGrid(); + if (!mSkipOffscreenDraw) { + CopySimulationImage(rect1); + mDocument->mPaletteUpdated = false; + } + } + + if (mDocument->mPaletteUpdated) { + GetClientRect(&rect1); + CopySimulationImage(rect1); + mDocument->mPaletteUpdated = false; + } +} + +/*virtual*/ void T2TowerMainView::tmv_vf11C() { +#pragma var_order(rect5, rect1, rect4, rect3, rect2) + RECT rect1, rect2, rect3, rect4, rect5; + + mImage->SetOrigin(mScrollOffset.x, mScrollOffset.y); + + UT2Coordinate::QDToUnit(m6C, rect1, mDocument->mZoomLevel); + UT2Coordinate::UnitToQD(rect1, mDocument->mZoomLevel, true); + if (!IsRectEmpty(&rect1) && mToolSpriteName != "") + UnionRect(&mSpriteUpdateRect, &mSpriteUpdateRect, &rect1); + + mImage->SetClipRect(&mSpriteUpdateRect); + mDocument->mSprite.DrawLayer(mImage, T2Sprite::ELayer_0, mDocument->mZoomLevel); + + UT2Coordinate::UnitToQD(mUpdateRect1, rect2, mDocument->mZoomLevel, true); + mImage->SetClipRect(&rect2); + UnionRect(&rect3, &mSpriteUpdateRect, &rect2); + + UT2Coordinate::UnitToBkgnd(mUpdateRect1, rect4); + mDocument->DrawBkgnd(rect4); + + mDocument->mSprite.DrawLayer(mImage, T2Sprite::ELayer_1, mDocument->mZoomLevel); + + UT2Coordinate::UnitToQD(mUpdateRect2, rect2, mDocument->mZoomLevel, true); + UT2Coordinate::UnitToQD(mUpdateRect1, rect5, mDocument->mZoomLevel, true); + UnionRect(&rect2, &rect2, &rect5); + UnionRect(&rect3, &rect3, &rect2); + mImage->SetClipRect(&rect2); + mDocument->towerDoc_vfF0(mUpdateRect2, mUpdateRect1); + + if (mDocument->GetViewMode() != kOutView) { + mImage->SetClipRect(&rect3); + mDocument->mSprite.DrawLayer(mImage, T2Sprite::ELayer_2, mDocument->mZoomLevel); + } + + mDocument->DrawBuilding(mUpdateRect2, mUpdateRect1); + + if (mDocument->GetViewMode() != kOutView) { + mImage->SetClipRect(&rect3); + mDocument->mSprite.DrawLayer(mImage, T2Sprite::ELayer_3, mDocument->mZoomLevel); + } + + UT2Coordinate::UnitToQD(mUpdateRect1, rect2, mDocument->mZoomLevel, true); + mImage->SetClipRect(&rect2); + mDocument->towerDoc_vf100(mVisibleArea); + + mImage->SetClipRect(&rect3); + mDocument->mSprite.DrawLayer(mImage, T2Sprite::ELayer_4, mDocument->mZoomLevel); + + mImage->SetClipRect(&mSpriteUpdateRect); + mDocument->mSprite.DrawLayer(mImage, T2Sprite::ELayer_5, mDocument->mZoomLevel); + + if (!IsRectEmpty(&rect1) && !mHideToolSpriteCount && mToolSpriteName != "") + mImage->DrawFocusRect(rect1); + + mImage->SetClipRect(&rect3); + mDocument->mSprite.DrawLayer(mImage, T2Sprite::ELayer_6, mDocument->mZoomLevel); + + mImage->SetClipRect(NULL); + DispatchOptionEvent(kTowerDrawFinishedOptionEvent, NULL); + + mImage->SetOrigin(0, 0); + ClearUpdateRect(); +} + +void func42B3A2(RECT &outRect, const RECT &inRect) { + outRect = inRect; + if (!IsRectEmpty(&outRect)) { + outRect.left -= 7; + outRect.right += 7; + outRect.bottom += 2; + outRect.top -= 2; + } +} + +/*virtual*/ void T2TowerMainView::CopySimulationImage(const RECT &inRect) { + RECT rect; + UT2Coordinate::UnitToQD(inRect, rect, mDocument->GetZoomLevel(), true); + OffsetRect(&rect, -mScrollOffset.x, -mScrollOffset.y); + + CDC *pDC = GetDC(); + x42B484(pDC, rect); + ReleaseDC(pDC); +} + +void T2TowerMainView::x42B484(CDC *pDC, const RECT &inRect) { + if (!DispatchOptionEvent(kTowerPreDrawOptionEvent, pDC)) + return; + + T2TowerDoc *theDoc = GetTowerDoc(); + if (!theDoc || !theDoc->mWorldDef) + return; + + RECT theDstRect = inRect; + RECT theRect = theDstRect; + + int saved = pDC->SaveDC(); + pDC->SelectPalette(theDoc->mWorldDef->GetPalette(), false); + pDC->RealizePalette(); + + theDstRect.left += mImageOrigin.x; + theDstRect.right += mImageOrigin.x; + theDstRect.top += mImageOrigin.y; + theDstRect.bottom += mImageOrigin.y; + mImage->CopyImage(pDC, theRect, theDstRect); + + if (mDebugMode == 1) + DrawDebugBkgndInfo(pDC); + else if (mDebugMode == 2) + DrawDebugFloorInfoTenant(pDC, mVisibleArea); + else if (mDebugMode == 3) + DrawDebugFloorInfoMover(pDC, mVisibleArea); + else if (mDebugMode == 4) + DrawDebugFloorInfoRequest(pDC, mVisibleArea); + + if (mDbgEquipID) + DrawDebugEquip(pDC, mVisibleArea); + + int theZoom = mDocument->GetZoomLevel(); + pDC->SetViewportOrg( + -mScrollOffset.x + UT2Coordinate::UnitHSize(theZoom) / 2, + -mScrollOffset.y + UT2Coordinate::UnitVSize(theZoom) / 2 + ); + + CPen pen; + pen.CreatePen(PS_SOLID, 2, RGB(255, 0, 0)); + pDC->SelectObject(pen); + + CBrush nullBrush; + nullBrush.CreateStockObject(NULL_BRUSH); + pDC->SelectObject(nullBrush); + + CFont font; + font.CreateFont(-14, 0, 0, 0, FW_BOLD, false, false, false, DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, DRAFT_QUALITY, DEFAULT_PITCH, "Arial"); + pDC->SelectObject(font); + + pDC->SetBkMode(TRANSPARENT); + pDC->SetTextColor(RGB(255, 0, 0)); + + pDC->RestoreDC(saved); +} + +/*virtual*/ void T2TowerMainView::DrawDebugGrid() { + int stride = ((mImage->mBitmap.header.biWidth + 3) / 4) * 4; + + for (int x1 = 8 - (mScrollOffset.x % 8); x1 < mImage->mBitmap.header.biWidth; x1 += (8 >> mDocument->mZoomLevel)) { + for (int y1 = 4 - (mScrollOffset.y % 4); y1 < mImage->mBitmap.header.biHeight; y1 += (4 >> mDocument->mZoomLevel)) { + mImage->mData[stride * y1 + x1] = 0; + } + } + + for (int y2 = 36 - (mScrollOffset.y % 36); y2 < mImage->mBitmap.header.biHeight; y2 += (36 >> mDocument->mZoomLevel)) { + for (int x2 = 4 - (mScrollOffset.x % 4); x2 < mImage->mBitmap.header.biWidth; x2 += (4 >> mDocument->mZoomLevel)) { + mImage->mData[stride * y2 + x2] = 0; + } + } +} + +/*virtual*/ void T2TowerMainView::Invalidate(BOOL inFlag) { + InvalUnitRect(mVisibleArea, inFlag); +} + +/*virtual*/ void T2TowerMainView::InvalUnitRect(const RECT &inRect, BOOL inFlag) { +#pragma var_order(rect2, rect3, rect5, rect4, rect1) + CRect rect1; + CRect rect2 = inRect; + CRect rect3 = mVisibleArea; + CRect rect4 = mUpdateRect1; + CRect rect5 = mUpdateRect2; + + rect1.IntersectRect(&rect2, &rect3); + if (!rect1.IsRectEmpty()) { + if (inFlag) + rect4.UnionRect(&rect4, &rect1); + rect5.UnionRect(&rect5, &rect1); + } + + mUpdateRect1.top = rect4.top; + mUpdateRect1.bottom = rect4.bottom; + mUpdateRect1.left = rect4.left; + mUpdateRect1.right = rect4.right; + mUpdateRect2.top = rect5.top; + mUpdateRect2.bottom = rect5.bottom; + mUpdateRect2.left = rect5.left; + mUpdateRect2.right = rect5.right; +} + +void T2TowerMainView::OnDebugNormalDisplay() { + mDebugMode = 0; + InvalidateRect(NULL); +} + +void T2TowerMainView::OnUpdateDebugNormalDisplay(CCmdUI *pCmdUI) { + if (mDebugMode == 0) + pCmdUI->SetCheck(true); + else + pCmdUI->SetCheck(false); +} + +void T2TowerMainView::OnDebugBkgndInfo() { + mDebugMode = 1; + InvalidateRect(NULL); +} + +void T2TowerMainView::OnUpdateDebugBkgndInfo(CCmdUI *pCmdUI) { + if (mDebugMode == 1) + pCmdUI->SetCheck(true); + else + pCmdUI->SetCheck(false); +} + +void T2TowerMainView::OnDebugFloorInfoTenant() { + mDebugMode = 2; + InvalidateRect(NULL); +} + +void T2TowerMainView::OnUpdateDebugFloorInfoTenant(CCmdUI *pCmdUI) { + if (mDebugMode == 2) + pCmdUI->SetCheck(true); + else + pCmdUI->SetCheck(false); +} + +void T2TowerMainView::OnDebugFloorInfoMover() { + mDebugMode = 3; + InvalidateRect(NULL); +} + +void T2TowerMainView::OnUpdateDebugFloorInfoMover(CCmdUI *pCmdUI) { + if (mDebugMode == 3) + pCmdUI->SetCheck(true); + else + pCmdUI->SetCheck(false); +} + +void T2TowerMainView::OnDebugFloorInfoRequest() { + mDebugMode = 4; + InvalidateRect(NULL); +} + +void T2TowerMainView::OnUpdateDebugFloorInfoRequest(CCmdUI *pCmdUI) { + if (mDebugMode == 4) + pCmdUI->SetCheck(true); + else + pCmdUI->SetCheck(false); +} + +void T2TowerMainView::DrawDebugBkgndInfo(CDC *pDC) { + CFont dbgFont; + dbgFont.CreateFont(-15, 10, 900, 900, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS | CLIP_LH_ANGLES, DRAFT_QUALITY, FIXED_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); + + CBrush nullBrush; + nullBrush.CreateStockObject(NULL_BRUSH); + + CPen pen(PS_DOT, 1, RGB(0, 0, 0)); + + int saved = pDC->SaveDC(); + pDC->SelectObject(dbgFont); + pDC->SelectObject(nullBrush); + pDC->SelectObject(pen); + pDC->SetBkMode(OPAQUE); + pDC->SetViewportOrg(-mScrollOffset.x, -mScrollOffset.y); + + T2TowerDoc *theDoc = GetTowerDoc(); + char tmpStr[12]; + + RECT rect; + UT2Coordinate::UnitToBkgnd(mWorldBounds, rect); + + for (int v = rect.top; v < rect.bottom; v++) { + for (int h = rect.left; h < rect.right; h++) { + unsigned int bkgndInfo = UT2BkgndInfo::GetBkgndInfo(theDoc->mBkgndInfo, v, h); + + RECT bkgndInfoRect; + SetRect(&bkgndInfoRect, h, v, h + 1, v + 1); + UT2Coordinate::BkgndToQD(bkgndInfoRect, theDoc->mZoomLevel); + + wsprintf(tmpStr, "%04d", bkgndInfo); + pDC->TextOut(bkgndInfoRect.left, bkgndInfoRect.top + 42, tmpStr); + + pDC->Rectangle(&bkgndInfoRect); + } + } + + pDC->RestoreDC(saved); + + dbgFont.DeleteObject(); + nullBrush.DeleteObject(); + pen.DeleteObject(); +} + +void T2TowerMainView::DrawDebugFloorInfoTenant(CDC *pDC, const RECT &inRect) { + CFont dbgFont; + dbgFont.CreateFont(-9, 5, 900, 900, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS | CLIP_LH_ANGLES, DRAFT_QUALITY, FIXED_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); + + CBrush nullBrush; + nullBrush.CreateStockObject(NULL_BRUSH); + + CPen pen(PS_DOT, 1, RGB(0, 0, 0)); + + int saved = pDC->SaveDC(); + pDC->SelectObject(dbgFont); + pDC->SelectObject(nullBrush); + pDC->SelectObject(pen); + pDC->SetBkMode(OPAQUE); + pDC->SetViewportOrg(-mScrollOffset.x, -mScrollOffset.y); + + T2TowerDoc *theDoc = GetTowerDoc(); + char tmpStr[12]; + + T2FInfoAreaIterator areaIterator(*theDoc->mFloorInfo, inRect); + T2Tenant *theTenant; + + while (areaIterator.NextTenant(theTenant)) { + if (theTenant) { + RECT tenantRect; + theTenant->GetEquipArea(tenantRect); + areaIterator.GetTenantRect(tenantRect); + UT2Coordinate::UnitToQD(tenantRect, theDoc->mZoomLevel, true); + + wsprintf(tmpStr, "%04d", theTenant->mEquipID); + pDC->TextOut(tenantRect.left, tenantRect.top + 22, tmpStr); + + wsprintf(tmpStr, "%02d", theTenant->GetStatus()); + pDC->TextOut(tenantRect.left, tenantRect.bottom - 2, tmpStr); + + pDC->Rectangle(&tenantRect); + } + } + + pDC->RestoreDC(saved); + + dbgFont.DeleteObject(); + nullBrush.DeleteObject(); + pen.DeleteObject(); +} + +void T2TowerMainView::DrawDebugFloorInfoMover(CDC *pDC, const RECT &inRect) { + CFont dbgFont; + dbgFont.CreateFont(-9, 5, 900, 900, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS | CLIP_LH_ANGLES, DRAFT_QUALITY, FIXED_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); + + CBrush nullBrush; + nullBrush.CreateStockObject(NULL_BRUSH); + + CPen pen(PS_DOT, 1, RGB(0, 0, 0)); + + int saved = pDC->SaveDC(); + pDC->SelectObject(dbgFont); + pDC->SelectObject(nullBrush); + pDC->SelectObject(pen); + pDC->SetBkMode(OPAQUE); + pDC->SetViewportOrg(-mScrollOffset.x, -mScrollOffset.y); + + T2TowerDoc *theDoc = GetTowerDoc(); + T2MoverArrayList *theMoverList = theDoc->mFloorInfo->GetMoverArrayList(); + LArrayIterator iterator(*theMoverList); + T2MoverArray *theMoverArray; + + char tmpStr[12]; + + while (iterator.Next(&theMoverArray)) { + for (int i = 0; i < T2MoverArray::kGroupSize; i++) { + if (theMoverArray->mMover[i].IsUsed()) { + T2Mover *theMover = &theMoverArray->mMover[i]; + + RECT moverRect; + theMover->GetEquipArea(moverRect); + UT2Coordinate::UnitToQD(moverRect, theDoc->mZoomLevel, true); + + wsprintf(tmpStr, "%04d", theMover->mEquipID); + pDC->TextOut(moverRect.left, moverRect.top + 22, tmpStr); + pDC->Rectangle(&moverRect); + } + } + } + + pDC->RestoreDC(saved); + + dbgFont.DeleteObject(); + nullBrush.DeleteObject(); + pen.DeleteObject(); +} + +void T2TowerMainView::DrawDebugFloorInfoRequest(CDC *pDC, const RECT &inRect) { + CFont dbgFont; + dbgFont.CreateFont(-9, 5, 900, 900, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS | CLIP_LH_ANGLES, DRAFT_QUALITY, FIXED_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); + + CBrush nullBrush; + nullBrush.CreateStockObject(NULL_BRUSH); + + CPen pen(PS_DOT, 1, RGB(0, 0, 0)); + + int saved = pDC->SaveDC(); + pDC->SelectObject(dbgFont); + pDC->SelectObject(nullBrush); + pDC->SelectObject(pen); + pDC->SetBkMode(OPAQUE); + pDC->SetViewportOrg(-mScrollOffset.x, -mScrollOffset.y); + + T2TowerDoc *theDoc = GetTowerDoc(); + char tmpStr[12]; + + T2FInfoAreaIterator areaIterator(*theDoc->mFloorInfo, inRect); + T2Request *theReq; + + while (areaIterator.NextRequest(theReq)) { + if (!theReq->IsUsed()) + continue; + + RECT requestRect; + theReq->CalcArea(requestRect); + UT2Coordinate::UnitToQD(requestRect, theDoc->mZoomLevel); + + wsprintf(tmpStr, "%04d", theReq->mRequestID); + + if (theReq->mIsGoDown) + pDC->SetBkColor(PALETTERGB(0, 255, 255)); + else + pDC->SetBkColor(PALETTERGB(255, 0, 255)); + + pDC->TextOut(requestRect.left, requestRect.top + 22, tmpStr); + pDC->Rectangle(&requestRect); + } + + pDC->RestoreDC(saved); + + dbgFont.DeleteObject(); + nullBrush.DeleteObject(); + pen.DeleteObject(); +} + +void T2TowerMainView::DrawDebugEquip(CDC *pDC, const RECT &inRect) { + CFont dbgFont; + dbgFont.CreateFont(-9, 5, 900, 900, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS | CLIP_LH_ANGLES, DRAFT_QUALITY, FIXED_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); + + CBrush nullBrush; + nullBrush.CreateStockObject(NULL_BRUSH); + + CPen pen(PS_DOT, 1, RGB(0, 0, 0)); + + int saved = pDC->SaveDC(); + pDC->SelectObject(dbgFont); + pDC->SelectObject(nullBrush); + pDC->SelectObject(pen); + pDC->SetBkMode(OPAQUE); + pDC->SetViewportOrg(-mScrollOffset.x, -mScrollOffset.y); + + T2TowerDoc *theDoc = GetTowerDoc(); + T2Equip *theSelEquip = NULL; + char tmpStr[12]; + + T2TenantArrayList *theTenantArrayList = theDoc->mFloorInfo->GetTenantArrayList(); + LArrayIterator arrayIterator(*theTenantArrayList); + T2TenantArray *thisArray; + + while (arrayIterator.Next(&thisArray) && !theSelEquip) { + for (int i = 0; i < T2TenantArray::kGroupSize; i++) { + if ( + thisArray->mTenants[i].IsUsed() && + thisArray->mTenants[i].mEquipID == mDbgEquipID + ) + { + theSelEquip = &thisArray->mTenants[i]; + break; + } + } + } + + T2FInfoAreaIterator areaIterator(*theDoc->mFloorInfo, inRect); + T2Tenant *theTenant = NULL; + + while (areaIterator.NextTenant(theTenant)) { + if (theTenant && theTenant->mEquipID == mDbgEquipID) { + theSelEquip = theTenant; + break; + } + } + + if (!theSelEquip) { + T2MoverArrayList *theList = theDoc->mFloorInfo->GetMoverArrayList(); + LArrayIterator iterator(*theList); + T2MoverArray *theMoverArray; + + while (iterator.Next(&theMoverArray)) { + for (int i = 0; i < T2MoverArray::kGroupSize; i++) { + if (theMoverArray->mMover[i].IsUsed()) { + T2Mover *theMover = &theMoverArray->mMover[i]; + if (theMover->mEquipID == mDbgEquipID) { + theSelEquip = theMover; + break; + } + } + } + } + } + + if (theSelEquip) { + RECT equipArea; + theSelEquip->GetEquipArea(equipArea); + UT2Coordinate::UnitToQD(equipArea, theDoc->mZoomLevel, true); + + wsprintf(tmpStr, "%04d", theSelEquip->mEquipID); + pDC->TextOut(equipArea.left, equipArea.top + 22, tmpStr); + pDC->Rectangle(&equipArea); + } + + pDC->RestoreDC(saved); + + dbgFont.DeleteObject(); + nullBrush.DeleteObject(); + pen.DeleteObject(); +} + +void T2TowerMainView::x42CA08(const POINT &inPt) { + if (mDbgEquipID) { + mDbgEquipID = 0; + InvalidateRect(NULL); + return; + } + + POINT pt = inPt; + UT2Coordinate::QDToUnit(pt, mDocument->mZoomLevel); + + T2Equip *theEquip = NULL; + theEquip = mDocument->mFloorInfo->GetMover(pt.y, pt.x); + if (!theEquip) + theEquip = mDocument->mFloorInfo->GetTenant(pt.y, pt.x); + if (!theEquip) + theEquip = mDocument->mFloorInfo->GetFloor(pt.y, pt.x); + + if (theEquip) { + mDbgEquip = theEquip; + + DbgEquipInfo dlg(NULL); + dlg.SetEquip(theEquip); + dlg.SetDocument(mDocument); + dlg.SetTowerMainView(this); + dlg.DoModal(); + + mDbgEquipID = 0; + InvalidateRect(NULL); + tmv_vf120(); + } +} + +void T2TowerMainView::OnCommand10000to10010(UINT nCmd) { + mDbgEquip->mCEArray->FetchItemAt(nCmd - 9999, &mDbgEquipID); + InvalidateRect(NULL); +} + +/*virtual*/ void T2TowerMainView::SetScrollV(int inV) { + RECT oldRect, diff; + + oldRect = mVisibleArea; + mScrollOffset.y = inV; + x42AC1B(); + + SubtractRect(&diff, &mVisibleArea, &oldRect); + diff = mVisibleArea; + InvalUnitRect(diff, true); + tmv_vf120(); +} + +/*virtual*/ void T2TowerMainView::SetScrollH(int inH) { + RECT oldRect, diff; + + oldRect = mVisibleArea; + mScrollOffset.x = inH; + x42AC1B(); + + SubtractRect(&diff, &mVisibleArea, &oldRect); + diff = mVisibleArea; + InvalUnitRect(diff, true); + tmv_vf120(); +} + +/*virtual*/ BOOL T2TowerMainView::tmv_vf160(POINT &outPt) { + BOOL result = false; + + GetCursorPos(&outPt); + ScreenToClient(&outPt); + + CRect rect; + GetClientRect(rect); + + if (rect.PtInRect(outPt)) { + outPt.x -= mImageOrigin.x; + outPt.y -= mImageOrigin.y; + outPt.x += mScrollOffset.x; + outPt.y += mScrollOffset.y; + + mImage->SetOrigin(mScrollOffset.x, mScrollOffset.y); + if (mImage->GetPixel(outPt) != -1) + result = true; + mImage->SetOrigin(0, 0); + } + + return result; +} + +void T2TowerMainView::OnLButtonDown(UINT nFlags, CPoint point) { + SetCapture(); + + if (!mDocument || !mDocument->mIsStuffLoadedFlag) + return; + + HandleLButtonDown(point); +} + +void T2TowerMainView::HandleLButtonDown(CPoint inPt) { + mPressedButtons |= MK_LBUTTON; + mDocument->SetCursorType(kCursorNoChange, true); + + if (!mDocument || !mDocument->mIsStuffLoadedFlag) + return; + if (mDocument->towerDoc_vf1A4()) + return; + + mInitialClickPos = inPt; + + inPt.x -= mImageOrigin.x; + inPt.y -= mImageOrigin.y; + + CRect clientArea; + GetClientRect(&clientArea); + if (!clientArea.PtInRect(inPt)) + return; + + inPt.Offset(mScrollOffset); + if (!PtInRect(&mWorldBounds, m7C)) + return; + + if (!DispatchOptionEvent(kLButtonDownOptionEvent, &inPt)) + return; + + int theTool = T2_MAIN_WINDOW->mToolWindow->GetSel(); + CString *theToolName = T2_MAIN_WINDOW->mToolWindow->GetIconName(theTool); + T2ToolDef *theToolDef = (T2ToolDef *) T2_MAIN_WINDOW->mToolWindow->GetIconPlugin(theTool); + unsigned int theIconValiation = T2_MAIN_WINDOW->mToolWindow->GetIconValiation(theTool); + DWORD option = T2_MAIN_WINDOW->mToolWindow->GetIconOption(theTool); + +#line 1081 + _ASSERT(theToolName != NULL); + + RECT unitRect; + UT2Coordinate::QDToUnit(m6C, unitRect, mDocument->mZoomLevel); + + if (mAnotherToolVar == kAnotherToolVar1) { + if (mDocument->DoClickByFingerTool(inPt)) + mActiveTool = kTool4_Finger; + else + mAnotherToolVar = kAnotherToolVar0; + } else if (*theToolName == "ToolDestruct") { + mDocument->DoDestruct(inPt); + } else if (*theToolName == "ToolFinger") { + if (mDocument->DoClickByFingerTool(inPt)) + mActiveTool = kTool4_Finger; + } else if (*theToolName == "ToolInfo" && GetAsyncKeyState(VK_CONTROL) < 0) { + CPoint pt = inPt; + UT2Coordinate::QDToUnit(pt, mDocument->mZoomLevel); + + T2Tenant *theTenant = mDocument->mFloorInfo->GetTenant(pt.y, pt.x); + if (theTenant && !theTenant->IsFloor()) + theTenant->CollectCustomer(mDocument, (T2Tenant *) NULL); + } else if (*theToolName == "ToolInfo") { + mDocument->DoGetInfo(inPt); + } else if (*theToolName == "ToolZoom") { + mDocument->CallbackZoomIn(inPt); + } else if (*theToolName == "ToolHand") { + HandToolClick(mInitialClickPos); + mActiveTool = kTool5_Hand; + } else if (*theToolName == "ToolMic") { + // nothing + } else if (*theToolName == "ToolRoot") { + mDocument->DoSearchRangeTool(inPt); + } else if (option == kToolOption1) { + mActiveTool = kTool1_Tenant; + mDocument->DoClickByTenantTool(unitRect, (T2TenantDef *) theToolDef, theIconValiation); + _108.x = -1; + _108.y = inPt.y; + } else if (option == kToolOption2) { + mActiveTool = kTool2_Mover; + mDocument->DoClickByMoverTool(unitRect, (T2MoverDef *) theToolDef, theIconValiation, false); + } else if (option == kToolOption3) { + mActiveTool = kTool3_OutObj; + mDocument->DoClickByOutObjTool(unitRect, (T2OuterObjDef *) theToolDef, theIconValiation); + } + + if (mActiveTool != kTool0_Null) + mDocument->towerDoc_vf290(true); +} + +void T2TowerMainView::OnMouseMove(UINT nFlags, CPoint point) { + if (!mDocument || !mDocument->mIsStuffLoadedFlag) + return; + + if (mDocument->towerDoc_vf1A4()) { + ReleaseCapture(); + return; + } + + if (nFlags & MK_LBUTTON) { + if (!(mPressedButtons & MK_LBUTTON)) + mDocument->SetCursorType(kCursorNoChange, true); + } else { + if (mPressedButtons & MK_LBUTTON) + mDocument->SetCursorType(kCursorNoChange, false); + } + + CPoint thePoint = point; + CURSORTYPE theNextCursor = CursorType_0; + + int theTool = T2_MAIN_WINDOW->mToolWindow->GetSel(); + CString *theToolName = T2_MAIN_WINDOW->mToolWindow->GetIconName(theTool); + T2ToolDef *theToolDef = (T2ToolDef *) T2_MAIN_WINDOW->mToolWindow->GetIconPlugin(theTool); + unsigned int theIconValiation = T2_MAIN_WINDOW->mToolWindow->GetIconValiation(theTool); + DWORD option = T2_MAIN_WINDOW->mToolWindow->GetIconOption(theTool); + + _E0 = point; + _E0.x += mScrollOffset.x; + _E0.y += mScrollOffset.y; + _E0.x -= mImageOrigin.x; + _E0.y -= mImageOrigin.y; + + if (!DispatchOptionEvent(kMouseMoveOptionEvent, &_E0)) + return; + + if (_108.x != -1) + _E0.x = _108.x; + if (_108.y != -1) + _E0.y = _108.y; + + if (mActiveTool == kTool0_Null) { + if (mAnotherToolVar != kAnotherToolVar1) { + if (mToolSpriteName != "" && mToolSpriteName != "Focus") + DeleteToolSprite(); + + mActiveToolDef = NULL; + + if (option == kToolOption1) { + mActiveToolDef = theToolDef; + if (mActiveToolDef) { + mToolSpriteName = ""; + theNextCursor = mActiveToolDef->QueryCursor(mDocument, _E0, mToolSpriteName, m6C, m7C, mDocument->mZoomLevel, theIconValiation, 0); + if (mToolSpriteName != "") { + CreateToolSprite(); + mDocument->SetCursorType(kCursorDefault, false); + } else { + mDocument->SetCursorType(kCursorNo, false); + } + } + } else if (option == kToolOption2) { + mActiveToolDef = theToolDef; + if (mActiveToolDef) { + mToolSpriteName = ""; + theNextCursor = mActiveToolDef->QueryCursor(mDocument, _E0, mToolSpriteName, m6C, m7C, mDocument->mZoomLevel, theIconValiation, 0); + CreateToolSprite(); + } + } else if (option == kToolOption3) { + mActiveToolDef = theToolDef; + if (mActiveToolDef) { + mToolSpriteName = ""; + theNextCursor = mActiveToolDef->QueryCursor(mDocument, _E0, mToolSpriteName, m6C, m7C, mDocument->mZoomLevel, theIconValiation, 0); + CreateToolSprite(); + } + } + } + + BOOL var34 = false; + int var38 = kAnotherToolVar0; + + if (option == kToolOption2) { + RECT rect48; + UT2Coordinate::QDToUnit(m6C, rect48, mDocument->mZoomLevel); + + if (!mDocument->DoClickByMoverTool(rect48, (T2MoverDef *) theToolDef, theIconValiation, true)) + var38 = kAnotherToolVar2; + + CPoint pt50 = point; + pt50.x -= mImageOrigin.x; + pt50.y -= mImageOrigin.y; + pt50.Offset(mScrollOffset); + if (mDocument->towerDoc_vf23C(pt50)) + var38 = kAnotherToolVar1; + + var34 = true; + } + + if (var34) { + mAnotherToolVar = var38; + + int var54; + switch (mAnotherToolVar) { + case kAnotherToolVar0: + var54 = kCursorDefault; + break; + case kAnotherToolVar1: + var54 = kCursorFinger; + mAnotherToolVar = kAnotherToolVar3; + break; + case kAnotherToolVar2: + var54 = kCursorNo; + break; + default: + var54 = kCursorDefault; + } + + mDocument->SetCursorType(var54, false); + } + } + + if (mActiveToolDef) { + if (mAnotherToolVar != kAnotherToolVar1) { + CString theOldSprite = mToolSpriteName; + theNextCursor = mActiveToolDef->QueryCursor(mDocument, _E0, mToolSpriteName, m6C, m7C, mDocument->mZoomLevel, theIconValiation, mActiveTool != kTool0_Null); + if (theOldSprite != mToolSpriteName) { + if (theOldSprite != "") + DeleteToolSprite(); + CreateToolSprite(true); + } + + POINT spritePt; + spritePt.x = m6C.left; + spritePt.y = m6C.top; + spritePt.x <<= mDocument->mZoomLevel; + spritePt.y <<= mDocument->mZoomLevel; + + if (mToolSpriteIndex != -1 && !mHideToolSpriteCount) { + mDocument->mSprite.MoveSprite(mToolSpriteIndex, spritePt); + if (theOldSprite != mToolSpriteName) + mDocument->mSprite.ShowSprite(mToolSpriteIndex, true); + } + } + } else { + m7C = _E0; + UT2Coordinate::QDToUnit(m7C, mDocument->mZoomLevel); + } + + if (mActiveTool == kTool0_Null) { + if (mAnotherToolVar != kAnotherToolVar1 && *theToolName == "ToolMic") + mDocument->DoInterview(_E0); + } else { + point.Offset(mScrollOffset); + + CPoint unitPoint = point; + UT2Coordinate::QDToUnit(unitPoint, mDocument->mZoomLevel); + RECT unitRect; + UT2Coordinate::QDToUnit(m6C, unitRect, mDocument->mZoomLevel); + + if (thePoint != mInitialClickPos) + mDocument->_B0 = false; + + BOOL var64 = true; + if ((unitRect.right - unitRect.left) <= 0 || (unitRect.bottom - unitRect.top) <= 0) + var64 = false; + + switch (mActiveTool) { + case kTool1_Tenant: + if (var64) + mDocument->DoDragByTenantTool(unitRect); + break; + case kTool2_Mover: + if (var64) + mDocument->DoDragByMoverTool(unitRect); + break; + case kTool3_OutObj: + if (var64) + mDocument->DoDragByOutObjTool(unitRect); + break; + case kTool4_Finger: + mDocument->DoDragByFingerTool(point); + break; + case kTool5_Hand: + HandToolDrag(thePoint); + break; + } + + mDocument->_B0 = true; + } + + if (mAnotherToolVar == kAnotherToolVar3) + mAnotherToolVar = kAnotherToolVar1; +} + +void T2TowerMainView::OnLButtonUp(UINT nFlags, CPoint point) { + HandleLButtonUp(point); + ReleaseCapture(); +} + +void T2TowerMainView::HandleLButtonUp(CPoint inPt) { + mPressedButtons &= MK_RBUTTON; + mDocument->SetCursorType(kCursorNoChange, false); + + if (!mDocument) + return; + if (mDocument->towerDoc_vf1A4()) + return; + if (!mDocument->mWorldDef) + return; + + if (mActiveTool == kTool0_Null) + return; + + inPt.x -= mImageOrigin.x; + inPt.y -= mImageOrigin.y; + inPt.Offset(mScrollOffset); + + if (!DispatchOptionEvent(kLButtonUpOptionEvent, &inPt)) + return; + + if (_108.x != -1) + inPt.x = _108.x; + if (_108.y != -1) + inPt.y = _108.y; + + RECT unitRect; + CPoint unitPt = inPt; + UT2Coordinate::QDToUnit(unitPt, mDocument->mZoomLevel); + UT2Coordinate::QDToUnit(m6C, unitRect, mDocument->mZoomLevel); + + if (mActiveTool == kTool1_Tenant) + mDocument->DoReleaseByTenantTool(unitRect); + else if (mActiveTool == kTool2_Mover) + mDocument->DoReleaseByMoverTool(unitRect); + else if (mActiveTool == kTool3_OutObj) + mDocument->DoReleaseByOutObjTool(unitRect); + else if (mActiveTool == kTool4_Finger) + mDocument->DoReleaseByFingerTool(inPt); + else if (mActiveTool == kTool5_Hand) + HandToolRelease(inPt); + + _108.x = -1; + _108.y = -1; + + if (mActiveTool != kTool0_Null) + mDocument->towerDoc_vf294(); + mActiveTool = kTool0_Null; +} + +void T2TowerMainView::OnUpdateDebugGrid(CCmdUI *pCmdUI) { + pCmdUI->SetCheck(mIsDebugGrid != FALSE); +} + +void T2TowerMainView::OnDebugGrid() { + mIsDebugGrid = !mIsDebugGrid; + AdjustWorldBounds(); + tmv_vf120(); +} + +void T2TowerMainView::x42E366(int inType) { + HCURSOR cursor; + + if (inType == 0) + cursor = LoadCursor(NULL, IDC_ARROW); + else if (inType == 1) + cursor = LoadCursor(NULL, IDC_SIZENS); + else if (inType == 2) + cursor = LoadCursor(NULL, IDC_SIZEWE); + else if (inType == 3) + cursor = LoadCursor(NULL, IDC_NO); + + SetCursor(cursor); +} + +void T2TowerMainView::OnRButtonDown(UINT nFlags, CPoint point) { + if (!mDocument || !mDocument->mIsStuffLoadedFlag) + return; + + HandleRButtonDown(point); +} + +void T2TowerMainView::HandleRButtonDown(CPoint inPt) { + mPressedButtons |= MK_RBUTTON; + + if (!mDocument->mWorldDef) + return; + T2TowerDoc *theTowerDoc = GetTowerDoc(); + if (theTowerDoc->towerDoc_vf1A4()) + return; + + inPt.x -= mImageOrigin.x; + inPt.y -= mImageOrigin.y; + + CRect mainViewRect; + GetClientRect(&mainViewRect); + if (!mainViewRect.PtInRect(inPt)) + return; + + inPt.Offset(mScrollOffset); + if (!PtInRect(&mWorldBounds, m7C)) + return; + + if (!DispatchOptionEvent(kRButtonDownOptionEvent, &inPt)) + return; + + int theTool = T2_MAIN_WINDOW->mToolWindow->GetSel(); + CString *theToolName = T2_MAIN_WINDOW->mToolWindow->GetIconName(theTool); +#line 1637 + _ASSERT(theToolName != NULL); + + RECT unitRect; + UT2Coordinate::QDToUnit(m6C, unitRect, mDocument->mZoomLevel); + + if (*theToolName == "ToolZoom") + mDocument->CallbackZoomOut(); +} + +void T2TowerMainView::OnRButtonUp(UINT nFlags, CPoint point) { + if (!mDocument || !mDocument->mIsStuffLoadedFlag) + return; + + HandleRButtonUp(point); +} + +void T2TowerMainView::HandleRButtonUp(CPoint inPt) { + mPressedButtons &= MK_LBUTTON; + + T2TowerDoc *theTowerDoc = GetTowerDoc(); + if (theTowerDoc->towerDoc_vf1A4()) + return; + if (!mDocument->mWorldDef) + return; + + inPt.x -= mImageOrigin.x; + inPt.y -= mImageOrigin.y; + + CRect mainViewRect; + GetClientRect(&mainViewRect); + if (!mainViewRect.PtInRect(inPt)) + return; + + inPt.Offset(mScrollOffset); + if (!PtInRect(&mWorldBounds, m7C)) + return; + + DispatchOptionEvent(kRButtonUpOptionEvent, &inPt); +} + + +/*virtual*/ void T2TowerMainView::tmv_vf13C(int inX, int inY, unsigned int inCode) { + POINT pt; + pt.x = inX; + pt.y = inY; + tmv_vf138(pt, inCode); +} + +/*virtual*/ void T2TowerMainView::tmv_vf138(const POINT &inPt, unsigned int inCode) { +#pragma var_order(worldRect, code3, viewRect, pt, code2, code1) + int code1 = inCode & kScrollOpt2Mask; + int code2 = inCode & kScrollOptionMask; + int code3 = inCode & kScrollOpt3Mask; + + POINT pt = inPt; + if (code2 == kScroll2) + pt.y += 2; + if (code2 != kScroll3) + UT2Coordinate::UnitToQD(pt, mDocument->mZoomLevel); + + CRect viewRect, worldRect; + GetClientRect(&viewRect); + + worldRect.SetRect(0, 0, mDocument->mWorldDef->GetWidth(), mDocument->mWorldDef->GetHeight()); + UT2Coordinate::UnitToQD(worldRect, mDocument->mZoomLevel, true); + + mImageOrigin.x = viewRect.Width() - worldRect.Width(); + mImageOrigin.y = viewRect.Height() - worldRect.Height(); + + if (mImageOrigin.x < 0) + mImageOrigin.x = 0; + else + mImageOrigin.x /= 2; + + if (mImageOrigin.y < 0) + mImageOrigin.y = 0; + else + mImageOrigin.y /= 2; + + if (code2 == kScroll1) { + mNextScrollOffset.x = pt.x - viewRect.Width() / 2; + mNextScrollOffset.y = pt.y - viewRect.Height() / 2; + } else if (code2 == kScroll2) { + mNextScrollOffset.x = pt.x - viewRect.Width() / 2; + mNextScrollOffset.y = pt.y - (viewRect.Height() * 4) / 5; + } else if (code2 == kScroll3) { + mNextScrollOffset.x = pt.x; + mNextScrollOffset.y = pt.y; + } + + if (mNextScrollOffset.x < 0) { + mNextScrollOffset.x = 0; + } else if ((mNextScrollOffset.x + viewRect.Width()) > worldRect.Width()) { + mNextScrollOffset.x = worldRect.Width() - viewRect.Width(); + if (mNextScrollOffset.x < 0) + mNextScrollOffset.x = 0; + } + + if (mNextScrollOffset.y < 0) { + mNextScrollOffset.y = 0; + } else if ((mNextScrollOffset.y + viewRect.Height()) > worldRect.Height()) { + mNextScrollOffset.y = worldRect.Height() - viewRect.Height(); + if (mNextScrollOffset.y < 0) + mNextScrollOffset.y = 0; + } + + if (code1 == kScrollOpt2) { + AfxGetMainWnd()->SetScrollPos(SB_HORZ, mNextScrollOffset.x); + AfxGetMainWnd()->SetScrollPos(SB_VERT, mNextScrollOffset.y); + + mScrollOffset = mNextScrollOffset; + + x42AC1B(); + + CRect rect3(0, 0, mDocument->mWorldDef->GetWidth(), mDocument->mWorldDef->GetHeight()); + AfxGetMainWnd()->Invalidate(); + InvalUnitRect(rect3, true); + if (!code3) + tmv_vf120(); + } +} + +/*virtual*/ void T2TowerMainView::DoZoomIn(POINT inPt) { + if (mDocument->mZoomLevel <= 0) + return; + + UT2Coordinate::QDToUnit(inPt, mDocument->mZoomLevel); + mDocument->mZoomLevel--; + + InvalidateRect(NULL, false); + + T2_MAIN_WINDOW->x4144FA(); + AdjustWorldBounds(); + tmv_vf138(inPt, kScroll1 | kScrollOpt2); +} + +/*virtual*/ void T2TowerMainView::DoZoomOut() { + if (mDocument->mZoomLevel >= 2) + return; + + POINT pt; + pt.x = (mVisibleArea.right + mVisibleArea.left) / 2; + pt.y = (mVisibleArea.bottom + mVisibleArea.top) / 2; + + mDocument->mZoomLevel++; + + InvalidateRect(NULL, false); + + T2_MAIN_WINDOW->x4144FA(); + AdjustWorldBounds(); + tmv_vf138(pt, kScroll1 | kScrollOpt2); +} + +/*virtual*/ void T2TowerMainView::UnhideToolSprite() { + if (mHideToolSpriteCount == 0) + return; + + mHideToolSpriteCount--; + if (mHideToolSpriteCount != 0) + return; + + if (!mDC) + return; + + if (mToolSpriteIndex != -1) { + POINT pt; + pt.x = m6C.left; + pt.y = m6C.top; + pt.x <<= mDocument->mZoomLevel; + pt.y <<= mDocument->mZoomLevel; + + mDocument->mSprite.MoveSprite(mToolSpriteIndex, pt); + mDocument->mSprite.ShowSprite(mToolSpriteIndex, true); + Invalidate(true); + } +} + +/*virtual*/ void T2TowerMainView::HideToolSprite() { + if (mHideToolSpriteCount == 0 && mActiveToolDef && mToolSpriteIndex != -1) { + mDocument->mSprite.ShowSprite(mToolSpriteIndex, false); + Invalidate(true); + } + + mHideToolSpriteCount++; +} + +/*virtual*/ void T2TowerMainView::CenterOnRectAndZoom(const RECT &inRect) { + POINT pt = URect::Center(inRect); + mDocument->SetZoomLevel(0); + tmv_vf138(pt, kScroll1 | kScrollOpt2); +} + +/*virtual*/ void T2TowerMainView::CenterOnRect(const RECT *inRect) { + int x = inRect->left + ((inRect->right - inRect->left) + 1) / 2; + int y = inRect->top + ((inRect->bottom - inRect->top) + 1) / 2; + tmv_vf13C(x, y, kScroll1 | kScrollOpt2); +} + +/*virtual*/ void T2TowerMainView::OnUpdate(CView *pSender, LPARAM lHint, CObject *pHint) { + if (mDocument->mWorldDef) { + SetRect(&mWorldBounds, 0, 0, mDocument->mWorldDef->GetWidth(), mDocument->mWorldDef->GetHeight()); + } else { + SetRect(&mWorldBounds, 0, 0, 100, 100); + InvalidateRect(NULL); + } + + AdjustWorldBounds(); + + if (mDocument->Get22C()) { +#pragma var_order(numTileY, grayBrush, tileFlags, saved, timeBegin, index, numTiles, viewRect, numTileX, rect3, bufferRect, pDC) + T2_MAIN_WINDOW->x4144FA(); + tmv_vf138(mDocument->m188, kScroll3 | kScrollOpt2 | kScrollOpt3); + Invalidate(true); + tmv_vf11C(); + + CDC *pDC = T2_MAIN_WINDOW->GetDC(); + int saved = pDC->SaveDC(); + pDC->SelectPalette(mDocument->mWorldDef->GetPalette(), false); + pDC->RealizePalette(); + pDC->RestoreDC(saved); + T2_MAIN_WINDOW->ReleaseDC(pDC); + + gT2App->app_vfB4(); + + pDC = GetDC(); + saved = pDC->SaveDC(); + pDC->SelectPalette(mDocument->mWorldDef->GetPalette(), false); + pDC->RealizePalette(); + + CBrush grayBrush; + grayBrush.CreateStockObject(GRAY_BRUSH); + + CRect viewRect; + GetClientRect(viewRect); + pDC->FillRect(viewRect, &grayBrush); + + CRect bufferRect, rect3; + bufferRect.SetRect(0, 0, mImage->mBitmap.header.biWidth, mImage->mBitmap.header.biHeight); + rect3 = bufferRect; + rect3.OffsetRect(mImageOrigin); + + int numTileX = (bufferRect.Width() + 24) / 25; + int numTileY = (bufferRect.Height() + 24) / 25; + int numTiles = numTileX * numTileY; + + unsigned char *tileFlags = (unsigned char *) malloc(numTiles); + memset(tileFlags, 0, numTiles); + + DWORD timeBegin = timeGetTime(); + int index = 0; + + while (index < numTiles) { + DWORD elapsed = timeGetTime() - timeBegin; + int end = min(numTiles, (int) ((numTiles * elapsed) / 1000)); + for (; index < end; index++) { + int h, v; + do { + h = UT2Utils::Randomize(numTileX); + v = UT2Utils::Randomize(numTileY); + } while (tileFlags[h + v * numTileX]); + + tileFlags[h + v * numTileX] = true; + + CRect copyRectSrc, copyRectDest; + copyRectSrc.SetRect(h * 25, v * 25, h * 25 + 25, v * 25 + 25); + copyRectDest = copyRectSrc; + copyRectDest.OffsetRect(mImageOrigin); + mImage->CopyImage(pDC, copyRectSrc, copyRectDest); + } + } + + free(tileFlags); + + pDC->RestoreDC(saved); + ReleaseDC(pDC); + + InvalidateRect(NULL); + UpdateWindow(); + } +} + +void T2TowerMainView::OnUpdateDebugDisplaySpeedMeasuring(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +void T2TowerMainView::OnDebugDisplaySpeedMeasuring() { + time_t t = time(NULL); +retry: + if (time(NULL) == t) + goto retry; + + t = time(NULL); + int counter = 0; + + while ((time(NULL) - t) < 5) { + Invalidate(false); + tmv_vf120(); + counter++; + } + + CString str; + str.Format("%.2f Frames/sec.", counter / 5.0f); + MessageBox(str, "RESULT"); +} + +void T2TowerMainView::OnUpdateDebugOffscreenSpeedMeasuring(CCmdUI *pCmdUI) { + pCmdUI->Enable(); +} + +void T2TowerMainView::OnDebugOffscreenSpeedMeasuring() { + time_t t = time(NULL); + retry: + if (time(NULL) == t) + goto retry; + + t = time(NULL); + int counter = 0; + + mSkipOffscreenDraw = true; + while ((time(NULL) - t) < 5) { + Invalidate(false); + tmv_vf120(); + counter++; + } + mSkipOffscreenDraw = false; + + CString str; + str.Format("%.2f Frames/sec.", counter / 5.0f); + MessageBox(str, "RESULT"); +} + +/*virtual*/ BOOL T2TowerMainView::PreTranslateMessage(MSG *pMsg) { + return !ExecuteAttachments(pMsg->message, pMsg); +} + +void T2TowerMainView::OnTimer(UINT nIDEvent) { + if (nIDEvent == 12345) { + CPoint cursorPos; + GetCursorPos(&cursorPos); + if (WindowFromPoint(cursorPos)->m_hWnd == m_hWnd) { + if (!_EC) { + UnhideToolSprite(); + _EC = true; + } + } else { + if (_EC) { + HideToolSprite(); + _EC = false; + } + } + } else { + MSG msg; + msg.message = WM_TIMER; + msg.wParam = nIDEvent; + PreTranslateMessage(&msg); + } +} + +/*virtual*/ void T2TowerMainView::GetVisibleUnitRect(RECT &outRect) const { + CRect rect; + GetClientRect(rect); + rect.OffsetRect(mScrollOffset); + UT2Coordinate::QDToUnit(rect, outRect, mDocument->mZoomLevel); +} + +void T2TowerMainView::HandToolClick(CPoint inPt) { + mHandToolLastPos = inPt; +} + +void T2TowerMainView::HandToolDrag(CPoint inPt) { + POINT pt; + pt.x = mHandToolLastPos.x - inPt.x; + pt.y = mHandToolLastPos.y - inPt.y; + + pt.x += mScrollOffset.x; + if (pt.x < 0) + pt.x = 0; + + pt.y += mScrollOffset.y; + if (pt.y < 0) + pt.y = 0; + + mHandToolLastPos = inPt; + InvalidateRect(NULL, false); + T2_MAIN_WINDOW->x4144FA(); + tmv_vf138(pt, kScroll3 | kScrollOpt2); +} + +void T2TowerMainView::HandToolRelease(CPoint inPt) { +} + +/*virtual*/ void T2TowerMainView::tmv_vf144() { + if (!mDocument) + return; + if (!mDocument->mWorldDef) + return; + + tmv_vf138(mScrollOffset, kScroll3 | kScrollOpt2); +} + +/*virtual*/ void T2TowerMainView::OnActivateView(BOOL bActivate, CView *pActivateView, CView *pDeactiveView) { + CView::OnActivateView(bActivate, pActivateView, pDeactiveView); +} + +BOOL T2TowerMainView::CreateToolSprite(BOOL inSkipShowing) { + if (mToolSpriteName != "" && mToolSpriteIndex == -1) { + mToolSpriteIndex = mDocument->mSprite.NewSprite(*mActiveToolDef->mImageObj, mToolSpriteName, T2Sprite::ELayer_5); + if (!mHideToolSpriteCount) { + mDC = true; + if (!inSkipShowing) + mDocument->mSprite.ShowSprite(mToolSpriteIndex, true); + } + } + + return false; +} + +BOOL T2TowerMainView::DeleteToolSprite() { + if (mToolSpriteIndex != -1) { + if (!mHideToolSpriteCount) { + mDC = false; + mDocument->mSprite.ShowSprite(mToolSpriteIndex, false); + } + + mDocument->mSprite.DeleteSprite(mToolSpriteIndex); + mToolSpriteName = ""; + mToolSpriteIndex = -1; + } + + return true; +} diff --git a/src/T2TowerMainView.h b/src/T2TowerMainView.h index 4bb33ad..0bccd8f 100644 --- a/src/T2TowerMainView.h +++ b/src/T2TowerMainView.h @@ -2,62 +2,179 @@ #include "common.h" #include "LAttachable.h" +enum { + kTool0_Null = 0, + kTool1_Tenant, + kTool2_Mover, + kTool3_OutObj, + kTool4_Finger, + kTool5_Hand +}; + +enum { + kAnotherToolVar0 = 0, + kAnotherToolVar1, + kAnotherToolVar2, + kAnotherToolVar3 +}; + +enum { + kScroll1 = 1, + kScroll2, + kScroll3, + kScrollOptionMask = 0xFF, + kScrollOpt2 = 0x100, + kScrollOpt2Mask = 0xFF00, + kScrollOpt3 = 0x10000, + kScrollOpt3Mask = 0xFF0000, +}; + class T2TowerMainView : public CView, public LAttachable { + DECLARE_MESSAGE_MAP() + DECLARE_DYNCREATE(T2TowerMainView) + public: + T2TowerMainView(); + virtual ~T2TowerMainView(); + virtual void AssertValid() const; + virtual void Dump(CDumpContext &dc) const; + virtual BOOL PreTranslateMessage(MSG *pMsg); + virtual void OnInitialUpdate() {} + virtual void tmv_vf110(); - virtual void tmv_vf114(); - virtual void tmv_vf118(); + virtual void DrawDebugGrid(); + virtual void CopySimulationImage(const RECT &inRect); + void x42B484(CDC *pDC, const RECT &inRect); virtual void tmv_vf11C(); virtual void tmv_vf120(); // DrawSimulation? - virtual void tmv_vf124(BOOL); // some invalidator - virtual void tmv_vf128(const RECT &, BOOL flag = false); // updates various rects - InvalUnitRect? - virtual void tmv_vf12C(); - virtual void tmv_vf130(int); // set scroll Y? - virtual void tmv_vf134(int); // set scroll X: - virtual void tmv_vf138(const POINT &, WPARAM); - virtual void tmv_vf13C(); - virtual void tmv_vf140(RECT &); // gets visible rect in unit coords? + virtual void Invalidate(BOOL inFlag); + virtual void InvalUnitRect(const RECT &inRect, BOOL inFlag = false); + virtual T2TowerDoc *GetTowerDoc(); + virtual void SetScrollV(int inV); + virtual void SetScrollH(int inH); + virtual void tmv_vf138(const POINT &inPt, unsigned int inCode); + virtual void tmv_vf13C(int inX, int inY, unsigned int inCode); + virtual void GetVisibleUnitRect(RECT &outRect) const; + void HandToolClick(CPoint inPt); + void HandToolDrag(CPoint inPt); + void HandToolRelease(CPoint inPt); virtual void tmv_vf144(); - virtual void tmv_vf148(); - virtual void tmv_vf14C(); - virtual void tmv_vf150(); - virtual void tmv_vf154(); - virtual void tmv_vf158(); - virtual void tmv_vf15C(const RECT *); // CenterOnView? - virtual void tmv_vf160(); + virtual void DoZoomIn(POINT inPt); + virtual void DoZoomOut(); + virtual void UnhideToolSprite(); + virtual void HideToolSprite(); + virtual void CenterOnRectAndZoom(const RECT &inRect); + virtual void CenterOnRect(const RECT *inRect); + + virtual BOOL tmv_vf160(POINT &outPt); T2TowerDoc *mDocument; - RECT m50; - T2BitImage *m60; - POINT m64; + + // Represents the full world area in unit coordinates + RECT mWorldBounds; + + // A buffer storing the entire tower + T2BitImage *mImage; + + // Where the view is currently scrolled to + POINT mScrollOffset; + RECT m6C; POINT m7C; - int m84; - int m88; - RECT m8C; - RECT m9C; - RECT mAC; - RECT mBC; - CPoint mCC; - int _D4; - int mD8; - int mDC; - int _E0; - int _E4; - int _E8; + + // An extra offset that will centre the image within the viewport, if the + // viewport is larger than the world area + POINT mImageOrigin; + + // The unit coordinates that are currently visible + RECT mVisibleArea; + + RECT mUpdateRect1; + RECT mUpdateRect2; + RECT mSpriteUpdateRect; + + // The last point handled when clicking or dragging with the Hand tool + CPoint mHandToolLastPos; + + // Which mouse buttons we consider to be held down + UINT mPressedButtons; + + // Tracks how many times the tool-specific sprite has been hidden + int mHideToolSpriteCount; + + BOOL mDC; + POINT _E0; + int mAnotherToolVar; int _EC; - BOOL mDebugMode; - BOOL mF4; - int _F8; - int mFC; - int mSomeSpriteIndex; - CString mSomeSpriteName; - int _108; - int _10C; - int _110; - int _114; + int mDebugMode; + int mActiveTool; + BOOL mIsDebugGrid; + T2ToolDef *mActiveToolDef; + int mToolSpriteIndex; + CString mToolSpriteName; + POINT _108; + BOOL mSkipOffscreenDraw; + unsigned int mDbgEquipID; T2Equip *mDbgEquip; - int _11C; - int _120; - CPoint m124; + POINT mNextScrollOffset; + + // Where the player initially clicked, in window coordinates + CPoint mInitialClickPos; + +protected: + virtual BOOL PreCreateWindow(CREATESTRUCT &cs); + virtual void OnDraw(CDC *pDC); + virtual void OnUpdate(CView *pSender, LPARAM lHint, CObject *pHint); + virtual void OnActivateView(BOOL bActivate, CView *pActivateView, CView *pDeactiveView); + + BOOL CreateToolSprite(BOOL inSkipShowing = false); + BOOL DeleteToolSprite(); + + afx_msg int OnCreate(LPCREATESTRUCT lpcs); + afx_msg void OnDestroy(); + void AdjustWorldBounds(); + void ClearUpdateRect(); + void x42AC1B(); + afx_msg void OnSize(UINT nType, int cx, int cy); + + afx_msg void OnDebugNormalDisplay(); + afx_msg void OnUpdateDebugNormalDisplay(CCmdUI *pCmdUI); + afx_msg void OnDebugBkgndInfo(); + afx_msg void OnUpdateDebugBkgndInfo(CCmdUI *pCmdUI); + afx_msg void OnDebugFloorInfoTenant(); + afx_msg void OnUpdateDebugFloorInfoTenant(CCmdUI *pCmdUI); + afx_msg void OnDebugFloorInfoMover(); + afx_msg void OnUpdateDebugFloorInfoMover(CCmdUI *pCmdUI); + afx_msg void OnDebugFloorInfoRequest(); + afx_msg void OnUpdateDebugFloorInfoRequest(CCmdUI *pCmdUI); + + void DrawDebugBkgndInfo(CDC *pDC); + void DrawDebugFloorInfoTenant(CDC *pDC, const RECT &inRect); + void DrawDebugFloorInfoMover(CDC *pDC, const RECT &inRect); + void DrawDebugFloorInfoRequest(CDC *pDC, const RECT &inRect); + void DrawDebugEquip(CDC *pDC, const RECT &inRect); + void x42CA08(const POINT &inPt); + afx_msg void OnCommand10000to10010(UINT nCmd); + + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + void HandleLButtonDown(CPoint inPt); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + void HandleLButtonUp(CPoint inPt); + + afx_msg void OnUpdateDebugGrid(CCmdUI *pCmdUI); + afx_msg void OnDebugGrid(); + + void x42E366(int inType); + + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + void HandleRButtonDown(CPoint inPt); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + void HandleRButtonUp(CPoint inPt); + + afx_msg void OnUpdateDebugDisplaySpeedMeasuring(CCmdUI *pCmdUI); + afx_msg void OnDebugDisplaySpeedMeasuring(); + afx_msg void OnUpdateDebugOffscreenSpeedMeasuring(CCmdUI *pCmdUI); + afx_msg void OnDebugOffscreenSpeedMeasuring(); + afx_msg void OnTimer(UINT nIDEvent); }; diff --git a/src/T2WorldSelectDlg.cpp b/src/T2WorldSelectDlg.cpp index 411e041..361aadb 100644 --- a/src/T2WorldSelectDlg.cpp +++ b/src/T2WorldSelectDlg.cpp @@ -1,2 +1,716 @@ +#include "GlobalFunc.h" +#include "T2BitImage.h" +#include "T2ImageObj.h" +#include "T2PluginLoader.h" +#include "T2PluginSpecifier.h" +#include "T2TowerDoc.h" #include "T2WorldSelectDlg.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +T2WorldSelectDlg::T2WorldSelectDlg() { + mDeleteOnClose = true; + + HRSRC rsrc = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(100), "PALETTE"); + HGLOBAL theHandle = LoadResource(AfxGetApp()->m_hInstance, rsrc); + void *resData = LockResource(theHandle); + + LOGPALETTE *theLogPalette = ConvACTPalette((ACTPALETTEENTRY *) resData); + mPalette.CreatePalette(theLogPalette); + + int i; + + mPal1 = (short *) malloc(sizeof(short) * 256); + for (i = 0; i < 256; i++) + mPal1[i] = i; + + mPal2 = (short *) malloc(sizeof(short) * 256); + for (i = 0; i < 256; i++) { + int r = theLogPalette->palPalEntry[i].peRed; + int g = theLogPalette->palPalEntry[i].peGreen; + int b = theLogPalette->palPalEntry[i].peBlue; + int index = mPalette.GetNearestPaletteIndex(RGB(r, g, b)); + + if (theLogPalette->palPalEntry[index].peRed == 1 && theLogPalette->palPalEntry[index].peGreen == 1 && theLogPalette->palPalEntry[index].peBlue == 1) + index = 255; + + mPal2[i] = index; + } + + free(theLogPalette); + + mBitmap.LoadBitmap(170); + mBrush.CreatePatternBrush(&mBitmap); + + mPlugins = NULL; + mScrollOffset = 0; + mSelectedPlugin = 0; +} + +/*virtual*/ T2WorldSelectDlg::~T2WorldSelectDlg() { + if (mPlugins) { + for (int i = 0; i < mPluginCount; i++) { + delete mPlugins[i].preview; + delete mPlugins[i].icon; + delete mPlugins[i].mStr8; + delete mPlugins[i].mStr18; + delete mPlugins[i].mStrC; + delete mPlugins[i].mStr10; + delete mPlugins[i].mStr14; + } + free(mPlugins); + } + + free(mPal1); + free(mPal2); + + mBrush.DeleteObject(); + mBitmap.DeleteObject(); + + if (mImageObj) + delete mImageObj; + if (mArrowButtonImages) + delete mArrowButtonImages; +} + +void T2WorldSelectDlg::ShowWorldSelectDlg(T2TowerDoc *inDoc, T2PluginLoader *inPluginLoader, BOOL inShowCancelButton) { + mDocument = inDoc; + mPluginLoader = inPluginLoader; + mShowCancelButton = inShowCancelButton; + + POSITION pos; + T2PluginSpecifier *specifier; + + mPluginLoader->SetTypeFilter(pos, 'WdPl'); + mPluginCount = 0; + + while ((specifier = mPluginLoader->GetNext(pos))) + mPluginCount++; + + mPlugins = (PluginRecord *) malloc(mPluginCount * sizeof(PluginRecord)); + + mPluginLoader->SetTypeFilter(pos, 'WdPl'); + int index = 0; + + while ((specifier = mPluginLoader->GetNext(pos))) { + mPluginLoader->LoadPlugin(specifier); + +#line 107 + mPlugins[index].preview = new T2BitImage(specifier->mInstance, 20000, false); + mPlugins[index].icon = new T2BitImage(specifier->mInstance, 20001, false); + mPlugins[index].mStr8 = new CString(specifier->mPluginName); + + char *buf = (char *) malloc(10000); + strcpy(buf, "NO TEXT|?\n?\n?"); + LoadString(specifier->mInstance, 20000, buf, 10000); + +#line 113 + mPlugins[index].mStr18 = new CString(strtok(buf, "|")); + mPlugins[index].mStrC = new CString(strtok(NULL, "\r\n")); + mPlugins[index].mStr10 = new CString(strtok(NULL, "\r\n")); + mPlugins[index].mStr14 = new CString(strtok(NULL, "\r\n")); + + free(buf); + + mPluginLoader->UnloadPlugin(specifier); + index++; + } + + CRect rect; + GetDesktopWindow()->GetWindowRect(rect); + + HMODULE instanceHandle = AfxGetInstanceHandle(); + + T2DLGTEMPLATE tmpl; + tmpl.pt = rect.CenterPoint(); + tmpl.moduleHandle = instanceHandle; + tmpl.resID = 178; + mDocumentAlso = NULL; + +#line 134 + mImageObj = new T2ImageObj; + mArrowButtonImages = new T2BitImage(instanceHandle, 179, true); + mImageObj->AddObject(instanceHandle, 179, mArrowButtonImages); + + Realize(this, &tmpl, mDocumentAlso, mImageObj, &mPalette, true, NULL, 0, true); + + mBackButton = (CButton *) GetDescendantWindow(101); + mNextButton = (CButton *) GetDescendantWindow(102); + + mBackButton->EnableWindow(false); +} + +/*virtual*/ BOOL T2WorldSelectDlg::PreCreateWindow(CREATESTRUCT &cs) { + return T2Dialog::PreCreateWindow(cs); +} + +T2PluginSpecifier *T2WorldSelectDlg::GetSelectedPlugin() { + POSITION pos; + T2PluginSpecifier *specifier; + int index = mSelectedPlugin; + + mPluginLoader->SetTypeFilter(pos, 'WdPl'); + + while ((specifier = mPluginLoader->GetNext(pos))) { + if (index == 0) + break; + index--; + } + + return specifier; +} + +/*virtual*/ BOOL T2WorldSelectDlg::OnT2PreEraseBkgnd(CDC *pDC) { +#pragma var_order(brush3, bitmap, newSave2, pen2, newSave, pen3, brush1, save, newDC, index, pen1, rectB, rectA, maxPlugin, brush2) + CRect rectA, rectB; + GetWindowRect(rectA); + ScreenToClient(rectA); + GetClientRect(mRect3); + + mRect3.left = 0; + mRect3.top = 0; + mRect3.right = 488; + mRect3.bottom = 364; + + mRect1.left = 30; + mRect1.top = 253; + mRect1.right = 458; + mRect1.bottom = 321; + + mRect2.left = 12; + mRect2.top = 11; + mRect2.right = 476; + mRect2.bottom = 238; + + int save = pDC->SaveDC(); + pDC->SelectPalette(&mPalette, false); + pDC->RealizePalette(); + + CBitmap bitmap; + bitmap.CreateCompatibleBitmap(pDC, mRect3.Width(), mRect3.Height()); + + CDC newDC; + newDC.CreateCompatibleDC(pDC); + int newSave = newDC.SaveDC(); + + newDC.SelectObject(bitmap); + newDC.SelectPalette(&mPalette, false); + newDC.RealizePalette(); + newDC.SetStretchBltMode(COLORONCOLOR); + + CBrush brush1, brush2, brush3; + brush1.CreateSolidBrush(PALETTERGB(204, 204, 204)); + brush2.CreateSolidBrush(PALETTERGB(255, 255, 255)); + brush3.CreateSolidBrush(PALETTERGB(200, 0, 0)); + + CPen pen1, pen2, pen3; + pen1.CreatePen(PS_SOLID, 0, PALETTERGB(255, 255, 255)); + pen2.CreatePen(PS_SOLID, 0, PALETTERGB(133, 133, 133)); + pen3.CreatePen(PS_SOLID, 0, PALETTERGB(0, 0, 0)); + + newDC.FillRect(mRect3, &brush1); + + newDC.SelectObject(brush2); + newDC.SelectObject(pen3); + newDC.Rectangle(mRect1.left + 1, mRect1.top + 1, mRect1.right - 1, mRect1.bottom - 1); + + newDC.SelectObject(pen2); + newDC.MoveTo(mRect1.right - 1, mRect1.top); + newDC.LineTo(mRect1.left, mRect1.top); + newDC.LineTo(mRect1.left, mRect1.bottom); + + newDC.SelectObject(pen1); + newDC.MoveTo(mRect1.left, mRect1.bottom - 1); + newDC.LineTo(mRect1.right - 1, mRect1.bottom - 1); + newDC.LineTo(mRect1.right - 1, mRect1.top); + + int maxPlugin = min(mScrollOffset + 6, mPluginCount); + for (int index = mScrollOffset; index < maxPlugin; index++) { +#pragma var_order(rect2, x, rect1) + int x = (index - mScrollOffset) * 70 + mRect1.left + 2; + + CRect rect1; + rect1.SetRect(x, mRect1.top + 2, x + 70, mRect1.bottom - 2); + + CRect rect2; + rect2.top = rect1.CenterPoint().y - mPlugins[index].icon->mBitmap.header.biHeight / 2; + rect2.left = rect1.CenterPoint().x - mPlugins[index].icon->mBitmap.header.biWidth / 2; + rect2.bottom = rect2.top + mPlugins[index].icon->mBitmap.header.biHeight; + rect2.right = rect2.left + mPlugins[index].icon->mBitmap.header.biWidth; + + if (index == mSelectedPlugin) { + CRect rect3 = rect2; + rect3.top -= 2; + rect3.left -= 2; + rect3.bottom += 2; + rect3.right += 2; + + newDC.FillRect(rect3, &brush3); + } + + memcpy(&mPlugins[index].icon->mBitmap.palette, mPal2, sizeof(short) * 256); + newDC.SelectObject(mBrush); + StretchDIBits( + newDC.m_hDC, + rect2.left, + rect2.top, + rect2.Width(), + rect2.Height(), + 0, + 0, + mPlugins[index].icon->mBitmap.header.biWidth, + mPlugins[index].icon->mBitmap.header.biHeight, + mPlugins[index].icon->mData, + (const BITMAPINFO *) &mPlugins[index].icon->mBitmap, + DIB_PAL_COLORS, + SRCCOPY + ); + } + +#pragma var_order(brush3, bitmap, newSave2, pen2, newSave, pen3, brush1, save, newDC, index, pen1, rectB, rectA, maxPlugin, brush2) + int newSave2 = newDC.SaveDC(); + newDC.SetViewportOrg(mRect2.TopLeft()); + newDC.SetViewportExt(mRect2.Width(), mRect2.Height()); + DrawWorldPreview(&newDC); + newDC.RestoreDC(newSave2); + + pDC->BitBlt(0, 0, mRect3.Width(), mRect3.Height(), &newDC, 0, 0, SRCCOPY); + + x432436(pDC); + + newDC.RestoreDC(newSave); + + pDC->RestoreDC(save); + return true; +} + +void T2WorldSelectDlg::GoLeft() { +#pragma var_order(bitmap, newSave, brush, save, newDC, i, left, pDC) + if (mSelectedPlugin <= 0) + return; + + mSelectedPlugin--; + if (mSelectedPlugin < mScrollOffset) + mScrollOffset = mSelectedPlugin; + + if (mSelectedPlugin == 0) { + mBackButton->EnableWindow(false); + SetFocus(); + } else { + mBackButton->EnableWindow(true); + } + + if (mSelectedPlugin < (mPluginCount - 1)) + mNextButton->EnableWindow(true); + + InvalidateRect(mRect1); + UpdateWindow(); + + CDC *pDC = GetDC(); + int save = pDC->SaveDC(); + + CBrush brush; + brush.CreateSolidBrush(PALETTERGB(204, 204, 204)); + + CBitmap bitmap; + bitmap.CreateCompatibleBitmap(pDC, mRect3.Width(), mRect3.Height()); + + CDC newDC; + newDC.CreateCompatibleDC(pDC); + int newSave = newDC.SaveDC(); + + newDC.SelectObject(bitmap); + newDC.SelectPalette(&mPalette, false); + newDC.RealizePalette(); + newDC.SetStretchBltMode(COLORONCOLOR); + + DrawWorldPreview(&newDC); + + int left = mRect2.left; + for (int i = 1; i <= 10; i++) { +#pragma var_order(right, rect2) + int right = mRect2.left + ((mRect3.right - mRect2.left) * i) / 10; + pDC->BitBlt(right, mRect2.top, mRect2.Width(), mRect2.Height(), pDC, left, mRect2.top, SRCCOPY); + + left = right; + pDC->BitBlt(mRect2.left, mRect2.top, right - mRect2.left, mRect2.Height(), &newDC, 0, 0, SRCCOPY); + + if (right >= mRect2.right) { + CRect rect; + rect.SetRect(mRect2.right, mRect2.top, mRect3.right, mRect2.bottom); + pDC->FillRect(rect, &brush); + } + + CRect rect2; + rect2.left = mRect2.right; + rect2.top = mRect2.top; + rect2.right = mRect3.right; + rect2.bottom = mRect2.bottom; + InvalidateRect(rect2); + + Sleep(30); + } + + newDC.RestoreDC(newSave); + + pDC->RestoreDC(save); + ReleaseDC(pDC); +} + +void T2WorldSelectDlg::GoRight() { +#pragma var_order(bitmap, newSave, brush, save, newDC, i, pDC) + if (mSelectedPlugin >= (mPluginCount - 1)) + return; + + mSelectedPlugin++; + if (mSelectedPlugin >= (mScrollOffset + 6)) + mScrollOffset = mSelectedPlugin - 5; + + if (mSelectedPlugin != 0) + mBackButton->EnableWindow(true); + + if (mSelectedPlugin < (mPluginCount - 1)) { + mNextButton->EnableWindow(true); + } else { + mNextButton->EnableWindow(false); + SetFocus(); + } + + InvalidateRect(mRect1); + UpdateWindow(); + + CDC *pDC = GetDC(); + int save = pDC->SaveDC(); + + CBrush brush; + brush.CreateSolidBrush(PALETTERGB(204, 204, 204)); + + CBitmap bitmap; + bitmap.CreateCompatibleBitmap(pDC, mRect3.Width(), mRect3.Height()); + + CDC newDC; + newDC.CreateCompatibleDC(pDC); + int newSave = newDC.SaveDC(); + + newDC.SelectObject(bitmap); + newDC.SelectPalette(&mPalette, false); + newDC.RealizePalette(); + newDC.SetStretchBltMode(COLORONCOLOR); + + DrawWorldPreview(&newDC); + + for (int i = 1; i <= 10; i++) { +#pragma var_order(x, rect2) + int x = mRect3.right - ((mRect3.right - mRect2.left) * i) / 10; + pDC->BitBlt(x, mRect2.top, mRect2.Width(), mRect2.Height(), &newDC, 0, 0, SRCCOPY); + + x += mRect2.Width(); + + if (x < mRect3.right) { + CRect rect; + rect.SetRect(x, mRect2.top, mRect3.right, mRect2.bottom); + pDC->FillRect(rect, &brush); + } + + CRect rect2; + rect2.left = x; + rect2.top = mRect2.top; + rect2.right = mRect3.right; + rect2.bottom = mRect2.bottom; + InvalidateRect(rect2); + UpdateWindow(); + + Sleep(30); + } + + newDC.RestoreDC(newSave); + + pDC->RestoreDC(save); + ReleaseDC(pDC); +} + +/*virtual*/ void T2WorldSelectDlg::OnT2DlgLButtonDown(UINT nFlags, CPoint pt) { + if (PtInRect(mRect1, pt)) { + pt.x -= mRect1.TopLeft().x; + int index = pt.x / 70 + mScrollOffset; + if (index < 0) + index = 0; + else if (index >= mPluginCount) + index = mPluginCount - 1; + + while (mSelectedPlugin < index) + GoRight(); + while (index < mSelectedPlugin) + GoLeft(); + } +} + +/*virtual*/ void T2WorldSelectDlg::OnT2DlgLButtonDblClk(UINT nFlags, CPoint pt) { + if (PtInRect(mRect1, pt)) { + OnT2DlgLButtonDown(nFlags, pt); + OnT2DialogCommand(100, 0); + } +} + +void T2WorldSelectDlg::DrawWorldPreview(CDC *pDC) { +#pragma var_order(pt2, clr1, str, brush3, rect1, pen2, clr2, rect3, pen3, brush1, font, previewWidth, rect2, clr3, save, x, previewHeight, pen4, pen1, pt, brush2) + CRect rect1 = mRect2; + rect1.OffsetRect(-rect1.left, -rect1.top); + + int save = pDC->SaveDC(); + pDC->SelectPalette(&mPalette, false); + pDC->RealizePalette(); + + CBrush brush1, brush2, brush3; + brush1.CreateSolidBrush(PALETTERGB(204, 204, 204)); + brush2.CreateSolidBrush(PALETTERGB(255, 255, 255)); + brush3.CreateSolidBrush(PALETTERGB(200, 0, 0)); + + CPen pen1, pen2, pen3, pen4; + pen1.CreatePen(PS_SOLID, 0, PALETTERGB(255, 255, 255)); + pen2.CreatePen(PS_SOLID, 0, PALETTERGB(133, 133, 133)); + pen3.CreatePen(PS_SOLID, 0, PALETTERGB(0, 0, 0)); + pen4.CreatePen(PS_SOLID, 0, PALETTERGB(0, 0, 0)); + + COLORREF clr1 = PALETTERGB(255, 255, 255); + COLORREF clr2 = PALETTERGB(133, 133, 133); + COLORREF clr3 = PALETTERGB(0, 0, 0); + + pDC->FillRect(rect1, &brush1); + + pDC->SelectObject(pen1); + + pDC->MoveTo(rect1.right - 1, rect1.top); + pDC->LineTo(rect1.left, rect1.top); + pDC->LineTo(rect1.left, rect1.bottom); + + pDC->MoveTo(rect1.right - 1, rect1.top + 1); + pDC->LineTo(rect1.left + 1, rect1.top + 1); + pDC->LineTo(rect1.left + 1, rect1.bottom); + + pDC->SelectObject(pen2); + + pDC->MoveTo(rect1.right - 1, rect1.top + 1); + pDC->LineTo(rect1.right - 1, rect1.bottom - 1); + pDC->LineTo(rect1.left - 1, rect1.bottom - 1); + + pDC->MoveTo(rect1.right - 2, rect1.top + 2); + pDC->LineTo(rect1.right - 2, rect1.bottom - 2); + pDC->LineTo(rect1.left, rect1.bottom - 2); + + CRect rect2; + int previewWidth = mPlugins[mSelectedPlugin].preview->mBitmap.header.biWidth; + int previewHeight = mPlugins[mSelectedPlugin].preview->mBitmap.header.biHeight; + + rect2.top = (rect1.Height() - previewHeight) / 2; + rect2.left = rect2.top - rect1.top; + rect2.bottom = rect2.top + previewHeight; + rect2.right = rect2.left + previewWidth; + + pDC->SelectObject(pen2); + + pDC->MoveTo(rect2.right, rect2.top - 1); + pDC->LineTo(rect2.left - 1, rect2.top - 1); + pDC->LineTo(rect2.left - 1, rect2.bottom + 1); + + pDC->SelectObject(pen1); + + pDC->MoveTo(rect2.right, rect2.top); + pDC->LineTo(rect2.right, rect2.bottom); + pDC->LineTo(rect2.left - 2, rect2.bottom); + + pDC->DrawText("PREVIEW", rect2, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX); + + StretchDIBits( + pDC->m_hDC, + rect2.left, + rect2.top, + rect2.Width(), + rect2.Height(), + 0, + 0, + previewWidth, + previewHeight, + mPlugins[mSelectedPlugin].preview->mData, + (const BITMAPINFO *) &mPlugins[mSelectedPlugin].preview->mBitmap, + DIB_PAL_COLORS, + SRCCOPY + ); + + CPoint pt; + pt.x = rect2.right + (rect2.left - rect1.left); + pt.y = rect2.left; + + pDC->SetBkMode(TRANSPARENT); + + CFont font; + font.CreateFont(-20, 0, 0, 0, FW_BOLD, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x82\x6F\x83\x53\x83\x56\x83\x62\x83\x4E"); + + CString str = *mPlugins[mSelectedPlugin].mStr8; + + pDC->SelectObject(font); + + pDC->SetTextColor(clr1); + pDC->TextOut(pt.x - 1, pt.y - 1, str); + pDC->SetTextColor(clr2); + pDC->TextOut(pt.x + 1, pt.y + 1, str); + pDC->SetTextColor(clr3); + pDC->TextOut(pt.x, pt.y, str); + + font.Detach(); + font.CreateFont(-14, 0, 0, 0, FW_BOLD, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x82\x6F\x83\x53\x83\x56\x83\x62\x83\x4E"); + pDC->SelectObject(&font)->DeleteObject(); + + pt.y += 38; + pt.x += 12; + + CPoint pt2 = pt; + + str = "\x8F\x89\x8A\xFA\x8E\x91\x8B\xE0"; + pDC->SetTextColor(clr1); + pDC->TextOut(pt.x + 1, pt.y + 1, str); + pDC->SetTextColor(clr3); + pDC->TextOut(pt.x, pt.y, str); + + pt.y += 23; + + str = "\x8D\x82\x82\xB3\x90\xA7\x8C\xC0"; + pDC->SetTextColor(clr1); + pDC->TextOut(pt.x + 1, pt.y + 1, str); + pDC->SetTextColor(clr3); + pDC->TextOut(pt.x, pt.y, str); + + pt.y += 23; + + str = "\x89\xA1\x95\x9D"; + pDC->SetTextColor(clr1); + pDC->TextOut(pt.x + 1, pt.y + 1, str); + pDC->SetTextColor(clr3); + pDC->TextOut(pt.x, pt.y, str); + + pt.y += 23; + + str = "\x89\xF0\x90\xE0"; + pDC->SetTextColor(clr1); + pDC->TextOut(pt.x + 1, pt.y + 1, str); + pDC->SetTextColor(clr3); + pDC->TextOut(pt.x, pt.y, str); + + CRect rect3; + rect3.left = pt.x + 15; + rect3.top = pt.y + 20; + rect3.right = rect1.right - (rect2.left - rect1.left); + rect3.bottom = rect1.bottom - (rect2.left - rect1.left); + + pt = pt2; + + pt.x += pDC->GetTextExtent("\x81\x97\x81\x97\x81\x97\x81\x97").cx + 3; + + pt2 = pt; + + int x = rect1.right - (rect2.left - rect1.left); + + pDC->SelectObject(pen4); + pDC->MoveTo(pt.x, pt.y + 14); + pDC->LineTo(x, pt.y + 14); + + pDC->SelectObject(pen1); + pDC->MoveTo(pt.x + 1, pt.y + 15); + pDC->LineTo(x + 1, pt.y + 15); + + pt.y += 23; + + pDC->SelectObject(pen4); + pDC->MoveTo(pt.x, pt.y + 14); + pDC->LineTo(x, pt.y + 14); + + pDC->SelectObject(pen1); + pDC->MoveTo(pt.x + 1, pt.y + 15); + pDC->LineTo(x + 1, pt.y + 15); + + pt.y += 23; + + pDC->SelectObject(pen4); + pDC->MoveTo(pt.x, pt.y + 14); + pDC->LineTo(x, pt.y + 14); + + pDC->SelectObject(pen1); + pDC->MoveTo(pt.x + 1, pt.y + 15); + pDC->LineTo(x + 1, pt.y + 15); + + font.Detach(); + font.CreateFont(-12, 0, 0, 0, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x82\x6F\x83\x53\x83\x56\x83\x62\x83\x4E"); + pDC->SelectObject(&font)->DeleteObject(); + + pDC->SetTextColor(clr3); + + pt = pt2; + pt.x = x; + + str = *mPlugins[mSelectedPlugin].mStrC; + pDC->TextOut(pt.x - pDC->GetTextExtent(str).cx, pt.y, str); + + pt.y += 23; + + str = *mPlugins[mSelectedPlugin].mStr10; + pDC->TextOut(pt.x - pDC->GetTextExtent(str).cx, pt.y, str); + + pt.y += 23; + + str = *mPlugins[mSelectedPlugin].mStr14; + pDC->TextOut(pt.x - pDC->GetTextExtent(str).cx, pt.y, str); + + pDC->DrawText(*mPlugins[mSelectedPlugin].mStr18, rect3, DT_WORDBREAK); + + pDC->RestoreDC(save); +} + +/*virtual*/ BOOL T2WorldSelectDlg::OnT2DialogCommand(WPARAM inWParam, LPARAM inLParam) { + BOOL result = true; + WORD code = HIWORD(inWParam); + WORD id = LOWORD(inWParam); + + if (id == 100 && code == 0) { + ShowWindow(SW_HIDE); + mDocument->xUnkNameSelectWorld(GetSelectedPlugin()); + DestroyWindow(); + } else if (id == 101 && code == 0) { + GoLeft(); + } else if (id == 102 && code == 0) { + GoRight(); + } else { + result = T2Dialog::OnCommand(inWParam, inLParam); + } + + return result; +} + +void T2WorldSelectDlg::x432436(CDC *pDC) { +#pragma var_order(pen1, pen2, save, rect) + int save = pDC->SaveDC(); + + CPen pen1; + pen1.CreatePen(PS_SOLID, 0, PALETTERGB(255, 255, 255)); + + CPen pen2; + pen2.CreatePen(PS_SOLID, 0, PALETTERGB(133, 133, 133)); + + CRect rect; + rect = mRect3; + + pDC->SelectObject(pen1); + pDC->MoveTo(rect.right - 1, rect.top); + pDC->LineTo(rect.left, rect.top); + pDC->LineTo(rect.left, rect.bottom); + + pDC->SelectObject(pen2); + pDC->MoveTo(rect.right - 1, rect.top + 1); + pDC->LineTo(rect.right - 1, rect.bottom - 1); + pDC->LineTo(rect.left, rect.bottom - 1); + + pDC->RestoreDC(save); +} diff --git a/src/T2WorldSelectDlg.h b/src/T2WorldSelectDlg.h index fcaf1ff..df75a94 100644 --- a/src/T2WorldSelectDlg.h +++ b/src/T2WorldSelectDlg.h @@ -1,3 +1,56 @@ #pragma once #include "common.h" +#include "T2Dialog.h" +struct PluginRecord { + T2BitImage *preview; + T2BitImage *icon; + CString *mStr8; + CString *mStrC; + CString *mStr10; + CString *mStr14; + CString *mStr18; +}; + +class T2WorldSelectDlg : public T2Dialog { +public: + T2WorldSelectDlg(); + virtual ~T2WorldSelectDlg(); + void ShowWorldSelectDlg(T2TowerDoc *inDoc, T2PluginLoader *inPluginLoader, BOOL inShowCancelButton); + T2PluginSpecifier *GetSelectedPlugin(); + +protected: + virtual BOOL PreCreateWindow(CREATESTRUCT &cs); + virtual BOOL OnT2PreEraseBkgnd(CDC *pDC); + virtual void OnT2DlgLButtonDown(UINT nFlags, CPoint pt); + virtual void OnT2DlgLButtonDblClk(UINT nFlags, CPoint pt); + virtual BOOL OnT2DialogCommand(WPARAM inWParam, LPARAM inLParam); + + void GoLeft(); + void GoRight(); + void DrawWorldPreview(CDC *pDC); + void x432436(CDC *pDC); + + T2TowerDoc *mDocumentAlso; + CPalette mPalette; + T2BitImage *mArrowButtonImages; + T2ImageObj *mImageObj; + T2PluginLoader *mPluginLoader; + BOOL mShowCancelButton; + T2TowerDoc *mDocument; + CFont mFont; + short *mPal1; + short *mPal2; + CBitmap mBitmap; + CBrush mBrush; + PluginRecord *mPlugins; + int mPluginCount; + int mScrollOffset; + int _144; + int mSelectedPlugin; + CRect mRect1; + CRect mRect2; + CRect mRect3; + CButton *mBackButton; + CButton *mNextButton; +};
\ No newline at end of file diff --git a/src/common.h b/src/common.h index 779d46f..958f0bb 100644 --- a/src/common.h +++ b/src/common.h @@ -32,6 +32,7 @@ class CFilePluginList; class CLink; class CObjectQueue; class CPluginInfo; +class CPluginInfoArray; class CProgramPlugin; class CResFile; class CResourcePlugin; @@ -215,23 +216,79 @@ enum CURSORTYPE { }; enum MOUSEEVENT { - MouseEvent_0 + MouseEvent_0, // mouse down + MouseEvent_1, // mouse move + MouseEvent_2 // mouse up }; enum OPTIONEVENTTYPE { - OptionEventType_0, // idle - no data - OptionEventType_1, - OptionEventType_2, - OptionEventType_3, - OptionEventType_4, - OptionEventType_5, - OptionEventType_6, + // Dispatched on each idle. + // Data: none + // Return value: ignored + kIdleOptionEvent, + + // Dispatched when the left mouse button is pressed in the tower view. + // Data: CPoint* (in QD coordinates) + // Return value: FALSE will cancel normal processing + kLButtonDownOptionEvent, + + // Dispatched when the right mouse button is pressed in the tower view. + // Data: CPoint* (in QD coordinates) + // Return value: FALSE will cancel normal processing + kRButtonDownOptionEvent, + + // Dispatched when the left mouse button is released in the tower view. + // Data: CPoint* (in QD coordinates) + // Return value: FALSE will cancel normal processing + kLButtonUpOptionEvent, + + // Dispatched when the right mouse button is released in the tower view. + // Data: CPoint* (in QD coordinates) + // Return value: ignored + kRButtonUpOptionEvent, + + // Dispatched when the mouse is moved within the tower view. + // Data: POINT* (in QD coordinates) + // Return value: FALSE will cancel normal processing + kMouseMoveOptionEvent, + + // Dispatched when plugins are about to be selected. + // Data: None + // Return value: ignored + kSelectPluginsOptionEvent, + OptionEventType_7, OptionEventType_8, - OptionEventType_9, - OptionEventType_10, - OptionEventType_11, // start of GetInterviewWords - OptionEventType_12, // end of GetInterviewWords + + // Dispatched when the tower has just been drawn to the buffer. + // Data: None + // Return value: ignored + kTowerDrawFinishedOptionEvent, + + // Dispatched when the tower is about to be drawn to the main view. + // Data: CDC* + // Return value: FALSE will cancel normal drawing + kTowerPreDrawOptionEvent, + + // Dispatched when interview words are about to be generated for a person. + // Data: OptionEvent11Data* + // Return value: FALSE will cancel the normal word selection process + kPreInterviewWordsOptionEvent, + + // Dispatched when interview words have been generated for a person. + // Data: OptionEvent11Data* + // Return value: ignored + kPostInterviewWordsOptionEvent, + + // Dispatched when all the option plugins have been loaded. + // Data: none + // Return value: ignored + kInitOptionEvent, + + // Dispatched right before the tower is unloaded. + // Data: none + // Return value: ignored + kDestroyOptionEvent, }; struct OptionEvent11Data { @@ -254,8 +311,10 @@ enum PROCCODE { }; enum ROOFANDFLOOR { + RoofAndFloor_None = 0, RoofAndFloor_Roof = 1, - RoofAndFloor_Floor = 2 + RoofAndFloor_Floor = 2, + RoofAndFloor_Both = 3, }; enum SIDEOBJPATTERN { @@ -264,12 +323,12 @@ enum SIDEOBJPATTERN { }; enum VIEWMODE { - ViewMode_0, - ViewMode_1, - ViewMode_2, - ViewMode_3, - ViewMode_4, - ViewMode_5, + kInView, // InView + kOutView, // OutView + kEvalView, // Eval + kPriceView, // Price + kMaintView, // Maint + kTransView, // Trans ViewMode_6, }; |