From c0c336500955a23e344651e5412c9d9d441ef4ee Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 28 Jun 2023 22:22:32 +0100 Subject: first pass of T2DLL --- src/T2DLL/T2DlgItemSTimeTbl.cpp | 68 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 5 deletions(-) (limited to 'src/T2DLL/T2DlgItemSTimeTbl.cpp') diff --git a/src/T2DLL/T2DlgItemSTimeTbl.cpp b/src/T2DLL/T2DlgItemSTimeTbl.cpp index a837aa5..e82ab91 100644 --- a/src/T2DLL/T2DlgItemSTimeTbl.cpp +++ b/src/T2DLL/T2DlgItemSTimeTbl.cpp @@ -1,19 +1,77 @@ #include "T2DlgItemSTimeTbl.h" +#include "T2MetroRailway.h" +#include "T2TowerDoc.h" +#include "T2WorldDef.h" -T2DlgItemSTimeTbl::T2DlgItemSTimeTbl(T2TowerDoc*, T2ImageObj*, CPalette*) { +T2DlgItemSTimeTbl::T2DlgItemSTimeTbl(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) + : T2DlgItem(inDoc, inImageObj, inPalette) +{ + mCFont = NULL; } /*virtual*/ T2DlgItemSTimeTbl::~T2DlgItemSTimeTbl() { + delete mCFont; } -/*virtual*/ int T2DlgItemSTimeTbl::Create(const char*, unsigned long, const RECT&, CWnd*, unsigned int) { +/*virtual*/ BOOL T2DlgItemSTimeTbl::Create(const char* windowName, DWORD style, const RECT& rect, CWnd* parentWnd, UINT nId) { + BOOL result = T2DlgItem::Create(windowName, style, rect, parentWnd, nId); + + if (result) { +#line 34 + mCFont = DEBUG_NEW CFont; + mCFont->CreateFont(-abs(9), 0, 0, 0, FW_NORMAL, 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"); + SetFont(*mCFont); + } + + return result; } -void T2DlgItemSTimeTbl::SetGrade(int) { +void T2DlgItemSTimeTbl::SetGrade(int inGrade) { + mGrade = inGrade; } -/*virtual*/ int T2DlgItemSTimeTbl::OnT2DlgItemEraseBkgnd(CDC*) { +/*virtual*/ BOOL T2DlgItemSTimeTbl::OnT2DlgItemEraseBkgnd(CDC* pDC) { + int save = pDC->SaveDC(); + pDC->SelectPalette(mPalette, false); + pDC->RealizePalette(); + + CString str; + + T2MetroRailway *theMetroRailway = mTowerDoc->mWorldDef->GetMetroRailway(); + if (theMetroRailway) { + CRect timeRect, clientRect; + GetClientRect(clientRect); + + SIZE timeSize; + timeSize.cx = (clientRect.right - clientRect.left) / (theMetroRailway->GetNofTimeTable() / 2); + timeSize.cy = (clientRect.bottom - clientRect.top) / 2; + + pDC->SelectObject(mFont); + pDC->SetBkMode(TRANSPARENT); + + for (int i = 0; i < theMetroRailway->GetNofTimeTable(); i++) { + timeRect.left = timeSize.cx * (i % (theMetroRailway->GetNofTimeTable() / 2)); + timeRect.right = timeRect.left + timeSize.cx; + timeRect.top = timeSize.cy * (i / (theMetroRailway->GetNofTimeTable() / 2)); + timeRect.bottom = timeRect.top + timeSize.cy; + + DrawTime(pDC, theMetroRailway->GetArriveTime(i), theMetroRailway->GetTrainType(i) < mGrade, timeRect); + } + } + + pDC->RestoreDC(save); + return true; } -void T2DlgItemSTimeTbl::DrawTime(CDC*, unsigned int, int, CRect&) { +void T2DlgItemSTimeTbl::DrawTime(CDC* pDC, unsigned int inArriveTime, BOOL isGrade, CRect& inRect) { + int hour = inArriveTime / 60; + int minute = inArriveTime % 60; + + UINT flag = DT_LEFT | DT_VCENTER | DT_WORDBREAK | DT_NOPREFIX; + + CString str; + str.Format("%2d:%02d", hour, minute); + + pDC->SetTextColor(isGrade ? PALETTEINDEX(255) : PALETTERGB(179, 179, 179)); + pDC->DrawText(str, inRect, flag); } -- cgit v1.2.3