SUIProperties::SUIProperties(void) { rectangle = SRectangle(0, 0, 0, 0); rotation = 0; rotationCenter = D3DXVECTOR2(0, 0); backgroundImage = NULL; backgroundColor = D3DXCOLOR(0,0,0,0); transparency = 1; layer = 0; backgroundX = 0; backgroundY = 0; backgroundPosition = Normal; backgroundMode = Positioning; //padding = D3DXVECTOR4(0,0,0,0); }
void CBasicMapDamage::RecalcArea(int x1, int x2, int y1, int y2) { const int minQuadNumX = (x1 * SQUARE_SIZE - (quadField->GetQuadSizeX() / 2)) / quadField->GetQuadSizeX(), maxQuadNumX = (x2 * SQUARE_SIZE + (quadField->GetQuadSizeX() / 2)) / quadField->GetQuadSizeX(); const int minQuadNumZ = (y1 * SQUARE_SIZE - (quadField->GetQuadSizeZ() / 2)) / quadField->GetQuadSizeZ(), maxQuadNumZ = (y2 * SQUARE_SIZE + (quadField->GetQuadSizeZ() / 2)) / quadField->GetQuadSizeZ(); const int decy = std::max( 0, minQuadNumZ); const int incy = std::min(quadField->GetNumQuadsZ() - 1, maxQuadNumZ); const int decx = std::max( 0, minQuadNumX); const int incx = std::min(quadField->GetNumQuadsX() - 1, maxQuadNumX); const int numQuadsX = quadField->GetNumQuadsX(); const int frameNum = gs->frameNum; for (int y = decy; y <= incy; y++) { for (int x = decx; x <= incx; x++) { if (inRelosQue[y * numQuadsX + x]) continue; RelosSquare rs; rs.x = x; rs.y = y; rs.neededUpdate = frameNum; rs.numUnits = quadField->GetQuadAt(x, y).units.size(); relosSize += rs.numUnits; inRelosQue[y * numQuadsX + x] = true; relosQue.push_back(rs); } } readMap->UpdateHeightMapSynced(SRectangle(x1, y1, x2, y2)); pathManager->TerrainChange(x1, y1, x2, y2, TERRAINCHANGE_DAMAGE_RECALCULATION); featureHandler->TerrainChanged(x1, y1, x2, y2); }
SRectangle SUIPictureBox::GetTexRect() { if (!picture) { return SRectangle(*properties.x, *properties.y, *properties.width, *properties.height); } SRectangle rect; int imageWidth = picture->GetWidth(); int imageHeight = picture->GetHeight(); int boxWidth = *properties.width; int boxHeight = *properties.height; if (fillMode == Positioning) { rect.Width = imageWidth; rect.Height = imageHeight; switch(positionMode) { case TopLeft: rect.X = 0; rect.Y = 0; break; case TopRight: rect.X = boxWidth - imageWidth; rect.Y = 0; break; case TopCenter: rect.X = (boxWidth - imageWidth) / 2; rect.Y = 0; break; case BottomLeft: rect.X = 0; rect.Y = boxHeight - imageHeight; break; case BottomRight: rect.X = boxWidth - imageWidth; rect.Y = boxHeight - imageHeight; break; case BottomCenter: rect.X = (boxWidth - imageWidth) / 2; rect.Y = boxHeight - imageHeight; break; case CenterLeft: rect.X = 0; rect.Y = (boxHeight - imageHeight) / 2; break; case CenterRight: rect.X = boxWidth - imageWidth; rect.Y = (boxHeight - imageHeight) / 2; break; case CenterAll: rect.X = (boxWidth - imageWidth) / 2; rect.Y = (boxHeight - imageHeight) / 2; break; default: rect.X = imagePos.x; rect.Y = imagePos.y; break; } return rect; } switch(fillMode) { case Fill: rect = GetRectangle(); rect.X = 0; rect.Y = 0; break; case FitWidth: rect.Width = boxWidth; rect.Height = (float)boxWidth / imageWidth * imageHeight; rect.X = 0; rect.Y = (boxHeight - rect.Height) / 2; break; case FitHeight: rect.Width = (float)boxHeight / imageHeight * imageWidth; rect.Height = boxHeight; rect.X = (boxWidth - rect.Width) / 2; rect.Y = 0; break; case FitMin: if ((float)boxWidth / imageWidth < (float)boxHeight / imageHeight) { rect.Width = boxWidth; rect.Height = (float)boxWidth / imageWidth * imageHeight; rect.X = 0; rect.Y = (boxHeight - rect.Height) / 2; } else { rect.Width = (float)boxHeight / imageHeight * imageWidth; rect.Height = boxHeight; rect.X = (boxWidth - rect.Width) / 2; rect.Y = 0; } break; case FitMax: if ((float)boxWidth / imageWidth > (float)boxHeight / imageHeight) { rect.Width = boxWidth; rect.Height = (float)boxWidth / imageWidth * imageHeight; rect.X = 0; rect.Y = (boxHeight - rect.Height) / 2; } else { rect.Width = (float)boxHeight / imageHeight * imageWidth; rect.Height = boxHeight; rect.X = (boxWidth - rect.Width) / 2; rect.Y = 0; } break; case ResizeBox: *properties.width = imageWidth; *properties.height = imageHeight; rect = GetRectangle(); rect.X = 0; rect.Y = 0; break; } return rect; }