fix tileset expander issues

* display the name 'tileset' instead of 'blockset' in the comment
* fix bug in calculating the number of tiles currently in a tileset
This commit is contained in:
haven1433 2023-01-08 21:18:40 -06:00
parent 8dbe4f4550
commit 74d35fc274
3 changed files with 15 additions and 4 deletions

View File

@ -451,7 +451,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
public string ExpandPrimaryTilesetText {
get {
var (currentCount, maxCount) = EstimateTileCount(GetLayout().GetSubTable(Format.PrimaryBlockset)[0]);
return $"This primary blockset contains {currentCount} of {maxCount} tiles.";
return $"This primary tileset contains {currentCount} of {maxCount} tiles.";
}
}
@ -462,7 +462,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
public string ExpandSecondaryTilesetText {
get {
var (currentCount, maxCount) = EstimateTileCount(GetLayout().GetSubTable(Format.SecondaryBlockset)[0]);
return $"This secondary blockset contains {currentCount} of {maxCount} tiles.";
return $"This secondary tileset contains {currentCount} of {maxCount} tiles.";
}
}
@ -503,7 +503,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
if (blockset.GetValue("isSecondary") != 0) maxTiles = 1024 - maxTiles;
int currentTiles = maxTiles;
var tilesetAddress = blockset.GetAddress(Format.Tileset);
if (blockset.GetValue("isCompressed") != 0) {
if (blockset.GetValue("isCompressed") == 0) {
BlocksetModel.EstimateTileCount(model, ref currentTiles, tilesetAddress);
} else {
var run = new LZRun(model, tilesetAddress);

View File

@ -19,7 +19,7 @@ namespace HavenSoft.HexManiac.Integration {
static IntegrationTests() {
lazyFireRed = new Lazy<ViewPort>(() => {
var model = new HardcodeTablesModel(singletons, File.ReadAllBytes(fireredName), new StoredMetadata(new string[0]));
return new ViewPort(fireredName, model, InstantDispatch.Instance, singletons);
return new ViewPort(fireredName, model, InstantDispatch.Instance, singletons, new(), new StubFileSystem());
});
}

View File

@ -18,5 +18,16 @@ namespace HavenSoft.HexManiac.Integration {
var forest = firered.Model.GetTableModel("data.maps.banks/1/maps/0/map/");
Assert.Equal(1, forest[0].GetSubTable("connections")[0].GetValue("count"));
}
[SkippableFact]
public void MapRepointer_ExpandPrimaryTilesetText_HasMaxTiles() {
var firered = LoadReadOnlyFireRed();
firered.Goto.Execute("maps.3-0 Palette Town");
var repointer = firered.MapEditor.PrimaryMap.MapRepointer;
var text = repointer.ExpandPrimaryTilesetText;
Assert.Equal("This primary tileset contains 640 of 640 tiles.", text);
}
}
}