test(dev-save): 支持从测试归档恢复阶段存档
This commit is contained in:
@@ -131,7 +131,7 @@ namespace AibisDream
|
||||
{
|
||||
GUI.Label(
|
||||
new Rect(0f, y, MenuWidth - 32f, RowHeight),
|
||||
"(empty — promote saves first)",
|
||||
"(empty — run Test Mode or promote saves)",
|
||||
statusStyle);
|
||||
y += RowHeight;
|
||||
}
|
||||
@@ -442,6 +442,11 @@ namespace AibisDream
|
||||
|
||||
if (explicitEntries != null && explicitEntries.Count > 0 && root != null)
|
||||
{
|
||||
var latestTestArchives = BuildLatestTestArchiveIndex(
|
||||
expectedSceneName,
|
||||
expectedYarnProjectId,
|
||||
allowedNodes);
|
||||
|
||||
foreach (var entryDto in explicitEntries)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entryDto.path))
|
||||
@@ -462,6 +467,26 @@ namespace AibisDream
|
||||
allowedNodes);
|
||||
if (!entry.TryLoadSnapshot(out _, out var error))
|
||||
{
|
||||
if (error == "file missing"
|
||||
&& !string.IsNullOrWhiteSpace(entryDto.anchorNode)
|
||||
&& latestTestArchives.TryGetValue(entryDto.anchorNode, out var archiveSnapshot))
|
||||
{
|
||||
entry = new DevSaveEntry(
|
||||
label: string.IsNullOrWhiteSpace(entryDto.label)
|
||||
? entryDto.anchorNode
|
||||
: entryDto.label,
|
||||
snapshotPathWithoutExtension: archiveSnapshot,
|
||||
expectedSceneName,
|
||||
expectedYarnProjectId,
|
||||
allowedNodes);
|
||||
|
||||
if (entry.TryLoadSnapshot(out _, out _))
|
||||
{
|
||||
entries.Add(entry);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogWarning($"[DevSaveJumpTool] 跳过无效存档 {entryDto.path}: {error}");
|
||||
continue;
|
||||
}
|
||||
@@ -494,6 +519,44 @@ namespace AibisDream
|
||||
return new DevSaveSection(id, title, entries);
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> BuildLatestTestArchiveIndex(
|
||||
string expectedSceneName,
|
||||
string expectedYarnProjectId,
|
||||
List<string> allowedNodes)
|
||||
{
|
||||
var result = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
var savedAtByNode = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
var archiveRoot = ConstRef.TestAutoSaveArchivePath;
|
||||
if (!Directory.Exists(archiveRoot) || allowedNodes == null || allowedNodes.Count == 0)
|
||||
return result;
|
||||
|
||||
foreach (var archiveDir in Directory.GetDirectories(archiveRoot))
|
||||
{
|
||||
var snapshotPath = Path.Combine(archiveDir, ConstRef.SaveSnapshotFileName);
|
||||
var candidate = new DevSaveEntry(
|
||||
string.Empty,
|
||||
snapshotPath,
|
||||
expectedSceneName,
|
||||
expectedYarnProjectId,
|
||||
allowedNodes);
|
||||
if (!candidate.TryLoadSnapshot(out var snapshot, out _))
|
||||
continue;
|
||||
|
||||
var nodeName = snapshot.anchor.nodeName;
|
||||
var savedAt = snapshot.savedAt ?? string.Empty;
|
||||
if (savedAtByNode.TryGetValue(nodeName, out var currentSavedAt)
|
||||
&& string.CompareOrdinal(savedAt, currentSavedAt) <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
savedAtByNode[nodeName] = savedAt;
|
||||
result[nodeName] = snapshotPath;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string FormatFolderLabel(string folderName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(folderName))
|
||||
@@ -524,6 +587,7 @@ namespace AibisDream
|
||||
{
|
||||
public string label;
|
||||
public string path;
|
||||
public string anchorNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user