Palette picks a whole object on a click; mod documentation
This commit is contained in:
1 parent
c585960c61
commit
bbdfe95de3
41 files changed
+1114
-179
No files matched your search
@@ -8,6 +8,37 @@ namespace Cthangover.Tools.RpgEditor.Tests
|
||||
{
|
||||
private static RpgMapDocument NewMap() => RpgMapDocument.Create("test_map", "village", 5, 4, 0);
|
||||
|
||||
[ModTest("document/rectangle_stamp_preserves_arrangement_and_undo")]
|
||||
static void RectangleStampAndUndo(ModTestContext ctx)
|
||||
{
|
||||
var document = NewMap();
|
||||
var stamp = new RpgTileStamp(2, 2, new[] { 64, 65, 67, 68 });
|
||||
document.BeginChange();
|
||||
ModAssert.Equal(4, document.Stamp(RpgEditLayer.Front, 1, 1, stamp), "the whole rectangle is placed");
|
||||
ModAssert.Equal(64, document.Grid.GetTile(RpgLayer.Front, 1, 1), "top left");
|
||||
ModAssert.Equal(65, document.Grid.GetTile(RpgLayer.Front, 2, 1), "top right");
|
||||
ModAssert.Equal(67, document.Grid.GetTile(RpgLayer.Front, 1, 2), "bottom left");
|
||||
ModAssert.Equal(68, document.Grid.GetTile(RpgLayer.Front, 2, 2), "bottom right");
|
||||
ModAssert.Equal(0, document.Stamp(RpgEditLayer.Front, 1, 1, stamp), "unchanged cells are not edits");
|
||||
ModAssert.True(document.Undo(), "one undo removes the entire group");
|
||||
ModAssert.Equal(-1, document.Grid.GetTile(RpgLayer.Front, 2, 2), "the final group cell is undone too");
|
||||
ModAssert.True(document.Redo(), "one redo restores the group");
|
||||
var restored = RpgMapDocument.Load(document.ToJson());
|
||||
ModAssert.Equal(68, restored.Grid.GetTile(RpgLayer.Front, 2, 2), "the group survives saving and loading");
|
||||
}
|
||||
|
||||
[ModTest("document/stamp_skips_padding_and_clips_at_map_edges")]
|
||||
static void StampGapsAndBounds(ModTestContext ctx)
|
||||
{
|
||||
var document = NewMap();
|
||||
var stamp = new RpgTileStamp(2, 2, new[] { -1, 11, 12, 13 });
|
||||
ModAssert.Equal(0, document.Stamp(RpgEditLayer.Main, 4, 3, stamp), "padding does not erase the destination and other cells clip");
|
||||
ModAssert.Equal(2, document.Stamp(RpgEditLayer.Main, -1, 0, stamp), "partially off-map stamps clip without shifting");
|
||||
ModAssert.Equal(11, document.Grid.GetTile(RpgLayer.Main, 0, 0), "top-right stamp cell reaches the map edge");
|
||||
ModAssert.Equal(13, document.Grid.GetTile(RpgLayer.Main, 0, 1), "bottom-right cell retains its offset");
|
||||
ModAssert.Equal(0, document.Stamp(RpgEditLayer.Collision, 0, 0, stamp), "a tile stamp never changes collision codes");
|
||||
}
|
||||
|
||||
[ModTest("document/create_fills_ground_and_centres_spawn")]
|
||||
static void CreateFillsGroundAndCentresSpawn(ModTestContext ctx)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using Cthangover.Core.Mods.Testing;
|
||||
using Cthangover.Mods.Rpg;
|
||||
using Godot;
|
||||
|
||||
namespace Cthangover.Tools.RpgEditor.Tests
|
||||
{
|
||||
/// <summary>Palette rectangles resolve physical cells back to stable logical map ids.</summary>
|
||||
public class RpgTileStampTests
|
||||
{
|
||||
[ModTest("stamp/atlas_rectangle_resolves_packed_ids_and_padding")]
|
||||
static void PackedRectangle(ModTestContext ctx)
|
||||
{
|
||||
var tileset = new RpgTileset { Columns = 3, Tiles = new List<RpgTileInfo>
|
||||
{
|
||||
new() { Index = 64, AtlasIndex = 1 }, new() { Index = 65, AtlasIndex = 2 },
|
||||
new() { Index = 67, AtlasIndex = 4 }
|
||||
}};
|
||||
var stamp = RpgTileStamp.FromAtlas(tileset, new Rect2I(1, 0, 2, 2));
|
||||
ModAssert.Equal(2, stamp.Width, "rectangle width");
|
||||
ModAssert.Equal(2, stamp.Height, "rectangle height");
|
||||
ModAssert.Equal(64, stamp.TileAt(0, 0), "top left logical id");
|
||||
ModAssert.Equal(65, stamp.TileAt(1, 0), "top right logical id");
|
||||
ModAssert.Equal(67, stamp.TileAt(0, 1), "bottom left logical id");
|
||||
ModAssert.Equal(-1, stamp.TileAt(1, 1), "an empty physical slot stays a gap");
|
||||
ModAssert.Equal(-1, stamp.TileAt(-1, 0), "outside selection is empty");
|
||||
ModAssert.Equal(40, RpgTileStamp.Single(40).TileAt(0, 0), "surface brushes also retain logical ids");
|
||||
var values = new[] { 11 };
|
||||
var copied = new RpgTileStamp(1, 1, values);
|
||||
values[0] = 99;
|
||||
ModAssert.Equal(11, copied.TileAt(0, 0), "the brush owns its tile snapshot");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user