Replays: final boss (#17621)
* Replays: final boss * Undo formatting change in EntryPoint
This commit is contained in:
committed by
GitHub
parent
204f6ca5c2
commit
bbd8ce8885
@@ -1,3 +1,4 @@
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using Content.Client.Message;
|
||||
using Content.Client.UserInterface.Systems.EscapeMenu;
|
||||
@@ -13,7 +14,7 @@ using Robust.Shared.Configuration;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.Serialization.Markdown.Value;
|
||||
using Robust.Shared.Utility;
|
||||
using static Robust.Shared.Replays.IReplayRecordingManager;
|
||||
using static Robust.Shared.Replays.ReplayConstants;
|
||||
|
||||
namespace Content.Replay.Menu;
|
||||
|
||||
@@ -71,8 +72,10 @@ public sealed class ReplayMainScreen : State
|
||||
return;
|
||||
}
|
||||
|
||||
using var fileReader = new ReplayFileReaderZip(
|
||||
new ZipArchive(_resMan.UserData.OpenRead(replay)), ReplayZipFolder);
|
||||
if (!_resMan.UserData.Exists(replay)
|
||||
|| _loadMan.LoadYamlMetadata(_resMan.UserData, replay) is not { } data)
|
||||
|| _loadMan.LoadYamlMetadata(fileReader) is not { } data)
|
||||
{
|
||||
info.SetMarkup(Loc.GetString("replay-info-invalid"));
|
||||
info.HorizontalAlignment = Control.HAlignment.Center;
|
||||
@@ -82,16 +85,16 @@ public sealed class ReplayMainScreen : State
|
||||
}
|
||||
|
||||
var file = replay.ToRelativePath().ToString();
|
||||
data.TryGet<ValueDataNode>(Time, out var timeNode);
|
||||
data.TryGet<ValueDataNode>(Duration, out var durationNode);
|
||||
data.TryGet<ValueDataNode>(MetaKeyTime, out var timeNode);
|
||||
data.TryGet<ValueDataNode>(MetaFinalKeyDuration, out var durationNode);
|
||||
data.TryGet<ValueDataNode>("roundId", out var roundIdNode);
|
||||
data.TryGet<ValueDataNode>(Hash, out var hashNode);
|
||||
data.TryGet<ValueDataNode>(CompHash, out var compHashNode);
|
||||
data.TryGet<ValueDataNode>(MetaKeyTypeHash, out var hashNode);
|
||||
data.TryGet<ValueDataNode>(MetaKeyComponentHash, out var compHashNode);
|
||||
DateTime.TryParse(timeNode?.Value, out var time);
|
||||
TimeSpan.TryParse(durationNode?.Value, out var duration);
|
||||
|
||||
var forkId = string.Empty;
|
||||
if (data.TryGet<ValueDataNode>(Fork, out var forkNode))
|
||||
if (data.TryGet<ValueDataNode>(MetaKeyForkId, out var forkNode))
|
||||
{
|
||||
// TODO Replay client build info.
|
||||
// When distributing the client we need to distribute a build.json or provide these cvars some other way?
|
||||
@@ -105,7 +108,7 @@ public sealed class ReplayMainScreen : State
|
||||
}
|
||||
|
||||
var forkVersion = string.Empty;
|
||||
if (data.TryGet<ValueDataNode>(ForkVersion, out var versionNode))
|
||||
if (data.TryGet<ValueDataNode>(MetaKeyForkVersion, out var versionNode))
|
||||
{
|
||||
forkVersion = versionNode.Value;
|
||||
// Why does this not have a try-convert function? I just want to check if it looks like a hash code.
|
||||
@@ -162,7 +165,7 @@ public sealed class ReplayMainScreen : State
|
||||
}
|
||||
|
||||
var engineVersion = string.Empty;
|
||||
if (data.TryGet<ValueDataNode>(Engine, out var engineNode))
|
||||
if (data.TryGet<ValueDataNode>(MetaKeyEngineVersion, out var engineNode))
|
||||
{
|
||||
var clientVer = _cfg.GetCVar(CVars.BuildEngineVersion);
|
||||
if (string.IsNullOrWhiteSpace(clientVer))
|
||||
@@ -176,7 +179,7 @@ public sealed class ReplayMainScreen : State
|
||||
// Strip milliseconds. Apparently there is no general format string that suppresses milliseconds.
|
||||
duration = new((int)Math.Floor(duration.TotalDays), duration.Hours, duration.Minutes, duration.Seconds);
|
||||
|
||||
data.TryGet<ValueDataNode>(Name, out var nameNode);
|
||||
data.TryGet<ValueDataNode>(MetaKeyName, out var nameNode);
|
||||
var name = nameNode?.Value ?? string.Empty;
|
||||
|
||||
info.HorizontalAlignment = Control.HAlignment.Left;
|
||||
@@ -205,7 +208,11 @@ public sealed class ReplayMainScreen : State
|
||||
private void OnLoadpressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_selected.HasValue)
|
||||
_loadMan.LoadAndStartReplay(_resMan.UserData, _selected.Value);
|
||||
{
|
||||
var fileReader = new ReplayFileReaderZip(
|
||||
new ZipArchive(_resMan.UserData.OpenRead(_selected.Value)), ReplayZipFolder);
|
||||
_loadMan.LoadAndStartReplay(fileReader);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshReplays()
|
||||
@@ -217,11 +224,14 @@ public sealed class ReplayMainScreen : State
|
||||
var file = _directory / entry;
|
||||
try
|
||||
{
|
||||
var data = _loadMan.LoadYamlMetadata(_resMan.UserData, file);
|
||||
using var fileReader = new ReplayFileReaderZip(
|
||||
new ZipArchive(_resMan.UserData.OpenRead(file)), ReplayZipFolder);
|
||||
|
||||
var data = _loadMan.LoadYamlMetadata(fileReader);
|
||||
if (data == null)
|
||||
continue;
|
||||
|
||||
var name = data.Get<ValueDataNode>(Name).Value;
|
||||
var name = data.Get<ValueDataNode>(MetaKeyName).Value;
|
||||
_replays.Add((name, file));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user