Load shared save preview metadata

This commit is contained in:
gamer147
2026-07-24 17:05:13 -04:00
parent eff45f8dad
commit aba29b9078
7 changed files with 183 additions and 20 deletions

View File

@@ -101,12 +101,26 @@ public class SaveUiIntegrationTests
}
store.SaveNumberedThumbnail(
0, NumberedThumbnailCodec.Encode(new(112, 84, pixels)));
var authoredProfile = new SharedProfile();
authoredProfile.StoreString(0x000, "序章 封印、そして");
authoredProfile.StoreString(0x0d2, "base part-time job");
authoredProfile.StoreString(0x1a4, "Lily");
authoredProfile.StoreInteger(0x0d7, 80);
authoredProfile.StoreInteger(0x27b, 98);
authoredProfile.StoreInteger(0x34d, 69);
authoredProfile.StoreInteger(0x41f, 0);
authoredProfile.StoreInteger(0x4f1, 0b1011);
authoredProfile.Save(
store, new NativeSystemTime(2026, 7, 5, 24, 13, 42, 17, 321), 7_445);
var loadedProfile = new SharedProfile();
Assert.True(loadedProfile.Load(store));
var scripts = Sys4ScriptProvider.Load(Table);
var host = new StopAtFirstMenuPollHost();
var vm = new VirtualMachine(
scripts.RequireByName("SAVE.BIN"), Table, host,
new VmOptions(MaxSteps: 500_000), scripts,
sharedProfile: loadedProfile,
nativeDatStore: store);
Assert.Throws<MenuReadyException>(() => vm.Run());
@@ -118,6 +132,15 @@ public class SaveUiIntegrationTests
Assert.Contains(host.SurfaceStrings, item => item.Text == "07");
Assert.Contains(host.SurfaceStrings, item => item.Text == "24");
Assert.Contains(host.SurfaceStrings, item => item.Text == "13");
Assert.Contains(host.SurfaceStrings, item => item.Text == "序章 封印、そして");
Assert.Contains(host.SurfaceStrings, item => item.Text == "base part-time job");
Assert.Contains(host.SurfaceStrings, item => item.Text == "Lily");
var objects = vm.Gfx.SnapshotVisibleObjects().ToDictionary(item => item.Handle);
Assert.Equal((0, 96), (objects[0x13137].SrcX, objects[0x13138].SrcX)); // level 80
Assert.Equal((96, 108), (objects[0x13146].SrcX, objects[0x13147].SrcX)); // growth 98
Assert.Equal((108, 72), (objects[0x13155].SrcX, objects[0x13156].SrcX)); // personality 69
Assert.Equal(3, host.TextureDraws.Count(
item => item.Slot == 193 && item.Width == 17 && item.Height == 17));
}
finally
{
@@ -191,11 +214,15 @@ public class SaveUiIntegrationTests
[(0x2, Array.Empty<Operand>())], []), 0x00fefefd);
var provider = new SaveUiProvider(nativeScripts, null, loadCallback);
var host = new ClickFirstSlotHost();
var store = new DirectoryNativeDatStore(root, Identity);
var sharedProfile = new SharedProfile();
Assert.True(sharedProfile.Load(store));
var vm = new VirtualMachine(
nativeScripts.RequireByName("SAVE.BIN"), Table, host,
new VmOptions(MaxSteps: 1_000_000), provider,
new StopAtInstalledResumeSink(),
nativeDatStore: new DirectoryNativeDatStore(root, Identity));
sharedProfile: sharedProfile,
nativeDatStore: store);
host.Vm = vm;
vm.Globals[0x6241b] = 1;
vm.Globals[0x696] = 0;

View File

@@ -27,6 +27,8 @@ internal class RecordingHost : IHost
public readonly List<SurfaceRectFill> SurfaceFills = new();
public readonly List<SurfaceRectCopy> SurfaceCopies = new();
public readonly List<(long First, long Count)> PresentedRanges = new();
public readonly List<(int Slot, int SourceX, int SourceY, int Width, int Height, int X, int Y)>
TextureDraws = new();
public readonly List<AdvWaitIndicatorConfig> WaitIndicators = new();
public readonly List<bool> WaitIndicatorEnabledChanges = new();
public readonly List<int> PublishedAdvTextLayouts = new();
@@ -144,7 +146,8 @@ internal class RecordingHost : IHost
public void SetTexture(long resId, int slot) => Textures.Add((resId, slot));
public void ClearRenderTarget(int surfaceSlot) => ClearedRenderTargets.Add(surfaceSlot);
public void ReleaseSurfaceRange(int firstSlot, int count) => ReleasedSurfaceRanges.Add((firstSlot, count));
public void DrawTexture(int slot, int sx, int sy, int w, int h, int dx, int dy) { }
public void DrawTexture(int slot, int sx, int sy, int w, int h, int dx, int dy)
=> TextureDraws.Add((slot, sx, sy, w, h, dx, dy));
public (int Width, int Height) GetTextureSize(int slot) => (0, 0);
public void PlayBgm(long id) { }
public void PlayVoice(long id) => Voices.Add(id);