| 212 | } |
| 213 | |
| 214 | void CLayerTune::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) |
| 215 | { |
| 216 | if(m_Readonly || (!Empty && pBrush->m_Type != LAYERTYPE_TILES)) |
| 217 | return; |
| 218 | |
| 219 | Snap(&Rect); |
| 220 | |
| 221 | int sx = ConvertX(Rect.x); |
| 222 | int sy = ConvertY(Rect.y); |
| 223 | int w = ConvertX(Rect.w); |
| 224 | int h = ConvertY(Rect.h); |
| 225 | |
| 226 | CLayerTune *pLt = static_cast<CLayerTune *>(pBrush); |
| 227 | |
| 228 | bool Destructive = Editor()->m_BrushDrawDestructive || Empty || pLt->IsEmpty(); |
| 229 | |
| 230 | for(int y = 0; y < h; y++) |
| 231 | { |
| 232 | for(int x = 0; x < w; x++) |
| 233 | { |
| 234 | int fx = x + sx; |
| 235 | int fy = y + sy; |
| 236 | |
| 237 | if(fx < 0 || fx >= m_Width || fy < 0 || fy >= m_Height) |
| 238 | continue; |
| 239 | |
| 240 | if(!Destructive && GetTile(fx, fy).m_Index) |
| 241 | continue; |
| 242 | |
| 243 | const int SrcIndex = Empty ? 0 : (y * pLt->m_Width + x % pLt->m_Width) % (pLt->m_Width * pLt->m_Height); |
| 244 | const int TgtIndex = fy * m_Width + fx; |
| 245 | |
| 246 | STuneTileStateChange::SData Previous{ |
| 247 | m_pTuneTile[TgtIndex].m_Number, |
| 248 | m_pTuneTile[TgtIndex].m_Type, |
| 249 | m_pTiles[TgtIndex].m_Index}; |
| 250 | |
| 251 | if(Empty || (!Editor()->IsAllowPlaceUnusedTiles() && !IsValidTuneTile((pLt->m_pTiles[SrcIndex]).m_Index))) |
| 252 | { |
| 253 | m_pTiles[TgtIndex].m_Index = 0; |
| 254 | m_pTuneTile[TgtIndex].m_Type = 0; |
| 255 | m_pTuneTile[TgtIndex].m_Number = 0; |
| 256 | |
| 257 | if(!Empty) |
| 258 | ShowPreventUnusedTilesWarning(); |
| 259 | } |
| 260 | else |
| 261 | { |
| 262 | m_pTiles[TgtIndex] = pLt->m_pTiles[SrcIndex]; |
| 263 | if(pLt->m_HasTune && m_pTiles[TgtIndex].m_Index > 0) |
| 264 | { |
| 265 | m_pTuneTile[TgtIndex].m_Type = m_pTiles[fy * m_Width + fx].m_Index; |
| 266 | |
| 267 | if((pLt->m_pTuneTile[SrcIndex].m_Number == 0 && Editor()->m_TuningNumber) || Editor()->m_TuningNumber != pLt->m_TuningNumber) |
| 268 | m_pTuneTile[TgtIndex].m_Number = Editor()->m_TuningNumber; |
| 269 | else |
| 270 | m_pTuneTile[TgtIndex].m_Number = pLt->m_pTuneTile[SrcIndex].m_Number; |
| 271 | } |
nothing calls this directly
no test coverage detected