Skip to content

Commit

Permalink
- Bug fix: Animated profile pictures were still displayed when switch…
Browse files Browse the repository at this point in the history
…ing to a profile without a set profile picture

- Bug fix: Steam shortcut ignores now entries with same name, when it was not created by the gamevault app
  • Loading branch information
Yelo420 committed Dec 16, 2024
1 parent cd0d317 commit 883636c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Recommended Gamevault Server Version: `v13.1.2`
- Bug fix: Crash on Media Slider navigation
- Bug fix: Crash on create shortcut after installation
- Bug fix: Prevent the message copy button from taking focus away from the current control
- Bug fix: Animated profile pictures were still displayed when switching to a profile without a set profile picture

## 1.13.1
Recommended Gamevault Server Version: `v13.1.0`
Expand Down
1 change: 1 addition & 0 deletions gamevault/Helper/CacheHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ internal static async Task LoadImageCacheToUIAsync(int identifier, int imageId,
}
}
catch { }
img.BeginAnimation(System.Windows.Controls.Image.SourceProperty, null);//Make sure all animations are removed, so a non animated image can be set to the source
img.Source = GetReplacementImage(cacheType);
}
}
Expand Down
28 changes: 17 additions & 11 deletions gamevault/Helper/Integrations/SteamHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ await Task.Run(async () =>
VdfMap shortcutFileMap = null;
string shortcutFile = Path.Combine(shortcutsDirectory, "shortcuts.vdf");
List<string> steamGridImageIDsToRemove = null;
Dictionary<Game, uint> steamGridGamesToAdd = new Dictionary<Game, uint>();
if (File.Exists(shortcutFile))
{
try
Expand All @@ -261,7 +262,7 @@ await Task.Run(async () =>
{
File.Create(shortcutFile).Close();
}
shortcutFileMap = AddGamesToShortcuts(shortcutFileMap, games, shortcutsDirectory);
shortcutFileMap = AddGamesToShortcuts(shortcutFileMap, games, shortcutsDirectory, steamGridGamesToAdd);

VdfMap root = new VdfMap();
root.Add("shortcuts", shortcutFileMap);//Adds back the first offset entry a vdf file needs to work
Expand All @@ -280,9 +281,9 @@ await Task.Run(async () =>
RemoveSteamGridImages(steamGridDirectory, steamGridImageToRemove);
}
}
foreach (KeyValuePair<Game, string> steamGridGame in games)
foreach (KeyValuePair<Game, uint> steamGridGame in steamGridGamesToAdd)
{
uint steamGridID = (uint)((VdfMap)shortcutFileMap.First(x => ((VdfMap)x.Value).ElementAt(1).Value.ToString() == steamGridGame.Key.Title).Value).ElementAt(0).Value;
uint steamGridID = steamGridGame.Value;
await CacheHelper.EnsureImageCacheForGame(steamGridGame.Key);
SetSteamGridImages(steamGridDirectory, steamGridGame.Key, steamGridID);
}
Expand Down Expand Up @@ -364,7 +365,7 @@ private static VdfMap RemoveUninstalledGames(VdfMap shortcutFileMap, Dictionary<
string currentGameExe = ((VdfMap)shortcutFileMap.Values.ElementAt(count)).ElementAt(2).Value.ToString();
string currentGameTitle = ((VdfMap)shortcutFileMap.Values.ElementAt(count)).ElementAt(1).Value.ToString();
//Check for gamevault protocol
if (currentGameExe.Contains("gamevault://", StringComparison.OrdinalIgnoreCase) && !games.Keys.Any(g => g?.Title == currentGameTitle))
if (currentGameExe!.Contains("gamevault://", StringComparison.OrdinalIgnoreCase) && !games.Keys.Any(g => g?.Title == currentGameTitle))
{
steamGridImagesToRemove.Add(((VdfMap)shortcutFileMap.Values.ElementAt(count)).ElementAt(0).Value.ToString());
shortcutFileMap.Remove(shortcutFileMap.ElementAt(count).Key);
Expand All @@ -373,7 +374,7 @@ private static VdfMap RemoveUninstalledGames(VdfMap shortcutFileMap, Dictionary<
}
return shortcutFileMap;
}
private static VdfMap AddGamesToShortcuts(VdfMap shortcutFileMap, Dictionary<Game, string> games, string shortcutDir)
private static VdfMap AddGamesToShortcuts(VdfMap shortcutFileMap, Dictionary<Game, string> games, string shortcutDir, Dictionary<Game, uint> steamGridGamesToAdd)
{
if (shortcutFileMap == null)
{
Expand All @@ -382,16 +383,17 @@ private static VdfMap AddGamesToShortcuts(VdfMap shortcutFileMap, Dictionary<Gam
int indexCount = shortcutFileMap.Count;
foreach (KeyValuePair<Game, string> game in games)
{
VdfMap newGameMap = GenerateVdfShortcutEntryFromGame(game.Key, shortcutDir);
VdfMap newGameMap = GenerateVdfShortcutEntryFromGame(game.Key, shortcutDir, steamGridGamesToAdd);
shortcutFileMap.Add(indexCount.ToString(), newGameMap);
indexCount++;
}
return shortcutFileMap;
}
private static VdfMap GenerateVdfShortcutEntryFromGame(Game game, string shortcutDir)
private static VdfMap GenerateVdfShortcutEntryFromGame(Game game, string shortcutDir, Dictionary<Game, uint> steamGridGamesToAdd)
{
string idInput = game.Title + game.ID;
uint steamGridId = VdfUtilities.GenerateSteamGridID(idInput);
steamGridGamesToAdd.Add(game, steamGridId);
string steamGridIconPath = Path.Combine(shortcutDir, "grid", $"{steamGridId}p.png");
string launchUrl = $"gamevault://start?gameid={game.ID}";
var newGame = new VdfMap
Expand Down Expand Up @@ -428,11 +430,15 @@ private static Dictionary<Game, string> TrimExistingGames(Dictionary<Game, strin
{
for (int count = 0; count < shortcutFileMap.Values.Count; count++)
{
string shortcutAppName = ((VdfMap)shortcutFileMap.Values.ElementAt(count)).ElementAt(1).Value as string;
KeyValuePair<Game, string> foundGame = games.Where(g => g.Key.Title == shortcutAppName).FirstOrDefault();
if (foundGame.Key != null)
string currentGameExe = ((VdfMap)shortcutFileMap.Values.ElementAt(count)).ElementAt(2).Value.ToString();
if (currentGameExe!.Contains("gamevault://", StringComparison.OrdinalIgnoreCase))
{
games.Remove(foundGame.Key);
string shortcutAppName = ((VdfMap)shortcutFileMap.Values.ElementAt(count)).ElementAt(1).Value as string;
KeyValuePair<Game, string> foundGame = games.Where(g => g.Key.Title == shortcutAppName).FirstOrDefault();
if (foundGame.Key != null)
{
games.Remove(foundGame.Key);
}
}
}
return games;
Expand Down

0 comments on commit 883636c

Please sign in to comment.