| 1967 | } |
| 1968 | |
| 1969 | void CStaticMap::DrawGrid() |
| 1970 | { |
| 1971 | float sizeLand = LandGrid * LandRange; |
| 1972 | float invSizeLand = 1.0f / sizeLand; |
| 1973 | |
| 1974 | const GridInfo* info = GWorld->GetGridInfo(_scaleX); |
| 1975 | if (!info) |
| 1976 | { |
| 1977 | return; |
| 1978 | } |
| 1979 | |
| 1980 | float offsetX = GWorld->GetGridOffsetX(); |
| 1981 | float offsetY = GWorld->GetGridOffsetY(); |
| 1982 | |
| 1983 | float coefX = sizeLand * info->invStepX; |
| 1984 | float invCoefX = invSizeLand * info->stepX; |
| 1985 | |
| 1986 | float coefY = sizeLand * info->invStepY; |
| 1987 | float invCoefY = invSizeLand * info->stepY; |
| 1988 | |
| 1989 | int xFrom = TO_INT(coefX, (-_mapX * _scaleX * sizeLand - offsetX) * info->invStepX); |
| 1990 | int zFrom = TO_INT(coefY, (-_mapY * _scaleY * sizeLand - offsetY) * info->invStepY); |
| 1991 | int xTo = TO_INT(coefX, ((_w - _mapX) * _scaleX * sizeLand - offsetX) * info->invStepX); |
| 1992 | int zTo = TO_INT(coefY, ((_h - _mapY) * _scaleY * sizeLand - offsetY) * info->invStepY); |
| 1993 | |
| 1994 | float xBeg = _x + _mapX + (xFrom * info->stepX + offsetX) * _invScaleX * invSizeLand; |
| 1995 | float zBeg = _y + _mapY + (zFrom * info->stepY + offsetY) * _invScaleY * invSizeLand; |
| 1996 | float xFld = fabs(_invScaleX * invCoefX); |
| 1997 | float zFld = fabs(_invScaleY * invCoefY); |
| 1998 | |
| 1999 | float h = _sizeGrid; |
| 2000 | |
| 2001 | float zAct = zBeg; |
| 2002 | int zSign = coefY > 0 ? 1 : -1; |
| 2003 | for (int z = zFrom; zSign * (zTo - z) >= 0; z += zSign) |
| 2004 | { |
| 2005 | if (zAct >= _y && zAct <= _y + _h) |
| 2006 | { |
| 2007 | GLOB_ENGINE->DrawLine(Line2DPixel(_clipRect.x, zAct * _hScreen, _clipRect.x + _clipRect.w, zAct * _hScreen), |
| 2008 | _colorGridMap, _colorGridMap); |
| 2009 | } |
| 2010 | BString<32> buffer; |
| 2011 | GridFormat(buffer, info->formatY, zSign == 1 ? z : z - 1); |
| 2012 | float width = GEngine->GetTextWidth(_sizeGrid, _fontGrid, buffer); |
| 2013 | float left = _x; |
| 2014 | float right = _x + _w - width; |
| 2015 | float top = zAct + 0.5 * (zFld - h); |
| 2016 | GLOB_ENGINE->DrawText(Point2DFloat(left, top), _sizeGrid, Rect2DFloat(_x, _y, _w, _h), _fontGrid, _colorGrid, |
| 2017 | buffer); |
| 2018 | GLOB_ENGINE->DrawText(Point2DFloat(right, top), _sizeGrid, Rect2DFloat(_x, _y, _w, _h), _fontGrid, _colorGrid, |
| 2019 | buffer); |
| 2020 | zAct += zFld; |
| 2021 | } |
| 2022 | float xAct = xBeg; |
| 2023 | int xSign = coefX > 0 ? 1 : -1; |
| 2024 | for (int x = xFrom; xSign * (xTo - x) >= 0; x += xSign) |
| 2025 | { |
| 2026 | if (xAct >= _x && xAct <= _x + _w) |
nothing calls this directly
no test coverage detected