Skip to content

Commit

Permalink
Use last background downloaded for that region for temporary poster i…
Browse files Browse the repository at this point in the history
…nstead
  • Loading branch information
bagusnl committed Nov 22, 2024
1 parent 425be6d commit 1147f9b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion CollapseLauncher/Classes/RegionManagement/RegionManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,24 @@ private async Task DownloadBackgroundImage(CancellationToken Token)
return;
}

#nullable enable
string? tempImage = null;
var lastBgCfg = "lastBg-" + LauncherMetadataHelper.CurrentMetadataConfig.GameLauncherApi.GameName +
"-" + LauncherMetadataHelper.CurrentMetadataConfig.GameLauncherApi.GameRegion;

// Check if the last background image exist, then use that temporarily instead
var lastGameBackground = GetAppConfigValue(lastBgCfg).ToString();
if (!string.IsNullOrEmpty(lastGameBackground))
{
if (File.Exists(lastGameBackground))
{
tempImage = lastGameBackground;
}
}

// If the file is not downloaded, use template image first, then download the image
var currentGameType = GamePropertyVault.GetCurrentGameProperty()._GameVersion.GameType;
var tempImage = currentGameType switch
tempImage ??= currentGameType switch
{
GameNameType.Honkai => Path.Combine(AppFolder, @"Assets\Images\GamePoster\poster_honkai.png"),
GameNameType.Genshin => Path.Combine(AppFolder, @"Assets\Images\GamePoster\poster_genshin.png"),
Expand All @@ -206,6 +221,8 @@ await ImageLoaderHelper.TryDownloadToCompleteness(
IsFirstStartup = false;
ColorPaletteUtility.ReloadPageTheme(this, CurrentAppTheme);
}, false, true, true);
SetAndSaveConfigValue(lastBgCfg, imgFileInfo.FullName);
#nullable disable
}

private async ValueTask FinalizeLoadRegion(string gameName, string gameRegion)
Expand Down

0 comments on commit 1147f9b

Please sign in to comment.