Revert "Не должно ебануть (#170)"

This reverts commit aabdcec60c.
This commit is contained in:
BIGZi0348
2024-11-12 20:48:25 +03:00
parent aabdcec60c
commit 55fe86dde4
70 changed files with 186 additions and 1097 deletions

View File

@@ -1,8 +1,10 @@
using System.IO.Compression;
using Content.Client.Administration.Managers;
using Content.Client.Launcher;
using Content.Client.MainMenu;
using Content.Client.Replay.Spectator;
using Content.Client.Replay.UI.Loading;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Systems.Chat;
using Content.Shared.Chat;
using Content.Shared.Effects;
@@ -24,6 +26,8 @@ using Robust.Client.Replays.Playback;
using Robust.Client.State;
using Robust.Client.Timing;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
@@ -56,7 +60,7 @@ public sealed class ContentReplayPlaybackManager
public bool IsScreenshotMode = false;
private bool _initialized;
/// <summary>
/// Most recently loaded file, for re-attempting the load with error tolerance.
/// Required because the zip reader auto-disposes and I'm too lazy to change it so that
@@ -92,18 +96,32 @@ public sealed class ContentReplayPlaybackManager
return;
}
if (_client.RunLevel == ClientRunLevel.SinglePlayerGame)
_client.StopSinglePlayer();
ReturnToDefaultState();
Action? retryAction = null;
Action? cancelAction = null;
// Show a popup window with the error message
var text = Loc.GetString("replay-loading-failed", ("reason", exception));
var box = new BoxContainer
{
Orientation = BoxContainer.LayoutOrientation.Vertical,
Children = {new Label {Text = text}}
};
var popup = new DefaultWindow { Title = "Error!" };
popup.Contents.AddChild(box);
// Add button for attempting to re-load the replay while ignoring some errors.
if (!_cfg.GetCVar(CVars.ReplayIgnoreErrors) && LastLoad is { } last)
if (!_cfg.GetCVar(CVars.ReplayIgnoreErrors) && LastLoad is {} last)
{
retryAction = () =>
var button = new Button
{
Text = Loc.GetString("replay-loading-retry"),
StyleClasses = { StyleBase.ButtonCaution }
};
button.OnPressed += _ =>
{
_cfg.SetCVar(CVars.ReplayIgnoreErrors, true);
popup.Dispose();
IReplayFileReader reader = last.Zip == null
? new ReplayFileReaderResources(_resMan, last.Folder)
@@ -111,19 +129,11 @@ public sealed class ContentReplayPlaybackManager
_loadMan.LoadAndStartReplay(reader);
};
box.AddChild(button);
}
// If we have an explicit menu to get back to (e.g. replay browser UI), show a cancel button.
if (DefaultState != null)
{
cancelAction = () =>
{
_stateMan.RequestStateChange(DefaultState);
};
}
// Switch to a new game state to present the error and cancel/retry options.
var state = _stateMan.RequestStateChange<ReplayLoadingFailed>();
state.SetData(exception, cancelAction, retryAction);
popup.OpenCentered();
}
public void ReturnToDefaultState()