From 97aed15d19b5aa70ad54fec597e9bc90b45c82a1 Mon Sep 17 00:00:00 2001 From: awesomeangotti Date: Fri, 3 Jul 2026 22:42:38 +0000 Subject: [PATCH] UI: Five minute coding adventure gone wrong (Fixing splashes) (#160) With help from LotP I added error logging and made some minor adjustments to the display of splash text in cases where there was no splash to display. Thanks for dealing with my shenanigans LotP. Reviewed-on: https://git.ryujinx.app/projects/Ryubing/pulls/160 --- src/Ryujinx/Common/SplashTextHelper.cs | 56 +++++++++---------- .../UI/ViewModels/MainWindowViewModel.cs | 8 ++- 2 files changed, 35 insertions(+), 29 deletions(-) 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: