diff --git a/src/Ryujinx/Common/SplashTextHelper.cs b/src/Ryujinx/Common/SplashTextHelper.cs index 9889a225d..e15ec1a27 100644 --- a/src/Ryujinx/Common/SplashTextHelper.cs +++ b/src/Ryujinx/Common/SplashTextHelper.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using Ryujinx.Common.Logging; using Gommon; using Ryujinx.Ava.Systems.Configuration; -using System; using System.Text.Json; namespace Ryujinx.Common @@ -11,47 +10,48 @@ namespace Ryujinx.Common { public static void PrintSplash() { + string splash = GetSplash(); + Logger.Notice.Print(LogClass.Application, " ___ __ _ "); Logger.Notice.Print(LogClass.Application, @" / _ \ __ __ __ __ / / (_) ___ ___ _"); Logger.Notice.Print(LogClass.Application, @" / , _/ / // // // / / _ \ / / / _ \ / _ `/"); Logger.Notice.Print(LogClass.Application, @"/_/|_| \_, / \_,_/ /_.__//_/ /_//_/ \_, / "); Logger.Notice.Print(LogClass.Application, " /___/ /___/ "); - Logger.Notice.Print(LogClass.Application, ""); - Logger.Notice.Print(LogClass.Application, GetSplash()); - Logger.Notice.Print(LogClass.Application, ""); + + if (splash is null) + { + Logger.Error?.Print(LogClass.Application, "Failed to fetch Splash Text! Splash JSON is invalid!"); + return; + } + + if (!splash.IsNullOrEmpty()) + { + Logger.Notice.Print(LogClass.Application, ""); + Logger.Notice.Print(LogClass.Application, splash); + Logger.Notice.Print(LogClass.Application, ""); + } } - private static string s_finalSplash = ""; + private static string _finalSplash; public static string GetSplash() { - if (string.IsNullOrEmpty(s_finalSplash)) + if (_finalSplash is null) { - s_finalSplash = GetLangJson(); - if (string.IsNullOrEmpty(s_finalSplash)) + try { - s_finalSplash = "Splash Text"; + string data; + data = EmbeddedResources.ReadAllText("Ryujinx/Assets/Splashes.json"); + SplashLocales splashJson = JsonSerializer.Deserialize(data); + _finalSplash = splashJson.Locales[ConfigurationState.Instance.UI.LanguageCode.Value].GetRandomElement() ?? ""; + } + catch + { + return null; } } - - return $"{s_finalSplash}"; - } - - private static SplashLocales s_splashJson; - - private static string GetLangJson() - { - try - { - string data; - data = EmbeddedResources.ReadAllText("Ryujinx/Assets/Splashes.json"); - s_splashJson = JsonSerializer.Deserialize(data); - return s_splashJson.Locales[ConfigurationState.Instance.UI.LanguageCode.Value].GetRandomElement(); - } - catch - { - return ""; - } + + return _finalSplash; } private struct SplashLocales diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index 66cb28fab..f71c3e908 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -1260,7 +1260,13 @@ namespace Ryujinx.Ava.UI.ViewModels break; case ShaderCacheLoadingState shaderCacheState: CacheLoadStatus = $"{current} / {total}"; - Splash = $"\"{SplashTextHelper.GetSplash()}\""; + + string splash = SplashTextHelper.GetSplash(); + + if (!splash.IsNullOrEmpty()) + { + Splash = $"\"{splash}\""; + } switch (shaderCacheState) { case ShaderCacheLoadingState.Start: