Skip to content

Commit 3368f5c

Browse files
committed
[Major] expand readme, add sprites origin export and improve the gameobject comparer
1 parent b80a5ff commit 3368f5c

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

DiffUtils.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public bool Equals(UndertaleGameObject? x, UndertaleGameObject? y)
5656
x.Persistent == y.Persistent &&
5757
x.Awake == y.Awake &&
5858
x.CollisionShape == y.CollisionShape &&
59-
x.Events.Count == y.Events.Count;
59+
x.Events.Enumerate().SelectMany(x => x.Item2.Select(y => (((EventType)x.Item1).ToString(), (int)y.EventSubtype))).ToList().Count == y.Events.Enumerate().SelectMany(x => x.Item2.Select(y => (((EventType)x.Item1).ToString(), (int)y.EventSubtype))).ToList().Count;
6060
}
6161

6262
// If Equals() returns true for a pair of objects
@@ -73,7 +73,7 @@ public int GetHashCode(UndertaleGameObject x)
7373
x.Persistent.GetHashCode() ^
7474
x.Awake.GetHashCode() ^
7575
x.CollisionShape.GetHashCode() ^
76-
x.Events.Count.GetHashCode();
76+
x.Events.Enumerate().SelectMany(x => x.Item2.Select(y => (((EventType)x.Item1).ToString(), (int)y.EventSubtype))).ToList().Count.GetHashCode();
7777
}
7878
}
7979
class UndertaleGameObjectNameComparer : IEqualityComparer<UndertaleGameObject>
@@ -348,6 +348,7 @@ private static void AddedRemovedSprites(UndertaleData name, UndertaleData refere
348348

349349
IEnumerable<UndertaleSprite> added = name.Sprites.Except(reference.Sprites, new UndertaleSpriteNameComparer());
350350
IEnumerable<UndertaleSprite> removed = reference.Sprites.Except(name.Sprites, new UndertaleSpriteNameComparer());
351+
using StreamWriter swOrigin = new(Path.Join(outputFolder.FullName, Path.DirectorySeparatorChar.ToString(), $"addedSpritesOrigin.txt"));
351352
using (StreamWriter sw = new(Path.Join(outputFolder.FullName, Path.DirectorySeparatorChar.ToString(), $"addedSprites.txt")))
352353
{
353354
foreach(UndertaleSprite sprite in added)
@@ -360,6 +361,7 @@ private static void AddedRemovedSprites(UndertaleData name, UndertaleData refere
360361
worker.ExportAsPNG(sprite.Textures[i].Texture, Path.Combine(dirAddedSprite.FullName , sprite.Name.Content + "_" + i + ".png"), null, true);
361362
}
362363
}
364+
swOrigin.WriteLine($"Msl.GetSprite(\"{sprite.Name.Content}\").OriginX = {sprite.OriginX};\nMsl.GetSprite(\"{sprite.Name.Content}\").OriginY = {sprite.OriginY};");
363365
}
364366
}
365367
File.WriteAllLines(Path.Join(outputFolder.FullName, Path.DirectorySeparatorChar.ToString(), $"removedSprites.txt"), removed.Select(x => x.Name.Content));

ModShardDiff.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<Authors>zizani</Authors>
1616
<PackageTags>msl;cli</PackageTags>
1717
<PackageProjectUrl>https://github.com/ModShardTeam/ModShardDiff</PackageProjectUrl>
18-
<Description>A cli tool to export all differences between two .win files.</Description>
18+
<Description>A cli tool to export differences between two .win files.</Description>
1919
</PropertyGroup>
2020

2121
<PropertyGroup>

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
11
# ModShardDiff
22

3-
A cli tool to export all differences between two .win files.
3+
A cli tool to export differences between two .win files.
4+
5+
## What will I get from this tool ?
6+
7+
MSD will export in seperate files the following:
8+
- list of added and removed `Codes` in txt
9+
- list of added and removed `GameObjects` in txt
10+
- list of added and removed `Rooms` in txt
11+
- list of added and removed `Sounds` in txt
12+
- list of added and removed `Sprites` in txt
13+
- list of added and removed `TexturePageItems` in txt
14+
- added `Codes` in gml
15+
- added `GameObjects` in json
16+
- added `Sprites` in png
17+
- modified diff `Codes` in html
18+
- modified diff `GameObjects` in html
19+
- modified `Sprites` in png
20+
- list of modified `Sprites origin` in txt
21+
22+
The diff for `Codes` and `GameObjects` is made using the `diff-match-patch` lib, and the html export relies on this same [api](https://github.com/google/diff-match-patch/wiki/API#diff_prettyhtmldiffs--html).
23+
24+
## How can I install it?
25+
26+
1. Install the latest [.NET Core SDK](https://dot.net).
27+
2. Run `dotnet tool install --global ModShardDiff`.
28+
29+
## How can I use it?
30+
31+
#### Using the CLI:
32+
33+
To compare `data_modified.win` from `data_vanilla.win` and export the results in the folder `PATH/TO/EXPORT`, run `msd -n data_modified.win -r data_vanilla.win -o PATH/TO/EXPORT`.

0 commit comments

Comments
 (0)