add metadata during create operations

for layout and blockmap
This commit is contained in:
haven1433 2022-10-28 17:29:34 -05:00
parent 19c15d96ed
commit 130e9f1eb8
3 changed files with 10 additions and 9 deletions

View File

@ -40,10 +40,12 @@ namespace HexManiac.Core.Models.Runs.Sprites {
public BlockmapRun(IDataModel model, int start, SortedSpan<int> sources, int width = -1, int height = -1) : base(start, sources) {
this.model = model;
var primarySource = sources[0];
var layoutStart = primarySource - 12;
if (width == -1) width = model.ReadValue(layoutStart);
if (height == -1) height = model.ReadValue(layoutStart + 4);
if (sources != null && sources.Count > 0) {
var primarySource = sources[0];
var layoutStart = primarySource - 12;
if (width == -1) width = model.ReadValue(layoutStart);
if (height == -1) height = model.ReadValue(layoutStart + 4);
}
(BlockWidth, BlockHeight) = (width, height);
var code = model.GetGameCode();

View File

@ -1049,16 +1049,12 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
model.WriteValue(token, layoutStart + 0, width);
model.WriteValue(token, layoutStart + 4, height);
// TODO update border block (layoutStart + 8)
// update blockmap (layoutStart + 12)
WritePointerAndSource(token, layoutStart + 12, MapRepointer.CreateNewBlockMap(token, width, height));
// TODO update primary blockset (layoutStart + 16)
// TODO update primary blockset (layoutStart + 20)
WritePointerAndSource(token, address + 0, layoutStart);
model.UpdateArrayPointer(token, null, null, -1, mapTable.Start + mapTable.Length - 4, address);
var otherMap = new BlockMapViewModel(fileSystem, viewPort, format, bank, mapTable.ElementCount - 1) { allOverworldSprites = allOverworldSprites };
otherMap.UpdateLayoutID();
return otherMap;

View File

@ -587,6 +587,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
model.WriteValue(token, layoutStart + 25, myLayout.GetValue(Format.BorderHeight));
model.WriteMultiByteValue(layoutStart + 26, 2, token, 0);
}
if (ArrayRun.TryParse(model, format.LayoutFormat, layoutStart, SortedSpan<int>.None, out var run) == ErrorInfo.NoError) model.ObserveRunWritten(token, run);
return layoutStart;
}
@ -594,6 +595,8 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
var blockmapLength = width * height * 2;
var blockmapStart = model.FindFreeSpace(model.FreeSpaceStart, blockmapLength);
token.ChangeData(model, blockmapStart, new byte[blockmapLength]);
var run = new BlockmapRun(model, blockmapStart, SortedSpan<int>.None, width, height);
model.ObserveRunWritten(token, run);
return blockmapStart;
}