#include "GlobalFunc.h" #include "T2Balloon.h" #include "T2BitImage.h" #include "T2ImageObj.h" #include "T2Sprite.h" #include "T2TowerDoc.h" #include "T2TowerMainView.h" #include "T2WorldDef.h" #include "UT2Coordinate.h" T2Balloon::T2Balloon() { mImage = NULL; mImageObj = NULL; mDoPause = false; } /*virtual*/ T2Balloon::~T2Balloon() { if (mDoPause) GetCurrentT2TowerDoc()->towerDoc_vf290(true); T2Sprite *theSprite = &GetCurrentT2TowerDoc()->mSprite; theSprite->ShowSprite(mSpriteID, false); theSprite->DeleteSprite(mSpriteID); if (mImage) delete mImage; if (mImageObj) delete mImageObj; } #pragma var_order(rect4, rect8, rect5, brush3, rect6, font, theSprite, bits, rect1, save, rect7, dc, rgn, rgn4, rect2, var, brush1, dib, thePalette, topLeft, rect3, brush2) void T2Balloon::Show(int inX, int inY, const CString& inText, BOOL inDoPause) { CFont font; CRect rect1; CRect rect2; CRgn rgn; CRect rect3(0, 0, 0, 0); mDoPause = inDoPause; font.CreateFontA(-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 \x82\x6F\x83\x53\x83\x56\x83\x62\x83\x4E"); CDC dc; dc.CreateCompatibleDC(NULL); int save = dc.SaveDC(); dc.SelectObject(font); rect1.SetRectEmpty(); // 123456789012345 dc.DrawText("\x82\x50\x82\x51\x82\x52\x82\x53\x82\x54\x82\x55\x82\x56\x82\x57\x82\x58\x82\x4F\x82\x50\x82\x51\x82\x52\x82\x53\x82\x54", &rect1, DT_SINGLELINE | DT_CALCRECT); dc.DrawText(inText, &rect1, DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX); rect1.NormalizeRect(); rect1.OffsetRect(-rect1.left, -rect1.top); rect2.SetRect(10, 10, 10, 10); rect1.OffsetRect(rect2.left, rect2.top); CRect rect4; GetCurrentT2TowerDoc()->GetTowerMainView()->tmv_vf140(rect4); UT2Coordinate::UnitToQD(rect4, 0); CRect rect5; rect5 = rect1; rect5 += rect2; rect5.InflateRect(0, 0, 0, 16); rect5.NormalizeRect(); rect5.OffsetRect(-rect5.left, -rect5.top); rect5.OffsetRect(inX, inY - rect5.Height()); int var = 1; CRect rect6; if (rect6.SubtractRect(rect5, rect4)) { rect5 = rect1; rect5 += rect2; rect5.InflateRect(0, 0, 0, 16); rect5.NormalizeRect(); rect5.OffsetRect(-rect5.left, -rect5.top); rect5.OffsetRect(inX - rect5.Width(), inY - rect5.Height()); var = 0; if (rect6.SubtractRect(rect5, rect4)) { rect5 = rect1; rect5 += rect2; rect5.InflateRect(0, 0, 0, 16); rect5.NormalizeRect(); rect5.OffsetRect(-rect5.left, -rect5.top); rect5.OffsetRect(inX, inY); var = 3; if (rect6.SubtractRect(rect5, rect4)) { rect5 = rect1; rect5 += rect2; rect5.InflateRect(0, 0, 0, 16); rect5.NormalizeRect(); rect5.OffsetRect(-rect5.left, -rect5.top); rect5.OffsetRect(inX - rect5.Width(), inY); var = 2; } } } rect5 += rect3; POINT topLeft = rect5.TopLeft(); rect5 -= rect3; rect5.OffsetRect(-rect5.left, -rect5.top); CRect rect7(1, 1, 1, 1); rect5 -= rect7; if (var == 1) { rgn.CreateRectRgn(0, 0, 1, 1); CRgn baseRegion; baseRegion.CreateRoundRectRgn(rect5.left, rect5.top, rect5.right, rect5.bottom - 16, 20, 20); CRgn arrowRegion; POINT arrowPoints[3]; arrowPoints[0].x = rect5.left + 10; arrowPoints[0].y = rect5.bottom - 18; arrowPoints[1].x = rect5.left; arrowPoints[1].y = rect5.bottom; arrowPoints[2].x = rect5.left + 21; arrowPoints[2].y = rect5.bottom - 18; arrowRegion.CreatePolygonRgn(arrowPoints, 3, ALTERNATE); rgn.CombineRgn(&baseRegion, &arrowRegion, RGN_OR); } else if (var == 0) { rgn.CreateRectRgn(0, 0, 1, 1); CRgn baseRegion; baseRegion.CreateRoundRectRgn(rect5.left, rect5.top, rect5.right, rect5.bottom - 16, 20, 20); CRgn arrowRegion; POINT arrowPoints[3]; arrowPoints[0].x = rect5.right - 10; arrowPoints[0].y = rect5.bottom - 18; arrowPoints[1].x = rect5.right; arrowPoints[1].y = rect5.bottom; arrowPoints[2].x = rect5.right - 21; arrowPoints[2].y = rect5.bottom - 18; arrowRegion.CreatePolygonRgn(arrowPoints, 3, ALTERNATE); rgn.CombineRgn(&baseRegion, &arrowRegion, RGN_OR); } else if (var == 3) { rect1.OffsetRect(0, 16); rgn.CreateRectRgn(0, 0, 1, 1); CRgn baseRegion; baseRegion.CreateRoundRectRgn(rect5.left, rect5.top + 16, rect5.right, rect5.bottom, 20, 20); CRgn arrowRegion; POINT arrowPoints[3]; arrowPoints[0].x = rect5.left + 10; arrowPoints[0].y = rect5.top + 18; arrowPoints[1].x = rect5.left; arrowPoints[1].y = rect5.top; arrowPoints[2].x = rect5.left + 21; arrowPoints[2].y = rect5.top + 18; arrowRegion.CreatePolygonRgn(arrowPoints, 3, ALTERNATE); rgn.CombineRgn(&baseRegion, &arrowRegion, RGN_OR); } else if (var == 2) { rect1.OffsetRect(0, 16); rgn.CreateRectRgn(0, 0, 1, 1); CRgn baseRegion; baseRegion.CreateRoundRectRgn(rect5.left, rect5.top + 16, rect5.right, rect5.bottom, 20, 20); CRgn arrowRegion; POINT arrowPoints[3]; arrowPoints[0].x = rect5.right - 10; arrowPoints[0].y = rect5.top + 18; arrowPoints[1].x = rect5.right; arrowPoints[1].y = rect5.top; arrowPoints[2].x = rect5.right - 21; arrowPoints[2].y = rect5.top + 18; arrowRegion.CreatePolygonRgn(arrowPoints, 3, ALTERNATE); rgn.CombineRgn(&baseRegion, &arrowRegion, RGN_OR); } else { rgn.CreateRoundRectRgn(rect5.left, rect5.top, rect5.right, rect5.bottom, 20, 20); } CRgn rgn4; rgn4.CreateRectRgn(0, 0, 1, 1); rgn4.CopyRgn(&rgn); rgn4.OffsetRgn(rect3.left, rect3.top); CRect rect8; rect8.top = 0; rect8.left = 0; rect8.bottom = ((rect5.Height() + 3) / 4) * 4; rect8.right = ((rect5.Width() + 3) / 4) * 4; #line 201 mImage = DEBUG_NEW T2BitImage(rect8); mImage->Clear(0); CPalette *thePalette = GetCurrentT2TowerDoc()->towerDoc_vf170()->GetPalette(); dc.SelectPalette(thePalette, false); dc.RealizePalette(); mImage->mBitmap.header.biHeight = -mImage->mBitmap.header.biHeight; void *bits; HBITMAP dib = CreateDIBSection(dc.m_hDC, (BITMAPINFO *) &mImage->mBitmap.header, DIB_PAL_COLORS, &bits, NULL, 0); mImage->mBitmap.header.biHeight = -mImage->mBitmap.header.biHeight; dc.SelectObject(dib); CBrush brush1; CBrush brush2; CBrush brush3; brush3.CreateSolidBrush(PALETTEINDEX(0)); brush1.CreateSolidBrush(PALETTEINDEX(255)); brush2.CreateSolidBrush(PALETTEINDEX(1)); dc.FillRect(rect8, &brush3); dc.FillRgn(&rgn, &brush2); dc.FrameRgn(&rgn, &brush1, 2, 2); dc.SetBkMode(TRANSPARENT); dc.SetTextColor(PALETTEINDEX(255)); dc.SelectObject(font); dc.DrawText(inText, &rect1, DT_WORDBREAK | DT_NOPREFIX); dc.RestoreDC(save); memcpy(mImage->mData, bits, mImage->mBitmap.header.biSizeImage); DeleteObject(dib); #line 233 mImageObj = DEBUG_NEW T2ImageObj; mImageObj->AddObject("BAL", 0, *mImage, rect8, true, false); T2Sprite *theSprite = &GetCurrentT2TowerDoc()->mSprite; mSpriteID = theSprite->NewSprite(*mImageObj, "BAL", T2Sprite::ELayer_6); theSprite->MoveSprite(mSpriteID, POINT(topLeft)); theSprite->ShowSprite(mSpriteID, true); if (mDoPause) GetCurrentT2TowerDoc()->towerDoc_vf290(true); mEndTime = GetTickCount() + 1500; }