summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2FloorNumberTable.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-06-28 22:22:32 +0100
committerAsh Wolf <ninji@wuffs.org>2023-06-28 22:22:32 +0100
commitc0c336500955a23e344651e5412c9d9d441ef4ee (patch)
tree790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2FloorNumberTable.cpp
parent37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff)
downloadt2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz
t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip
first pass of T2DLL
Diffstat (limited to 'src/T2DLL/T2FloorNumberTable.cpp')
-rw-r--r--src/T2DLL/T2FloorNumberTable.cpp128
1 files changed, 117 insertions, 11 deletions
diff --git a/src/T2DLL/T2FloorNumberTable.cpp b/src/T2DLL/T2FloorNumberTable.cpp
index 4a49252..41bd585 100644
--- a/src/T2DLL/T2FloorNumberTable.cpp
+++ b/src/T2DLL/T2FloorNumberTable.cpp
@@ -1,40 +1,146 @@
+#include "GlobalFunc.h"
+#include "T2FloorInfo.h"
#include "T2FloorNumberTable.h"
+#include "T2Mover.h"
+#include "T2MoverModuleTable.h"
+#include "T2TowerDoc.h"
-T2FloorNumberTable::T2FloorNumberTable(T2TowerDoc*, T2ImageObj*, CPalette*) {
+T2FloorNumberTable::T2FloorNumberTable(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
+ : T2DlgItemImageTable(inDoc, inImageObj, inPalette)
+ , mMover(NULL)
+ , mMoverModuleTable(NULL)
+{
+ SetRect(&mRect, 0, 0, 0, 0);
+ _10C = 0;
+ _110 = 0;
}
/*virtual*/ T2FloorNumberTable::~T2FloorNumberTable() {
}
-/*virtual*/ int T2FloorNumberTable::Create(const char*, unsigned long, const RECT&, CWnd*, unsigned int) {
+/*virtual*/ BOOL T2FloorNumberTable::Create(const char* inWindowName, DWORD inStyle, const RECT& inRect, CWnd* inParentWnd, UINT inID) {
+ return T2DlgItem::Create(inWindowName, inStyle, inRect, inParentWnd, inID);
}
-void T2FloorNumberTable::SetMover(T2Mover*) {
+void T2FloorNumberTable::SetMover(T2Mover* inMover) {
+ mMover = inMover;
+ InsertRows(mMover->GetLength(), 0, NULL);
}
-void T2FloorNumberTable::SetMoverModuleTable(T2MoverModuleTable*) {
+void T2FloorNumberTable::SetMoverModuleTable(T2MoverModuleTable* inTable) {
+ mMoverModuleTable = inTable;
}
int T2FloorNumberTable::GetVScrValue() {
+ if (mMoverModuleTable)
+ return mMoverModuleTable->GetVScrValue();
+ else
+ return 0;
}
-void T2FloorNumberTable::ClickCell(const TableCellT&, POINT) {
+void T2FloorNumberTable::ClickCell(const TableCellT& inCell, POINT inPt) {
+ if (mMover) {
+ StflNotification info;
+ info.floorNumber = mRows - inCell.row;
+ info.theTable = this;
+ BroadcastMessage('stfl', &info);
+ }
}
-void T2FloorNumberTable::RefreshCell(int) {
+void T2FloorNumberTable::RefreshCell(int inFloor) {
+ TableCellT theCell;
+ theCell.row = mRows - inFloor;
+ theCell.col = 1;
+
+ RECT cellRect;
+ if (FetchLocalCellFrame(theCell, cellRect))
+ InvalidateRect(&cellRect);
}
-/*virtual*/ void T2FloorNumberTable::DrawCellSelf(CDC*, const TableCellT&, int) {
+/*virtual*/ void T2FloorNumberTable::DrawCellSelf(CDC* pDC, const TableCellT& inCell, BOOL inSelected) {
+ if (mMover) {
+ RECT cellRect;
+ if (FetchLocalCellFrame(inCell, cellRect)) {
+ RECT theDrawArea = mRect;
+ OffsetRect(&theDrawArea, cellRect.left, cellRect.top);
+
+ T2FloorInfo *theFloorInfo = GetCurrentT2TowerDoc()->towerDoc_vf12C();
+ RECT moverArea;
+ mMover->GetEquipArea(moverArea);
+
+ int floor = mRows - inCell.row;
+ int floorNum = theFloorInfo->UnitToFloor(moverArea.top + inCell.row);
+
+ char buffer[256];
+ sprintf(buffer, "%d", floorNum);
+
+ int saveDC = pDC->SaveDC();
+
+ CBrush baseBrush;
+ baseBrush.CreateSolidBrush(RGB(255, 255, 255));
+ pDC->SelectObject(baseBrush);
+
+ pDC->SelectStockObject(BLACK_PEN);
+
+ pDC->Rectangle(&moverArea);
+ pDC->MoveTo(cellRect.left, cellRect.bottom - 1);
+ pDC->LineTo(cellRect.right - 1, cellRect.bottom - 1);
+
+ InflateRect(&theDrawArea, 1, 1);
+ pDC->DrawText(buffer, strlen(buffer), &theDrawArea, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
+
+ if (!mMover->IsStopPosition(floor)) {
+ pDC->SetTextColor(_110);
+ pDC->MoveTo(theDrawArea.left, theDrawArea.top);
+ pDC->LineTo(theDrawArea.right - 1, theDrawArea.bottom - 1);
+ pDC->MoveTo(theDrawArea.left, theDrawArea.bottom - 1);
+ pDC->LineTo(theDrawArea.right - 1, theDrawArea.top);
+ }
+
+ pDC->RestoreDC(saveDC);
+ }
+ }
}
-/*virtual*/ int T2FloorNumberTable::OnT2DlgItemEraseBkgnd(CDC*) {
+/*virtual*/ BOOL T2FloorNumberTable::OnT2DlgItemEraseBkgnd(CDC* pDC) {
+ RECT theTableRect, cellFrame;
+ GetClientRect(&theTableRect);
+
+ unsigned int height, width;
+ GetTableSize(height, width);
+
+ int position = GetVScrValue() * mRowHeight;
+
+ for (unsigned int x = 1; x <= width; x++) {
+ for (unsigned int y = 1; y <= height; y++) {
+ TableCellT cell;
+ cell.row = y;
+ cell.col = x;
+
+ if (FetchLocalCellFrame(cell, cellFrame)) {
+ OffsetRect(&cellFrame, 0, -position);
+ BOOL isVisible = IntersectRect(&cellFrame, &cellFrame, &theTableRect);
+ if (isVisible)
+ DrawCellSelf(pDC, cell, false);
+ }
+ }
+ }
+
+ InvalidateRect(&cellFrame);
+ return true;
}
-/*virtual*/ void T2FloorNumberTable::OnT2DlgItemLButtonDown(unsigned int, CPoint) {
+/*virtual*/ void T2FloorNumberTable::OnT2DlgItemLButtonDown(UINT inFlags, CPoint inPt) {
+ POINT pt = inPt;
+ ClientToView(&pt, 1);
+
+ TableCellT cell;
+ FetchCellHitBy(pt, cell);
+ ClickCell(cell, inPt);
}
-/*virtual*/ void T2FloorNumberTable::OnT2DlgItemLButtonUp(unsigned int, CPoint) {
+/*virtual*/ void T2FloorNumberTable::OnT2DlgItemLButtonUp(UINT inFlags, CPoint inPt) {
}
-/*virtual*/ void T2FloorNumberTable::OnT2DlgItemMouseMove(unsigned int, CPoint) {
+/*virtual*/ void T2FloorNumberTable::OnT2DlgItemMouseMove(UINT inFlags, CPoint inPt) {
}