Skip to content

Commit

Permalink
* Fix incorrectly enabled ComboBox for DLL types in configuration view
Browse files Browse the repository at this point in the history
* Fix AsyncFileWatcher not correctly removing removed games
  • Loading branch information
Drommedhar committed Sep 30, 2024
1 parent 859f8ba commit 00170af
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 38 deletions.
4 changes: 2 additions & 2 deletions DlssUpdater/DLSSUpdater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>x64</Platforms>
<FileVersion>1.0.5.0</FileVersion>
<FileVersion>1.0.5.1</FileVersion>
<SelfContained>true</SelfContained>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<SignAssembly>False</SignAssembly>
<AssemblyVersion>1.0.5.0</AssemblyVersion>
<AssemblyVersion>1.0.5.1</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand Down
19 changes: 18 additions & 1 deletion DlssUpdater/Defines/GameInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace DlssUpdater.Defines;

public partial class GameInfo : ObservableObject
public partial class GameInfo : ObservableObject, IEquatable<GameInfo>
{
public string UniqueId { get; set; }
[ObservableProperty] [JsonIgnore] public ImageSource? _gameImage;
Expand Down Expand Up @@ -129,6 +129,23 @@ public void SetGameImageUri(string imageUri)
TextVisible = Visibility.Visible;
}
}

public bool Equals(GameInfo? other)
{
return UniqueId == other?.UniqueId;
}

public override bool Equals(object? obj)
{
if (obj == null)
return false;
return Equals(obj as GameInfo);
}

public override int GetHashCode()
{
return HashCode.Combine(UniqueId);
}
}

public class GameConvert : JsonConverter<GameInfo>
Expand Down
49 changes: 19 additions & 30 deletions DlssUpdater/Singletons/AsyncFileWatcher.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

using DlssUpdater.Defines;
using DlssUpdater.Singletons;
using System.Collections.Concurrent;

namespace DLSSUpdater.Singletons
{
Expand All @@ -11,8 +12,7 @@ public class AsyncFileWatcher
{
public event EventHandler? FilesChanged;

private Queue<GameInfo> _queueFiles = new();
private object _lock = new();
private ConcurrentQueue<GameInfo> _queueFiles = new();
private Timer? _timer;

private readonly DllUpdater _updater;
Expand All @@ -25,52 +25,41 @@ public AsyncFileWatcher(DllUpdater updater)

public void AddFile(GameInfo info)
{
lock (_lock)
{
_queueFiles.Enqueue(info);
}
_queueFiles.Enqueue(info);
}

public void RemoveFile(GameInfo info)
{
lock (_lock)
{
var files = _queueFiles.ToList();
var updated = files.Remove(info);
var files = _queueFiles.ToList();
var updated = files.Remove(info);

if (updated)
if (updated)
{
_queueFiles.Clear();
foreach (var file in files)
{
_queueFiles.Clear();
foreach (var file in files)
{
_queueFiles.Enqueue(file);
}
_queueFiles.Enqueue(file);
}
}
}

private async void Check(object? state)
{
GameInfo? info = null;
lock (_lock)
if(_queueFiles.Count == 0)
{
if(_queueFiles.Count == 0)
{
return;
}
info = _queueFiles.Dequeue();
return;
}

var bChanged = await info.GatherInstalledVersions();
if (bChanged)
if(_queueFiles.TryDequeue(out var info))
{
FilesChanged?.Invoke(this, EventArgs.Empty);
}
var bChanged = await info.GatherInstalledVersions();
if (bChanged)
{
FilesChanged?.Invoke(this, EventArgs.Empty);
}

lock (_lock)
{
_queueFiles.Enqueue(info);
}

}
}
}
6 changes: 3 additions & 3 deletions DlssUpdater/ViewModels/Pages/GamesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public void Update()
}
else
{
DlssItemInstalled = SelectedGame.InstalledDlls[DlssTypes.DllType.Dlss].Version ?? _notInstalled;
DlssDItemInstalled = SelectedGame.InstalledDlls[DlssTypes.DllType.DlssD].Version ?? _notInstalled;
DlssGItemInstalled = SelectedGame.InstalledDlls[DlssTypes.DllType.DlssG].Version ?? _notInstalled;
DlssItemInstalled = string.IsNullOrEmpty(SelectedGame.InstalledDlls[DlssTypes.DllType.Dlss].Version) ? _notInstalled : SelectedGame.InstalledDlls[DlssTypes.DllType.Dlss].Version;
DlssDItemInstalled = string.IsNullOrEmpty(SelectedGame.InstalledDlls[DlssTypes.DllType.DlssD].Version) ? _notInstalled : SelectedGame.InstalledDlls[DlssTypes.DllType.DlssD].Version;
DlssGItemInstalled = string.IsNullOrEmpty(SelectedGame.InstalledDlls[DlssTypes.DllType.DlssG].Version) ? _notInstalled : SelectedGame.InstalledDlls[DlssTypes.DllType.DlssG].Version;
}

DlssItemEnabled = DlssItemInstalled != _notInstalled;
Expand Down
1 change: 1 addition & 0 deletions DlssUpdater/Windows/Splashscreen/Splashscreen.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using DlssUpdater.ViewModels.Windows;
using DlssUpdater.Views.Windows;
using DLSSUpdater.Singletons;
using Wpf.Ui.Appearance;
using MessageBox = Wpf.Ui.Controls.MessageBox;
using MessageBoxResult = Wpf.Ui.Controls.MessageBoxResult;

Expand Down
6 changes: 5 additions & 1 deletion DlssUpdater/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# 1.0.5.0
# 1.0.5.1
* Fix incorrectly enabled ComboBox for DLL types in configuration view
* Fix AsyncFileWatcher not correctly removing removed games

# 1.0.5.0
* Add support for hiding games from main list with right mouse button
* Add filter to games page
* Validate MD5 hash and signature of downloaded DLL
Expand Down
2 changes: 1 addition & 1 deletion DlssUpdater/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "1.0.5.0"
"version": "1.0.5.1"
}

0 comments on commit 00170af

Please sign in to comment.