Revert "Улучшена обработка фоновой загрузки ресурсов в лобби: добавлен контроль версий фона для предотвращения применения устаревших результатов загрузки."
This reverts commit 62fb6bada4.
This commit is contained in:
parent
8e9f2e5749
commit
7a18716b8a
2 changed files with 6 additions and 60 deletions
|
|
@ -70,11 +70,6 @@ namespace Content.Client.Lobby
|
|||
private ResPath? _currentAnimationPath;
|
||||
private ResPath? _currentArtPath;
|
||||
|
||||
// Используется для «мягкой отмены» фоновых загрузок (арт / анимация / параллакс).
|
||||
// При каждом запуске новой загрузки увеличиваем версию и перед применением результата
|
||||
// проверяем, что версия всё ещё совпадает (иначе результат игнорируем).
|
||||
private int _backgroundLoadVersion = 0;
|
||||
|
||||
private const string LoadingRsiPath = "/Textures/_Sunrise/loading.rsi";
|
||||
private const string LoadingState = "loading";
|
||||
|
||||
|
|
@ -446,8 +441,6 @@ namespace Content.Client.Lobby
|
|||
lobbyBackgroundTypeString = default;
|
||||
}
|
||||
|
||||
_backgroundLoadVersion++;
|
||||
|
||||
// Lobby may be null during reconnection or before initialization
|
||||
// This is normal, just return silently - the background will be set when Lobby is initialized
|
||||
if (Lobby == null)
|
||||
|
|
@ -514,8 +507,6 @@ namespace Content.Client.Lobby
|
|||
|
||||
private void SetLobbyAnimation(string lobbyAnimation)
|
||||
{
|
||||
var loadVersion = _backgroundLoadVersion;
|
||||
|
||||
// Check if animation background type is currently selected
|
||||
var backgroundType = _cfg.GetCVar(SunriseCCVars.LobbyBackgroundType);
|
||||
if (backgroundType == "Random" && _gameTicker.LobbyType != null)
|
||||
|
|
@ -541,12 +532,6 @@ namespace Content.Client.Lobby
|
|||
return;
|
||||
}
|
||||
|
||||
if (loadVersion != _backgroundLoadVersion)
|
||||
{
|
||||
_sawmill.Debug("SetLobbyAnimation aborted due to background load version change");
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide old animation and show loading animation immediately (before any resource checks)
|
||||
Lobby!.LobbyAnimation.Visible = false;
|
||||
ShowLoadingAnimation();
|
||||
|
|
@ -658,11 +643,11 @@ namespace Content.Client.Lobby
|
|||
{
|
||||
// First try to get from cache
|
||||
bool fromCache = _resourceCache.TryGetResource<RSIResource>(targetPath, out rsiResource);
|
||||
|
||||
|
||||
if (fromCache && rsiResource != null)
|
||||
{
|
||||
_sawmill.Debug($"RSI resource found in cache: {targetPath}");
|
||||
|
||||
|
||||
// Verify that cached resource is still valid by checking if the state exists
|
||||
// This is important after reconnection when files in VFS may have been cleared
|
||||
if (!rsiResource.RSI.TryGetState(requiredState, out _))
|
||||
|
|
@ -673,7 +658,7 @@ namespace Content.Client.Lobby
|
|||
rsiResource = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!fromCache)
|
||||
{
|
||||
_sawmill.Debug($"RSI resource not in cache or invalid, attempting to load: {targetPath}");
|
||||
|
|
@ -698,12 +683,6 @@ namespace Content.Client.Lobby
|
|||
return;
|
||||
}
|
||||
|
||||
if (loadVersion != _backgroundLoadVersion)
|
||||
{
|
||||
_sawmill.Debug("SetLobbyAnimation result ignored due to background load version change");
|
||||
return;
|
||||
}
|
||||
|
||||
// Final verification that the resource actually loaded correctly by checking if the state exists
|
||||
if (rsiResource == null || !rsiResource.RSI.TryGetState(requiredState, out _))
|
||||
{
|
||||
|
|
@ -733,7 +712,6 @@ namespace Content.Client.Lobby
|
|||
|
||||
private void SetLobbyArt(string lobbyArt)
|
||||
{
|
||||
var loadVersion = _backgroundLoadVersion;
|
||||
// Check if art background type is currently selected
|
||||
var backgroundType = _cfg.GetCVar(SunriseCCVars.LobbyBackgroundType);
|
||||
if (backgroundType == "Random" && _gameTicker.LobbyType != null)
|
||||
|
|
@ -759,12 +737,6 @@ namespace Content.Client.Lobby
|
|||
return;
|
||||
}
|
||||
|
||||
if (loadVersion != _backgroundLoadVersion)
|
||||
{
|
||||
_sawmill.Debug("SetLobbyArt aborted due to background load version change");
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide old art and show loading animation immediately
|
||||
Lobby!.LobbyArt.Visible = false;
|
||||
ShowLoadingAnimation();
|
||||
|
|
@ -807,12 +779,6 @@ namespace Content.Client.Lobby
|
|||
// Try to set the art, handle errors gracefully
|
||||
try
|
||||
{
|
||||
if (loadVersion != _backgroundLoadVersion)
|
||||
{
|
||||
_sawmill.Debug("SetLobbyArt result ignored due to background load version change");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_resourceCache.TryGetResource<TextureResource>(targetPath, out var textureResource))
|
||||
{
|
||||
Lobby!.LobbyArt.Texture = textureResource.Texture;
|
||||
|
|
@ -834,7 +800,6 @@ namespace Content.Client.Lobby
|
|||
|
||||
private void SetLobbyParallax(string lobbyParallax)
|
||||
{
|
||||
var loadVersion = _backgroundLoadVersion;
|
||||
// Check if parallax background type is currently selected
|
||||
var backgroundType = _cfg.GetCVar(SunriseCCVars.LobbyBackgroundType);
|
||||
if (backgroundType == "Random" && _gameTicker.LobbyType != null)
|
||||
|
|
@ -860,24 +825,12 @@ namespace Content.Client.Lobby
|
|||
return;
|
||||
}
|
||||
|
||||
if (loadVersion != _backgroundLoadVersion)
|
||||
{
|
||||
_sawmill.Debug("SetLobbyParallax aborted due to background load version change");
|
||||
return;
|
||||
}
|
||||
|
||||
// Show loading animation for parallax (it may load network textures)
|
||||
ShowLoadingAnimation();
|
||||
|
||||
// Subscribe to resource loaded events to hide loading animation when parallax textures are ready
|
||||
void OnParallaxResourceLoaded(string resourcePath)
|
||||
{
|
||||
if (loadVersion != _backgroundLoadVersion)
|
||||
{
|
||||
_netTexturesManager.ResourceLoaded -= OnParallaxResourceLoaded;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if parallax is loaded
|
||||
if (_parallaxManager.IsLoaded(lobbyParallaxPrototype.Parallax))
|
||||
{
|
||||
|
|
@ -890,12 +843,7 @@ namespace Content.Client.Lobby
|
|||
|
||||
_parallaxManager.LoadParallaxByName(lobbyParallaxPrototype.Parallax).ContinueWith(task =>
|
||||
{
|
||||
if (loadVersion != _backgroundLoadVersion)
|
||||
{
|
||||
_netTexturesManager.ResourceLoaded -= OnParallaxResourceLoaded;
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide loading animation when parallax loading completes
|
||||
if (Lobby != null && _parallaxManager.IsLoaded(lobbyParallaxPrototype.Parallax))
|
||||
{
|
||||
_netTexturesManager.ResourceLoaded -= OnParallaxResourceLoaded;
|
||||
|
|
|
|||
|
|
@ -44,14 +44,12 @@
|
|||
Name="LoadingAnimationContainer"
|
||||
Orientation="Vertical"
|
||||
VerticalAlignment="Center"
|
||||
Visible="False"
|
||||
MouseFilter="Pass">
|
||||
Visible="False">
|
||||
<AnimatedTextureRect
|
||||
Access="Public"
|
||||
HorizontalAlignment="Center"
|
||||
Name="LoadingAnimation"
|
||||
VerticalAlignment="Center"
|
||||
MouseFilter="Pass" />
|
||||
VerticalAlignment="Center" />
|
||||
</BoxContainer>
|
||||
<BoxContainer
|
||||
HorizontalAlignment="Left"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue