Public Sub Flip()
On Error Resume Next
Dim l_undUndo As cMultiUndoEntry, l_brsBrush As Fury2Brush
Dim l_undTileUndo As cTileUndoEntry, l_undBlockingUndo As cBlockingUndoEntry, l_undObjectUndo As cObjectUndoEntry, l_undPropertyUndo As cPropertyUndoEntry
Dim l_lyrLayer As Fury2MapLayer, l_sprSprite As Fury2Sprite, l_araArea As Fury2Area, l_lngLines As Long
Dim l_lnLines() As FLine, l_intTile As Integer
Dim l_lngX As Long, l_lngY As Long
BeginProcess "Flipping..."
Set l_undUndo = New cMultiUndoEntry
For Each l_araArea In Map.Areas
Set l_undPropertyUndo = New cPropertyUndoEntry
With l_undPropertyUndo
.MethodName = "Y"
Set .Object = l_araArea
.Value = l_araArea.Y
End With
l_undUndo.Entries.Add l_undPropertyUndo
l_araArea.Y = Map.MaxY - l_araArea.Y - l_araArea.Height
Next l_araArea
For Each l_sprSprite In Map.Sprites
Set l_undPropertyUndo = New cPropertyUndoEntry
With l_undPropertyUndo
.MethodName = "Y"
Set .Object = l_sprSprite
.Value = l_sprSprite.Y
End With
l_undUndo.Entries.Add l_undPropertyUndo
l_sprSprite.Y = Map.MaxY - l_sprSprite.Y
Next l_sprSprite
For Each l_lyrLayer In Map.Layers
Set l_undTileUndo = New cTileUndoEntry
With l_undTileUndo
.X = 0
.Y = 0
.Layer = l_lyrLayer.Index
Set .Map = Map
Set .Brush = New Fury2Brush
.Brush.Grab Map, l_lyrLayer.Index, 0, 0, l_lyrLayer.Width, l_lyrLayer.Height, , , True
End With
l_undUndo.Entries.Add l_undTileUndo
With l_lyrLayer
If Not .Prerendered Then
For l_lngY = 0 To (.Height - 1) \ 2
For l_lngX = 0 To .Width - 1
l_intTile = .Tile(l_lngX, l_lngY)
.Tile(l_lngX, l_lngY) = .Tile(l_lngX, (.Height - 1) - l_lngY)
.Tile(l_lngX, (.Height - 1) - l_lngY) = l_intTile
Next l_lngX
Next l_lngY
End If
End With
Set l_undBlockingUndo = New cBlockingUndoEntry
With l_undBlockingUndo
.Layer = l_lyrLayer.Index
.Lines = l_lyrLayer.CollisionLines
Set .Map = Map
End With
l_undUndo.Entries.Add l_undBlockingUndo
With l_lyrLayer
l_lnLines = .CollisionLines
For l_lngLines = LBound(l_lnLines) To UBound(l_lnLines)
With l_lnLines(l_lngLines)
.Start.Y = Map.MaxY - .Start.Y
.end.Y = Map.MaxY - .end.Y
End With
Next l_lngLines
.CollisionLines = l_lnLines
End With
Next l_lyrLayer
m_colUndo.Add l_undUndo
m_colRedo.Clear
If m_colUndo.Count > c_lngUndoStackLength Then
m_colUndo.Remove 1
End If
EndProcess
Redraw
End Sub