Add batch editor

Similar to PKHeX's batch editor, probably with some stubbed functionality.

Example to change Oak Trees to apple trees:
=ItemId=60000
.ItemId=60001
;
=ExtensionItemId=60000
.ExtensionItemId=60001

Example to unbury all items:
=IsBuried=True
.IsBuried=False
.IsDropped=True
This commit is contained in:
Kurt
2021-03-21 11:51:57 -07:00
parent c9a4554beb
commit 0798aa5a97
18 changed files with 1115 additions and 35 deletions

View File

@@ -7,7 +7,9 @@ public abstract class ItemLayer : MapGrid
{
public readonly Item[] Tiles;
protected ItemLayer(Item[] tiles, int w, int h) : this(tiles, w, h, w, h) { }
protected ItemLayer(Item[] tiles, int w, int h) : this(tiles, w, h, w, h)
{
}
protected ItemLayer(Item[] tiles, int w, int h, int gw, int gh) : base(gw, gh, w, h)
{
@@ -52,6 +54,7 @@ public int RemoveAll(in int xmin, in int ymin, in int width, in int height, Func
count++;
}
}
return count;
}
@@ -169,7 +172,47 @@ public int ReplaceAll(Item oldItem, Item newItem, in int xmin, in int ymin, in i
count++;
}
}
return count;
}
public int ClearDanglingExtensions(in int xmin, in int ymin, in int width, in int height)
{
int count = 0;
for (int x = xmin; x < xmin + width; x++)
{
for (int y = ymin; y < ymin + height; y++)
{
var t = GetTile(x, y);
if (IsValidExtension(t, x, y))
continue;
t.Delete();
count++;
}
}
return count;
}
private bool IsValidExtension(Item t, int x, int y)
{
if (!t.IsExtension)
return true;
var parentX = x - t.ExtensionX;
var parentY = y - t.ExtensionY;
try
{
var parent = GetTile(parentX, parentY);
if (parent.ItemId == t.ExtensionItemId)
return true;
}
#pragma warning disable CA1031 // Do not catch general exception types
catch
{
// corrupt?
}
#pragma warning restore CA1031 // Do not catch general exception types
return false;
}
}
}