void CMapView::OnRButtonDown(UINT, CPoint point) { CPoint pt = point + GetScrollPosition(); int x = pt.x / 40; int y = pt.y / 40; int xe = (pt.x % 40) / 10; int ye = (pt.y % 40) / 10; CMapDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); int w = pDoc->GetWidth(); int h = pDoc->GetHeight(); if (w > 0 && h > 0 && x >= 0 && y >= 0 && x < w && y < h && xe >= 0 && xe < 4 && ye >= 0 && ye < 4) { int r = y*w + x; int e = ye*4 + xe; CTile Tile = pDoc->GetTile(r); g_Tile = Tile.E[e]; g_Elevation = Tile.Elevation; CString str; str.Format("Select %s (%dm) from %d [%d]", g_App.m_Elements[g_Tile].Name, g_Elevation, r,e); g_App.PrintStatus(str); } }
void CMapView::DrawMegaTile(CDC* pDC, int x, int y) { CMapDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); int r = y * pDoc->GetWidth() + x; CTile Tile = pDoc->GetTile(r); if (m_ViewMode == VIEW_MODE_TILES) { for (int ye = 0; ye < 4; ye++) { for (int xe = 0; xe < 4; xe++) { DrawTile(pDC, x,y,xe,ye, Tile); } } } else { ASSERT(m_ViewMode == VIEW_MODE_ELEVATION); BYTE v = (BYTE)(Tile.Elevation); v = (BYTE)min(255, v*5); // make difference in color more noticable pDC->FillSolidRect(x*40, y*40, 40,40, RGB(v,v,v)); } }
void CMapView::OnMouseMove(UINT, CPoint point) { if (m_HandDown && m_Tracking) { CPoint Delta = m_LastPoint - point; CPoint NewPoint = GetScrollPosition() + Delta; ScrollToPosition(NewPoint); m_LastPoint = point; } else { point += GetScrollPosition(); int x = point.x / 40; int y = point.y / 40; int xe = (point.x % 40) / 10; int ye = (point.y % 40) / 10; CMapDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); int w = pDoc->GetWidth(); int h = pDoc->GetHeight(); CString str; if (w > 0 && h > 0 && x >= 0 && y >= 0 && x < w && y < h && xe >= 0 && xe < 4 && ye >= 0 && ye < 4) { int r = y*w + x; int e = ye*4 + xe; CTile Tile = pDoc->GetTile(r); int Elevation = Tile.Elevation; CElement Element = g_App.m_Elements[Tile.E[e]]; str.Format("%s (%d)", Element.Name, Element.Type); g_App.PrintStatus(str,1); str.Format("%dm", Elevation); g_App.PrintStatus(str,2); str.Format("%d,%d (%d,%d)", x,y, xe,ye); g_App.PrintStatus(str,3); str.Format("%d E%d", r,e); g_App.PrintStatus(str,4); if (m_Tracking) { if (m_ViewMode == VIEW_MODE_ELEVATION) { pDoc->SetTileElevation(r, g_Elevation); CString str; str.Format("Change %d to %dm", r, g_Elevation); g_App.PrintStatus(str); CRect rect(CPoint(x*40, y*40), CSize(40,40)); rect.OffsetRect(-GetScrollPosition()); InvalidateRect(rect, FALSE); } else { pDoc->SetTile(r,e, g_Tile); CString str; str.Format("Change %d [%d] to %s", r,e, g_App.m_Elements[g_Tile].Name); g_App.PrintStatus(str); CRect rect(CPoint(x*40 + xe*10, y*40 + ye*10), CSize(10,10)); rect.OffsetRect(-GetScrollPosition()); InvalidateRect(rect, FALSE); } } } else { str.Empty(); g_App.PrintStatus(str,1); g_App.PrintStatus(str,2); g_App.PrintStatus(str,3); g_App.PrintStatus(str,4); } str.Format("%d,%d", point.x,point.y); g_App.PrintStatus(str,5,true); } }