diff options
Diffstat (limited to 'src/T2DLL/T2ToolHelpWnd.cpp')
-rw-r--r-- | src/T2DLL/T2ToolHelpWnd.cpp | 211 |
1 files changed, 191 insertions, 20 deletions
diff --git a/src/T2DLL/T2ToolHelpWnd.cpp b/src/T2DLL/T2ToolHelpWnd.cpp index f839139..19b53a9 100644 --- a/src/T2DLL/T2ToolHelpWnd.cpp +++ b/src/T2DLL/T2ToolHelpWnd.cpp @@ -1,43 +1,214 @@ +#include "T2ToolDef.h" #include "T2ToolHelpWnd.h" -/*static*/ CObject* __stdcall T2ToolHelpWnd::CreateObject() { -} - -/*static*/ CRuntimeClass* __stdcall T2ToolHelpWnd::_GetBaseClass() { -} - -/*virtual*/ CRuntimeClass* T2ToolHelpWnd::GetRuntimeClass() const { +CObject* PASCAL T2ToolHelpWnd::CreateObject() { +#line 20 + return DEBUG_NEW T2ToolHelpWnd; } +IMPLEMENT_DYNAMIC(T2ToolHelpWnd, CFrameWnd); T2ToolHelpWnd::T2ToolHelpWnd() { + mVisible = false; } /*virtual*/ T2ToolHelpWnd::~T2ToolHelpWnd() { } -/*static*/ const AFX_MSGMAP* __stdcall T2ToolHelpWnd::_GetBaseMessageMap() { -} +BEGIN_MESSAGE_MAP(T2ToolHelpWnd, CFrameWnd) + ON_WM_ERASEBKGND() + ON_WM_DESTROY() +END_MESSAGE_MAP() -/*virtual*/ const AFX_MSGMAP* T2ToolHelpWnd::GetMessageMap() const { -} +void T2ToolHelpWnd::OpenToolHelp(POINT& inPt, int inMode, const char* inStr1, const char* inStr2, T2ToolDef* inToolDef, int inValiation) { +#pragma var_order(rect5, rect, save, unit, var48, var4C, rgn, rect2, rect4, rect3, pDC) + int var48 = inPt.x; + int var4C = inPt.y; + + if (inMode == kToolHelpMode0) { + mHeader = inStr2; + mHeader = mHeader.Left(mHeader.Find("\n")); + mText = inStr2; + mText = mText.Mid(mText.Find("\n") + 1); + mComment = ""; + } else if (inMode == kToolHelpMode1) { + mHeader = inStr1; + mText = inStr2; + mComment = ""; + } else if (inMode == kToolHelpMode2) { + CString tmp; + mHeader = *inToolDef->mToolName[inValiation]; + + // "設置費:" - Installation fee: + mText = "\x90\xDD\x92\x75\x94\xEF\x81\x46"; + mText += *inToolDef->mPriceString[inValiation]; + + // "\n維持費:" - Maintenance costs: + mText += "\n\x88\xDB\x8E\x9D\x94\xEF\x81\x46"; + mText += *inToolDef->mOutMoneyString[inValiation]; + + // "\n電 力:%d" - Power: %d + tmp.Format("\n\x93\x64\x81\x40\x97\xCD\x81\x46\x25\x64", inToolDef->mConsumptionPower[inValiation]); + mText += tmp; + + // "\n設置数:%d/" - Installed number: %d/ + tmp.Format("\n\x90\xDD\x92\x75\x90\x94\x81\x46\x25\x64\x81\x5E", inToolDef->mCurBuildCount); + mText += tmp; + + if (inToolDef->mMaxBuildCount == 0) { + // "無制限" - Unlimited + mText += "\x96\xB3\x90\xA7\x8C\xC0"; + } else { + tmp.Format("%d", inToolDef->mMaxBuildCount); + mText += tmp; + } + + mComment = *inToolDef->mCommentString[inValiation]; + } + + mHeader.TrimRight(); + mText.TrimRight(); + mComment.TrimRight(); + + mFont.CreatePointFont(90, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); + mWndClass = AfxRegisterWndClass(CS_NOCLOSE, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); + + CRect rect(0, 0, 50, 50); + Create(mWndClass, "", WS_POPUP, rect, AfxGetMainWnd(), NULL, WS_EX_TOPMOST); + + CRect rect2; + GetClientRect(rect2); + ClientToScreen(rect2); + + CRect rect3; + rect3.top = rect2.top - rect.top; + rect3.left = rect2.left - rect.left; + rect3.bottom = rect.bottom - rect2.bottom; + rect3.right = rect.right - rect2.right; + + CDC *pDC = GetDC(); + int save = pDC->SaveDC(); + pDC->SelectObject(mFont); + + mRect.SetRectEmpty(); + // "1234567890123456789" + pDC->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\x82\x55\x82\x56\x82\x57\x82\x58", &mRect, DT_SINGLELINE | DT_CALCRECT); + pDC->DrawText(mText, &mRect, DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX); + + if (mComment != "") { + CRect innerRect; + innerRect.SetRectEmpty(); + pDC->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\x82\x55\x82\x56\x82\x57\x82\x58", innerRect, DT_SINGLELINE | DT_CALCRECT); + pDC->DrawText(mComment, &innerRect, DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX); + + mRect.right = max(mRect.right, innerRect.right); + mRect.bottom += innerRect.bottom + 10; + } -void T2ToolHelpWnd::OpenToolHelp(POINT&, int, const char*, const char*, T2ToolDef*, int) { + if (mHeader != "") { + CRect innerRect; + innerRect.SetRectEmpty(); + pDC->DrawText(mHeader, &innerRect, DT_CALCRECT | DT_NOPREFIX); + + mRect.right = max(mRect.right, innerRect.right); + mRect.bottom += innerRect.bottom + 10; + } + + mRect.NormalizeRect(); + mRect.OffsetRect(-mRect.left, -mRect.top); + + CRect rect4; + rect4.SetRect(10, 10, 10, 10); + mRect.OffsetRect(rect4.left, rect4.top); + + CRect rect5; + rect5 = mRect; + rect5 += rect4; + rect5.InflateRect(0, 0, 0, 16); + rect5.NormalizeRect(); + rect5.OffsetRect(-rect5.left, -rect5.top); + rect5.OffsetRect(var48, var4C); + rect5 += rect3; + + SetWindowPos(NULL, rect5.left, rect5.top, rect5.Width(), rect5.Height(), SWP_NOZORDER | SWP_NOACTIVATE); + + rect5 -= rect3; + rect5.OffsetRect(-rect5.left, -rect5.top); + + CRect unit(1, 1, 1, 1); + rect5 -= unit; + + mRgn.CreateRoundRectRgn(rect5.left, rect5.top, rect5.right, rect5.bottom, 10, 10); + + CRgn rgn; + rgn.CreateRectRgn(0, 0, 1, 1); + rgn.CopyRgn(&mRgn); + rgn.OffsetRgn(rect3.left, rect3.top); + ::SetWindowRgn(m_hWnd, rgn, true); + rgn.Detach(); + + pDC->RestoreDC(save); + ReleaseDC(pDC); + + ShowWindow(SW_SHOWNA); + mVisible = true; } void T2ToolHelpWnd::CloseToolHelp() { + if (mVisible) { + ShowWindow(SW_HIDE); + DestroyWindow(); + mVisible = false; + } } -int T2ToolHelpWnd::OnEraseBkgnd(CDC*) { -} +BOOL T2ToolHelpWnd::OnEraseBkgnd(CDC* pDC) { + int saved = pDC->SaveDC(); -void T2ToolHelpWnd::OnDestroy() { -} + CRect clientRect; + GetClientRect(clientRect); + pDC->FillSolidRect(clientRect, RGB(255, 255, 255)); -/*static*/ const CRuntimeClass T2ToolHelpWnd::classT2ToolHelpWnd { -} + CBrush theBrush; + theBrush.CreateStockObject(BLACK_BRUSH); + pDC->FrameRgn(&mRgn, &theBrush, 1, 1); + + pDC->SetBkMode(TRANSPARENT); + pDC->SetTextColor(RGB(0, 0, 0)); + pDC->SelectObject(mFont); + + CRect curRect = mRect; + int curY = mRect.top; -/*static*/ const AFX_MSGMAP T2ToolHelpWnd::messageMap { + if (mHeader != "") { + curRect.top = curY; + curY += pDC->DrawText(mHeader, curRect, DT_CENTER); + curY += 5; + pDC->MoveTo(curRect.left + 15, curY); + pDC->LineTo(curRect.right - 15, curY); + curY += 5; + } + + if (mText != "") { + curRect.top = curY; + curY += pDC->DrawText(mText, curRect, DT_WORDBREAK | DT_NOPREFIX); + + if (mComment != "") { + curY += 5; + pDC->MoveTo(curRect.left + 15, curY); + pDC->LineTo(curRect.right - 15, curY); + curY += 5; + } + } + + if (mComment != "") { + curRect.top = curY; + curY += pDC->DrawText(mComment, curRect, DT_WORDBREAK | DT_NOPREFIX); + } + + pDC->RestoreDC(saved); + return true; } -/*static*/ const AFX_MSGMAP_ENTRY* const T2ToolHelpWnd::_messageEntries { +void T2ToolHelpWnd::OnDestroy() { + CFrameWnd::OnDestroy(); } |