mirror of
https://github.com/tgeorgiadis/quiver-launcher.git
synced 2026-11-22 21:50:52 -05:00
Rebrand to Quiver 2.0.0 with in-repo Core and expanded catalog features.
Rename GithubLauncher to Quiver, vendor Quiver.Core into the main repository, add community catalog support, tests, and updated branding assets for the 2.0 release. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
74f648e977
commit
7b674a9d08
94 files changed
+9394
-3225
No files matched your search
@@ -8,18 +8,14 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
|
||||
env:
|
||||
Solution_Name: GithubLauncher.sln
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
@@ -27,15 +23,45 @@ jobs:
|
||||
dotnet-version: 9.0.x
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore GithubLauncher.sln
|
||||
run: dotnet restore Quiver.sln
|
||||
|
||||
- name: Test with coverage
|
||||
run: dotnet test Quiver.sln -c Release --no-restore --collect:"XPlat Code Coverage" --results-directory "${{ runner.temp }}/coverage"
|
||||
|
||||
- name: Upload coverage report
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: coverage-cobertura
|
||||
path: ${{ runner.temp }}/coverage/**/coverage.cobertura.xml
|
||||
retention-days: 14
|
||||
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
|
||||
env:
|
||||
Solution_Name: Quiver.sln
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 9.0.x
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore Quiver.sln
|
||||
|
||||
- name: Publish Windows x64
|
||||
run: dotnet publish GithubLauncher.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -o publish/win-x64
|
||||
run: dotnet publish Quiver.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -o publish/win-x64
|
||||
|
||||
- name: Upload Windows x64
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: GithubLauncher-Windows-x64
|
||||
name: Quiver-Windows-x64
|
||||
path: publish/win-x64
|
||||
retention-days: 14
|
||||
|
||||
@@ -43,14 +69,13 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
Solution_Name: GithubLauncher.sln
|
||||
Solution_Name: Quiver.sln
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
@@ -58,25 +83,25 @@ jobs:
|
||||
dotnet-version: 9.0.x
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore GithubLauncher.sln
|
||||
run: dotnet restore Quiver.sln
|
||||
|
||||
- name: Publish Linux x64
|
||||
run: dotnet publish GithubLauncher.csproj -c Release -r linux-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -o publish/linux-x64
|
||||
run: dotnet publish Quiver.csproj -c Release -r linux-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -o publish/linux-x64
|
||||
|
||||
- name: Publish Linux ARM64
|
||||
run: dotnet publish GithubLauncher.csproj -c Release -r linux-arm64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -o publish/linux-arm64
|
||||
run: dotnet publish Quiver.csproj -c Release -r linux-arm64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -o publish/linux-arm64
|
||||
|
||||
- name: Upload Linux x64
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: GithubLauncher-Linux-x64
|
||||
name: Quiver-Linux-x64
|
||||
path: publish/linux-x64
|
||||
retention-days: 14
|
||||
|
||||
- name: Upload Linux ARM64
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: GithubLauncher-Linux-ARM64
|
||||
name: Quiver-Linux-ARM64
|
||||
path: publish/linux-arm64
|
||||
retention-days: 14
|
||||
|
||||
@@ -84,15 +109,14 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
env:
|
||||
Solution_Name: GithubLauncher.sln
|
||||
App_Name: GithubLauncher
|
||||
Solution_Name: Quiver.sln
|
||||
App_Name: Quiver
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
@@ -100,10 +124,10 @@ jobs:
|
||||
dotnet-version: 9.0.x
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore GithubLauncher.sln
|
||||
run: dotnet restore Quiver.sln
|
||||
|
||||
- name: Publish macOS x64
|
||||
run: dotnet publish GithubLauncher.csproj -c Release -r osx-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -o publish/osx-x64
|
||||
run: dotnet publish Quiver.csproj -c Release -r osx-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -o publish/osx-x64
|
||||
|
||||
- name: Create macOS .app bundle
|
||||
run: |
|
||||
@@ -126,13 +150,13 @@ jobs:
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${{ env.App_Name }}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.sirdiabo.githublauncher</string>
|
||||
<string>com.tgeorgiadis.quiver</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${{ env.App_Name }}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0.0</string>
|
||||
<string>2.0.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<string>2.0.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
@@ -146,6 +170,6 @@ jobs:
|
||||
- name: Upload macOS x64
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: GithubLauncher-macOS-x64
|
||||
name: Quiver-macOS-x64
|
||||
path: publish/${{ env.App_Name }}.app
|
||||
retention-days: 14
|
||||
@@ -1,3 +0,0 @@
|
||||
[submodule "lib/GitHubLauncher.Core"]
|
||||
path = lib/GitHubLauncher.Core
|
||||
url = https://github.com/SirDiabo/GitHubLauncher.core
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Drawing.Common" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,84 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
|
||||
if (args.Length < 2)
|
||||
{
|
||||
Console.Error.WriteLine("Usage: IcoGen <input.png> <output.ico>");
|
||||
return 1;
|
||||
}
|
||||
|
||||
var inputPath = Path.GetFullPath(args[0]);
|
||||
var outputPath = Path.GetFullPath(args[1]);
|
||||
|
||||
if (!File.Exists(inputPath))
|
||||
{
|
||||
Console.Error.WriteLine($"Input not found: {inputPath}");
|
||||
return 1;
|
||||
}
|
||||
|
||||
using var source = new Bitmap(inputPath);
|
||||
int[] sizes = [16, 32, 48, 64, 128, 256];
|
||||
var pngImages = new List<byte[]>(sizes.Length);
|
||||
|
||||
foreach (var size in sizes)
|
||||
{
|
||||
using var square = RenderSquareIcon(source, size);
|
||||
using var ms = new MemoryStream();
|
||||
square.Save(ms, ImageFormat.Png);
|
||||
pngImages.Add(ms.ToArray());
|
||||
}
|
||||
|
||||
WriteIco(outputPath, sizes, pngImages);
|
||||
Console.WriteLine($"Wrote {outputPath} ({sizes.Length} sizes from {source.Width}x{source.Height})");
|
||||
return 0;
|
||||
|
||||
static Bitmap RenderSquareIcon(Bitmap source, int size)
|
||||
{
|
||||
var result = new Bitmap(size, size, PixelFormat.Format32bppArgb);
|
||||
using var graphics = Graphics.FromImage(result);
|
||||
graphics.Clear(Color.Transparent);
|
||||
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||
|
||||
var scale = Math.Min((float)size / source.Width, (float)size / source.Height) * 0.92f;
|
||||
var drawWidth = source.Width * scale;
|
||||
var drawHeight = source.Height * scale;
|
||||
var x = (size - drawWidth) / 2f;
|
||||
var y = (size - drawHeight) / 2f;
|
||||
graphics.DrawImage(source, x, y, drawWidth, drawHeight);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void WriteIco(string path, IReadOnlyList<int> sizes, IReadOnlyList<byte[]> pngImages)
|
||||
{
|
||||
using var stream = new FileStream(path, FileMode.Create, FileAccess.Write);
|
||||
using var writer = new BinaryWriter(stream);
|
||||
|
||||
writer.Write((ushort)0);
|
||||
writer.Write((ushort)1);
|
||||
writer.Write((ushort)sizes.Count);
|
||||
|
||||
var dataOffset = 6 + (16 * sizes.Count);
|
||||
for (var i = 0; i < sizes.Count; i++)
|
||||
{
|
||||
var size = sizes[i];
|
||||
var dimension = (byte)(size >= 256 ? 0 : size);
|
||||
writer.Write(dimension);
|
||||
writer.Write(dimension);
|
||||
writer.Write((byte)0);
|
||||
writer.Write((byte)0);
|
||||
writer.Write((ushort)1);
|
||||
writer.Write((ushort)32);
|
||||
writer.Write(pngImages[i].Length);
|
||||
writer.Write(dataOffset);
|
||||
dataOffset += pngImages[i].Length;
|
||||
}
|
||||
|
||||
foreach (var png in pngImages)
|
||||
{
|
||||
writer.Write(png);
|
||||
}
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Quiver (Debug)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/bin/Debug/net9.0/Quiver.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}/bin/Debug/net9.0",
|
||||
"console": "internalConsole"
|
||||
}
|
||||
]
|
||||
}
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/Quiver.csproj",
|
||||
"-c",
|
||||
"Debug",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "test",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"test",
|
||||
"${workspaceFolder}/Quiver.sln",
|
||||
"-c",
|
||||
"Debug",
|
||||
"--verbosity",
|
||||
"minimal"
|
||||
],
|
||||
"group": "test",
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<Application xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="GithubLauncher.App"
|
||||
x:Class="Quiver.App"
|
||||
RequestedThemeVariant="Default">
|
||||
|
||||
<Application.Styles>
|
||||
|
||||
+58
-90
@@ -16,8 +16,9 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace GithubLauncher;
|
||||
namespace Quiver;
|
||||
|
||||
public class App : Application, INotifyPropertyChanged
|
||||
{
|
||||
@@ -130,7 +131,7 @@ public class App : Application, INotifyPropertyChanged
|
||||
|
||||
private static bool _hasCheckedForAppUpdates = false;
|
||||
private static readonly object _updateLock = new object();
|
||||
private const string Repository = "SirDiabo/GithubLauncher";
|
||||
private const string Repository = "tgeorgiadis/quiver";
|
||||
private const string VersionFileName = "version.txt";
|
||||
private const string UpdateCheckFileName = "update_check.json";
|
||||
private const string BackupDirectoryPrefix = "backup_";
|
||||
@@ -147,6 +148,14 @@ public class App : Application, INotifyPropertyChanged
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
#if DEBUG
|
||||
Dispatcher.UIThread.UnhandledException += (_, e) =>
|
||||
{
|
||||
Program.LogCrashFromUiThread("Dispatcher.UIThread.UnhandledException", e.Exception);
|
||||
e.Handled = true;
|
||||
};
|
||||
#endif
|
||||
|
||||
CleanupStaleUpdateBackups();
|
||||
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
@@ -206,8 +215,28 @@ public class App : Application, INotifyPropertyChanged
|
||||
await CheckForUpdatesAndApplyAsync(isManualCheck: true);
|
||||
}
|
||||
|
||||
private static bool ShouldSkipLauncherSelfUpdate(bool isManualCheck)
|
||||
{
|
||||
if (isManualCheck)
|
||||
return false;
|
||||
|
||||
#if DEBUG
|
||||
return true;
|
||||
#else
|
||||
var skip = Environment.GetEnvironmentVariable("Quiver_SKIP_UPDATES");
|
||||
return string.Equals(skip, "1", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(skip, "true", StringComparison.OrdinalIgnoreCase);
|
||||
#endif
|
||||
}
|
||||
|
||||
private async Task CheckForUpdatesAndApplyAsync(bool isManualCheck = false)
|
||||
{
|
||||
if (ShouldSkipLauncherSelfUpdate(isManualCheck))
|
||||
{
|
||||
Trace.WriteLine("Skipping launcher self-update check (DEBUG build or Quiver_SKIP_UPDATES is set).");
|
||||
return;
|
||||
}
|
||||
|
||||
string currentAppDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string updateCheckFilePath = Path.Combine(currentAppDirectory, UpdateCheckFileName);
|
||||
|
||||
@@ -255,7 +284,7 @@ public class App : Application, INotifyPropertyChanged
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
httpClient.Timeout = DownloadTimeout;
|
||||
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("GithubLauncher-Updater");
|
||||
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Quiver-Updater");
|
||||
|
||||
var settings = AppSettings.Load();
|
||||
if (!string.IsNullOrEmpty(settings?.GitHubApiToken))
|
||||
@@ -299,7 +328,7 @@ public class App : Application, INotifyPropertyChanged
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
httpClient.Timeout = DownloadTimeout;
|
||||
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("GithubLauncher-Updater");
|
||||
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Quiver-Updater");
|
||||
|
||||
var settings = AppSettings.Load();
|
||||
if (!string.IsNullOrEmpty(settings?.GitHubApiToken))
|
||||
@@ -337,7 +366,7 @@ public class App : Application, INotifyPropertyChanged
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
httpClient.Timeout = DownloadTimeout;
|
||||
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("GithubLauncher-Updater");
|
||||
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Quiver-Updater");
|
||||
|
||||
var settings = AppSettings.Load();
|
||||
if (!string.IsNullOrEmpty(settings?.GitHubApiToken))
|
||||
@@ -663,38 +692,14 @@ public class App : Application, INotifyPropertyChanged
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsNewerVersion(string latestVersion, string currentVersion)
|
||||
{
|
||||
try
|
||||
{
|
||||
string normalizedLatest = NormalizeVersionString(latestVersion);
|
||||
string normalizedCurrent = NormalizeVersionString(currentVersion);
|
||||
|
||||
Trace.WriteLine($"Comparing versions - Latest: '{latestVersion}' ({normalizedLatest}) vs Current: '{currentVersion}' ({normalizedCurrent})");
|
||||
|
||||
Version current = new Version(normalizedCurrent);
|
||||
Version latest = new Version(normalizedLatest);
|
||||
|
||||
bool isNewer = latest.CompareTo(current) > 0;
|
||||
Trace.WriteLine($"IsNewerVersion result: {isNewer}");
|
||||
|
||||
return isNewer;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Error comparing versions '{latestVersion}' vs '{currentVersion}': {ex.Message}");
|
||||
|
||||
bool shouldUpdate = !latestVersion.TrimStart('v', 'V').Equals(currentVersion.TrimStart('v', 'V'), StringComparison.OrdinalIgnoreCase);
|
||||
Trace.WriteLine($"Version parsing failed, using string comparison: {shouldUpdate}");
|
||||
return shouldUpdate;
|
||||
}
|
||||
}
|
||||
private bool IsNewerVersion(string latestVersion, string currentVersion) =>
|
||||
LauncherVersionService.IsNewerVersion(latestVersion, currentVersion);
|
||||
|
||||
private bool IsBootstrapVersion(string version)
|
||||
{
|
||||
try
|
||||
{
|
||||
Version parsedVersion = new Version(NormalizeVersionString(version));
|
||||
Version parsedVersion = new Version(LauncherVersionService.NormalizeVersionString(version));
|
||||
return parsedVersion == new Version(0, 0);
|
||||
}
|
||||
catch
|
||||
@@ -704,43 +709,6 @@ public class App : Application, INotifyPropertyChanged
|
||||
}
|
||||
}
|
||||
|
||||
private string NormalizeVersionString(string version)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(version))
|
||||
return "0.0.0.0";
|
||||
|
||||
version = version.TrimStart('v', 'V').Trim();
|
||||
|
||||
var parts = version.Split('.');
|
||||
var validParts = new List<string>();
|
||||
|
||||
foreach (var part in parts)
|
||||
{
|
||||
if (int.TryParse(part.Trim(), out int number))
|
||||
{
|
||||
validParts.Add(number.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
while (validParts.Count < 2)
|
||||
{
|
||||
validParts.Add("0");
|
||||
}
|
||||
|
||||
if (validParts.Count == 2)
|
||||
{
|
||||
return $"{validParts[0]}.{validParts[1]}";
|
||||
}
|
||||
else if (validParts.Count == 3)
|
||||
{
|
||||
return $"{validParts[0]}.{validParts[1]}.{validParts[2]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{validParts[0]}.{validParts[1]}.{validParts[2]}.{validParts[3]}";
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DownloadAndApplyUpdate(GitHubRelease latestRelease, string currentAppDirectory, UpdateCheckInfo updateCheckInfo)
|
||||
{
|
||||
string platformIdentifier = GetPlatformIdentifier();
|
||||
@@ -824,7 +792,7 @@ public class App : Application, INotifyPropertyChanged
|
||||
progressWindow?.UpdateProgress(100, "Download complete. Extracting...");
|
||||
await Task.Delay(500); // Brief pause so user can see 100%
|
||||
|
||||
string tempUpdateFolder = Path.Combine(Path.GetTempPath(), "GithubLauncher_temp_update");
|
||||
string tempUpdateFolder = Path.Combine(Path.GetTempPath(), "Quiver_temp_update");
|
||||
if (Directory.Exists(tempUpdateFolder))
|
||||
{
|
||||
Directory.Delete(tempUpdateFolder, true);
|
||||
@@ -979,7 +947,7 @@ public class App : Application, INotifyPropertyChanged
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
mainExecutable = Path.Combine(updateDirectory, "GithubLauncher.exe");
|
||||
mainExecutable = Path.Combine(updateDirectory, "Quiver.exe");
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
@@ -992,12 +960,12 @@ public class App : Application, INotifyPropertyChanged
|
||||
}
|
||||
else
|
||||
{
|
||||
mainExecutable = Path.Combine(updateDirectory, "GithubLauncher");
|
||||
mainExecutable = Path.Combine(updateDirectory, "Quiver");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mainExecutable = Path.Combine(updateDirectory, "GithubLauncher");
|
||||
mainExecutable = Path.Combine(updateDirectory, "Quiver");
|
||||
}
|
||||
|
||||
if (!File.Exists(mainExecutable) && !Directory.Exists(mainExecutable))
|
||||
@@ -1029,7 +997,7 @@ public class App : Application, INotifyPropertyChanged
|
||||
int currentProcessId = Environment.ProcessId;
|
||||
string applicationExecutable = Process.GetCurrentProcess().MainModule?.FileName
|
||||
?? throw new InvalidOperationException("Could not determine the current application executable path.");
|
||||
string backupDir = Path.Combine(Path.GetTempPath(), "GithubLauncher_backup_" + DateTime.Now.ToString("yyyyMMdd_HHmmss"));
|
||||
string backupDir = Path.Combine(Path.GetTempPath(), "Quiver_backup_" + DateTime.Now.ToString("yyyyMMdd_HHmmss"));
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
@@ -1043,14 +1011,14 @@ public class App : Application, INotifyPropertyChanged
|
||||
|
||||
private async Task CreateWindowsUpdaterScript(GitHubRelease latestRelease, string tempUpdateFolder, string tempDownloadPath, string currentAppDirectory, UpdateCheckInfo updateCheckInfo, string applicationExecutable, string backupDir, int currentProcessId)
|
||||
{
|
||||
string updaterScriptPath = Path.Combine(Path.GetTempPath(), "GithubLauncher_Updater.cmd");
|
||||
string updaterScriptPath = Path.Combine(Path.GetTempPath(), "Quiver_Updater.cmd");
|
||||
string updateCheckFilePath = Path.Combine(currentAppDirectory, UpdateCheckFileName);
|
||||
|
||||
string scriptContent = $@"@echo off
|
||||
echo GithubLauncher Updater - Version {latestRelease.tag_name}
|
||||
echo Quiver Updater - Version {latestRelease.tag_name}
|
||||
echo.
|
||||
|
||||
echo Waiting for GithubLauncher to close...
|
||||
echo Waiting for Quiver to close...
|
||||
set /A waitCount=0
|
||||
:wait_loop
|
||||
tasklist /FI ""PID eq {currentProcessId}"" 2>NUL | find /I ""{currentProcessId}"">NUL
|
||||
@@ -1095,7 +1063,7 @@ echo Updating version info...
|
||||
echo {{""CurrentVersion"":""{latestRelease.tag_name}"",""LastCheckTime"":""{DateTime.UtcNow:o}"",""LastKnownVersion"":""{latestRelease.tag_name}"",""ETag"":"""",""UpdateAvailable"":false}} > ""{updateCheckFilePath}""
|
||||
|
||||
echo Update completed successfully!
|
||||
echo Restarting GithubLauncher...
|
||||
echo Restarting Quiver...
|
||||
start """" ""{applicationExecutable}""
|
||||
|
||||
:cleanup
|
||||
@@ -1129,17 +1097,17 @@ del ""%~f0""
|
||||
|
||||
private async Task CreateUnixUpdaterScript(GitHubRelease latestRelease, string tempUpdateFolder, string tempDownloadPath, string currentAppDirectory, UpdateCheckInfo updateCheckInfo, string applicationExecutable, string backupDir, int currentProcessId)
|
||||
{
|
||||
string updaterScriptPath = Path.Combine(Path.GetTempPath(), "GithubLauncher_Updater.sh");
|
||||
string updaterScriptPath = Path.Combine(Path.GetTempPath(), "Quiver_Updater.sh");
|
||||
string updateCheckFilePath = Path.Combine(currentAppDirectory, UpdateCheckFileName);
|
||||
|
||||
bool isMacAppBundle = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) &&
|
||||
Directory.GetDirectories(tempUpdateFolder, "*.app", SearchOption.TopDirectoryOnly).Any();
|
||||
|
||||
string scriptContent = $@"#!/bin/bash
|
||||
echo ""GithubLauncher Updater - Version {latestRelease.tag_name}""
|
||||
echo ""Quiver Updater - Version {latestRelease.tag_name}""
|
||||
echo
|
||||
|
||||
echo ""Waiting for GithubLauncher to close...""
|
||||
echo ""Waiting for Quiver to close...""
|
||||
waitCount=0
|
||||
while kill -0 {currentProcessId} 2>/dev/null; do
|
||||
if [ ""$waitCount"" -ge {UpdaterProcessExitTimeoutSeconds} ]; then
|
||||
@@ -1197,30 +1165,30 @@ if [ ""{RuntimeInformation.IsOSPlatform(OSPlatform.OSX).ToString().ToLower()}""
|
||||
appBundle=$(find ""$appDir"" -maxdepth 1 -name ""*.app"" -type d | head -n 1)
|
||||
if [ -n ""$appBundle"" ]; then
|
||||
echo ""Found .app bundle: $appBundle""
|
||||
elif [ -f ""$appDir/GithubLauncher"" ]; then
|
||||
chmod +x ""$appDir/GithubLauncher""
|
||||
elif [ -f ""$appDir/Quiver"" ]; then
|
||||
chmod +x ""$appDir/Quiver""
|
||||
fi
|
||||
else
|
||||
if [ -f ""$appDir/GithubLauncher"" ]; then
|
||||
chmod +x ""$appDir/GithubLauncher""
|
||||
if [ -f ""$appDir/Quiver"" ]; then
|
||||
chmod +x ""$appDir/Quiver""
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""Restarting GithubLauncher...""
|
||||
echo ""Restarting Quiver...""
|
||||
|
||||
if [ ""{RuntimeInformation.IsOSPlatform(OSPlatform.OSX).ToString().ToLower()}"" = ""true"" ]; then
|
||||
appBundle=$(find ""$appDir"" -maxdepth 1 -name ""*.app"" -type d | head -n 1)
|
||||
if [ -n ""$appBundle"" ]; then
|
||||
echo ""Starting .app bundle: $appBundle""
|
||||
nohup open ""$appBundle"" > /dev/null 2>&1 &
|
||||
elif [ -f ""$appDir/GithubLauncher"" ]; then
|
||||
elif [ -f ""$appDir/Quiver"" ]; then
|
||||
cd ""$appDir""
|
||||
nohup ""./GithubLauncher"" > /dev/null 2>&1 &
|
||||
nohup ""./Quiver"" > /dev/null 2>&1 &
|
||||
fi
|
||||
else
|
||||
if [ -f ""$appDir/GithubLauncher"" ]; then
|
||||
if [ -f ""$appDir/Quiver"" ]; then
|
||||
cd ""$appDir""
|
||||
nohup ""./GithubLauncher"" > /dev/null 2>&1 &
|
||||
nohup ""./Quiver"" > /dev/null 2>&1 &
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 124 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 290 KiB |
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace GithubLauncher
|
||||
namespace Quiver
|
||||
{
|
||||
public class BooleanToStretchConverter : IValueConverter
|
||||
{
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace Quiver
|
||||
{
|
||||
public class DoubleScaleConverter : IValueConverter
|
||||
{
|
||||
public static readonly DoubleScaleConverter Instance = new();
|
||||
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
double doubleValue = value switch
|
||||
{
|
||||
double d => d,
|
||||
int i => i,
|
||||
float f => f,
|
||||
_ => 0d
|
||||
};
|
||||
|
||||
if (parameter is string paramString &&
|
||||
double.TryParse(paramString, NumberStyles.Float, CultureInfo.InvariantCulture, out var scale))
|
||||
{
|
||||
return doubleValue * scale;
|
||||
}
|
||||
|
||||
return doubleValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.Globalization;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia;
|
||||
|
||||
namespace GithubLauncher
|
||||
namespace Quiver
|
||||
{
|
||||
public class ThicknessConverter : IValueConverter
|
||||
{
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36310.24
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GithubLauncher", "GithubLauncher.csproj", "{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHubLauncher.Core", "lib\GitHubLauncher.Core\GitHubLauncher.Core.csproj", "{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {9092E66B-AF24-466E-84DB-F80364B83B55}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
+804
-308
File diff suppressed because it is too large.
Load diff
+1234
-924
File diff suppressed because it is too large.
Load diff
+142
-1329
File diff suppressed because it is too large.
Load diff
+63
-1
@@ -1,12 +1,18 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.Platform;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace GithubLauncher
|
||||
namespace Quiver
|
||||
{
|
||||
class Program
|
||||
{
|
||||
private static readonly string CrashLogPath = Path.Combine(
|
||||
AppDomain.CurrentDomain.BaseDirectory,
|
||||
"crash.log");
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern bool AttachConsole(int dwProcessId);
|
||||
|
||||
@@ -39,11 +45,67 @@ namespace GithubLauncher
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
RegisterDebugExceptionHandlers();
|
||||
#endif
|
||||
|
||||
DefaultMenuInteractionHandler.MenuShowDelay = TimeSpan.Zero;
|
||||
|
||||
BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
private static void RegisterDebugExceptionHandlers()
|
||||
{
|
||||
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
|
||||
{
|
||||
if (e.ExceptionObject is Exception ex)
|
||||
LogCrash("AppDomain.UnhandledException", ex);
|
||||
};
|
||||
|
||||
TaskScheduler.UnobservedTaskException += (_, e) =>
|
||||
{
|
||||
LogCrash("TaskScheduler.UnobservedTaskException", e.Exception);
|
||||
e.SetObserved();
|
||||
};
|
||||
}
|
||||
|
||||
internal static void LogCrashFromUiThread(string source, Exception ex)
|
||||
{
|
||||
LogCrash(source, ex);
|
||||
}
|
||||
|
||||
private static void LogCrash(string source, Exception ex)
|
||||
{
|
||||
var message = new StringBuilder();
|
||||
message.AppendLine($"[{DateTime.UtcNow:O}] {source}");
|
||||
message.AppendLine(ex.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
File.AppendAllText(CrashLogPath, message.ToString() + Environment.NewLine);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Best-effort logging only.
|
||||
}
|
||||
|
||||
Debug.WriteLine(message.ToString());
|
||||
Trace.WriteLine(message.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
Console.Error.WriteLine(message.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
// WinExe may have no console attached.
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private static int RunCLI(string[] args)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Quiver.Tests")]
|
||||
@@ -0,0 +1,161 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class AcceptCatalogUpdateTests
|
||||
{
|
||||
private static GameInfo CreateApp(
|
||||
string repository,
|
||||
string name = "Test App",
|
||||
string folderName = "TestFolder")
|
||||
{
|
||||
return new GameInfo
|
||||
{
|
||||
Repository = repository,
|
||||
Name = name,
|
||||
FolderName = folderName,
|
||||
};
|
||||
}
|
||||
|
||||
private static string GetAcceptedSnapshotPath(string sourceId) =>
|
||||
Path.Combine(
|
||||
AppContext.BaseDirectory,
|
||||
"Cache",
|
||||
"CatalogSources",
|
||||
$"{sourceId}.accepted.json");
|
||||
|
||||
private static async Task<List<GameInfo>> ReadAcceptedSnapshotAsync(string sourceId)
|
||||
{
|
||||
var path = GetAcceptedSnapshotPath(sourceId);
|
||||
File.Exists(path).Should().BeTrue($"expected accepted snapshot at {path}");
|
||||
|
||||
var service = new AppCatalogService();
|
||||
return service.ParseAppsFromJson(await File.ReadAllTextAsync(path));
|
||||
}
|
||||
|
||||
private static List<GameInfo> BuildUpdateFixture()
|
||||
{
|
||||
return
|
||||
[
|
||||
CreateApp("owner/unchanged", "Unchanged", "UnchangedFolder"),
|
||||
CreateApp("owner/changed", "New Name", "OldFolder"),
|
||||
CreateApp("owner/added", "Added", "AddedFolder"),
|
||||
];
|
||||
}
|
||||
|
||||
private static List<GameInfo> BuildAcceptedFixture()
|
||||
{
|
||||
return
|
||||
[
|
||||
CreateApp("owner/unchanged", "Unchanged", "UnchangedFolder"),
|
||||
CreateApp("owner/removed", "Removed", "RemovedFolder"),
|
||||
CreateApp("owner/changed", "Old Name", "OldFolder"),
|
||||
];
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ApplyAll_replaces_accepted_with_remote()
|
||||
{
|
||||
var sourceId = Guid.NewGuid().ToString();
|
||||
var source = new AppCatalogSource { Id = sourceId, UpdateAvailable = true };
|
||||
var service = new AppCatalogService();
|
||||
var accepted = BuildAcceptedFixture();
|
||||
var remote = BuildUpdateFixture();
|
||||
|
||||
await service.InitializeAcceptedSnapshotAsync(source, accepted);
|
||||
await service.AcceptCatalogUpdateAsync(source, remote, accepted, CatalogUpdateChoice.ApplyAll);
|
||||
|
||||
source.UpdateAvailable.Should().BeFalse();
|
||||
var snapshot = await ReadAcceptedSnapshotAsync(sourceId);
|
||||
snapshot.Select(a => a.Repository).Should().BeEquivalentTo(["owner/unchanged", "owner/changed", "owner/added"]);
|
||||
snapshot.Should().NotContain(a => a.Repository == "owner/removed");
|
||||
snapshot.Single(a => a.Repository == "owner/changed").Name.Should().Be("New Name");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ApplyNewOnly_keeps_removed_but_applies_remote_changes()
|
||||
{
|
||||
var sourceId = Guid.NewGuid().ToString();
|
||||
var source = new AppCatalogSource { Id = sourceId, UpdateAvailable = true };
|
||||
var service = new AppCatalogService();
|
||||
var accepted = BuildAcceptedFixture();
|
||||
var remote = BuildUpdateFixture();
|
||||
|
||||
await service.InitializeAcceptedSnapshotAsync(source, accepted);
|
||||
await service.AcceptCatalogUpdateAsync(source, remote, accepted, CatalogUpdateChoice.ApplyNewOnly);
|
||||
|
||||
var snapshot = await ReadAcceptedSnapshotAsync(sourceId);
|
||||
snapshot.Select(a => a.Repository).Should().BeEquivalentTo(
|
||||
["owner/unchanged", "owner/removed", "owner/changed", "owner/added"]);
|
||||
snapshot.Single(a => a.Repository == "owner/changed").Name.Should().Be("New Name");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task KeepCurrent_clears_flag_without_touching_snapshot()
|
||||
{
|
||||
var sourceId = Guid.NewGuid().ToString();
|
||||
var source = new AppCatalogSource
|
||||
{
|
||||
Id = sourceId,
|
||||
UpdateAvailable = true,
|
||||
AcceptedContentHash = "ORIGINAL_HASH",
|
||||
};
|
||||
var service = new AppCatalogService();
|
||||
var accepted = BuildAcceptedFixture();
|
||||
var remote = BuildUpdateFixture();
|
||||
|
||||
await service.InitializeAcceptedSnapshotAsync(source, accepted);
|
||||
var before = await File.ReadAllTextAsync(GetAcceptedSnapshotPath(sourceId));
|
||||
var hashBefore = source.AcceptedContentHash;
|
||||
|
||||
await service.AcceptCatalogUpdateAsync(source, remote, accepted, CatalogUpdateChoice.KeepCurrent);
|
||||
|
||||
source.UpdateAvailable.Should().BeFalse();
|
||||
source.AcceptedContentHash.Should().Be(hashBefore);
|
||||
var after = await File.ReadAllTextAsync(GetAcceptedSnapshotPath(sourceId));
|
||||
after.Should().Be(before);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ApplyAll_updates_AcceptedContentHash()
|
||||
{
|
||||
var sourceId = Guid.NewGuid().ToString();
|
||||
var source = new AppCatalogSource { Id = sourceId, UpdateAvailable = true };
|
||||
var service = new AppCatalogService();
|
||||
var accepted = BuildAcceptedFixture();
|
||||
var remote = BuildUpdateFixture();
|
||||
|
||||
await service.InitializeAcceptedSnapshotAsync(source, accepted);
|
||||
await service.AcceptCatalogUpdateAsync(source, remote, accepted, CatalogUpdateChoice.ApplyAll);
|
||||
|
||||
var snapshot = await ReadAcceptedSnapshotAsync(sourceId);
|
||||
source.AcceptedContentHash.Should().Be(AppCatalogService.ComputeCatalogContentHash(snapshot));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CatalogMerge_ApplyNewOnly_ignores_blank_repository_entries()
|
||||
{
|
||||
var accepted = new List<GameInfo> { CreateApp("owner/kept") };
|
||||
var remote = new List<GameInfo>
|
||||
{
|
||||
CreateApp(""),
|
||||
CreateApp("owner/new", "New"),
|
||||
};
|
||||
|
||||
var merged = CatalogMerge.ApplyChoice(
|
||||
CatalogUpdateChoice.ApplyNewOnly,
|
||||
accepted,
|
||||
remote,
|
||||
app => new GameInfo
|
||||
{
|
||||
Repository = app.Repository,
|
||||
Name = app.Name,
|
||||
FolderName = app.FolderName,
|
||||
});
|
||||
|
||||
merged.Should().NotBeNull();
|
||||
merged!.Select(a => a.Repository).Should().BeEquivalentTo(["owner/kept", "owner/new"]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class AppCatalogServiceTests
|
||||
{
|
||||
private static GameInfo CreateApp(
|
||||
string repository,
|
||||
string name = "Test App",
|
||||
string folderName = "TestFolder",
|
||||
string? gameIconUrl = null,
|
||||
string? installPath = null)
|
||||
{
|
||||
return new GameInfo
|
||||
{
|
||||
Repository = repository,
|
||||
Name = name,
|
||||
FolderName = folderName,
|
||||
GameIconUrl = gameIconUrl,
|
||||
InstallPath = installPath,
|
||||
};
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("https://example.com/apps.json", true)]
|
||||
[InlineData("http://example.com/apps.json", true)]
|
||||
[InlineData("HTTPS://EXAMPLE.COM/apps.json", true)]
|
||||
[InlineData("community-app-lists/n64-recomp.json", false)]
|
||||
[InlineData(@"C:\Catalogs\apps.json", false)]
|
||||
public void IsRemoteLocation_classifies_locations(string location, bool expectedRemote)
|
||||
{
|
||||
AppCatalogService.IsRemoteLocation(location).Should().Be(expectedRemote);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveLocalPath_combines_relative_paths_with_base_directory()
|
||||
{
|
||||
var resolved = AppCatalogService.ResolveLocalPath("community-app-lists/index.json");
|
||||
|
||||
resolved.Should().Be(Path.Combine(AppContext.BaseDirectory, "community-app-lists/index.json"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveLocalPath_preserves_rooted_and_remote_paths()
|
||||
{
|
||||
const string remote = "https://example.com/index.json";
|
||||
AppCatalogService.ResolveLocalPath(remote).Should().Be(remote);
|
||||
|
||||
var rooted = Path.GetFullPath(Path.Combine(Path.GetTempPath(), "apps.json"));
|
||||
AppCatalogService.ResolveLocalPath(rooted).Should().Be(rooted);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetCatalogDiff_detects_added_removed_and_changed_apps()
|
||||
{
|
||||
var accepted = new List<GameInfo>
|
||||
{
|
||||
CreateApp("owner/unchanged", "Unchanged", "UnchangedFolder"),
|
||||
CreateApp("owner/removed", "Removed", "RemovedFolder"),
|
||||
CreateApp("owner/changed", "Old Name", "OldFolder"),
|
||||
};
|
||||
|
||||
var remote = new List<GameInfo>
|
||||
{
|
||||
CreateApp("owner/unchanged", "Unchanged", "UnchangedFolder"),
|
||||
CreateApp("owner/changed", "New Name", "OldFolder"),
|
||||
CreateApp("owner/added", "Added", "AddedFolder"),
|
||||
};
|
||||
|
||||
var diff = AppCatalogService.GetCatalogDiff(accepted, remote);
|
||||
|
||||
diff.HasChanges.Should().BeTrue();
|
||||
diff.Added.Should().ContainSingle(a => a.Repository == "owner/added");
|
||||
diff.Removed.Should().ContainSingle(a => a.Repository == "owner/removed");
|
||||
diff.Changed.Should().ContainSingle(a => a.Repository == "owner/changed" && a.Name == "New Name");
|
||||
diff.AddedCount.Should().Be(1);
|
||||
diff.RemovedCount.Should().Be(1);
|
||||
diff.ChangedCount.Should().Be(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetCatalogDiff_is_case_insensitive_for_repository_keys()
|
||||
{
|
||||
var accepted = new List<GameInfo> { CreateApp("Owner/App", "Same", "Folder") };
|
||||
var remote = new List<GameInfo> { CreateApp("owner/app", "Same", "Folder") };
|
||||
|
||||
var diff = AppCatalogService.GetCatalogDiff(accepted, remote);
|
||||
|
||||
diff.HasChanges.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetCatalogDiff_reports_no_changes_when_identical()
|
||||
{
|
||||
var accepted = new List<GameInfo>
|
||||
{
|
||||
CreateApp("owner/app", "Name", "Folder", installPath: "C:\\Games\\App", gameIconUrl: "https://example.com/icon.png"),
|
||||
};
|
||||
var remote = new List<GameInfo>
|
||||
{
|
||||
CreateApp("owner/app", "Name", "Folder", installPath: "C:\\Games\\App", gameIconUrl: "https://example.com/icon.png"),
|
||||
};
|
||||
remote[0].PreferredVersion = "v1.0.0";
|
||||
remote[0].SkippedUpdateVersion = "v2.0.0";
|
||||
accepted[0].PreferredVersion = "v1.0.0";
|
||||
accepted[0].SkippedUpdateVersion = "v2.0.0";
|
||||
|
||||
AppCatalogService.GetCatalogDiff(accepted, remote).HasChanges.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetCatalogDiff_detects_metadata_field_changes()
|
||||
{
|
||||
var accepted = new List<GameInfo>
|
||||
{
|
||||
CreateApp("owner/app", "Name", "Folder", installPath: null, gameIconUrl: null),
|
||||
};
|
||||
accepted[0].PreferredVersion = "v1.0.0";
|
||||
accepted[0].SkippedUpdateVersion = null;
|
||||
|
||||
var remote = new List<GameInfo>
|
||||
{
|
||||
CreateApp("owner/app", "Name", "Folder", installPath: "D:\\Custom", gameIconUrl: "https://example.com/icon.png"),
|
||||
};
|
||||
remote[0].PreferredVersion = "v2.0.0";
|
||||
remote[0].SkippedUpdateVersion = "v3.0.0";
|
||||
|
||||
var diff = AppCatalogService.GetCatalogDiff(accepted, remote);
|
||||
|
||||
diff.HasChanges.Should().BeTrue();
|
||||
diff.Changed.Should().ContainSingle(a => a.Repository == "owner/app");
|
||||
diff.Added.Should().BeEmpty();
|
||||
diff.Removed.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetCatalogDiff_detects_tag_changes()
|
||||
{
|
||||
var accepted = new List<GameInfo> { CreateApp("owner/app", "Name", "Folder") };
|
||||
accepted[0].Tags = ["n64"];
|
||||
|
||||
var remote = new List<GameInfo> { CreateApp("owner/app", "Name", "Folder") };
|
||||
remote[0].Tags = ["n64", "recomp"];
|
||||
|
||||
var diff = AppCatalogService.GetCatalogDiff(accepted, remote);
|
||||
|
||||
diff.HasChanges.Should().BeTrue();
|
||||
diff.Changed.Should().ContainSingle(a => a.Repository == "owner/app");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyUserAppTags_replaces_tags_when_override_exists()
|
||||
{
|
||||
var app = CreateApp("owner/app", "Name", "Folder");
|
||||
app.Tags = ["catalog"];
|
||||
|
||||
var settings = new AppSettings
|
||||
{
|
||||
UserAppTags = new Dictionary<string, List<string>>
|
||||
{
|
||||
["owner/app"] = ["custom", "n64"],
|
||||
},
|
||||
};
|
||||
|
||||
AppCatalogService.ApplyUserAppTags(app, settings);
|
||||
|
||||
app.Tags.Should().BeEquivalentTo(["custom", "n64"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ComputeCatalogContentHash_is_stable_for_same_content_regardless_of_order()
|
||||
{
|
||||
var first = new List<GameInfo>
|
||||
{
|
||||
CreateApp("b/repo", "Beta", "BetaFolder"),
|
||||
CreateApp("a/repo", "Alpha", "AlphaFolder"),
|
||||
};
|
||||
|
||||
var second = new List<GameInfo>
|
||||
{
|
||||
CreateApp("a/repo", "Alpha", "AlphaFolder"),
|
||||
CreateApp("b/repo", "Beta", "BetaFolder"),
|
||||
};
|
||||
|
||||
AppCatalogService.ComputeCatalogContentHash(first)
|
||||
.Should()
|
||||
.Be(AppCatalogService.ComputeCatalogContentHash(second));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ComputeCatalogContentHash_changes_when_app_metadata_changes()
|
||||
{
|
||||
var baseline = new List<GameInfo> { CreateApp("owner/app", "Name", "Folder") };
|
||||
var changed = new List<GameInfo> { CreateApp("owner/app", "Different Name", "Folder") };
|
||||
|
||||
AppCatalogService.ComputeCatalogContentHash(baseline)
|
||||
.Should()
|
||||
.NotBe(AppCatalogService.ComputeCatalogContentHash(changed));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseAppsFromJson_reads_community_n64_recomp_fixture()
|
||||
{
|
||||
var service = new AppCatalogService();
|
||||
var apps = service.ParseAppsFromJson(TestFixtures.ReadN64RecompListJson());
|
||||
|
||||
apps.Should().NotBeEmpty();
|
||||
apps.Should().Contain(app => app.Repository == "Zelda64Recomp/Zelda64Recomp");
|
||||
apps.Should().OnlyContain(app => !string.IsNullOrWhiteSpace(app.Repository));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Services;
|
||||
using System.Net;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class CatalogLocationReaderTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task ReadAsync_reads_local_file()
|
||||
{
|
||||
var reader = new CatalogLocationReader();
|
||||
var json = await reader.ReadAsync(new HttpClient(), TestFixtures.CommunityIndexPath);
|
||||
|
||||
json.Should().Contain("n64-recomp");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReadAsync_fetches_remote_content_via_http_handler()
|
||||
{
|
||||
var handler = new StubHttpMessageHandler(_ => new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new StringContent("{\"apps\":[]}"),
|
||||
});
|
||||
var client = new HttpClient(handler);
|
||||
var reader = new CatalogLocationReader();
|
||||
|
||||
var json = await reader.ReadAsync(client, "https://example.com/apps.json");
|
||||
|
||||
json.Should().Be("{\"apps\":[]}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReadAsync_throws_when_local_file_missing()
|
||||
{
|
||||
var reader = new CatalogLocationReader();
|
||||
var act = () => reader.ReadAsync(new HttpClient(), "missing/catalog.json");
|
||||
|
||||
await act.Should().ThrowAsync<FileNotFoundException>();
|
||||
}
|
||||
|
||||
private sealed class StubHttpMessageHandler : HttpMessageHandler
|
||||
{
|
||||
private readonly Func<HttpRequestMessage, HttpResponseMessage> _handler;
|
||||
|
||||
public StubHttpMessageHandler(Func<HttpRequestMessage, HttpResponseMessage> handler)
|
||||
{
|
||||
_handler = handler;
|
||||
}
|
||||
|
||||
protected override Task<HttpResponseMessage> SendAsync(
|
||||
HttpRequestMessage request,
|
||||
CancellationToken cancellationToken) =>
|
||||
Task.FromResult(_handler(request));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class CatalogSourceListItemTests
|
||||
{
|
||||
[Fact]
|
||||
public void GetStatusText_returns_update_available_when_flag_set()
|
||||
{
|
||||
var source = new AppCatalogSource
|
||||
{
|
||||
UpdateAvailable = true,
|
||||
LastFetchedUtc = DateTime.UtcNow,
|
||||
};
|
||||
|
||||
CatalogSourceListItem.GetStatusText(source).Should().Be("Update available");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetStatusText_returns_last_error_when_present()
|
||||
{
|
||||
var source = new AppCatalogSource
|
||||
{
|
||||
LastError = "Network timeout",
|
||||
LastFetchedUtc = DateTime.UtcNow,
|
||||
};
|
||||
|
||||
CatalogSourceListItem.GetStatusText(source).Should().Be("Network timeout");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetStatusText_returns_not_loaded_when_never_fetched()
|
||||
{
|
||||
CatalogSourceListItem.GetStatusText(new AppCatalogSource()).Should().Be("Not loaded yet");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetStatusText_returns_updated_timestamp_when_fetched_successfully()
|
||||
{
|
||||
var fetchedAt = new DateTime(2026, 6, 11, 14, 30, 0, DateTimeKind.Utc);
|
||||
var source = new AppCatalogSource { LastFetchedUtc = fetchedAt };
|
||||
|
||||
CatalogSourceListItem.GetStatusText(source).Should().Be($"Updated {fetchedAt.ToLocalTime():g}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class CatalogSyncTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task CheckPendingCatalogUpdatesAsync_returns_diff_when_update_available()
|
||||
{
|
||||
var sourceId = Guid.NewGuid().ToString();
|
||||
var service = new AppCatalogService();
|
||||
var settings = new AppSettings();
|
||||
settings.EnsureInitialized();
|
||||
|
||||
var source = new AppCatalogSource
|
||||
{
|
||||
Id = sourceId,
|
||||
Name = "Remote List",
|
||||
Location = "https://example.com/list.json",
|
||||
Enabled = true,
|
||||
UpdateAvailable = true,
|
||||
};
|
||||
settings.AppCatalogSources.Add(source);
|
||||
|
||||
var accepted = new List<GameInfo>
|
||||
{
|
||||
new() { Repository = "owner/old", Name = "Old", FolderName = "OldFolder" },
|
||||
};
|
||||
var remote = new List<GameInfo>
|
||||
{
|
||||
new() { Repository = "owner/old", Name = "Updated", FolderName = "OldFolder" },
|
||||
new() { Repository = "owner/new", Name = "New", FolderName = "NewFolder" },
|
||||
};
|
||||
|
||||
await service.RegisterNewSourceAsync(source, remote);
|
||||
await service.InitializeAcceptedSnapshotAsync(source, accepted);
|
||||
source.UpdateAvailable = true;
|
||||
|
||||
using var httpClient = new HttpClient();
|
||||
var pending = await service.CheckPendingCatalogUpdatesAsync(httpClient, settings);
|
||||
|
||||
pending.Should().ContainSingle();
|
||||
pending[0].Diff.HasChanges.Should().BeTrue();
|
||||
pending[0].Diff.AddedCount.Should().Be(1);
|
||||
pending[0].Diff.ChangedCount.Should().Be(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
using Quiver.ViewModels;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class CatalogViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
public void BuildSourceListItems_maps_enabled_sources()
|
||||
{
|
||||
var settings = new AppSettings();
|
||||
settings.EnsureInitialized();
|
||||
settings.AppCatalogSources.Add(new AppCatalogSource
|
||||
{
|
||||
Name = "Local",
|
||||
Location = "apps.json",
|
||||
Enabled = true,
|
||||
});
|
||||
|
||||
var viewModel = new CatalogViewModel();
|
||||
var items = viewModel.BuildSourceListItems(settings);
|
||||
|
||||
items.Should().ContainSingle();
|
||||
items[0].Name.Should().Be("Local");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsAlreadySubscribed_matches_community_id_or_location()
|
||||
{
|
||||
var settings = new AppSettings();
|
||||
settings.EnsureInitialized();
|
||||
settings.AppCatalogSources.Add(new AppCatalogSource
|
||||
{
|
||||
CommunityListId = "n64-recomp",
|
||||
Location = "https://example.com/n64-recomp.json",
|
||||
});
|
||||
|
||||
var viewModel = new CatalogViewModel();
|
||||
viewModel.IsAlreadySubscribed(settings, new CommunityCatalogListEntry
|
||||
{
|
||||
Id = "n64-recomp",
|
||||
Location = "https://example.com/other.json",
|
||||
}).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreateSourceFromCommunityEntry_uses_entry_name()
|
||||
{
|
||||
var viewModel = new CatalogViewModel();
|
||||
var source = viewModel.CreateSourceFromCommunityEntry(new CommunityCatalogListEntry
|
||||
{
|
||||
Id = "list-id",
|
||||
Name = "N64 Recomp",
|
||||
Location = "https://example.com/list.json",
|
||||
});
|
||||
|
||||
source.Name.Should().Be("N64 Recomp");
|
||||
source.CommunityListId.Should().Be("list-id");
|
||||
source.Enabled.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class CommunityCatalogIndexTests
|
||||
{
|
||||
[Fact]
|
||||
public void ParseIndex_reads_community_index_fixture()
|
||||
{
|
||||
var index = CommunityCatalogIndexService.ParseIndex(TestFixtures.ReadCommunityIndexJson());
|
||||
|
||||
index.Version.Should().Be(1);
|
||||
index.Lists.Should().ContainSingle(list =>
|
||||
list.Id == "n64-recomp" &&
|
||||
list.Name == "N64 Recomp Games" &&
|
||||
list.Location == "community-app-lists/n64-recomp.json" &&
|
||||
list.ListVersion == "1.0.0");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FetchIndexAsync_reads_local_index_file()
|
||||
{
|
||||
var (index, error) = await CommunityCatalogIndexService.FetchIndexAsync(
|
||||
new HttpClient(),
|
||||
TestFixtures.CommunityIndexPath);
|
||||
|
||||
error.Should().BeNull();
|
||||
index.Should().NotBeNull();
|
||||
index!.Lists.Should().NotBeEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using FluentAssertions;
|
||||
using Quiver;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class FileSettingsStoreTests : IDisposable
|
||||
{
|
||||
private readonly string _tempDirectory;
|
||||
private readonly string _settingsPath;
|
||||
|
||||
public FileSettingsStoreTests()
|
||||
{
|
||||
_tempDirectory = Path.Combine(Path.GetTempPath(), "Quiver.Tests", Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(_tempDirectory);
|
||||
_settingsPath = Path.Combine(_tempDirectory, "settings.json");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Directory.Exists(_tempDirectory))
|
||||
Directory.Delete(_tempDirectory, recursive: true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_returns_defaults_when_file_missing()
|
||||
{
|
||||
var store = new FileSettingsStore(_settingsPath);
|
||||
|
||||
store.Current.FirstStartup.Should().BeTrue();
|
||||
store.Current.AppCatalogSources.Should().NotBeNull();
|
||||
store.Current.HiddenApps.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Save_and_Load_round_trip_settings()
|
||||
{
|
||||
var store = new FileSettingsStore(_settingsPath);
|
||||
var settings = store.Load();
|
||||
settings.GitHubApiToken = "test-token";
|
||||
settings.SortBy = "Name";
|
||||
settings.ListScope = AppListScope.InstalledOnly;
|
||||
settings.ManuallyHiddenApps.Add("folder:TestGame");
|
||||
|
||||
store.Save(settings);
|
||||
|
||||
var reloaded = new FileSettingsStore(_settingsPath).Load();
|
||||
reloaded.GitHubApiToken.Should().Be("test-token");
|
||||
reloaded.SortBy.Should().Be("Name");
|
||||
reloaded.ListScope.Should().Be(AppListScope.InstalledOnly);
|
||||
reloaded.ManuallyHiddenApps.Should().Contain("folder:TestGame");
|
||||
reloaded.HiddenApps.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Current_reflects_last_saved_settings()
|
||||
{
|
||||
var store = new FileSettingsStore(_settingsPath);
|
||||
var settings = store.Load();
|
||||
settings.CommunityCatalogIndexUrl = "community-app-lists/index.json";
|
||||
|
||||
store.Save(settings);
|
||||
|
||||
store.Current.CommunityCatalogIndexUrl.Should().Be("community-app-lists/index.json");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AppSettings_static_methods_use_default_store()
|
||||
{
|
||||
var original = SettingsStoreProvider.Default;
|
||||
try
|
||||
{
|
||||
SettingsStoreProvider.Default = new FileSettingsStore(_settingsPath);
|
||||
var settings = AppSettings.Load();
|
||||
settings.AppsPath = "D:\\Apps";
|
||||
AppSettings.Save(settings);
|
||||
|
||||
AppSettings.Load().AppsPath.Should().Be("D:\\Apps");
|
||||
}
|
||||
finally
|
||||
{
|
||||
SettingsStoreProvider.Default = original;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using FluentAssertions;
|
||||
using Quiver.Core.Models;
|
||||
using Quiver.Core.Services;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class GameDownloadInstallServiceTests
|
||||
{
|
||||
public GameDownloadInstallServiceTests()
|
||||
{
|
||||
var cacheDir = Path.Combine(Path.GetTempPath(), "QuiverTests", Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(cacheDir);
|
||||
GitHubApiCache.Initialize(cacheDir);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DownloadAndInstallAsync_installs_single_zip_asset()
|
||||
{
|
||||
var gamesFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(gamesFolder);
|
||||
|
||||
try
|
||||
{
|
||||
const string assetName = "payload.zip";
|
||||
var release = new GitHubRelease
|
||||
{
|
||||
tag_name = "v1.2.3",
|
||||
assets =
|
||||
[
|
||||
new GitHubAsset
|
||||
{
|
||||
name = assetName,
|
||||
browser_download_url = "https://example.com/download/asset",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
var game = new GameInfo
|
||||
{
|
||||
Name = "Test Game",
|
||||
Repository = "owner/test-game",
|
||||
FolderName = "TestGameFolder",
|
||||
};
|
||||
|
||||
var dialogs = new RecordingDialogs();
|
||||
using var client = new HttpClient(new StubHttpMessageHandler(_ => new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new ByteArrayContent(CreateMinimalZipWithExe()),
|
||||
}));
|
||||
|
||||
await GameDownloadInstallService.DownloadAndInstallAsync(
|
||||
game,
|
||||
client,
|
||||
gamesFolder,
|
||||
release,
|
||||
new AppSettings(),
|
||||
GameStatus.NotInstalled,
|
||||
dialogs);
|
||||
|
||||
dialogs.LastError.Should().BeNull("install failed with: {0}", dialogs.LastError);
|
||||
game.Status.Should().Be(GameStatus.Installed);
|
||||
game.InstalledVersion.Should().Be("v1.2.3");
|
||||
|
||||
var gamePath = game.GetInstallPath(gamesFolder);
|
||||
File.Exists(Path.Combine(gamePath, "version.txt")).Should().BeTrue();
|
||||
File.ReadAllText(Path.Combine(gamePath, "version.txt")).Trim().Should().Be("v1.2.3");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (Directory.Exists(gamesFolder))
|
||||
Directory.Delete(gamesFolder, true);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DownloadAndInstallAsync_resets_status_when_release_has_no_assets()
|
||||
{
|
||||
var gamesFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(gamesFolder);
|
||||
|
||||
try
|
||||
{
|
||||
var game = new GameInfo
|
||||
{
|
||||
Name = "Empty Assets",
|
||||
Repository = "owner/empty",
|
||||
FolderName = "EmptyAssets",
|
||||
};
|
||||
|
||||
var release = new GitHubRelease
|
||||
{
|
||||
tag_name = "v1.0.0",
|
||||
assets = [],
|
||||
};
|
||||
|
||||
using var client = new HttpClient(new StubHttpMessageHandler(_ =>
|
||||
throw new InvalidOperationException("HTTP should not be called when there are no assets")));
|
||||
|
||||
await GameDownloadInstallService.DownloadAndInstallAsync(
|
||||
game,
|
||||
client,
|
||||
gamesFolder,
|
||||
release,
|
||||
new AppSettings(),
|
||||
GameStatus.NotInstalled,
|
||||
HeadlessGameDownloadDialogs.Instance);
|
||||
|
||||
game.Status.Should().Be(GameStatus.NotInstalled);
|
||||
game.DownloadProgress.Should().Be(0);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (Directory.Exists(gamesFolder))
|
||||
Directory.Delete(gamesFolder, true);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DownloadAndInstallAsync_waits_for_asset_selection_when_multiple_downloads()
|
||||
{
|
||||
var gamesFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(gamesFolder);
|
||||
|
||||
try
|
||||
{
|
||||
var game = new GameInfo
|
||||
{
|
||||
Name = "Multi Asset",
|
||||
Repository = "owner/multi",
|
||||
FolderName = "MultiAsset",
|
||||
};
|
||||
|
||||
var release = new GitHubRelease
|
||||
{
|
||||
tag_name = "v2.0.0",
|
||||
assets =
|
||||
[
|
||||
new GitHubAsset { name = "linux.zip", browser_download_url = "https://example.com/linux.zip" },
|
||||
new GitHubAsset { name = "win.zip", browser_download_url = "https://example.com/win.zip" },
|
||||
],
|
||||
};
|
||||
|
||||
using var client = new HttpClient(new StubHttpMessageHandler(_ =>
|
||||
throw new InvalidOperationException("HTTP should not be called before asset selection")));
|
||||
|
||||
await GameDownloadInstallService.DownloadAndInstallAsync(
|
||||
game,
|
||||
client,
|
||||
gamesFolder,
|
||||
release,
|
||||
new AppSettings(),
|
||||
GameStatus.NotInstalled,
|
||||
HeadlessGameDownloadDialogs.Instance);
|
||||
|
||||
game.Status.Should().Be(GameStatus.NotInstalled);
|
||||
game.AvailableDownloads.Should().HaveCount(2);
|
||||
game.SelectedDownload.Should().BeNull();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (Directory.Exists(gamesFolder))
|
||||
Directory.Delete(gamesFolder, true);
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] CreateMinimalZipWithExe()
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, leaveOpen: true))
|
||||
{
|
||||
var entry = archive.CreateEntry("game.exe");
|
||||
using var writer = entry.Open();
|
||||
writer.Write(new byte[] { 0x4D, 0x5A, 0x90, 0x00 });
|
||||
}
|
||||
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
private sealed class RecordingDialogs : IGameDownloadDialogs
|
||||
{
|
||||
public string? LastError { get; private set; }
|
||||
|
||||
public Task<bool> ConfirmDownloadWithoutRunnerAsync() => Task.FromResult(true);
|
||||
|
||||
public Task<bool> ConfirmDownloadWithRunnerAsync() => Task.FromResult(true);
|
||||
|
||||
public Task ShowRateLimitExceededAsync() => Task.CompletedTask;
|
||||
|
||||
public Task ShowErrorAsync(string message, string title)
|
||||
{
|
||||
LastError = $"{title}: {message}";
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class StubHttpMessageHandler : HttpMessageHandler
|
||||
{
|
||||
private readonly Func<HttpRequestMessage, HttpResponseMessage> _handler;
|
||||
|
||||
public StubHttpMessageHandler(Func<HttpRequestMessage, HttpResponseMessage> handler)
|
||||
{
|
||||
_handler = handler;
|
||||
}
|
||||
|
||||
protected override Task<HttpResponseMessage> SendAsync(
|
||||
HttpRequestMessage request,
|
||||
CancellationToken cancellationToken) =>
|
||||
Task.FromResult(_handler(request));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Core.Models;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class GameDownloadServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void TrySelectPlatformDownload_selects_matching_platform_asset()
|
||||
{
|
||||
var game = new GameInfo { Name = "Test", Repository = "owner/app", FolderName = "TestFolder" };
|
||||
var settings = new AppSettings { Platform = TargetOS.Windows };
|
||||
var release = new GitHubRelease
|
||||
{
|
||||
tag_name = "v1.0.0",
|
||||
assets =
|
||||
[
|
||||
new GitHubAsset { name = "app-linux-x64.zip", browser_download_url = "https://example.com/linux.zip" },
|
||||
new GitHubAsset { name = "app-win-x64.zip", browser_download_url = "https://example.com/win.zip" },
|
||||
],
|
||||
};
|
||||
|
||||
GameDownloadService.TrySelectPlatformDownload(game, release, settings).Should().BeTrue();
|
||||
game.SelectedDownload!.name.Should().Contain("win");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TrySelectPlatformDownload_returns_false_without_release()
|
||||
{
|
||||
var game = new GameInfo();
|
||||
GameDownloadService.TrySelectPlatformDownload(game, null, new AppSettings()).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Models;
|
||||
using Quiver.ViewModels;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class GameGridViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
public void SortGames_orders_by_name_by_default()
|
||||
{
|
||||
var games = new[]
|
||||
{
|
||||
new GameInfo { Name = "Zelda" },
|
||||
new GameInfo { Name = "Banjo" },
|
||||
};
|
||||
|
||||
var sorted = new GameGridViewModel().SortGames(games, "Name", "/apps");
|
||||
sorted.Select(g => g.Name).Should().Equal("Banjo", "Zelda");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetLastPlayedTime_reads_timestamp_file()
|
||||
{
|
||||
var tempRoot = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
var gameFolder = Path.Combine(tempRoot, "TestGame");
|
||||
Directory.CreateDirectory(gameFolder);
|
||||
|
||||
try
|
||||
{
|
||||
var timestamp = "2024-06-01 12:00:00";
|
||||
File.WriteAllText(Path.Combine(gameFolder, "LastPlayed.txt"), timestamp);
|
||||
|
||||
var game = new GameInfo { FolderName = "TestGame" };
|
||||
var parsed = GameGridViewModel.GetLastPlayedTime(game, tempRoot);
|
||||
|
||||
parsed.Should().Be(DateTime.ParseExact(timestamp, "yyyy-MM-dd HH:mm:ss", null));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(tempRoot, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
using FluentAssertions;
|
||||
using Quiver;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
using Quiver.Core.Models;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class GameManagerFilterTests
|
||||
{
|
||||
private static (GameManager manager, FileSettingsStore store, string tempDir) CreateManager()
|
||||
{
|
||||
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(tempDir);
|
||||
var store = new FileSettingsStore(Path.Combine(tempDir, "settings.json"));
|
||||
var manager = new GameManager(store);
|
||||
return (manager, store, tempDir);
|
||||
}
|
||||
|
||||
private static GameInfo CreateGame(string name, string folder, GameStatus status, params string[] tags) =>
|
||||
new()
|
||||
{
|
||||
Name = name,
|
||||
FolderName = folder,
|
||||
Repository = $"owner/{folder}",
|
||||
Status = status,
|
||||
Tags = tags.ToList(),
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void InstalledOnly_scope_excludes_not_installed_apps()
|
||||
{
|
||||
var (manager, store, tempDir) = CreateManager();
|
||||
var settings = store.Current;
|
||||
settings.ListScope = AppListScope.InstalledOnly;
|
||||
|
||||
var catalog = new List<GameInfo>
|
||||
{
|
||||
CreateGame("Installed", "installed", GameStatus.Installed, "n64"),
|
||||
CreateGame("Not Installed", "missing", GameStatus.NotInstalled, "n64"),
|
||||
};
|
||||
|
||||
manager.SetCatalogAppsAndFilter(catalog, settings);
|
||||
|
||||
manager.Games.Should().ContainSingle(g => g.FolderName == "installed");
|
||||
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Tag_filter_and_InstalledOnly_scope_compose()
|
||||
{
|
||||
var (manager, store, tempDir) = CreateManager();
|
||||
var settings = store.Current;
|
||||
settings.ListScope = AppListScope.InstalledOnly;
|
||||
var filter = new TagDisplayFilter { Name = "N64", Tags = ["n64"] };
|
||||
settings.TagDisplayFilters.Add(filter);
|
||||
settings.ActiveTagDisplayFilterId = filter.Id;
|
||||
|
||||
var catalog = new List<GameInfo>
|
||||
{
|
||||
CreateGame("N64 Installed", "n64-installed", GameStatus.Installed, "n64"),
|
||||
CreateGame("N64 Missing", "n64-missing", GameStatus.NotInstalled, "n64"),
|
||||
CreateGame("Other Installed", "other", GameStatus.Installed, "pc"),
|
||||
};
|
||||
|
||||
manager.SetCatalogAppsAndFilter(catalog, settings);
|
||||
|
||||
manager.Games.Should().ContainSingle(g => g.FolderName == "n64-installed");
|
||||
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Tag_filter_preserves_ListScope_when_applied()
|
||||
{
|
||||
var (manager, store, tempDir) = CreateManager();
|
||||
var settings = store.Current;
|
||||
settings.ListScope = AppListScope.InstalledOnly;
|
||||
var filter = new TagDisplayFilter { Name = "N64", Tags = ["n64"] };
|
||||
settings.TagDisplayFilters.Add(filter);
|
||||
|
||||
manager.SetCatalogAppsAndFilter(
|
||||
[
|
||||
CreateGame("N64 Installed", "n64-installed", GameStatus.Installed, "n64"),
|
||||
CreateGame("Other Installed", "other", GameStatus.Installed, "pc"),
|
||||
],
|
||||
settings);
|
||||
|
||||
settings.ActiveTagDisplayFilterId = filter.Id;
|
||||
manager.ApplyTagDisplayFilter(settings);
|
||||
|
||||
settings.ListScope.Should().Be(AppListScope.InstalledOnly);
|
||||
manager.Games.Should().ContainSingle(g => g.FolderName == "n64-installed");
|
||||
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetListScope_AllApps_preserves_ActiveTagDisplayFilterId()
|
||||
{
|
||||
var (manager, store, tempDir) = CreateManager();
|
||||
var settings = store.Current;
|
||||
settings.ListScope = AppListScope.InstalledOnly;
|
||||
var filter = new TagDisplayFilter { Name = "N64", Tags = ["n64"] };
|
||||
settings.TagDisplayFilters.Add(filter);
|
||||
settings.ActiveTagDisplayFilterId = filter.Id;
|
||||
|
||||
manager.SetCatalogAppsAndFilter(
|
||||
[
|
||||
CreateGame("N64 Installed", "n64-installed", GameStatus.Installed, "n64"),
|
||||
CreateGame("N64 Missing", "n64-missing", GameStatus.NotInstalled, "n64"),
|
||||
],
|
||||
settings);
|
||||
|
||||
manager.SetListScope(AppListScope.AllApps, settings);
|
||||
|
||||
settings.ListScope.Should().Be(AppListScope.AllApps);
|
||||
settings.ActiveTagDisplayFilterId.Should().Be(filter.Id);
|
||||
manager.Games.Select(g => g.FolderName).Should().BeEquivalentTo("n64-installed", "n64-missing");
|
||||
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Manually_hidden_app_stays_hidden_in_all_scopes()
|
||||
{
|
||||
var (manager, store, tempDir) = CreateManager();
|
||||
var settings = store.Current;
|
||||
var game = CreateGame("Hidden", "hidden", GameStatus.Installed, "n64");
|
||||
settings.ManuallyHiddenApps.Add("folder:hidden");
|
||||
|
||||
manager.SetCatalogAppsAndFilter([game, CreateGame("Visible", "visible", GameStatus.Installed)], settings);
|
||||
|
||||
manager.Games.Should().ContainSingle(g => g.FolderName == "visible");
|
||||
|
||||
settings.ListScope = AppListScope.InstalledOnly;
|
||||
manager.SetCatalogAppsAndFilter(
|
||||
[
|
||||
game,
|
||||
CreateGame("Visible", "visible", GameStatus.Installed),
|
||||
],
|
||||
settings);
|
||||
|
||||
manager.Games.Should().ContainSingle(g => g.FolderName == "visible");
|
||||
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetLatestPlayedInstalledGame_is_not_affected_by_display_filters()
|
||||
{
|
||||
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
var appsFolder = Path.Combine(tempDir, "Apps");
|
||||
Directory.CreateDirectory(appsFolder);
|
||||
|
||||
var store = new FileSettingsStore(Path.Combine(tempDir, "settings.json"));
|
||||
store.Current.AppsPath = appsFolder;
|
||||
store.Save(store.Current);
|
||||
|
||||
var manager = new GameManager(store);
|
||||
var settings = store.Current;
|
||||
var continueGame = CreateGame("Continue Game", "continue-game", GameStatus.Installed, "n64");
|
||||
var continuePath = Path.Combine(appsFolder, "continue-game");
|
||||
Directory.CreateDirectory(continuePath);
|
||||
File.WriteAllText(Path.Combine(continuePath, "LastPlayed.txt"), "2025-06-01 12:00:00");
|
||||
|
||||
settings.ListScope = AppListScope.InstalledOnly;
|
||||
var filter = new TagDisplayFilter { Name = "PC", Tags = ["pc"] };
|
||||
settings.TagDisplayFilters.Add(filter);
|
||||
settings.ActiveTagDisplayFilterId = filter.Id;
|
||||
|
||||
manager.SetCatalogAppsAndFilter(
|
||||
[
|
||||
continueGame,
|
||||
CreateGame("Other", "other", GameStatus.Installed, "pc"),
|
||||
],
|
||||
settings);
|
||||
|
||||
manager.Games.Should().NotContain(g => g.FolderName == "continue-game");
|
||||
manager.GetLatestPlayedInstalledGame()?.FolderName.Should().Be("continue-game");
|
||||
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Tag_filter_with_All_match_mode_requires_every_tag()
|
||||
{
|
||||
var (manager, store, tempDir) = CreateManager();
|
||||
var settings = store.Current;
|
||||
var filter = new TagDisplayFilter
|
||||
{
|
||||
Name = "N64 Recomp",
|
||||
Tags = ["n64", "recomp"],
|
||||
MatchMode = TagFilterMatchMode.All,
|
||||
};
|
||||
settings.TagDisplayFilters.Add(filter);
|
||||
settings.ActiveTagDisplayFilterId = filter.Id;
|
||||
|
||||
manager.SetCatalogAppsAndFilter(
|
||||
[
|
||||
CreateGame("Both", "both", GameStatus.Installed, "n64", "recomp"),
|
||||
CreateGame("N64 Only", "n64-only", GameStatus.Installed, "n64"),
|
||||
CreateGame("Recomp Only", "recomp-only", GameStatus.Installed, "recomp"),
|
||||
],
|
||||
settings);
|
||||
|
||||
manager.Games.Select(g => g.FolderName).Should().ContainSingle().Which.Should().Be("both");
|
||||
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Tag_filter_with_Any_match_mode_matches_either_tag()
|
||||
{
|
||||
var (manager, store, tempDir) = CreateManager();
|
||||
var settings = store.Current;
|
||||
var filter = new TagDisplayFilter
|
||||
{
|
||||
Name = "N64 Recomp",
|
||||
Tags = ["n64", "recomp"],
|
||||
MatchMode = TagFilterMatchMode.Any,
|
||||
};
|
||||
settings.TagDisplayFilters.Add(filter);
|
||||
settings.ActiveTagDisplayFilterId = filter.Id;
|
||||
|
||||
manager.SetCatalogAppsAndFilter(
|
||||
[
|
||||
CreateGame("Both", "both", GameStatus.Installed, "n64", "recomp"),
|
||||
CreateGame("N64 Only", "n64-only", GameStatus.Installed, "n64"),
|
||||
CreateGame("Recomp Only", "recomp-only", GameStatus.Installed, "recomp"),
|
||||
CreateGame("Other", "other", GameStatus.Installed, "pc"),
|
||||
],
|
||||
settings);
|
||||
|
||||
manager.Games.Select(g => g.FolderName)
|
||||
.Should()
|
||||
.BeEquivalentTo("both", "n64-only", "recomp-only");
|
||||
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Clearing_active_tag_filter_restores_scope_only_list()
|
||||
{
|
||||
var (manager, store, tempDir) = CreateManager();
|
||||
var settings = store.Current;
|
||||
settings.ListScope = AppListScope.InstalledOnly;
|
||||
var filter = new TagDisplayFilter { Name = "N64", Tags = ["n64"] };
|
||||
settings.TagDisplayFilters.Add(filter);
|
||||
settings.ActiveTagDisplayFilterId = filter.Id;
|
||||
|
||||
manager.SetCatalogAppsAndFilter(
|
||||
[
|
||||
CreateGame("N64 Installed", "n64-installed", GameStatus.Installed, "n64"),
|
||||
CreateGame("PC Installed", "pc-installed", GameStatus.Installed, "pc"),
|
||||
CreateGame("N64 Missing", "n64-missing", GameStatus.NotInstalled, "n64"),
|
||||
],
|
||||
settings);
|
||||
|
||||
manager.Games.Select(g => g.FolderName).Should().ContainSingle().Which.Should().Be("n64-installed");
|
||||
|
||||
settings.ActiveTagDisplayFilterId = null;
|
||||
manager.ApplyTagDisplayFilter(settings);
|
||||
|
||||
manager.Games.Select(g => g.FolderName)
|
||||
.Should()
|
||||
.BeEquivalentTo("n64-installed", "pc-installed");
|
||||
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class GameManagerTests
|
||||
{
|
||||
[Fact]
|
||||
public void HideGame_adds_hidden_key_and_filters_collection()
|
||||
{
|
||||
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(tempDir);
|
||||
var store = new FileSettingsStore(Path.Combine(tempDir, "settings.json"));
|
||||
var manager = new GameManager(store);
|
||||
var game = new GameInfo
|
||||
{
|
||||
Name = "Hidden Game",
|
||||
FolderName = "HiddenFolder",
|
||||
Repository = "owner/hidden",
|
||||
};
|
||||
|
||||
manager.Games.Add(game);
|
||||
manager.HideGame(game);
|
||||
|
||||
store.Current.ManuallyHiddenApps.Should().Contain("folder:HiddenFolder");
|
||||
manager.Games.Should().BeEmpty();
|
||||
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsManuallyHidden_reflects_manual_hide_list()
|
||||
{
|
||||
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(tempDir);
|
||||
var store = new FileSettingsStore(Path.Combine(tempDir, "settings.json"));
|
||||
var manager = new GameManager(store);
|
||||
var game = new GameInfo { Name = "Manual", FolderName = "ManualFolder" };
|
||||
|
||||
manager.ToggleUserHide(game);
|
||||
manager.IsManuallyHidden(game).Should().BeTrue();
|
||||
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Core.Models;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class GameStatusServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task CheckStatusAsync_marks_missing_folder_as_not_installed()
|
||||
{
|
||||
var tempRoot = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(tempRoot);
|
||||
|
||||
try
|
||||
{
|
||||
var game = new GameInfo
|
||||
{
|
||||
Name = "Missing",
|
||||
FolderName = "MissingFolder",
|
||||
Repository = "owner/missing",
|
||||
};
|
||||
|
||||
using var httpClient = new HttpClient();
|
||||
await GameStatusService.CheckStatusAsync(game, httpClient, tempRoot);
|
||||
|
||||
game.Status.Should().Be(GameStatus.NotInstalled);
|
||||
game.IsLoading.Should().BeFalse();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(tempRoot, true);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsureInstalledVersionFileAsync_writes_default_version()
|
||||
{
|
||||
var tempFile = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid():N}.txt");
|
||||
|
||||
try
|
||||
{
|
||||
var version = await GameStatusService.EnsureInstalledVersionFileAsync(tempFile);
|
||||
version.Should().Be("0.0.0");
|
||||
File.ReadAllText(tempFile).Trim().Should().Be("0.0.0");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(tempFile))
|
||||
File.Delete(tempFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Avalonia.Headless.XUnit;
|
||||
using FluentAssertions;
|
||||
using Quiver;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class HeadlessSmokeTests
|
||||
{
|
||||
[AvaloniaFact]
|
||||
public void App_type_can_be_created_in_headless_mode()
|
||||
{
|
||||
var app = new App();
|
||||
|
||||
app.Should().NotBeNull();
|
||||
}
|
||||
|
||||
// Smoke test only: validates MainWindow visual tree and ctor wiring.
|
||||
// Does not exercise music playback, async icon loading, or catalog refresh.
|
||||
[AvaloniaFact]
|
||||
public void MainWindow_can_be_created_in_headless_mode()
|
||||
{
|
||||
var window = new MainWindow();
|
||||
|
||||
window.Should().NotBeNull();
|
||||
window.Width.Should().BeGreaterThan(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Headless;
|
||||
|
||||
[assembly: AvaloniaTestApplication(typeof(Quiver.Tests.HeadlessTestApp))]
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public static class HeadlessTestApp
|
||||
{
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<Quiver.App>()
|
||||
.UseHeadless(new AvaloniaHeadlessPlatformOptions());
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class LauncherUpdateServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void IsUpdateAvailable_detects_newer_tag()
|
||||
{
|
||||
var service = new LauncherUpdateService();
|
||||
service.IsUpdateAvailable("1.0.0", "v1.1.0").Should().BeTrue();
|
||||
service.IsUpdateAvailable("1.1.0", "v1.1.0").Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadInstalledVersion_reads_version_txt_from_directory()
|
||||
{
|
||||
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(tempDir);
|
||||
File.WriteAllText(Path.Combine(tempDir, "version.txt"), "2.3.4");
|
||||
|
||||
try
|
||||
{
|
||||
new LauncherUpdateService().ReadInstalledVersion(tempDir).Should().Be("2.3.4");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using FluentAssertions;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class LauncherVersionServiceTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("v1.2.3", "1.0.0", true)]
|
||||
[InlineData("1.0.0", "1.0.0", false)]
|
||||
[InlineData("0.9.0", "1.0.0", false)]
|
||||
[InlineData("V2.0", "1.9.9", true)]
|
||||
public void IsNewerVersion_compares_semantic_versions(string candidate, string baseline, bool expected)
|
||||
{
|
||||
LauncherVersionService.IsNewerVersion(candidate, baseline).Should().Be(expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AreVersionsEquivalent_treats_v_prefix_as_equal()
|
||||
{
|
||||
LauncherVersionService.AreVersionsEquivalent("v1.0.0", "1.0.0").Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NormalizeVersionString_pads_short_versions()
|
||||
{
|
||||
LauncherVersionService.NormalizeVersionString("v2").Should().Be("2.0.0");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadInstalledVersion_reads_version_file_from_directory()
|
||||
{
|
||||
var tempDirectory = Path.Combine(Path.GetTempPath(), "Quiver.Tests", Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(tempDirectory);
|
||||
File.WriteAllText(Path.Combine(tempDirectory, "version.txt"), "v1.2.3");
|
||||
|
||||
try
|
||||
{
|
||||
LauncherVersionService.ReadInstalledVersion(tempDirectory).Should().Be("v1.2.3");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(tempDirectory, recursive: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<CoverletOutputFormat>cobertura</CoverletOutputFormat>
|
||||
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
|
||||
<Exclude>[*.Tests]*</Exclude>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.Headless.XUnit" Version="11.3.12" />
|
||||
<PackageReference Include="coverlet.collector" Version="10.0.1">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="FluentAssertions" Version="8.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Quiver.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\community-app-lists\index.json" Link="Fixtures\community-app-lists\index.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
<None Include="..\community-app-lists\n64-recomp.json" Link="Fixtures\community-app-lists\n64-recomp.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,79 @@
|
||||
using FluentAssertions;
|
||||
using Quiver;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class TagHelperTests
|
||||
{
|
||||
[Fact]
|
||||
public void ParseCommaSeparatedTags_normalizes_and_deduplicates()
|
||||
{
|
||||
var tags = TagHelper.ParseCommaSeparatedTags(" N64, Recomp, n64 , ");
|
||||
|
||||
tags.Should().BeEquivalentTo(["n64", "recomp"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatchesAnyFilterTags_returns_true_when_any_tag_matches()
|
||||
{
|
||||
TagHelper.MatchesAnyFilterTags(["n64", "favorites"], ["recomp", "n64"]).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatchesAnyFilterTags_returns_false_when_no_tags_match()
|
||||
{
|
||||
TagHelper.MatchesAnyFilterTags(["n64"], ["recomp", "gc"]).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatchesAnyFilterTags_returns_true_when_filter_has_no_tags()
|
||||
{
|
||||
TagHelper.MatchesAnyFilterTags(["n64"], []).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MergeTags_combines_and_deduplicates()
|
||||
{
|
||||
TagHelper.MergeTags(["n64", "recomp"], ["favorites", "N64"])
|
||||
.Should()
|
||||
.BeEquivalentTo(["n64", "recomp", "favorites"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatchesAllFilterTags_returns_true_when_app_has_every_tag()
|
||||
{
|
||||
TagHelper.MatchesAllFilterTags(["n64", "recomp", "favorites"], ["n64", "recomp"]).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatchesAllFilterTags_returns_false_when_app_missing_a_tag()
|
||||
{
|
||||
TagHelper.MatchesAllFilterTags(["n64"], ["n64", "recomp"]).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatchesAllFilterTags_returns_true_when_filter_has_no_tags()
|
||||
{
|
||||
TagHelper.MatchesAllFilterTags(["n64"], []).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatchesFilterTags_routes_to_any_or_all()
|
||||
{
|
||||
var appTags = new[] { "n64", "recomp" };
|
||||
var filterTags = new[] { "n64", "gc" };
|
||||
|
||||
TagHelper.MatchesFilterTags(appTags, filterTags, TagFilterMatchMode.Any).Should().BeTrue();
|
||||
TagHelper.MatchesFilterTags(appTags, filterTags, TagFilterMatchMode.All).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatchesFilterTags_single_tag_behaves_same_for_any_and_all()
|
||||
{
|
||||
TagHelper.MatchesFilterTags(["n64"], ["n64"], TagFilterMatchMode.Any).Should().BeTrue();
|
||||
TagHelper.MatchesFilterTags(["n64"], ["n64"], TagFilterMatchMode.All).Should().BeTrue();
|
||||
TagHelper.MatchesFilterTags(["recomp"], ["n64"], TagFilterMatchMode.Any).Should().BeFalse();
|
||||
TagHelper.MatchesFilterTags(["recomp"], ["n64"], TagFilterMatchMode.All).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace Quiver.Tests;
|
||||
|
||||
internal static class TestFixtures
|
||||
{
|
||||
public static string CommunityAppListsDirectory =>
|
||||
Path.Combine(AppContext.BaseDirectory, "Fixtures", "community-app-lists");
|
||||
|
||||
public static string CommunityIndexPath =>
|
||||
Path.Combine(CommunityAppListsDirectory, "index.json");
|
||||
|
||||
public static string N64RecompListPath =>
|
||||
Path.Combine(CommunityAppListsDirectory, "n64-recomp.json");
|
||||
|
||||
public static string ReadCommunityIndexJson() =>
|
||||
File.ReadAllText(CommunityIndexPath);
|
||||
|
||||
public static string ReadN64RecompListJson() =>
|
||||
File.ReadAllText(N64RecompListPath);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using FluentAssertions;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.Tests;
|
||||
|
||||
public class WindowsRunnerServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void BuildWindowsRunnerCommand_appends_exe_placeholder_when_missing()
|
||||
{
|
||||
var command = WindowsRunnerService.BuildWindowsRunnerCommand(
|
||||
"wine",
|
||||
"/games/app/game.exe",
|
||||
"/games/app");
|
||||
|
||||
command.FileName.Should().Be("wine");
|
||||
command.Arguments.Should().ContainSingle("/games/app/game.exe");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildWindowsRunnerCommand_resolves_custom_placeholders()
|
||||
{
|
||||
var command = WindowsRunnerService.BuildWindowsRunnerCommand(
|
||||
"custom-runner --dir {exeDir} --root {gamePath} {exe}",
|
||||
"/games/app/game.exe",
|
||||
"/games/app");
|
||||
|
||||
command.Arguments.Should().Contain("/games/app");
|
||||
command.Arguments.Should().Contain("/games/app/game.exe");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SplitRunnerCommand_handles_quoted_arguments()
|
||||
{
|
||||
var tokens = WindowsRunnerService.SplitRunnerCommand("runner \"quoted path\" {exe}");
|
||||
|
||||
tokens.Should().Equal("runner", "quoted path", "{exe}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsWindowsRunnerAvailable_respects_platform_and_custom_command()
|
||||
{
|
||||
var settings = new AppSettings
|
||||
{
|
||||
LinuxWindowsLaunchCommand = "wine {exe}",
|
||||
};
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
WindowsRunnerService.IsWindowsRunnerAvailable(settings).Should().BeTrue();
|
||||
else
|
||||
WindowsRunnerService.IsWindowsRunnerAvailable(settings).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,13 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||
<AssemblyTitle>Github Launcher</AssemblyTitle>
|
||||
<AssemblyName>Quiver</AssemblyName>
|
||||
<RootNamespace>Quiver</RootNamespace>
|
||||
<AssemblyTitle>Quiver</AssemblyTitle>
|
||||
<AssemblyDescription>Download and manage GitHub-hosted game ports</AssemblyDescription>
|
||||
<AssemblyVersion>1.0.0.0</AssemblyVersion>
|
||||
<FileVersion>1.0.0.0</FileVersion>
|
||||
<Version>2.0.0</Version>
|
||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||
<FileVersion>2.0.0.0</FileVersion>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<Nullable>enable</Nullable>
|
||||
@@ -25,7 +28,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AnimatedImage.Avalonia" Version="2.1.4" />
|
||||
<PackageReference Include="AsyncImageLoader.Avalonia" Version="3.6.0" />
|
||||
<PackageReference Include="Avalonia" Version="11.3.12" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.12" />
|
||||
@@ -43,12 +45,21 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="lib\GitHubLauncher.Core\GitHubLauncher.Core.csproj" />
|
||||
<None Update="version.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="lib\GitHubLauncher.Core\**\*.cs" />
|
||||
<EmbeddedResource Remove="lib\GitHubLauncher.Core\**\*.*" />
|
||||
<None Remove="lib\GitHubLauncher.Core\**\*.*" />
|
||||
<ProjectReference Include="lib\Quiver.Core\Quiver.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="lib\Quiver.Core\**\*.cs" />
|
||||
<Compile Remove="Quiver.Tests\**\*.cs" />
|
||||
<EmbeddedResource Remove="lib\Quiver.Core\**\*.*" />
|
||||
<EmbeddedResource Remove="Quiver.Tests\**\*.*" />
|
||||
<None Remove="lib\Quiver.Core\**\*.*" />
|
||||
<None Remove="Quiver.Tests\**\*.*" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36310.24
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quiver", "Quiver.csproj", "{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quiver.Core", "lib\Quiver.Core\Quiver.Core.csproj", "{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quiver.Tests", "Quiver.Tests\Quiver.Tests.csproj", "{A90562B1-1583-469F-A0B1-2C32215E8A87}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Release|x64.Build.0 = Release|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{71EB560C-A7EB-C4F2-645D-9FB2ADA2916C}.Release|x86.Build.0 = Release|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Release|x64.Build.0 = Release|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{2C32DAAB-3EBA-4B2D-8323-BFB0C2426855}.Release|x86.Build.0 = Release|Any CPU
|
||||
{A90562B1-1583-469F-A0B1-2C32215E8A87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A90562B1-1583-469F-A0B1-2C32215E8A87}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A90562B1-1583-469F-A0B1-2C32215E8A87}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{A90562B1-1583-469F-A0B1-2C32215E8A87}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{A90562B1-1583-469F-A0B1-2C32215E8A87}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{A90562B1-1583-469F-A0B1-2C32215E8A87}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{A90562B1-1583-469F-A0B1-2C32215E8A87}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A90562B1-1583-469F-A0B1-2C32215E8A87}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A90562B1-1583-469F-A0B1-2C32215E8A87}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{A90562B1-1583-469F-A0B1-2C32215E8A87}.Release|x64.Build.0 = Release|Any CPU
|
||||
{A90562B1-1583-469F-A0B1-2C32215E8A87}.Release|x86.ActiveCfg = Debug|Any CPU
|
||||
{A90562B1-1583-469F-A0B1-2C32215E8A87}.Release|x86.Build.0 = Debug|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {9092E66B-AF24-466E-84DB-F80364B83B55}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,12 +1,12 @@
|
||||
# Github Launcher
|
||||
# Quiver
|
||||
|
||||
[](https://dotnet.microsoft.com/)
|
||||
[](https://github.com/SirDiabo/GithubLauncher/blob/main/LICENSE)
|
||||
[](https://github.com/tgeorgiadis/quiver/blob/main/LICENSE)
|
||||
|
||||
>## Important
|
||||
>This software was previously knows as the "N64Recomp Launcher", but this had to be changed due to the continued requests by the N64Recomp Tool Developers. If you are interested in a version of the launcher that is primarily for N64 Recompiled Games, then check out [this version](https://github.com/SirDiabo/GithubLauncher/releases/tag/v1.70).
|
||||
|
||||

|
||||

|
||||
A modern, user-friendly launcher application for managing and running GitHub-hosted applications. This tool streamlines the process of downloading, installing, and launching your favorite projects.
|
||||
|
||||
## Features
|
||||
@@ -25,7 +25,7 @@ A modern, user-friendly launcher application for managing and running GitHub-hos
|
||||
|
||||
### Installation
|
||||
|
||||
1. Download the latest release from the [Releases](https://github.com/SirDiabo/GithubLauncher/releases) page
|
||||
1. Download the latest release from the [Releases](https://github.com/tgeorgiadis/quiver/releases) page
|
||||
2. Extract the downloaded archive to your preferred location
|
||||
3. Run the executable.
|
||||
|
||||
@@ -36,6 +36,48 @@ A modern, user-friendly launcher application for managing and running GitHub-hos
|
||||
3. Browse your app library through the interface
|
||||
4. Select an app and click "Download/Launch" to use it
|
||||
|
||||
## Local Development
|
||||
|
||||
When building and running from source, the launcher skips automatic self-update checks so a GitHub release does not overwrite your local build output.
|
||||
|
||||
- **Debug builds** (`dotnet run -c Debug`): startup self-update is always skipped.
|
||||
- **Release builds** run locally: set `Quiver_SKIP_UPDATES=1` (or `true`) before launching.
|
||||
|
||||
Manual update checks from the in-app **Check for Updates** button still work in all configurations.
|
||||
|
||||
```powershell
|
||||
# Debug — no env var needed
|
||||
dotnet run --project Quiver.csproj -c Debug
|
||||
|
||||
# Release local testing
|
||||
$env:Quiver_SKIP_UPDATES = "1"
|
||||
dotnet run --project Quiver.csproj -c Release
|
||||
```
|
||||
|
||||
If a previous run already downloaded a release into your output folder, delete `update_check.json` and any `backup_*` folders under `bin\Debug` or `bin\Release`, then rebuild.
|
||||
|
||||
### Automated tests
|
||||
|
||||
Run the xUnit test suite:
|
||||
|
||||
```powershell
|
||||
dotnet test Quiver.sln
|
||||
```
|
||||
|
||||
Release configuration matches CI:
|
||||
|
||||
```powershell
|
||||
dotnet test Quiver.sln -c Release
|
||||
```
|
||||
|
||||
Test categories include catalog merge and sync, settings store round-trip, launcher version helpers, Windows runner command building, download asset selection, game status checks, ViewModel sorting/catalog helpers, GameManager hide/filter behavior, and Avalonia headless smoke tests.
|
||||
|
||||
Collect coverage locally with:
|
||||
|
||||
```powershell
|
||||
dotnet test Quiver.sln -c Release --collect:"XPlat Code Coverage"
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### GitHub API Token
|
||||
@@ -46,7 +88,22 @@ You don't need to give it any special permissions. Then paste that Token into yo
|
||||
|
||||
### apps.json Structure
|
||||
|
||||
The launcher uses an `apps.json` file to manage the available apps. Every entry is user-managed and editable; there are no built-in stable, experimental, or custom categories.
|
||||
The launcher uses an `apps.json` file to manage the available apps. Every entry is user-managed and editable; there are no built-in stable, experimental, or custom categories. Add, edit, or remove entries from the **Library** using **+ Add New Entry** or each app's **Catalog** context menu.
|
||||
|
||||
#### External catalog sources
|
||||
|
||||
You can add additional `apps.json` catalogs in **Settings → General → App Catalog Sources**. Each source can be a remote URL (for example a raw GitHub link) or a local file path. Multiple sources are merged into your library; entries in the local `apps.json` take priority when the same repository appears in more than one place. Removing a source prompts you to keep its exclusive apps (copied into your local list) or remove them from the library. Installed app files on disk are never deleted automatically.
|
||||
|
||||
#### Community catalog lists
|
||||
|
||||
The `community-app-lists/` folder contains a sample community index and starter list (`n64-recomp.json`). To browse community-maintained lists:
|
||||
|
||||
1. Set **Community index URL** in **Settings → General** to a hosted `index.json` URL or a local file path (for example `community-app-lists/index.json` in this repo).
|
||||
2. Click **Browse Community Lists** and subscribe to any entry.
|
||||
|
||||
When a subscribed list changes remotely, the launcher detects the diff on startup or when you click **Refresh All Sources**, then prompts you to **Apply All**, **Apply New Only**, or **Keep Current**. The launcher stores an accepted snapshot per source so your library does not change until you confirm.
|
||||
|
||||
See [`community-app-lists/README.md`](community-app-lists/README.md) for how to publish and maintain community lists.
|
||||
|
||||
#### App Entry Properties
|
||||
|
||||
@@ -81,5 +138,5 @@ Each app entry requires the following properties:
|
||||
## Support
|
||||
|
||||
If you encounter any issues or have questions:
|
||||
- [Open an issue](https://github.com/SirDiabo/GithubLauncher/issues)
|
||||
- [Open an issue](https://github.com/tgeorgiadis/quiver/issues)
|
||||
- Check existing issues for solutions
|
||||
@@ -0,0 +1,678 @@
|
||||
using Quiver.Models;
|
||||
using System.Net.Http;
|
||||
using AppSettings = Quiver.AppSettings;
|
||||
using AppCatalogSource = Quiver.AppCatalogSource;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Quiver.Services
|
||||
{
|
||||
public class AppCatalogService
|
||||
{
|
||||
private readonly string _appsConfigPath;
|
||||
private readonly string _legacyGamesConfigPath;
|
||||
private readonly string _catalogSourcesCacheFolder;
|
||||
private readonly GameManager? _gameManager;
|
||||
private readonly ICatalogLocationReader _locationReader;
|
||||
|
||||
public AppCatalogService(GameManager? gameManager = null, ICatalogLocationReader? locationReader = null)
|
||||
{
|
||||
_gameManager = gameManager;
|
||||
_locationReader = locationReader ?? CatalogLocationReader.Default;
|
||||
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
_appsConfigPath = Path.Combine(baseDir, "apps.json");
|
||||
_legacyGamesConfigPath = Path.Combine(baseDir, "games.json");
|
||||
_catalogSourcesCacheFolder = Path.Combine(baseDir, "Cache", "CatalogSources");
|
||||
Directory.CreateDirectory(_catalogSourcesCacheFolder);
|
||||
}
|
||||
|
||||
public string AppsConfigPath => _appsConfigPath;
|
||||
|
||||
public async Task<List<GameInfo>> LoadLocalAppsAsync()
|
||||
{
|
||||
if (!File.Exists(_appsConfigPath))
|
||||
{
|
||||
if (File.Exists(_legacyGamesConfigPath))
|
||||
{
|
||||
var migratedApps = await LoadAppsFromFileAsync(_legacyGamesConfigPath).ConfigureAwait(false);
|
||||
await SaveLocalAppsAsync(migratedApps).ConfigureAwait(false);
|
||||
return migratedApps;
|
||||
}
|
||||
|
||||
await SaveLocalAppsAsync([]).ConfigureAwait(false);
|
||||
return [];
|
||||
}
|
||||
|
||||
return await LoadAppsFromFileAsync(_appsConfigPath).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task ValidateAndFixLocalAppsJsonAsync()
|
||||
{
|
||||
var apps = await LoadLocalAppsAsync().ConfigureAwait(false);
|
||||
await SaveLocalAppsAsync(apps).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<List<GameInfo>> LoadMergedCatalogAsync(HttpClient httpClient, AppSettings settings)
|
||||
{
|
||||
settings.EnsureInitialized();
|
||||
var localApps = await LoadLocalAppsAsync().ConfigureAwait(false);
|
||||
foreach (var app in localApps)
|
||||
{
|
||||
app.CatalogSourceId = null;
|
||||
app.GameManager = _gameManager;
|
||||
}
|
||||
|
||||
var merged = new List<GameInfo>(localApps);
|
||||
var seenRepos = new HashSet<string>(
|
||||
localApps
|
||||
.Where(a => !string.IsNullOrWhiteSpace(a.Repository))
|
||||
.Select(a => a.Repository!),
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
foreach (var source in settings.AppCatalogSources.Where(s => s.Enabled))
|
||||
{
|
||||
var acceptedApps = await SyncAndGetAcceptedAppsAsync(httpClient, source).ConfigureAwait(false);
|
||||
foreach (var app in acceptedApps)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(app.Repository))
|
||||
continue;
|
||||
|
||||
if (seenRepos.Add(app.Repository))
|
||||
{
|
||||
app.CatalogSourceId = source.Id;
|
||||
app.GameManager = _gameManager;
|
||||
merged.Add(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var app in merged)
|
||||
ApplyUserAppTags(app, settings);
|
||||
|
||||
AppSettings.Save(settings);
|
||||
return merged;
|
||||
}
|
||||
|
||||
public static void ApplyUserAppTags(GameInfo app, AppSettings settings)
|
||||
{
|
||||
settings.EnsureInitialized();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(app.Repository))
|
||||
{
|
||||
app.Tags = TagHelper.NormalizeTags(app.Tags);
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.UserAppTags.TryGetValue(app.Repository, out var userTags))
|
||||
app.Tags = TagHelper.NormalizeTags(userTags);
|
||||
else
|
||||
app.Tags = TagHelper.NormalizeTags(app.Tags);
|
||||
}
|
||||
|
||||
public async Task<List<PendingCatalogUpdate>> CheckPendingCatalogUpdatesAsync(
|
||||
HttpClient httpClient,
|
||||
AppSettings settings)
|
||||
{
|
||||
settings.EnsureInitialized();
|
||||
var pending = new List<PendingCatalogUpdate>();
|
||||
|
||||
foreach (var source in settings.AppCatalogSources.Where(s => s.Enabled && s.UpdateAvailable))
|
||||
{
|
||||
var acceptedApps = await LoadAcceptedAppsAsync(source.Id).ConfigureAwait(false);
|
||||
var remoteApps = await LoadFetchedAppsFromCacheAsync(source.Id).ConfigureAwait(false);
|
||||
|
||||
if (remoteApps.Count == 0)
|
||||
continue;
|
||||
|
||||
pending.Add(new PendingCatalogUpdate
|
||||
{
|
||||
Source = source,
|
||||
AcceptedApps = acceptedApps,
|
||||
RemoteApps = remoteApps,
|
||||
Diff = GetCatalogDiff(acceptedApps, remoteApps),
|
||||
});
|
||||
}
|
||||
|
||||
return pending;
|
||||
}
|
||||
|
||||
public async Task AcceptCatalogUpdateAsync(
|
||||
AppCatalogSource source,
|
||||
List<GameInfo> remoteApps,
|
||||
List<GameInfo> acceptedApps,
|
||||
CatalogUpdateChoice choice)
|
||||
{
|
||||
if (choice == CatalogUpdateChoice.KeepCurrent)
|
||||
{
|
||||
source.UpdateAvailable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var newAccepted = CatalogMerge.ApplyChoice(choice, acceptedApps, remoteApps, CloneCatalogApp);
|
||||
if (newAccepted == null)
|
||||
return;
|
||||
|
||||
await SaveAcceptedSnapshotAsync(source, newAccepted).ConfigureAwait(false);
|
||||
source.UpdateAvailable = false;
|
||||
}
|
||||
|
||||
public async Task InitializeAcceptedSnapshotAsync(AppCatalogSource source, List<GameInfo> apps)
|
||||
{
|
||||
await SaveAcceptedSnapshotAsync(source, apps).ConfigureAwait(false);
|
||||
source.UpdateAvailable = false;
|
||||
}
|
||||
|
||||
public async Task RegisterNewSourceAsync(AppCatalogSource source, List<GameInfo> apps)
|
||||
{
|
||||
await WriteAppsToFileAsync(GetSourceCachePath(source.Id), apps).ConfigureAwait(false);
|
||||
source.LastFetchedUtc = DateTime.UtcNow;
|
||||
source.LastError = null;
|
||||
await InitializeAcceptedSnapshotAsync(source, apps).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<(List<GameInfo> Apps, string? Error)> TryLoadSourceAsync(
|
||||
HttpClient httpClient,
|
||||
string location)
|
||||
{
|
||||
try
|
||||
{
|
||||
var json = await _locationReader.ReadAsync(httpClient, location).ConfigureAwait(false);
|
||||
using var document = JsonDocument.Parse(json);
|
||||
var apps = ParseAppsRoot(document.RootElement);
|
||||
foreach (var app in apps)
|
||||
app.GameManager = _gameManager;
|
||||
|
||||
return (apps, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ([], ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<GameInfo>> GetExclusiveAppsForSourceAsync(
|
||||
HttpClient httpClient,
|
||||
AppSettings settings,
|
||||
AppCatalogSource source)
|
||||
{
|
||||
settings.EnsureInitialized();
|
||||
var localApps = await LoadLocalAppsAsync().ConfigureAwait(false);
|
||||
var localRepos = new HashSet<string>(
|
||||
localApps
|
||||
.Where(a => !string.IsNullOrWhiteSpace(a.Repository))
|
||||
.Select(a => a.Repository!),
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var sourceApps = await LoadAcceptedAppsAsync(source.Id).ConfigureAwait(false);
|
||||
if (sourceApps.Count == 0)
|
||||
{
|
||||
sourceApps = await SyncAndGetAcceptedAppsAsync(httpClient, source, persistSettings: false)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var sourceRepos = sourceApps
|
||||
.Where(a => !string.IsNullOrWhiteSpace(a.Repository))
|
||||
.ToDictionary(a => a.Repository!, a => a, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var otherSourceRepos = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var other in settings.AppCatalogSources.Where(s => s.Enabled && s.Id != source.Id))
|
||||
{
|
||||
var otherApps = await LoadAcceptedAppsAsync(other.Id).ConfigureAwait(false);
|
||||
foreach (var app in otherApps)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(app.Repository))
|
||||
otherSourceRepos.Add(app.Repository);
|
||||
}
|
||||
}
|
||||
|
||||
var exclusive = new List<GameInfo>();
|
||||
foreach (var (repo, app) in sourceRepos)
|
||||
{
|
||||
if (!localRepos.Contains(repo) && !otherSourceRepos.Contains(repo))
|
||||
exclusive.Add(app);
|
||||
}
|
||||
|
||||
return exclusive;
|
||||
}
|
||||
|
||||
public async Task PromoteAppsToLocalAsync(IEnumerable<GameInfo> apps)
|
||||
{
|
||||
var localApps = await LoadLocalAppsAsync().ConfigureAwait(false);
|
||||
var localRepos = new HashSet<string>(
|
||||
localApps
|
||||
.Where(a => !string.IsNullOrWhiteSpace(a.Repository))
|
||||
.Select(a => a.Repository!),
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
foreach (var app in apps)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(app.Repository) || localRepos.Contains(app.Repository))
|
||||
continue;
|
||||
|
||||
localApps.Add(CloneForLocal(app));
|
||||
localRepos.Add(app.Repository);
|
||||
}
|
||||
|
||||
await SaveLocalAppsAsync(localApps).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task PromoteAppToLocalIfNeededAsync(GameInfo app)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(app.Repository))
|
||||
return;
|
||||
|
||||
var localApps = await LoadLocalAppsAsync().ConfigureAwait(false);
|
||||
var exists = localApps.Any(g =>
|
||||
g.Repository != null &&
|
||||
g.Repository.Equals(app.Repository, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (exists)
|
||||
return;
|
||||
|
||||
localApps.Add(CloneForLocal(app));
|
||||
await SaveLocalAppsAsync(localApps).ConfigureAwait(false);
|
||||
app.CatalogSourceId = null;
|
||||
}
|
||||
|
||||
public async Task SaveLocalAppsAsync(List<GameInfo> apps)
|
||||
{
|
||||
await WriteAppsToFileAsync(_appsConfigPath, apps).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task ExportLocalAppsToFileAsync(string exportPath, List<GameInfo>? apps = null)
|
||||
{
|
||||
apps ??= await LoadLocalAppsAsync().ConfigureAwait(false);
|
||||
await WriteAppsToFileAsync(exportPath, apps).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public static string ComputeCatalogContentHash(IEnumerable<GameInfo> apps)
|
||||
{
|
||||
var entries = apps
|
||||
.Where(a => !string.IsNullOrWhiteSpace(a.Repository))
|
||||
.Select(a => string.Join("|",
|
||||
a.Repository!.Trim(),
|
||||
a.Name ?? "",
|
||||
a.FolderName ?? "",
|
||||
a.InstallPath ?? "",
|
||||
a.GameIconUrl ?? "",
|
||||
a.PreferredVersion ?? "",
|
||||
a.SkippedUpdateVersion ?? "",
|
||||
TagHelper.FormatTagsForDisplay(a.Tags)))
|
||||
.OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var payload = string.Join("\n", entries);
|
||||
var hashBytes = SHA256.HashData(Encoding.UTF8.GetBytes(payload));
|
||||
return Convert.ToHexString(hashBytes);
|
||||
}
|
||||
|
||||
public static CatalogDiff GetCatalogDiff(List<GameInfo> acceptedApps, List<GameInfo> remoteApps)
|
||||
{
|
||||
var acceptedByRepo = acceptedApps
|
||||
.Where(a => !string.IsNullOrWhiteSpace(a.Repository))
|
||||
.ToDictionary(a => a.Repository!, a => a, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var remoteByRepo = remoteApps
|
||||
.Where(a => !string.IsNullOrWhiteSpace(a.Repository))
|
||||
.ToDictionary(a => a.Repository!, a => a, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var diff = new CatalogDiff();
|
||||
|
||||
foreach (var (repo, remote) in remoteByRepo)
|
||||
{
|
||||
if (!acceptedByRepo.ContainsKey(repo))
|
||||
diff.Added.Add(remote);
|
||||
else if (!AppsEquivalent(acceptedByRepo[repo], remote))
|
||||
diff.Changed.Add(remote);
|
||||
}
|
||||
|
||||
foreach (var (repo, accepted) in acceptedByRepo)
|
||||
{
|
||||
if (!remoteByRepo.ContainsKey(repo))
|
||||
diff.Removed.Add(accepted);
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
private static bool AppsEquivalent(GameInfo a, GameInfo b) =>
|
||||
string.Equals(a.Name, b.Name, StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(a.FolderName, b.FolderName, StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(a.InstallPath ?? "", b.InstallPath ?? "", StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(a.GameIconUrl ?? "", b.GameIconUrl ?? "", StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(a.PreferredVersion ?? "", b.PreferredVersion ?? "", StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(a.SkippedUpdateVersion ?? "", b.SkippedUpdateVersion ?? "", StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(TagHelper.FormatTagsForDisplay(a.Tags), TagHelper.FormatTagsForDisplay(b.Tags), StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private async Task<List<GameInfo>> SyncAndGetAcceptedAppsAsync(
|
||||
HttpClient httpClient,
|
||||
AppCatalogSource source,
|
||||
bool persistSettings = true)
|
||||
{
|
||||
var fetchSucceeded = await FetchSourceToCacheAsync(httpClient, source, persistMetadata: persistSettings)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var acceptedApps = await LoadAcceptedAppsAsync(source.Id).ConfigureAwait(false);
|
||||
var fetchedApps = await LoadFetchedAppsFromCacheAsync(source.Id).ConfigureAwait(false);
|
||||
|
||||
if (acceptedApps.Count == 0 && fetchSucceeded && fetchedApps.Count > 0)
|
||||
{
|
||||
await SaveAcceptedSnapshotAsync(source, fetchedApps).ConfigureAwait(false);
|
||||
source.UpdateAvailable = false;
|
||||
return fetchedApps;
|
||||
}
|
||||
|
||||
if (fetchSucceeded && fetchedApps.Count > 0)
|
||||
{
|
||||
var remoteHash = ComputeCatalogContentHash(fetchedApps);
|
||||
source.UpdateAvailable = !string.Equals(
|
||||
remoteHash,
|
||||
source.AcceptedContentHash,
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
else if (acceptedApps.Count > 0)
|
||||
{
|
||||
return acceptedApps;
|
||||
}
|
||||
|
||||
return acceptedApps;
|
||||
}
|
||||
|
||||
private async Task<bool> FetchSourceToCacheAsync(
|
||||
HttpClient httpClient,
|
||||
AppCatalogSource source,
|
||||
bool persistMetadata = true)
|
||||
{
|
||||
var cachePath = GetSourceCachePath(source.Id);
|
||||
|
||||
try
|
||||
{
|
||||
var json = await _locationReader.ReadAsync(httpClient, source.Location).ConfigureAwait(false);
|
||||
await File.WriteAllTextAsync(cachePath, json).ConfigureAwait(false);
|
||||
|
||||
if (persistMetadata)
|
||||
{
|
||||
source.LastFetchedUtc = DateTime.UtcNow;
|
||||
source.LastError = null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (File.Exists(cachePath))
|
||||
{
|
||||
if (persistMetadata)
|
||||
source.LastError = $"{ex.Message} (using cached copy)";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (persistMetadata)
|
||||
source.LastError = ex.Message;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<GameInfo>> LoadAcceptedAppsAsync(string sourceId)
|
||||
{
|
||||
var path = GetAcceptedCachePath(sourceId);
|
||||
if (!File.Exists(path))
|
||||
return [];
|
||||
|
||||
return await LoadAppsFromFileAsync(path).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<List<GameInfo>> LoadFetchedAppsFromCacheAsync(string sourceId)
|
||||
{
|
||||
var path = GetSourceCachePath(sourceId);
|
||||
if (!File.Exists(path))
|
||||
return [];
|
||||
|
||||
return await LoadAppsFromFileAsync(path).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task SaveAcceptedSnapshotAsync(AppCatalogSource source, List<GameInfo> apps)
|
||||
{
|
||||
await WriteAppsToFileAsync(GetAcceptedCachePath(source.Id), apps).ConfigureAwait(false);
|
||||
source.AcceptedContentHash = ComputeCatalogContentHash(apps);
|
||||
}
|
||||
|
||||
private static async Task WriteAppsToFileAsync(string path, List<GameInfo> apps)
|
||||
{
|
||||
var data = new
|
||||
{
|
||||
apps = apps.Select(SerializeApp).ToList()
|
||||
};
|
||||
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
await File.WriteAllTextAsync(path, JsonSerializer.Serialize(data, options)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public void SaveLocalApps(List<GameInfo> apps)
|
||||
{
|
||||
WriteAppsToFileAsync(_appsConfigPath, apps).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public List<GameInfo> ParseAppsFromDictionary(Dictionary<string, JsonElement> gamesData)
|
||||
{
|
||||
var apps = new List<GameInfo>();
|
||||
if (gamesData.TryGetValue("apps", out var appsArray))
|
||||
apps.AddRange(ParseAppArray(appsArray));
|
||||
|
||||
foreach (var legacySection in new[] { "standard", "experimental", "custom" })
|
||||
{
|
||||
if (gamesData.TryGetValue(legacySection, out var legacyArray))
|
||||
apps.AddRange(ParseAppArray(legacyArray));
|
||||
}
|
||||
|
||||
return DedupeByRepository(apps);
|
||||
}
|
||||
|
||||
public List<GameInfo> ParseAppsFromJson(string json)
|
||||
{
|
||||
using var document = JsonDocument.Parse(json);
|
||||
return ParseAppsRoot(document.RootElement);
|
||||
}
|
||||
|
||||
public static bool IsRemoteLocation(string location)
|
||||
{
|
||||
return location.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
|
||||
location.StartsWith("https://", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public static string ResolveLocalPath(string location)
|
||||
{
|
||||
if (IsRemoteLocation(location) || Path.IsPathRooted(location))
|
||||
return location;
|
||||
|
||||
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, location);
|
||||
}
|
||||
|
||||
private string GetSourceCachePath(string sourceId) =>
|
||||
Path.Combine(_catalogSourcesCacheFolder, $"{sourceId}.json");
|
||||
|
||||
private string GetAcceptedCachePath(string sourceId) =>
|
||||
Path.Combine(_catalogSourcesCacheFolder, $"{sourceId}.accepted.json");
|
||||
|
||||
private async Task<List<GameInfo>> LoadAppsFromFileAsync(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
string json = await File.ReadAllTextAsync(path).ConfigureAwait(false);
|
||||
using var document = JsonDocument.Parse(json);
|
||||
var apps = ParseAppsRoot(document.RootElement);
|
||||
foreach (var app in apps)
|
||||
app.GameManager = _gameManager;
|
||||
|
||||
return apps;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error reading {Path.GetFileName(path)}: {ex.Message}");
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private List<GameInfo> ParseAppsRoot(JsonElement root)
|
||||
{
|
||||
var apps = new List<GameInfo>();
|
||||
|
||||
if (root.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
apps.AddRange(ParseAppArray(root));
|
||||
return DedupeByRepository(apps);
|
||||
}
|
||||
|
||||
if (root.TryGetProperty("apps", out var appsArray))
|
||||
apps.AddRange(ParseAppArray(appsArray));
|
||||
|
||||
foreach (var legacySection in new[] { "standard", "experimental", "custom" })
|
||||
{
|
||||
if (root.TryGetProperty(legacySection, out var legacyArray))
|
||||
apps.AddRange(ParseAppArray(legacyArray));
|
||||
}
|
||||
|
||||
return DedupeByRepository(apps);
|
||||
}
|
||||
|
||||
private static List<GameInfo> DedupeByRepository(List<GameInfo> apps) =>
|
||||
apps
|
||||
.GroupBy(app => app.Repository ?? string.Empty, StringComparer.OrdinalIgnoreCase)
|
||||
.Select(group => group.First())
|
||||
.ToList();
|
||||
|
||||
private List<GameInfo> ParseAppArray(JsonElement appsArray)
|
||||
{
|
||||
var apps = new List<GameInfo>();
|
||||
|
||||
foreach (var appElement in appsArray.EnumerateArray())
|
||||
{
|
||||
try
|
||||
{
|
||||
var app = new GameInfo
|
||||
{
|
||||
Name = (appElement.TryGetProperty("name", out var nameElement) ? nameElement.GetString() : null) ?? string.Empty,
|
||||
Repository = (appElement.TryGetProperty("repository", out var repoElement) ? repoElement.GetString() : null) ?? string.Empty,
|
||||
FolderName = (appElement.TryGetProperty("folderName", out var folderElement) ? folderElement.GetString() : null) ?? string.Empty,
|
||||
InstallPath = appElement.TryGetProperty("installPath", out var installPathElement) ? installPathElement.GetString() : null,
|
||||
GameIconUrl = GetIconUrl(appElement),
|
||||
PreferredVersion = appElement.TryGetProperty("preferredVersion", out var preferredVersionElement) ? preferredVersionElement.GetString() : null,
|
||||
SkippedUpdateVersion = appElement.TryGetProperty("skippedUpdateVersion", out var skippedUpdateVersionElement) ? skippedUpdateVersionElement.GetString() : null,
|
||||
Tags = ParseTagsProperty(appElement),
|
||||
IsExperimental = false,
|
||||
IsCustom = true,
|
||||
GameManager = _gameManager,
|
||||
};
|
||||
|
||||
apps.Add(app);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error parsing app: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return apps;
|
||||
}
|
||||
|
||||
private static string? GetIconUrl(JsonElement appElement)
|
||||
{
|
||||
if (appElement.TryGetProperty("appIconUrl", out var appIconUrlElement) && appIconUrlElement.ValueKind != JsonValueKind.Null)
|
||||
return appIconUrlElement.GetString();
|
||||
|
||||
if (appElement.TryGetProperty("gameIconUrl", out var gameIconUrlElement) && gameIconUrlElement.ValueKind != JsonValueKind.Null)
|
||||
return gameIconUrlElement.GetString();
|
||||
|
||||
if (appElement.TryGetProperty("customDefaultIconUrl", out var legacyIconElement) && legacyIconElement.ValueKind != JsonValueKind.Null)
|
||||
return legacyIconElement.GetString();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<string> ParseTagsProperty(JsonElement appElement)
|
||||
{
|
||||
if (!appElement.TryGetProperty("tags", out var tagsElement) || tagsElement.ValueKind != JsonValueKind.Array)
|
||||
return [];
|
||||
|
||||
var tags = new List<string>();
|
||||
foreach (var tagElement in tagsElement.EnumerateArray())
|
||||
{
|
||||
if (tagElement.ValueKind == JsonValueKind.String)
|
||||
{
|
||||
var tag = tagElement.GetString();
|
||||
if (!string.IsNullOrWhiteSpace(tag))
|
||||
tags.Add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
return TagHelper.NormalizeTags(tags);
|
||||
}
|
||||
|
||||
private static List<string> CloneTags(IEnumerable<string>? tags) =>
|
||||
TagHelper.NormalizeTags(tags);
|
||||
|
||||
private static GameInfo CloneCatalogApp(GameInfo app) =>
|
||||
new()
|
||||
{
|
||||
Name = app.Name,
|
||||
Repository = app.Repository,
|
||||
FolderName = app.FolderName,
|
||||
InstallPath = app.InstallPath,
|
||||
GameIconUrl = app.GameIconUrl,
|
||||
PreferredVersion = app.PreferredVersion,
|
||||
SkippedUpdateVersion = app.SkippedUpdateVersion,
|
||||
Tags = CloneTags(app.Tags),
|
||||
IsExperimental = false,
|
||||
IsCustom = true,
|
||||
GameManager = app.GameManager,
|
||||
};
|
||||
|
||||
private static GameInfo CloneForLocal(GameInfo app) =>
|
||||
new()
|
||||
{
|
||||
Name = app.Name,
|
||||
Repository = app.Repository,
|
||||
FolderName = app.FolderName,
|
||||
InstallPath = app.InstallPath,
|
||||
GameIconUrl = app.GameIconUrl,
|
||||
PreferredVersion = app.PreferredVersion,
|
||||
SkippedUpdateVersion = app.SkippedUpdateVersion,
|
||||
Tags = CloneTags(app.Tags),
|
||||
IsExperimental = false,
|
||||
IsCustom = true,
|
||||
GameManager = app.GameManager,
|
||||
CatalogSourceId = null,
|
||||
};
|
||||
|
||||
private static object SerializeApp(GameInfo app)
|
||||
{
|
||||
var normalizedTags = TagHelper.NormalizeTags(app.Tags);
|
||||
if (normalizedTags.Count == 0)
|
||||
{
|
||||
return new
|
||||
{
|
||||
name = app.Name,
|
||||
repository = app.Repository,
|
||||
folderName = app.FolderName,
|
||||
installPath = app.InstallPath,
|
||||
appIconUrl = app.GameIconUrl,
|
||||
preferredVersion = app.PreferredVersion,
|
||||
skippedUpdateVersion = app.SkippedUpdateVersion
|
||||
};
|
||||
}
|
||||
|
||||
return new
|
||||
{
|
||||
name = app.Name,
|
||||
repository = app.Repository,
|
||||
folderName = app.FolderName,
|
||||
installPath = app.InstallPath,
|
||||
appIconUrl = app.GameIconUrl,
|
||||
preferredVersion = app.PreferredVersion,
|
||||
skippedUpdateVersion = app.SkippedUpdateVersion,
|
||||
tags = normalizedTags
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
+61
-39
@@ -1,20 +1,56 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using GitHubLauncher.Core.Models;
|
||||
using Quiver.Core.Models;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace GithubLauncher
|
||||
namespace Quiver
|
||||
{
|
||||
public enum AppListScope
|
||||
{
|
||||
AllApps,
|
||||
InstalledOnly,
|
||||
}
|
||||
|
||||
public enum TagFilterMatchMode
|
||||
{
|
||||
Any,
|
||||
All,
|
||||
}
|
||||
|
||||
public class TagDisplayFilter
|
||||
{
|
||||
public string Id { get; set; } = Guid.NewGuid().ToString();
|
||||
public string Name { get; set; } = "";
|
||||
public List<string> Tags { get; set; } = new List<string>();
|
||||
public TagFilterMatchMode MatchMode { get; set; } = TagFilterMatchMode.Any;
|
||||
}
|
||||
|
||||
public class AppCatalogSource
|
||||
{
|
||||
public string Id { get; set; } = Guid.NewGuid().ToString();
|
||||
public string Name { get; set; } = "";
|
||||
public string Location { get; set; } = "";
|
||||
public bool Enabled { get; set; } = true;
|
||||
public DateTime? LastFetchedUtc { get; set; }
|
||||
public string? LastError { get; set; }
|
||||
public string? CommunityListId { get; set; }
|
||||
public string? AcceptedContentHash { get; set; }
|
||||
public bool UpdateAvailable { get; set; }
|
||||
}
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
public bool FirstStartup { get; set; } = true;
|
||||
public bool IconFill { get; set; } = true;
|
||||
public bool IconFill { get; set; } = false;
|
||||
public bool UseGridView { get; set; } = true;
|
||||
public bool GridCompactCards { get; set; } = true;
|
||||
public float IconOpacity { get; set; } = 1.0f;
|
||||
public int IconSize { get; set; } = 220;
|
||||
public int IconSize { get; set; } = 124;
|
||||
public int IconMargin { get; set; } = 8;
|
||||
public int SlotTextMargin { get; set; } = 112;
|
||||
public int SlotSize { get; set; } = 220;
|
||||
public int SlotSize { get; set; } = 152;
|
||||
public int ActionButtonSize { get; set; } = 36;
|
||||
public bool WindowBorderRounding { get; set; } = true;
|
||||
public bool ShowOSTopBar { get; set; } = false;
|
||||
public string PrimaryColor { get; set; } = "#18181b";
|
||||
@@ -33,45 +69,31 @@ namespace GithubLauncher
|
||||
public float BackgroundOpacity { get; set; } = 0.15f;
|
||||
public bool EnableGamepadInput { get; set; } = true;
|
||||
public string LinuxWindowsLaunchCommand { get; set; } = string.Empty;
|
||||
private static readonly string SettingsPath = Path.Combine(
|
||||
AppDomain.CurrentDomain.BaseDirectory,
|
||||
"settings.json"
|
||||
);
|
||||
public List<AppCatalogSource> AppCatalogSources { get; set; } = new List<AppCatalogSource>();
|
||||
public string CommunityCatalogIndexUrl { get; set; } = string.Empty;
|
||||
public List<TagDisplayFilter> TagDisplayFilters { get; set; } = new List<TagDisplayFilter>();
|
||||
public string? ActiveTagDisplayFilterId { get; set; }
|
||||
public AppListScope ListScope { get; set; } = AppListScope.AllApps;
|
||||
public Dictionary<string, List<string>> UserAppTags { get; set; } = new Dictionary<string, List<string>>();
|
||||
|
||||
public static AppSettings Load()
|
||||
public void EnsureInitialized()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(SettingsPath))
|
||||
{
|
||||
string json = File.ReadAllText(SettingsPath);
|
||||
return JsonSerializer.Deserialize<AppSettings>(json) ?? new AppSettings();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Failed to load settings: {ex.Message}");
|
||||
}
|
||||
AppCatalogSources ??= new List<AppCatalogSource>();
|
||||
HiddenApps ??= new List<string>();
|
||||
ManuallyHiddenApps ??= new List<string>();
|
||||
TagDisplayFilters ??= new List<TagDisplayFilter>();
|
||||
UserAppTags ??= new Dictionary<string, List<string>>();
|
||||
|
||||
return new AppSettings();
|
||||
if (HiddenApps.Count > 0)
|
||||
{
|
||||
ListScope = AppListScope.InstalledOnly;
|
||||
HiddenApps.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save(AppSettings settings)
|
||||
{
|
||||
try
|
||||
{
|
||||
string json = JsonSerializer.Serialize(settings, new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true
|
||||
});
|
||||
File.WriteAllText(SettingsPath, json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Failed to save settings: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public static AppSettings Load() => SettingsStoreProvider.Default.Load();
|
||||
|
||||
public static void Save(AppSettings settings) => SettingsStoreProvider.Default.Save(settings);
|
||||
}
|
||||
}
|
||||
|
||||
+55
-147
@@ -1,7 +1,7 @@
|
||||
using GitHubLauncher.Core.Models;
|
||||
using GitHubLauncher.Core.Services;
|
||||
using GithubLauncher.Models;
|
||||
using GithubLauncher.Services;
|
||||
using Quiver.Core.Models;
|
||||
using Quiver.Core.Services;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
@@ -13,7 +13,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GithubLauncher
|
||||
namespace Quiver
|
||||
{
|
||||
public class CLIHandler
|
||||
{
|
||||
@@ -22,7 +22,7 @@ namespace GithubLauncher
|
||||
private const ConsoleColor ColorWarning = ConsoleColor.Yellow;
|
||||
private const ConsoleColor ColorError = ConsoleColor.Red;
|
||||
private const ConsoleColor ColorMuted = ConsoleColor.DarkGray;
|
||||
private static readonly GithubLauncherProfile Profile = GithubLauncherProfile.Instance;
|
||||
private static readonly QuiverProfile Profile = QuiverProfile.Instance;
|
||||
private static readonly string Repository = Profile.Repository;
|
||||
private const string VersionFileName = "version.txt";
|
||||
private const string UpdateCheckFileName = "update_check.json";
|
||||
@@ -30,6 +30,13 @@ namespace GithubLauncher
|
||||
|
||||
private GameManager? _gameManager;
|
||||
private string _currentVersion = "Unknown";
|
||||
private readonly LauncherUpdateService _launcherUpdateService;
|
||||
|
||||
public CLIHandler(GameManager? gameManager = null, LauncherUpdateService? launcherUpdateService = null)
|
||||
{
|
||||
_gameManager = gameManager;
|
||||
_launcherUpdateService = launcherUpdateService ?? new LauncherUpdateService();
|
||||
}
|
||||
|
||||
public async Task<int> Execute(string[] args)
|
||||
{
|
||||
@@ -135,16 +142,16 @@ namespace GithubLauncher
|
||||
if (_gameManager == null)
|
||||
{
|
||||
_gameManager = new GameManager();
|
||||
|
||||
// Force load all games
|
||||
var settings = AppSettings.Load();
|
||||
var originalHiddenApps = settings.HiddenApps.ToList();
|
||||
settings.HiddenApps.Clear();
|
||||
settings.EnsureInitialized();
|
||||
var originalScope = settings.ListScope;
|
||||
settings.ListScope = AppListScope.AllApps;
|
||||
AppSettings.Save(settings);
|
||||
|
||||
await _gameManager.LoadGamesAsync();
|
||||
|
||||
// Restore hidden games list
|
||||
settings.HiddenApps = originalHiddenApps;
|
||||
settings.ListScope = originalScope;
|
||||
AppSettings.Save(settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,33 +167,25 @@ namespace GithubLauncher
|
||||
}
|
||||
|
||||
private void LoadVersion()
|
||||
{
|
||||
_currentVersion = _launcherUpdateService.ReadInstalledVersion();
|
||||
}
|
||||
|
||||
private async Task CheckForLauncherUpdates()
|
||||
{
|
||||
try
|
||||
{
|
||||
string currentAppDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string updateCheckFilePath = Path.Combine(currentAppDirectory, "update_check.json");
|
||||
|
||||
if (File.Exists(updateCheckFilePath))
|
||||
var latestTag = await _launcherUpdateService.FetchLatestReleaseTagAsync();
|
||||
if (_launcherUpdateService.IsUpdateAvailable(_currentVersion, latestTag))
|
||||
{
|
||||
var json = File.ReadAllText(updateCheckFilePath);
|
||||
var updateInfo = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(json);
|
||||
if (updateInfo != null && updateInfo.TryGetValue("CurrentVersion", out var versionElement))
|
||||
{
|
||||
_currentVersion = versionElement.GetString() ?? "Unknown";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to version.txt
|
||||
string versionFilePath = Path.Combine(currentAppDirectory, "version.txt");
|
||||
if (File.Exists(versionFilePath))
|
||||
{
|
||||
_currentVersion = File.ReadAllText(versionFilePath).Trim();
|
||||
WriteColor($" [UPDATE AVAILABLE] ", ColorWarning);
|
||||
Console.WriteLine($"New version {latestTag} is available! Use --update-launcher to upgrade.");
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_currentVersion = "Unknown";
|
||||
// Silently skip update check if offline or error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,34 +224,9 @@ namespace GithubLauncher
|
||||
PrintLine();
|
||||
}
|
||||
|
||||
private async Task CheckForLauncherUpdates()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var client = new HttpClient();
|
||||
client.Timeout = TimeSpan.FromSeconds(5);
|
||||
client.DefaultRequestHeaders.Add("User-Agent", Profile.CliUserAgent);
|
||||
|
||||
var response = await client.GetStringAsync("https://api.github.com/repos/sirdiabo/GithubLauncher/releases/latest");
|
||||
using var doc = JsonDocument.Parse(response);
|
||||
var latestTag = doc.RootElement.GetProperty("tag_name").GetString();
|
||||
|
||||
if (!string.IsNullOrEmpty(latestTag) && latestTag != _currentVersion)
|
||||
{
|
||||
WriteColor($" [UPDATE AVAILABLE] ", ColorWarning);
|
||||
Console.WriteLine($"New version {latestTag} is available! Use --update-launcher to upgrade.");
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Silently skip update check if offline or error
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowHelp()
|
||||
{
|
||||
Console.WriteLine("Usage: GithubLauncher [command] [game name]");
|
||||
Console.WriteLine("Usage: Quiver [command] [game name]");
|
||||
Console.WriteLine();
|
||||
WriteColor("Commands:", ColorTitle);
|
||||
Console.WriteLine();
|
||||
@@ -266,10 +240,10 @@ namespace GithubLauncher
|
||||
Console.WriteLine();
|
||||
WriteColor("Examples:", ColorMuted);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" GithubLauncher --list");
|
||||
Console.WriteLine(" GithubLauncher --download Banjo64");
|
||||
Console.WriteLine(" GithubLauncher --run Banjo64");
|
||||
Console.WriteLine(" GithubLauncher -r \"Mario Kart 64\"");
|
||||
Console.WriteLine(" Quiver --list");
|
||||
Console.WriteLine(" Quiver --download Banjo64");
|
||||
Console.WriteLine(" Quiver --run Banjo64");
|
||||
Console.WriteLine(" Quiver -r \"Mario Kart 64\"");
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
@@ -442,7 +416,7 @@ namespace GithubLauncher
|
||||
// If running the CLI version, try to find the GUI version
|
||||
if (exePath.Contains("CLI", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var possibleGuiExe = Path.Combine(exeDir, "GithubLauncher.exe");
|
||||
var possibleGuiExe = Path.Combine(exeDir, "Quiver.exe");
|
||||
if (File.Exists(possibleGuiExe))
|
||||
{
|
||||
guiExe = possibleGuiExe;
|
||||
@@ -616,70 +590,17 @@ namespace GithubLauncher
|
||||
// Get the latest release info
|
||||
await game.CheckStatusAsync(_gameManager.HttpClient, _gameManager.GamesFolder, forceUpdateCheck: true);
|
||||
|
||||
// Get platform identifier
|
||||
string platformIdentifier = GameInfo.GetPlatformIdentifier(settings);
|
||||
WriteColor($"→ Detected platform: {platformIdentifier}", ColorMuted);
|
||||
Console.WriteLine();
|
||||
|
||||
// Check for multiple downloads first
|
||||
var cachedRelease = game.GetType().GetMethod("GetLatestRelease", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.Invoke(game, null);
|
||||
|
||||
if (cachedRelease != null)
|
||||
if (game.TrySelectPlatformDownload(settings) && game.SelectedDownload != null)
|
||||
{
|
||||
var assetsProperty = cachedRelease.GetType().GetProperty("assets");
|
||||
if (assetsProperty != null)
|
||||
{
|
||||
var assets = assetsProperty.GetValue(cachedRelease) as System.Collections.IEnumerable;
|
||||
var assetList = assets?.Cast<object>().ToList();
|
||||
|
||||
if (assetList != null && assetList.Count > 1)
|
||||
{
|
||||
WriteColor($"→ Finding {platformIdentifier} version...", ColorMuted);
|
||||
Console.WriteLine();
|
||||
|
||||
// Find matching platform
|
||||
object? matchingAsset = null;
|
||||
foreach (var asset in assetList)
|
||||
{
|
||||
var nameProperty = asset.GetType().GetProperty("name");
|
||||
if (nameProperty != null)
|
||||
{
|
||||
var assetName = nameProperty.GetValue(asset)?.ToString();
|
||||
if (!string.IsNullOrEmpty(assetName) && GameInfo.MatchesPlatform(assetName, platformIdentifier))
|
||||
{
|
||||
matchingAsset = asset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (matchingAsset != null)
|
||||
{
|
||||
var nameProperty = matchingAsset.GetType().GetProperty("name");
|
||||
var assetName = nameProperty?.GetValue(matchingAsset)?.ToString();
|
||||
|
||||
// Set the selected download via reflection
|
||||
var selectedDownloadProperty = game.GetType().GetProperty("SelectedDownload");
|
||||
selectedDownloadProperty?.SetValue(game, matchingAsset);
|
||||
|
||||
WriteColor($"→ Selected: {assetName}", ColorSuccess);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteColor($"⚠ No {platformIdentifier} version found, using first available", ColorWarning);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine();
|
||||
|
||||
var selectedDownloadProperty = game.GetType().GetProperty("SelectedDownload");
|
||||
selectedDownloadProperty?.SetValue(game, assetList[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
WriteColor($"→ Selected: {game.SelectedDownload.name}", ColorSuccess);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
// Start the actual download
|
||||
var downloadTask = game.PerformActionAsync(
|
||||
_gameManager.HttpClient,
|
||||
_gameManager.GamesFolder,
|
||||
@@ -870,7 +791,7 @@ namespace GithubLauncher
|
||||
Console.WriteLine();
|
||||
|
||||
string tempDownloadPath = Path.Combine(Path.GetTempPath(), asset.name);
|
||||
string tempUpdateFolder = Path.Combine(Path.GetTempPath(), "GithubLauncher_temp_update");
|
||||
string tempUpdateFolder = Path.Combine(Path.GetTempPath(), "Quiver_temp_update");
|
||||
if (Directory.Exists(tempUpdateFolder))
|
||||
Directory.Delete(tempUpdateFolder, true);
|
||||
Directory.CreateDirectory(tempUpdateFolder);
|
||||
@@ -944,8 +865,8 @@ namespace GithubLauncher
|
||||
}
|
||||
|
||||
string executableName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||
? "GithubLauncher.exe"
|
||||
: "GithubLauncher";
|
||||
? "Quiver.exe"
|
||||
: "Quiver";
|
||||
|
||||
string executablePath = Path.Combine(updateDirectory, executableName);
|
||||
return File.Exists(executablePath) && new FileInfo(executablePath).Length > 1024;
|
||||
@@ -976,16 +897,16 @@ namespace GithubLauncher
|
||||
string applicationExecutable = Environment.ProcessPath
|
||||
?? Process.GetCurrentProcess().MainModule?.FileName
|
||||
?? throw new InvalidOperationException("Could not determine launcher executable path.");
|
||||
string backupDir = Path.Combine(Path.GetTempPath(), "GithubLauncher_backup_" + DateTime.Now.ToString("yyyyMMdd_HHmmss"));
|
||||
string backupDir = Path.Combine(Path.GetTempPath(), "Quiver_backup_" + DateTime.Now.ToString("yyyyMMdd_HHmmss"));
|
||||
string updateCheckFilePath = Path.Combine(currentAppDirectory, UpdateCheckFileName);
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
string updaterScriptPath = Path.Combine(Path.GetTempPath(), "GithubLauncher_Updater.cmd");
|
||||
string updaterScriptPath = Path.Combine(Path.GetTempPath(), "Quiver_Updater.cmd");
|
||||
string scriptContent = $@"@echo off
|
||||
echo GithubLauncher Updater - Version {release.tag_name}
|
||||
echo Quiver Updater - Version {release.tag_name}
|
||||
echo.
|
||||
echo Waiting for GithubLauncher CLI to close...
|
||||
echo Waiting for Quiver CLI to close...
|
||||
set /A waitCount=0
|
||||
:wait_loop
|
||||
tasklist /FI ""PID eq {currentProcessId}"" 2>NUL | find /I ""{currentProcessId}"">NUL
|
||||
@@ -1045,11 +966,11 @@ del ""%~f0""
|
||||
}
|
||||
else
|
||||
{
|
||||
string updaterScriptPath = Path.Combine(Path.GetTempPath(), "GithubLauncher_Updater.sh");
|
||||
string updaterScriptPath = Path.Combine(Path.GetTempPath(), "Quiver_Updater.sh");
|
||||
string scriptContent = $@"#!/bin/bash
|
||||
echo ""GithubLauncher Updater - Version {release.tag_name}""
|
||||
echo ""Quiver Updater - Version {release.tag_name}""
|
||||
echo
|
||||
echo ""Waiting for GithubLauncher CLI to close...""
|
||||
echo ""Waiting for Quiver CLI to close...""
|
||||
waitCount=0
|
||||
while kill -0 {currentProcessId} 2>/dev/null; do
|
||||
if [ ""$waitCount"" -ge {UpdaterProcessExitTimeoutSeconds} ]; then
|
||||
@@ -1087,10 +1008,10 @@ cat > ""{updateCheckFilePath}"" << 'EOF'
|
||||
{{""CurrentVersion"":""{release.tag_name}"",""LastCheckTime"":""{DateTime.UtcNow:o}"",""LastKnownVersion"":""{release.tag_name}"",""ETag"":"""",""UpdateAvailable"":false}}
|
||||
EOF
|
||||
|
||||
if [ -f ""$appDir/GithubLauncher"" ]; then
|
||||
chmod +x ""$appDir/GithubLauncher""
|
||||
if [ -f ""$appDir/Quiver"" ]; then
|
||||
chmod +x ""$appDir/Quiver""
|
||||
cd ""$appDir""
|
||||
nohup ""./GithubLauncher"" > /dev/null 2>&1 &
|
||||
nohup ""./Quiver"" > /dev/null 2>&1 &
|
||||
fi
|
||||
|
||||
rm -rf ""$backupDir"" ""$updateDir"" 2>/dev/null || true
|
||||
@@ -1141,21 +1062,8 @@ rm -- ""$0""
|
||||
throw new PlatformNotSupportedException("Unsupported operating system");
|
||||
}
|
||||
|
||||
private static bool IsNewerVersion(string latestVersion, string currentVersion)
|
||||
{
|
||||
try
|
||||
{
|
||||
string cleanLatest = latestVersion.TrimStart('v', 'V');
|
||||
string cleanCurrent = currentVersion.TrimStart('v', 'V');
|
||||
return Version.TryParse(cleanLatest, out var latest) &&
|
||||
Version.TryParse(cleanCurrent, out var current) &&
|
||||
latest > current;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return !string.Equals(latestVersion, currentVersion, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
private static bool IsNewerVersion(string latestVersion, string currentVersion) =>
|
||||
LauncherVersionService.IsNewerVersion(latestVersion, currentVersion);
|
||||
|
||||
private async Task<int> UninstallGame(string gameName)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using Quiver.Models;
|
||||
using AppCatalogSource = Quiver.AppCatalogSource;
|
||||
|
||||
namespace Quiver.Services
|
||||
{
|
||||
public class CatalogDiff
|
||||
{
|
||||
public List<GameInfo> Added { get; set; } = [];
|
||||
public List<GameInfo> Removed { get; set; } = [];
|
||||
public List<GameInfo> Changed { get; set; } = [];
|
||||
|
||||
public int AddedCount => Added.Count;
|
||||
public int RemovedCount => Removed.Count;
|
||||
public int ChangedCount => Changed.Count;
|
||||
|
||||
public bool HasChanges => AddedCount > 0 || RemovedCount > 0 || ChangedCount > 0;
|
||||
}
|
||||
|
||||
public class PendingCatalogUpdate
|
||||
{
|
||||
public AppCatalogSource Source { get; set; } = null!;
|
||||
public CatalogDiff Diff { get; set; } = new();
|
||||
public List<GameInfo> RemoteApps { get; set; } = [];
|
||||
public List<GameInfo> AcceptedApps { get; set; } = [];
|
||||
}
|
||||
|
||||
public enum CatalogUpdateChoice
|
||||
{
|
||||
ApplyAll,
|
||||
ApplyNewOnly,
|
||||
KeepCurrent,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Quiver.Services;
|
||||
|
||||
public interface ICatalogLocationReader
|
||||
{
|
||||
Task<string> ReadAsync(HttpClient httpClient, string location, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
public sealed class CatalogLocationReader : ICatalogLocationReader
|
||||
{
|
||||
public static ICatalogLocationReader Default { get; } = new CatalogLocationReader();
|
||||
|
||||
public async Task<string> ReadAsync(HttpClient httpClient, string location, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (AppCatalogService.IsRemoteLocation(location))
|
||||
{
|
||||
var response = await httpClient.GetAsync(location, cancellationToken).ConfigureAwait(false);
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var resolvedPath = AppCatalogService.ResolveLocalPath(location);
|
||||
if (!File.Exists(resolvedPath))
|
||||
throw new FileNotFoundException($"Catalog file not found: {location}");
|
||||
|
||||
return await File.ReadAllTextAsync(resolvedPath, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using Quiver.Models;
|
||||
|
||||
namespace Quiver.Services;
|
||||
|
||||
internal static class CatalogMerge
|
||||
{
|
||||
internal static List<GameInfo>? ApplyChoice(
|
||||
CatalogUpdateChoice choice,
|
||||
List<GameInfo> acceptedApps,
|
||||
List<GameInfo> remoteApps,
|
||||
Func<GameInfo, GameInfo> clone)
|
||||
{
|
||||
return choice switch
|
||||
{
|
||||
CatalogUpdateChoice.ApplyAll => remoteApps.Select(clone).ToList(),
|
||||
CatalogUpdateChoice.ApplyNewOnly => MergeAcceptedWithRemote(acceptedApps, remoteApps, clone),
|
||||
CatalogUpdateChoice.KeepCurrent => null,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
internal static List<GameInfo> MergeAcceptedWithRemote(
|
||||
List<GameInfo> acceptedApps,
|
||||
List<GameInfo> remoteApps,
|
||||
Func<GameInfo, GameInfo> clone)
|
||||
{
|
||||
var merged = acceptedApps
|
||||
.Where(a => !string.IsNullOrWhiteSpace(a.Repository))
|
||||
.ToDictionary(a => a.Repository!, a => clone(a), StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
foreach (var remote in remoteApps)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(remote.Repository))
|
||||
continue;
|
||||
|
||||
merged[remote.Repository] = clone(remote);
|
||||
}
|
||||
|
||||
return merged.Values.ToList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace Quiver.Services
|
||||
{
|
||||
public class CatalogSourceListItem
|
||||
{
|
||||
public string SourceId { get; init; } = "";
|
||||
public string Name { get; init; } = "";
|
||||
public string Location { get; init; } = "";
|
||||
public string StatusText { get; init; } = "";
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public static CatalogSourceListItem FromSource(AppCatalogSource source) =>
|
||||
new()
|
||||
{
|
||||
SourceId = source.Id,
|
||||
Name = source.Name,
|
||||
Location = source.Location,
|
||||
Enabled = source.Enabled,
|
||||
StatusText = GetStatusText(source),
|
||||
};
|
||||
|
||||
public static string GetStatusText(AppCatalogSource source)
|
||||
{
|
||||
if (source.UpdateAvailable)
|
||||
return "Update available";
|
||||
|
||||
if (!string.IsNullOrEmpty(source.LastError))
|
||||
return source.LastError;
|
||||
|
||||
if (source.LastFetchedUtc.HasValue)
|
||||
return $"Updated {source.LastFetchedUtc.Value.ToLocalTime():g}";
|
||||
|
||||
return "Not loaded yet";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Quiver.Services
|
||||
{
|
||||
public class CommunityCatalogListEntry
|
||||
{
|
||||
public string Id { get; set; } = "";
|
||||
public string Name { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
public string Location { get; set; } = "";
|
||||
public string ListVersion { get; set; } = "";
|
||||
}
|
||||
|
||||
public class CommunityCatalogIndex
|
||||
{
|
||||
public int Version { get; set; }
|
||||
public List<CommunityCatalogListEntry> Lists { get; set; } = [];
|
||||
}
|
||||
|
||||
public static class CommunityCatalogIndexService
|
||||
{
|
||||
public static async Task<(CommunityCatalogIndex? Index, string? Error)> FetchIndexAsync(
|
||||
HttpClient httpClient,
|
||||
string indexUrl)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(indexUrl))
|
||||
return (null, "Community index URL is not configured.");
|
||||
|
||||
try
|
||||
{
|
||||
var json = await CatalogLocationReader.Default.ReadAsync(httpClient, indexUrl).ConfigureAwait(false);
|
||||
return (ParseIndex(json), null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public static CommunityCatalogIndex ParseIndex(string json)
|
||||
{
|
||||
using var document = JsonDocument.Parse(json);
|
||||
var root = document.RootElement;
|
||||
|
||||
var index = new CommunityCatalogIndex
|
||||
{
|
||||
Version = root.TryGetProperty("version", out var versionElement) && versionElement.TryGetInt32(out var v)
|
||||
? v
|
||||
: 1,
|
||||
};
|
||||
|
||||
if (!root.TryGetProperty("lists", out var listsArray))
|
||||
return index;
|
||||
|
||||
foreach (var entry in listsArray.EnumerateArray())
|
||||
{
|
||||
index.Lists.Add(new CommunityCatalogListEntry
|
||||
{
|
||||
Id = entry.TryGetProperty("id", out var id) ? id.GetString() ?? "" : "",
|
||||
Name = entry.TryGetProperty("name", out var name) ? name.GetString() ?? "" : "",
|
||||
Description = entry.TryGetProperty("description", out var desc) ? desc.GetString() ?? "" : "",
|
||||
Location = entry.TryGetProperty("location", out var loc) ? loc.GetString() ?? "" : "",
|
||||
ListVersion = entry.TryGetProperty("listVersion", out var lv) ? lv.GetString() ?? "" : "",
|
||||
});
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Quiver.Services;
|
||||
|
||||
public class FileSettingsStore : ISettingsStore
|
||||
{
|
||||
private readonly string _settingsPath;
|
||||
private AppSettings _current;
|
||||
|
||||
public FileSettingsStore(string? settingsPath = null)
|
||||
{
|
||||
_settingsPath = settingsPath ?? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.json");
|
||||
_current = ReadFromDisk();
|
||||
}
|
||||
|
||||
public AppSettings Current => _current;
|
||||
|
||||
public AppSettings Load()
|
||||
{
|
||||
_current = ReadFromDisk();
|
||||
return _current;
|
||||
}
|
||||
|
||||
public void Save(AppSettings settings)
|
||||
{
|
||||
settings.EnsureInitialized();
|
||||
var json = JsonSerializer.Serialize(settings, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(_settingsPath, json);
|
||||
_current = settings;
|
||||
}
|
||||
|
||||
private AppSettings ReadFromDisk()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(_settingsPath))
|
||||
return CreateDefault();
|
||||
|
||||
var json = File.ReadAllText(_settingsPath);
|
||||
if (string.IsNullOrWhiteSpace(json))
|
||||
return CreateDefault();
|
||||
|
||||
var settings = JsonSerializer.Deserialize<AppSettings>(json) ?? CreateDefault();
|
||||
settings.EnsureInitialized();
|
||||
return settings;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Failed to load settings: {ex.Message}");
|
||||
return CreateDefault();
|
||||
}
|
||||
}
|
||||
|
||||
private static AppSettings CreateDefault()
|
||||
{
|
||||
var settings = new AppSettings();
|
||||
settings.EnsureInitialized();
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace Quiver.Services;
|
||||
|
||||
public static class GameDialogService
|
||||
{
|
||||
public static async Task ShowMessageBoxAsync(string message, string title)
|
||||
{
|
||||
await Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop &&
|
||||
desktop.MainWindow != null)
|
||||
{
|
||||
var messageBox = new Window
|
||||
{
|
||||
Title = title,
|
||||
Width = 800,
|
||||
Height = 400,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||||
Content = new StackPanel
|
||||
{
|
||||
Margin = new Thickness(20),
|
||||
Children =
|
||||
{
|
||||
new TextBlock { Text = message, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 0, 0, 20) },
|
||||
new Button { Content = "OK", HorizontalAlignment = HorizontalAlignment.Center },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (((StackPanel)messageBox.Content).Children[1] is Button okButton)
|
||||
okButton.Click += (_, _) => messageBox.Close();
|
||||
|
||||
await messageBox.ShowDialog(desktop.MainWindow);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine($"ERROR: {title}");
|
||||
Console.ResetColor();
|
||||
Console.WriteLine(message);
|
||||
Console.WriteLine();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static async Task<bool> ShowWineNotFoundWarningAsync()
|
||||
{
|
||||
var userChoice = false;
|
||||
|
||||
await Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop ||
|
||||
desktop.MainWindow == null)
|
||||
{
|
||||
userChoice = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var messageBox = new Window
|
||||
{
|
||||
Title = "Windows Runner Not Found",
|
||||
Width = 500,
|
||||
Height = 220,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||||
Content = new StackPanel
|
||||
{
|
||||
Margin = new Thickness(20),
|
||||
Children =
|
||||
{
|
||||
new TextBlock
|
||||
{
|
||||
Text = "This game requires a Linux Windows-runner to launch, but none was detected.\n\n" +
|
||||
"Install Wine/Proton or set a custom command in Settings for Bottles or another launcher.\n\n" +
|
||||
"Do you want to download anyway? The game will not launch without a configured runner.",
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Margin = new Thickness(0, 0, 0, 20),
|
||||
},
|
||||
new StackPanel
|
||||
{
|
||||
Orientation = Orientation.Horizontal,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
Spacing = 10,
|
||||
Children =
|
||||
{
|
||||
new Button { Content = "Download Anyway", Width = 140 },
|
||||
new Button { Content = "Cancel", Width = 100 },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (((StackPanel)messageBox.Content).Children[1] is StackPanel buttonPanel &&
|
||||
buttonPanel.Children[0] is Button yesButton &&
|
||||
buttonPanel.Children[1] is Button noButton)
|
||||
{
|
||||
yesButton.Click += (_, _) => { userChoice = true; messageBox.Close(); };
|
||||
noButton.Click += (_, _) => { userChoice = false; messageBox.Close(); };
|
||||
}
|
||||
|
||||
await messageBox.ShowDialog(desktop.MainWindow);
|
||||
});
|
||||
|
||||
return userChoice;
|
||||
}
|
||||
|
||||
public static async Task<bool> ShowWineDownloadWarningAsync()
|
||||
{
|
||||
var userChoice = false;
|
||||
|
||||
await Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop ||
|
||||
desktop.MainWindow == null)
|
||||
{
|
||||
userChoice = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var messageBox = new Window
|
||||
{
|
||||
Title = "Windows Runner Required",
|
||||
Width = 500,
|
||||
Height = 200,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||||
Content = new StackPanel
|
||||
{
|
||||
Margin = new Thickness(20),
|
||||
Children =
|
||||
{
|
||||
new TextBlock
|
||||
{
|
||||
Text = "This game requires a Linux Windows-runner to launch. A compatible runner was detected or configured and will be used.\n\nWant to download?",
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Margin = new Thickness(0, 0, 0, 20),
|
||||
},
|
||||
new StackPanel
|
||||
{
|
||||
Orientation = Orientation.Horizontal,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
Spacing = 10,
|
||||
Children =
|
||||
{
|
||||
new Button { Content = "Yes", Width = 100 },
|
||||
new Button { Content = "No", Width = 100 },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (((StackPanel)messageBox.Content).Children[1] is StackPanel buttonPanel &&
|
||||
buttonPanel.Children[0] is Button yesButton &&
|
||||
buttonPanel.Children[1] is Button noButton)
|
||||
{
|
||||
yesButton.Click += (_, _) => { userChoice = true; messageBox.Close(); };
|
||||
noButton.Click += (_, _) => { userChoice = false; messageBox.Close(); };
|
||||
}
|
||||
|
||||
await messageBox.ShowDialog(desktop.MainWindow);
|
||||
});
|
||||
|
||||
return userChoice;
|
||||
}
|
||||
|
||||
public static async Task ShowRateLimitErrorAsync()
|
||||
{
|
||||
await Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop ||
|
||||
desktop.MainWindow == null)
|
||||
return;
|
||||
|
||||
var hyperlinkText = new TextBlock
|
||||
{
|
||||
Text = "https://github.com/settings/tokens",
|
||||
Foreground = new SolidColorBrush(Color.FromRgb(0, 122, 255)),
|
||||
Cursor = new Cursor(StandardCursorType.Hand),
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Margin = new Thickness(10, 0, 0, 0),
|
||||
};
|
||||
|
||||
hyperlinkText.PointerPressed += (_, _) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var url = "https://github.com/settings/tokens";
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
Process.Start("xdg-open", url);
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
Process.Start("open", url);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"Failed to open URL: {ex.Message}");
|
||||
}
|
||||
};
|
||||
|
||||
var okButton = new Button
|
||||
{
|
||||
Content = "OK",
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
Margin = new Thickness(0, 10, 0, 0),
|
||||
MinWidth = 100,
|
||||
};
|
||||
|
||||
var messageBox = new Window
|
||||
{
|
||||
Title = "Rate Limit Exceeded",
|
||||
Width = 600,
|
||||
Height = 450,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||||
Content = new ScrollViewer
|
||||
{
|
||||
Content = new StackPanel
|
||||
{
|
||||
Margin = new Thickness(20),
|
||||
Spacing = 15,
|
||||
Children =
|
||||
{
|
||||
new TextBlock
|
||||
{
|
||||
Text = "GitHub API rate limit exceeded.",
|
||||
FontWeight = FontWeight.Bold,
|
||||
FontSize = 16,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
},
|
||||
new TextBlock
|
||||
{
|
||||
Text = "GitHub limits anonymous requests to 60 per hour. The limit resets one hour after depletion.",
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
},
|
||||
new TextBlock
|
||||
{
|
||||
Text = "To avoid this, add a GitHub API token in Settings:",
|
||||
FontWeight = FontWeight.SemiBold,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Margin = new Thickness(0, 10, 0, 0),
|
||||
},
|
||||
new TextBlock
|
||||
{
|
||||
Text = "1. Click the link below to create a token:",
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
},
|
||||
hyperlinkText,
|
||||
new TextBlock { Text = "2. Click 'Generate new token (classic)'", TextWrapping = TextWrapping.Wrap },
|
||||
new TextBlock { Text = "3. Give it a name (no special permissions needed)", TextWrapping = TextWrapping.Wrap },
|
||||
new TextBlock { Text = "4. Click 'Generate token' at the bottom", TextWrapping = TextWrapping.Wrap },
|
||||
new TextBlock { Text = "5. Copy the token and paste it in the launcher Settings", TextWrapping = TextWrapping.Wrap },
|
||||
new TextBlock
|
||||
{
|
||||
Text = "Do not share your token with anyone!",
|
||||
Foreground = new SolidColorBrush(Color.FromRgb(255, 149, 0)),
|
||||
FontWeight = FontWeight.Bold,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Margin = new Thickness(0, 10, 0, 0),
|
||||
},
|
||||
okButton,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
okButton.Click += (_, _) => messageBox.Close();
|
||||
await messageBox.ShowDialog(desktop.MainWindow);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Avalonia.Threading;
|
||||
using Quiver.Core.Models;
|
||||
using Quiver.Core.Services;
|
||||
using Quiver.Models;
|
||||
|
||||
namespace Quiver.Services;
|
||||
|
||||
public static class GameDownloadInstallService
|
||||
{
|
||||
public static async Task DownloadAndInstallAsync(
|
||||
GameInfo game,
|
||||
HttpClient httpClient,
|
||||
string gamesFolder,
|
||||
GitHubRelease? latestRelease,
|
||||
AppSettings settings,
|
||||
GameStatus triggerStatus,
|
||||
IGameDownloadDialogs? dialogs = null)
|
||||
{
|
||||
dialogs ??= AvaloniaGameDownloadDialogs.Instance;
|
||||
|
||||
if (string.IsNullOrEmpty(game.FolderName))
|
||||
{
|
||||
await dialogs.ShowErrorAsync("App configuration is invalid (missing folder name).", "Configuration Error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(game.Repository))
|
||||
{
|
||||
await dialogs.ShowErrorAsync("App configuration is invalid (missing repository).", "Configuration Error");
|
||||
return;
|
||||
}
|
||||
|
||||
var apiToken = settings?.GitHubApiToken ?? string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
game.Status = triggerStatus == GameStatus.UpdateAvailable ? GameStatus.Updating : GameStatus.Downloading;
|
||||
game.DownloadProgress = 0;
|
||||
|
||||
var gamePath = game.GetInstallPath(gamesFolder);
|
||||
var versionFile = Path.Combine(gamePath, "version.txt");
|
||||
|
||||
if (latestRelease == null)
|
||||
{
|
||||
if (GitHubApiCache.TryGetCachedVersion(game.Repository, out var cache) && cache?.CachedRelease != null)
|
||||
{
|
||||
latestRelease = cache.CachedRelease;
|
||||
}
|
||||
else
|
||||
{
|
||||
game.DownloadProgress = 5;
|
||||
var releaseResult = await GitHubReleaseService.FetchReleasesAsync(
|
||||
httpClient,
|
||||
game.Repository,
|
||||
apiToken).ConfigureAwait(false);
|
||||
|
||||
if (releaseResult.Releases.Count == 0)
|
||||
{
|
||||
await dialogs.ShowErrorAsync($"No releases found for {game.Name}.", "No Releases");
|
||||
game.Status = GameStatus.NotInstalled;
|
||||
game.DownloadProgress = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
latestRelease = releaseResult.Releases.FirstOrDefault();
|
||||
|
||||
if (latestRelease == null)
|
||||
{
|
||||
await dialogs.ShowErrorAsync($"No valid releases found for {game.Name}.", "No Releases");
|
||||
game.Status = GameStatus.NotInstalled;
|
||||
game.DownloadProgress = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
GitHubApiCache.SetCache(
|
||||
game.Repository,
|
||||
latestRelease.tag_name,
|
||||
releaseResult.ETag ?? string.Empty,
|
||||
latestRelease);
|
||||
}
|
||||
}
|
||||
|
||||
game.DownloadProgress = 10;
|
||||
|
||||
if (File.Exists(versionFile))
|
||||
{
|
||||
var existingVersion = (await File.ReadAllTextAsync(versionFile).ConfigureAwait(false))?.Trim();
|
||||
if (existingVersion == latestRelease.tag_name)
|
||||
{
|
||||
game.Status = GameStatus.Installed;
|
||||
game.InstalledVersion = existingVersion;
|
||||
game.LatestVersion = latestRelease.tag_name;
|
||||
game.DownloadProgress = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var availableAssets = GitHubReleaseService.GetDownloadableAssets(latestRelease);
|
||||
|
||||
if (availableAssets.Count == 0)
|
||||
{
|
||||
await dialogs.ShowErrorAsync($"No download files found for {game.Name}.", "No Assets");
|
||||
game.Status = GameStatus.NotInstalled;
|
||||
game.DownloadProgress = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
game.AvailableDownloads = availableAssets;
|
||||
|
||||
if (availableAssets.Count > 1 && game.SelectedDownload == null)
|
||||
{
|
||||
game.NotifyMultipleDownloadsChanged();
|
||||
game.Status = GameStatus.NotInstalled;
|
||||
game.DownloadProgress = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
var asset = game.SelectedDownload ?? availableAssets[0];
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) &&
|
||||
PlatformAssetMatcher.IsWindowsAsset(asset.name))
|
||||
{
|
||||
if (!WindowsRunnerService.IsWindowsRunnerAvailable(settings))
|
||||
{
|
||||
if (!await dialogs.ConfirmDownloadWithoutRunnerAsync())
|
||||
{
|
||||
game.Status = GameStatus.NotInstalled;
|
||||
game.DownloadProgress = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!await dialogs.ConfirmDownloadWithRunnerAsync())
|
||||
{
|
||||
game.Status = GameStatus.NotInstalled;
|
||||
game.DownloadProgress = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var downloadPath = Path.Combine(Path.GetTempPath(), asset.name);
|
||||
|
||||
try
|
||||
{
|
||||
using var request = new HttpRequestMessage(HttpMethod.Get, asset.browser_download_url);
|
||||
using var downloadResponse = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead)
|
||||
.ConfigureAwait(false);
|
||||
downloadResponse.EnsureSuccessStatusCode();
|
||||
|
||||
var totalBytes = downloadResponse.Content.Headers.ContentLength ?? 0;
|
||||
var canReportProgress = totalBytes > 0;
|
||||
|
||||
using (var contentStream = await downloadResponse.Content.ReadAsStreamAsync().ConfigureAwait(false))
|
||||
using (var fs = new FileStream(downloadPath, FileMode.Create, FileAccess.Write, FileShare.None, 8192, true))
|
||||
{
|
||||
var buffer = new byte[8192];
|
||||
long totalRead = 0;
|
||||
int bytesRead;
|
||||
|
||||
while ((bytesRead = await contentStream.ReadAsync(buffer).ConfigureAwait(false)) > 0)
|
||||
{
|
||||
await fs.WriteAsync(buffer.AsMemory(0, bytesRead)).ConfigureAwait(false);
|
||||
totalRead += bytesRead;
|
||||
|
||||
if (canReportProgress)
|
||||
{
|
||||
var downloadPercent = (double)totalRead / totalBytes;
|
||||
game.DownloadProgress = 10 + (downloadPercent * 80);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
game.DownloadProgress = 90;
|
||||
game.Status = GameStatus.Installing;
|
||||
game.DownloadProgress = 95;
|
||||
|
||||
await GameInstallationService.InstallOrUpdateGameAsync(
|
||||
downloadPath,
|
||||
gamePath,
|
||||
asset.name,
|
||||
latestRelease.tag_name,
|
||||
game.GetInstallationOptions()).ConfigureAwait(false);
|
||||
|
||||
game.DownloadProgress = 100;
|
||||
await Task.Delay(500).ConfigureAwait(false);
|
||||
|
||||
game.InstalledVersion = latestRelease.tag_name;
|
||||
if (string.IsNullOrWhiteSpace(game.LatestVersion) ||
|
||||
LauncherVersionService.IsNewerVersion(latestRelease.tag_name, game.LatestVersion))
|
||||
{
|
||||
game.LatestVersion = latestRelease.tag_name;
|
||||
}
|
||||
|
||||
game.Status = GameStatus.Installed;
|
||||
game.DownloadProgress = 0;
|
||||
game.SelectedDownload = null;
|
||||
game.AvailableDownloads = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
var wasSingleExecutable = asset.name.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) ||
|
||||
asset.name.EndsWith(".appimage", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (!wasSingleExecutable && File.Exists(downloadPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(downloadPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"Failed to delete temp file {downloadPath}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (game.GameManager != null)
|
||||
{
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
game.GameManager.OnPropertyChanged(nameof(GameManager.Games));
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
if (ex.Message.Contains("403", StringComparison.OrdinalIgnoreCase) ||
|
||||
ex.Message.Contains("rate limit", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
await dialogs.ShowRateLimitExceededAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await dialogs.ShowErrorAsync(
|
||||
$"Network error installing {game.Name}: {ex.Message}\n\nPlease check your internet connection.",
|
||||
"Network Error");
|
||||
}
|
||||
|
||||
game.Status = GameStatus.NotInstalled;
|
||||
game.DownloadProgress = 0;
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
await dialogs.ShowErrorAsync(
|
||||
$"Permission error installing {game.Name}: {ex.Message}\n\nPlease check folder permissions.",
|
||||
"Permission Error");
|
||||
game.Status = GameStatus.NotInstalled;
|
||||
game.DownloadProgress = 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await dialogs.ShowErrorAsync($"Error installing {game.Name}: {ex.Message}", "Installation Error");
|
||||
game.Status = GameStatus.NotInstalled;
|
||||
game.DownloadProgress = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Quiver.Core.Models;
|
||||
using Quiver.Core.Services;
|
||||
using Quiver.Models;
|
||||
|
||||
namespace Quiver.Services;
|
||||
|
||||
public static class GameDownloadService
|
||||
{
|
||||
public static bool TrySelectPlatformDownload(GameInfo game, GitHubRelease? release, AppSettings settings)
|
||||
{
|
||||
if (release == null)
|
||||
return false;
|
||||
|
||||
var assets = GitHubReleaseService.GetDownloadableAssets(release);
|
||||
if (assets.Count == 0)
|
||||
return false;
|
||||
|
||||
game.AvailableDownloads = assets;
|
||||
|
||||
if (assets.Count == 1)
|
||||
{
|
||||
game.SelectedDownload = assets[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
var platformIdentifier = GameInfo.GetPlatformIdentifier(settings);
|
||||
var matchingAsset = assets.FirstOrDefault(asset =>
|
||||
GameInfo.MatchesPlatform(asset.name, platformIdentifier));
|
||||
|
||||
game.SelectedDownload = matchingAsset ?? assets[0];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Quiver.Core.Services;
|
||||
using Quiver.Models;
|
||||
|
||||
namespace Quiver.Services;
|
||||
|
||||
public static class GameLaunchService
|
||||
{
|
||||
public static async Task LaunchAsync(GameInfo game, string gamesFolder)
|
||||
{
|
||||
if (string.IsNullOrEmpty(game.FolderName))
|
||||
{
|
||||
await GameDialogService.ShowMessageBoxAsync("Cannot launch game: folder name is not configured.", "Configuration Error");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var gamePath = game.GetInstallPath(gamesFolder);
|
||||
|
||||
if (!Directory.Exists(gamePath))
|
||||
{
|
||||
await GameDialogService.ShowMessageBoxAsync($"App directory not found: {gamePath}", "Directory Not Found");
|
||||
return;
|
||||
}
|
||||
|
||||
GameInstallationService.EnsureExecutableAtRoot(gamePath, game.GetInstallationOptions());
|
||||
|
||||
var executables = GameInstallationService.FindExecutableCandidates(
|
||||
gamePath,
|
||||
SearchOption.TopDirectoryOnly,
|
||||
game.GetInstallationOptions(),
|
||||
out var needsWine);
|
||||
|
||||
if (executables.Count == 0)
|
||||
{
|
||||
executables = GameInstallationService.FindExecutableCandidates(
|
||||
gamePath,
|
||||
SearchOption.AllDirectories,
|
||||
game.GetInstallationOptions(),
|
||||
out needsWine);
|
||||
}
|
||||
|
||||
if (executables.Count == 0)
|
||||
{
|
||||
await GameDialogService.ShowMessageBoxAsync(
|
||||
$"No executable found for {game.Name} in:\n{gamePath}\n\nThe game may not have installed correctly.",
|
||||
"Executable Not Found");
|
||||
return;
|
||||
}
|
||||
|
||||
var settings = AppSettings.Load();
|
||||
|
||||
if (needsWine && !WindowsRunnerService.IsWindowsRunnerAvailable(settings))
|
||||
{
|
||||
await GameDialogService.ShowMessageBoxAsync(
|
||||
"Only a Windows executable was found, but no Linux Windows-runner is configured or detected.\n\n" +
|
||||
"Install Wine/Proton or set a custom command in Settings to launch Windows apps.",
|
||||
"Windows Runner Not Found");
|
||||
return;
|
||||
}
|
||||
|
||||
game.AvailableExecutables = executables;
|
||||
|
||||
if (string.IsNullOrEmpty(game.SelectedExecutable))
|
||||
game.SelectedExecutable = game.LoadSelectedExecutable(gamesFolder);
|
||||
|
||||
if (executables.Count > 1 &&
|
||||
(string.IsNullOrEmpty(game.SelectedExecutable) || !executables.Contains(game.SelectedExecutable)))
|
||||
{
|
||||
game.SelectedExecutable = null;
|
||||
game.NotifyMultipleExecutablesChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
var executablePath = !string.IsNullOrEmpty(game.SelectedExecutable) &&
|
||||
executables.Contains(game.SelectedExecutable)
|
||||
? game.SelectedExecutable
|
||||
: executables[0];
|
||||
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
|
||||
!executablePath.EndsWith(".app") &&
|
||||
!needsWine)
|
||||
{
|
||||
await MakeExecutableAsync(executablePath);
|
||||
}
|
||||
|
||||
var startInfo = new ProcessStartInfo();
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && executablePath.EndsWith(".app"))
|
||||
{
|
||||
startInfo.FileName = "open";
|
||||
startInfo.Arguments = $"\"{executablePath}\"";
|
||||
startInfo.UseShellExecute = false;
|
||||
startInfo.WorkingDirectory = gamePath;
|
||||
}
|
||||
else if (needsWine && RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
var runnerCommand = WindowsRunnerService.GetWindowsRunnerCommand(settings, executablePath, gamePath);
|
||||
if (runnerCommand == null)
|
||||
{
|
||||
await GameDialogService.ShowMessageBoxAsync(
|
||||
"A Linux Windows-runner was detected earlier but is no longer available.",
|
||||
"Windows Runner Error");
|
||||
return;
|
||||
}
|
||||
|
||||
startInfo.UseShellExecute = false;
|
||||
startInfo.WorkingDirectory = gamePath;
|
||||
startInfo.FileName = runnerCommand.FileName;
|
||||
|
||||
foreach (var argument in runnerCommand.Arguments)
|
||||
startInfo.ArgumentList.Add(argument);
|
||||
|
||||
foreach (var variable in runnerCommand.EnvironmentVariables)
|
||||
startInfo.Environment[variable.Key] = variable.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
startInfo.FileName = executablePath;
|
||||
startInfo.WorkingDirectory = Path.GetDirectoryName(executablePath) ?? gamePath;
|
||||
startInfo.UseShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
}
|
||||
|
||||
game.UpdateLastPlayedTime(RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && executablePath.EndsWith(".app")
|
||||
? gamePath
|
||||
: (Path.GetDirectoryName(executablePath) ?? gamePath));
|
||||
|
||||
var gameProcess = Process.Start(startInfo);
|
||||
game.RaiseGameProcessStarted(gameProcess);
|
||||
|
||||
if (game.GameManager != null && Avalonia.Application.Current != null)
|
||||
game.GameManager.OnPropertyChanged(nameof(GameManager.Games));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (Avalonia.Application.Current != null)
|
||||
await GameDialogService.ShowMessageBoxAsync($"Error launching {game.Name}: {ex.Message}", "Launch Error");
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task MakeExecutableAsync(string executablePath)
|
||||
{
|
||||
var chmodProcess = new ProcessStartInfo
|
||||
{
|
||||
FileName = "chmod",
|
||||
Arguments = $"+x \"{executablePath}\"",
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
};
|
||||
|
||||
using var process = Process.Start(chmodProcess);
|
||||
if (process != null)
|
||||
await process.WaitForExitAsync();
|
||||
}
|
||||
}
|
||||
+138
-270
@@ -1,27 +1,29 @@
|
||||
using GitHubLauncher.Core.Models;
|
||||
using GitHubLauncher.Core.Services;
|
||||
using GithubLauncher.Models;
|
||||
using Quiver.Core.Models;
|
||||
using Quiver.Core.Services;
|
||||
using Quiver.Models;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace GithubLauncher.Services
|
||||
namespace Quiver.Services
|
||||
{
|
||||
public class GameManager : INotifyPropertyChanged, IDisposable
|
||||
{
|
||||
private static readonly GithubLauncherProfile Profile = GithubLauncherProfile.Instance;
|
||||
private static readonly QuiverProfile Profile = QuiverProfile.Instance;
|
||||
private readonly ISettingsStore _settingsStore;
|
||||
public AppSettings _settings = new();
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly AppCatalogService _catalogService;
|
||||
private bool _disposed;
|
||||
private string _appsFolder;
|
||||
private readonly string _cacheFolder;
|
||||
private readonly string _appsConfigPath;
|
||||
private readonly string _legacyGamesConfigPath;
|
||||
private List<GameInfo> _catalogApps = [];
|
||||
private List<GameInfo> _allGames = [];
|
||||
|
||||
public ObservableCollection<GameInfo> Games { get; set; } = [];
|
||||
public HttpClient HttpClient => _httpClient;
|
||||
public AppCatalogService CatalogService => _catalogService;
|
||||
public string AppsFolder => _appsFolder;
|
||||
public string GamesFolder => _appsFolder;
|
||||
public string CacheFolder => _cacheFolder;
|
||||
@@ -40,15 +42,18 @@ namespace GithubLauncher.Services
|
||||
}
|
||||
}
|
||||
|
||||
public GameManager()
|
||||
public GameManager(
|
||||
ISettingsStore? settingsStore = null,
|
||||
HttpClient? httpClient = null,
|
||||
AppCatalogService? catalogService = null)
|
||||
{
|
||||
_httpClient = new HttpClient();
|
||||
_httpClient.DefaultRequestHeaders.Add("User-Agent", Profile.UserAgent);
|
||||
_httpClient.Timeout = TimeSpan.FromMinutes(30);
|
||||
_settingsStore = settingsStore ?? SettingsStoreProvider.Default;
|
||||
_httpClient = httpClient ?? CreateDefaultHttpClient();
|
||||
_catalogService = catalogService ?? new AppCatalogService(this);
|
||||
|
||||
try
|
||||
{
|
||||
_settings = AppSettings.Load();
|
||||
_settings = _settingsStore.Load();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -61,8 +66,6 @@ namespace GithubLauncher.Services
|
||||
: Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Profile.DefaultInstallFolderName);
|
||||
|
||||
_cacheFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Cache");
|
||||
_appsConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "apps.json");
|
||||
_legacyGamesConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "games.json");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -76,7 +79,15 @@ namespace GithubLauncher.Services
|
||||
}
|
||||
|
||||
LoadVersionString();
|
||||
_ = ValidateAndFixAppsJsonAsync();
|
||||
_ = _catalogService.ValidateAndFixLocalAppsJsonAsync();
|
||||
}
|
||||
|
||||
private static HttpClient CreateDefaultHttpClient()
|
||||
{
|
||||
var client = new HttpClient();
|
||||
client.DefaultRequestHeaders.Add("User-Agent", Profile.UserAgent);
|
||||
client.Timeout = TimeSpan.FromMinutes(30);
|
||||
return client;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -101,47 +112,29 @@ namespace GithubLauncher.Services
|
||||
await LoadGamesAsync(forceUpdateCheck: true);
|
||||
}
|
||||
|
||||
private async Task ValidateAndFixAppsJsonAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var apps = await LoadAppsFromJsonAsync().ConfigureAwait(false);
|
||||
await SaveAppsToJsonAsync(apps).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error during apps.json integrity check: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadVersionString()
|
||||
{
|
||||
try
|
||||
{
|
||||
string versionFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "version.txt");
|
||||
CurrentVersionString = File.Exists(versionFilePath)
|
||||
? File.ReadAllText(versionFilePath).Trim()
|
||||
: "Version information not found";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error loading version: {ex.Message}");
|
||||
CurrentVersionString = "Version loading failed";
|
||||
}
|
||||
CurrentVersionString = LauncherVersionService.ReadInstalledVersion();
|
||||
}
|
||||
|
||||
public GameInfo? GetLatestPlayedInstalledGame()
|
||||
{
|
||||
if (Games == null || string.IsNullOrEmpty(_appsFolder))
|
||||
if (_catalogApps.Count == 0 || string.IsNullOrEmpty(_appsFolder))
|
||||
return null;
|
||||
|
||||
var settings = _settingsStore.Current;
|
||||
settings.EnsureInitialized();
|
||||
|
||||
DateTime latestTime = DateTime.MinValue;
|
||||
GameInfo? latestGame = null;
|
||||
foreach (var game in Games)
|
||||
foreach (var game in _catalogApps)
|
||||
{
|
||||
if (game == null || string.IsNullOrEmpty(game.FolderName))
|
||||
continue;
|
||||
|
||||
if (IsGameManuallyHidden(settings, game))
|
||||
continue;
|
||||
|
||||
var gamePath = game.GetInstallPath(_appsFolder);
|
||||
var lastPlayedPath = Path.Combine(gamePath, "LastPlayed.txt");
|
||||
if (File.Exists(lastPlayedPath))
|
||||
@@ -157,149 +150,6 @@ namespace GithubLauncher.Services
|
||||
return latestGame;
|
||||
}
|
||||
|
||||
private async Task<List<GameInfo>> LoadAppsFromJsonAsync()
|
||||
{
|
||||
if (!File.Exists(_appsConfigPath))
|
||||
{
|
||||
if (File.Exists(_legacyGamesConfigPath))
|
||||
{
|
||||
var migratedApps = await LoadAppsFromFileAsync(_legacyGamesConfigPath).ConfigureAwait(false);
|
||||
await SaveAppsToJsonAsync(migratedApps).ConfigureAwait(false);
|
||||
return migratedApps;
|
||||
}
|
||||
|
||||
await SaveAppsToJsonAsync([]).ConfigureAwait(false);
|
||||
return [];
|
||||
}
|
||||
|
||||
return await LoadAppsFromFileAsync(_appsConfigPath).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<List<GameInfo>> LoadAppsFromFileAsync(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
string json = await File.ReadAllTextAsync(path).ConfigureAwait(false);
|
||||
using var document = JsonDocument.Parse(json);
|
||||
return ParseAppsRoot(document.RootElement);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error reading {Path.GetFileName(path)}: {ex.Message}");
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private List<GameInfo> ParseAppsRoot(JsonElement root)
|
||||
{
|
||||
var apps = new List<GameInfo>();
|
||||
|
||||
if (root.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
apps.AddRange(ParseAppArray(root));
|
||||
return apps;
|
||||
}
|
||||
|
||||
if (root.TryGetProperty("apps", out var appsArray))
|
||||
{
|
||||
apps.AddRange(ParseAppArray(appsArray));
|
||||
}
|
||||
|
||||
foreach (var legacySection in new[] { "standard", "experimental", "custom" })
|
||||
{
|
||||
if (root.TryGetProperty(legacySection, out var legacyArray))
|
||||
apps.AddRange(ParseAppArray(legacyArray));
|
||||
}
|
||||
|
||||
return apps
|
||||
.GroupBy(app => app.Repository ?? string.Empty, StringComparer.OrdinalIgnoreCase)
|
||||
.Select(group => group.First())
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private List<GameInfo> ParseAppArray(JsonElement appsArray)
|
||||
{
|
||||
var apps = new List<GameInfo>();
|
||||
|
||||
foreach (var appElement in appsArray.EnumerateArray())
|
||||
{
|
||||
try
|
||||
{
|
||||
var app = new GameInfo
|
||||
{
|
||||
Name = (appElement.TryGetProperty("name", out var nameElement) ? nameElement.GetString() : null) ?? string.Empty,
|
||||
Repository = (appElement.TryGetProperty("repository", out var repoElement) ? repoElement.GetString() : null) ?? string.Empty,
|
||||
FolderName = (appElement.TryGetProperty("folderName", out var folderElement) ? folderElement.GetString() : null) ?? string.Empty,
|
||||
InstallPath = appElement.TryGetProperty("installPath", out var installPathElement) ? installPathElement.GetString() : null,
|
||||
GameIconUrl = GetIconUrl(appElement),
|
||||
PreferredVersion = appElement.TryGetProperty("preferredVersion", out var preferredVersionElement) ? preferredVersionElement.GetString() : null,
|
||||
SkippedUpdateVersion = appElement.TryGetProperty("skippedUpdateVersion", out var skippedUpdateVersionElement) ? skippedUpdateVersionElement.GetString() : null,
|
||||
IsExperimental = false,
|
||||
IsCustom = true,
|
||||
GameManager = this,
|
||||
};
|
||||
|
||||
apps.Add(app);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error parsing app: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return apps;
|
||||
}
|
||||
|
||||
private static string? GetIconUrl(JsonElement appElement)
|
||||
{
|
||||
if (appElement.TryGetProperty("appIconUrl", out var appIconUrlElement) && appIconUrlElement.ValueKind != JsonValueKind.Null)
|
||||
return appIconUrlElement.GetString();
|
||||
|
||||
if (appElement.TryGetProperty("gameIconUrl", out var gameIconUrlElement) && gameIconUrlElement.ValueKind != JsonValueKind.Null)
|
||||
return gameIconUrlElement.GetString();
|
||||
|
||||
if (appElement.TryGetProperty("customDefaultIconUrl", out var legacyIconElement) && legacyIconElement.ValueKind != JsonValueKind.Null)
|
||||
return legacyIconElement.GetString();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static object SerializeApp(GameInfo app)
|
||||
{
|
||||
return new
|
||||
{
|
||||
name = app.Name,
|
||||
repository = app.Repository,
|
||||
folderName = app.FolderName,
|
||||
installPath = app.InstallPath,
|
||||
appIconUrl = app.GameIconUrl,
|
||||
preferredVersion = app.PreferredVersion,
|
||||
skippedUpdateVersion = app.SkippedUpdateVersion
|
||||
};
|
||||
}
|
||||
|
||||
private async Task SaveAppsToJsonAsync(List<GameInfo> apps)
|
||||
{
|
||||
var data = new
|
||||
{
|
||||
apps = apps.Select(SerializeApp).ToList()
|
||||
};
|
||||
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
await File.WriteAllTextAsync(_appsConfigPath, JsonSerializer.Serialize(data, options)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void SaveAppsToJson(List<GameInfo> apps)
|
||||
{
|
||||
var data = new
|
||||
{
|
||||
apps = apps.Select(SerializeApp).ToList()
|
||||
};
|
||||
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
File.WriteAllText(_appsConfigPath, JsonSerializer.Serialize(data, options));
|
||||
}
|
||||
|
||||
private async Task LoadCustomAndCachedIconsAsync()
|
||||
{
|
||||
if (Games == null || string.IsNullOrEmpty(_cacheFolder))
|
||||
@@ -346,47 +196,55 @@ namespace GithubLauncher.Services
|
||||
|
||||
public async Task LoadGamesAsync(bool forceUpdateCheck = false)
|
||||
{
|
||||
var settings = AppSettings.Load();
|
||||
_settings = _settingsStore.Load();
|
||||
|
||||
Games ??= [];
|
||||
var allApps = await LoadAppsFromJsonAsync();
|
||||
var filteredApps = allApps
|
||||
.Where(app => app != null && !IsGameHidden(settings, app))
|
||||
.ToList();
|
||||
var localApps = await _catalogService.LoadLocalAppsAsync();
|
||||
var localRepos = new HashSet<string>(
|
||||
localApps
|
||||
.Where(a => !string.IsNullOrWhiteSpace(a.Repository))
|
||||
.Select(a => a.Repository!),
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
Games.Clear();
|
||||
var allApps = await _catalogService.LoadMergedCatalogAsync(_httpClient, _settings);
|
||||
_catalogApps = allApps.Where(app => app != null).Cast<GameInfo>().ToList();
|
||||
|
||||
foreach (var app in filteredApps)
|
||||
foreach (var app in _catalogApps)
|
||||
{
|
||||
if (app != null)
|
||||
Games.Add(app);
|
||||
if (app == null)
|
||||
continue;
|
||||
|
||||
app.IsInLocalAppsJson = !string.IsNullOrWhiteSpace(app.Repository) &&
|
||||
localRepos.Contains(app.Repository);
|
||||
}
|
||||
|
||||
await LoadCustomAndCachedIconsAsync();
|
||||
|
||||
if (string.IsNullOrEmpty(_appsFolder))
|
||||
return;
|
||||
|
||||
await Task.WhenAll(Games.Where(app => app != null).Select(async app =>
|
||||
if (!string.IsNullOrEmpty(_appsFolder))
|
||||
{
|
||||
try
|
||||
await Task.WhenAll(_catalogApps.Where(app => app != null).Select(async app =>
|
||||
{
|
||||
await app.CheckStatusAsync(_httpClient, _appsFolder, forceUpdateCheck);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error checking status for {app.Name}: {ex.Message}");
|
||||
}
|
||||
}));
|
||||
try
|
||||
{
|
||||
await app.CheckStatusAsync(_httpClient, _appsFolder, forceUpdateCheck);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error checking status for {app.Name}: {ex.Message}");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
RebuildVisibleGames(_settings);
|
||||
|
||||
await LoadCustomAndCachedIconsAsync();
|
||||
}
|
||||
|
||||
public async Task ExportGamesAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var apps = await LoadAppsFromJsonAsync().ConfigureAwait(false);
|
||||
await SaveAppsToJsonAsync(apps).ConfigureAwait(false);
|
||||
System.Diagnostics.Debug.WriteLine($"Apps exported successfully to {_appsConfigPath}");
|
||||
var apps = await _catalogService.LoadLocalAppsAsync().ConfigureAwait(false);
|
||||
await _catalogService.SaveLocalAppsAsync(apps).ConfigureAwait(false);
|
||||
System.Diagnostics.Debug.WriteLine($"Apps exported successfully to {_catalogService.AppsConfigPath}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -442,23 +300,12 @@ namespace GithubLauncher.Services
|
||||
return $"name:{game.Name ?? string.Empty}";
|
||||
}
|
||||
|
||||
private static bool IsGameHidden(AppSettings settings, GameInfo game)
|
||||
{
|
||||
if (settings?.HiddenApps == null)
|
||||
return false;
|
||||
|
||||
var hiddenKey = GetHiddenGameKey(game);
|
||||
return settings.HiddenApps.Contains(hiddenKey) ||
|
||||
(!string.IsNullOrWhiteSpace(game.Name) && settings.HiddenApps.Contains(game.Name)) ||
|
||||
IsGameManuallyHidden(settings, game);
|
||||
}
|
||||
|
||||
public void ToggleUserHide(GameInfo game)
|
||||
{
|
||||
if (game == null)
|
||||
return;
|
||||
|
||||
var settings = AppSettings.Load();
|
||||
var settings = _settingsStore.Current;
|
||||
if (IsGameManuallyHidden(settings, game))
|
||||
{
|
||||
RemoveManuallyHiddenGame(settings, game);
|
||||
@@ -467,24 +314,14 @@ namespace GithubLauncher.Services
|
||||
{
|
||||
AddManuallyHiddenGame(settings, game);
|
||||
}
|
||||
AppSettings.Save(settings);
|
||||
_settingsStore.Save(settings);
|
||||
_settings = settings;
|
||||
FilterGames(settings);
|
||||
}
|
||||
|
||||
public bool IsManuallyHidden(GameInfo game)
|
||||
{
|
||||
var settings = AppSettings.Load();
|
||||
return IsGameManuallyHidden(settings, game);
|
||||
}
|
||||
|
||||
private static void AddHiddenGame(AppSettings settings, GameInfo game)
|
||||
{
|
||||
if (settings?.HiddenApps == null)
|
||||
return;
|
||||
|
||||
var hiddenKey = GetHiddenGameKey(game);
|
||||
if (!settings.HiddenApps.Contains(hiddenKey))
|
||||
settings.HiddenApps.Add(hiddenKey);
|
||||
return IsGameManuallyHidden(_settingsStore.Current, game);
|
||||
}
|
||||
|
||||
public void HideGame(GameInfo game)
|
||||
@@ -492,55 +329,86 @@ namespace GithubLauncher.Services
|
||||
if (game == null)
|
||||
return;
|
||||
|
||||
var settings = AppSettings.Load();
|
||||
if (!IsGameHidden(settings, game))
|
||||
var settings = _settingsStore.Current;
|
||||
settings.EnsureInitialized();
|
||||
if (!IsGameManuallyHidden(settings, game))
|
||||
{
|
||||
AddHiddenGame(settings, game);
|
||||
AppSettings.Save(settings);
|
||||
AddManuallyHiddenGame(settings, game);
|
||||
_settingsStore.Save(settings);
|
||||
_settings = settings;
|
||||
FilterGames(settings);
|
||||
}
|
||||
}
|
||||
|
||||
public void UnhideAllGames()
|
||||
{
|
||||
var settings = AppSettings.Load();
|
||||
SetListScope(AppListScope.AllApps);
|
||||
}
|
||||
|
||||
public void HideAllNonInstalledGames()
|
||||
{
|
||||
SetListScope(AppListScope.InstalledOnly);
|
||||
}
|
||||
|
||||
public void SetListScope(AppListScope scope, AppSettings? settings = null)
|
||||
{
|
||||
settings ??= _settingsStore.Load();
|
||||
settings.EnsureInitialized();
|
||||
settings.ListScope = scope;
|
||||
settings.HiddenApps.Clear();
|
||||
AppSettings.Save(settings);
|
||||
_settingsStore.Save(settings);
|
||||
_settings = settings;
|
||||
FilterGames(settings);
|
||||
}
|
||||
|
||||
public async Task HideAllNonInstalledGames()
|
||||
{
|
||||
var settings = AppSettings.Load();
|
||||
settings.HiddenApps.Clear();
|
||||
AppSettings.Save(settings);
|
||||
|
||||
await LoadGamesAsync();
|
||||
|
||||
foreach (var game in Games)
|
||||
{
|
||||
if (game != null && game.Status == GameStatus.NotInstalled && !IsGameHidden(settings, game))
|
||||
AddHiddenGame(settings, game);
|
||||
}
|
||||
AppSettings.Save(settings);
|
||||
await LoadGamesAsync();
|
||||
}
|
||||
|
||||
private List<GameInfo> LoadGamesFromJson()
|
||||
{
|
||||
return LoadAppsFromJsonAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
private void FilterGames(AppSettings settings)
|
||||
{
|
||||
if (Games == null || settings?.HiddenApps == null)
|
||||
return;
|
||||
RebuildVisibleGames(settings);
|
||||
}
|
||||
|
||||
for (int i = Games.Count - 1; i >= 0; i--)
|
||||
public void ApplyTagDisplayFilter(AppSettings? settings = null)
|
||||
{
|
||||
settings ??= _settingsStore.Load();
|
||||
settings.EnsureInitialized();
|
||||
|
||||
IEnumerable<GameInfo> visibleGames = _allGames;
|
||||
if (!string.IsNullOrWhiteSpace(settings.ActiveTagDisplayFilterId))
|
||||
{
|
||||
if (Games[i] != null && IsGameHidden(settings, Games[i]))
|
||||
Games.RemoveAt(i);
|
||||
var filter = settings.TagDisplayFilters.FirstOrDefault(f =>
|
||||
string.Equals(f.Id, settings.ActiveTagDisplayFilterId, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (filter != null)
|
||||
{
|
||||
visibleGames = _allGames.Where(game =>
|
||||
TagHelper.MatchesFilterTags(game.Tags, filter.Tags, filter.MatchMode));
|
||||
}
|
||||
}
|
||||
|
||||
Games.Clear();
|
||||
foreach (var app in visibleGames)
|
||||
Games.Add(app);
|
||||
|
||||
OnPropertyChanged(nameof(Games));
|
||||
}
|
||||
|
||||
private void RebuildVisibleGames(AppSettings settings)
|
||||
{
|
||||
settings.EnsureInitialized();
|
||||
|
||||
_allGames = _catalogApps
|
||||
.Where(app => app != null && !IsGameManuallyHidden(settings, app))
|
||||
.Where(app => settings.ListScope != AppListScope.InstalledOnly
|
||||
|| app.Status != GameStatus.NotInstalled)
|
||||
.ToList();
|
||||
|
||||
ApplyTagDisplayFilter(settings);
|
||||
}
|
||||
|
||||
internal void SetCatalogAppsAndFilter(List<GameInfo> catalogApps, AppSettings settings)
|
||||
{
|
||||
_catalogApps = catalogApps;
|
||||
_settings = settings;
|
||||
RebuildVisibleGames(settings);
|
||||
}
|
||||
|
||||
private static bool IsGameManuallyHidden(AppSettings settings, GameInfo game)
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
using Quiver.Core.Models;
|
||||
using Quiver.Core.Services;
|
||||
using Quiver.Models;
|
||||
|
||||
namespace Quiver.Services;
|
||||
|
||||
public static class GameStatusService
|
||||
{
|
||||
private const string DefaultInstalledVersion = "0.0.0";
|
||||
|
||||
public static async Task CheckStatusAsync(
|
||||
GameInfo game,
|
||||
HttpClient httpClient,
|
||||
string gamesFolder,
|
||||
bool forceUpdateCheck = false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(game.FolderName))
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Warning: FolderName is null or empty for game {game.Name}");
|
||||
game.Status = GameStatus.NotInstalled;
|
||||
return;
|
||||
}
|
||||
|
||||
game.IsLoading = true;
|
||||
|
||||
try
|
||||
{
|
||||
var gamePath = game.GetInstallPath(gamesFolder);
|
||||
var versionFile = Path.Combine(gamePath, "version.txt");
|
||||
|
||||
var directoryExists = Directory.Exists(gamePath);
|
||||
var versionFileExists = File.Exists(versionFile);
|
||||
|
||||
var isInstalled = false;
|
||||
if (directoryExists)
|
||||
{
|
||||
if (versionFileExists)
|
||||
{
|
||||
try
|
||||
{
|
||||
game.InstalledVersion = (await File.ReadAllTextAsync(versionFile).ConfigureAwait(false))?.Trim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(game.InstalledVersion))
|
||||
game.InstalledVersion = await EnsureInstalledVersionFileAsync(versionFile).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
game.InstalledVersion = null;
|
||||
}
|
||||
|
||||
game.Status = GameStatus.Installed;
|
||||
isInstalled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
game.Status = GameStatus.Installed;
|
||||
game.InstalledVersion = await EnsureInstalledVersionFileAsync(versionFile).ConfigureAwait(false);
|
||||
isInstalled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
game.Status = GameStatus.NotInstalled;
|
||||
game.InstalledVersion = "";
|
||||
}
|
||||
|
||||
if (forceUpdateCheck)
|
||||
await game.CheckLatestVersionAsync(httpClient, forceCheck: true).ConfigureAwait(false);
|
||||
else if (isInstalled)
|
||||
{
|
||||
if (GitHubApiCache.NeedsUpdateCheck(game.Repository ?? string.Empty, isInstalledGame: true))
|
||||
await game.CheckLatestVersionAsync(httpClient).ConfigureAwait(false);
|
||||
else if (GitHubApiCache.TryGetCachedVersion(game.Repository, out var cache) && cache != null)
|
||||
game.ApplyCachedRelease(cache.Version, cache.CachedRelease);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GitHubApiCache.NeedsUpdateCheck(game.Repository ?? string.Empty, isInstalledGame: false))
|
||||
await game.CheckLatestVersionAsync(httpClient).ConfigureAwait(false);
|
||||
else if (GitHubApiCache.TryGetCachedVersion(game.Repository, out var cache) && cache != null)
|
||||
game.ApplyCachedRelease(cache.Version, cache.CachedRelease);
|
||||
}
|
||||
|
||||
if (isInstalled && string.IsNullOrWhiteSpace(game.InstalledVersion))
|
||||
{
|
||||
game.InstalledVersion = string.IsNullOrWhiteSpace(game.LatestVersion)
|
||||
? "Unknown"
|
||||
: DefaultInstalledVersion;
|
||||
}
|
||||
|
||||
if (isInstalled)
|
||||
game.RefreshInstalledStatus();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error checking status for {game.Name}: {ex.Message}");
|
||||
game.Status = GameStatus.NotInstalled;
|
||||
}
|
||||
finally
|
||||
{
|
||||
game.IsLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal static async Task<string?> EnsureInstalledVersionFileAsync(string versionFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
var versionDirectory = Path.GetDirectoryName(versionFile);
|
||||
if (!string.IsNullOrEmpty(versionDirectory))
|
||||
Directory.CreateDirectory(versionDirectory);
|
||||
|
||||
await File.WriteAllTextAsync(versionFile, DefaultInstalledVersion).ConfigureAwait(false);
|
||||
return DefaultInstalledVersion;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using GitHubLauncher.Core.Services;
|
||||
|
||||
namespace GithubLauncher.Services
|
||||
{
|
||||
public sealed class GithubLauncherProfile : LauncherProfile
|
||||
{
|
||||
public static GithubLauncherProfile Instance { get; } = new();
|
||||
|
||||
public override string DisplayName => "Github Launcher";
|
||||
public override string ApplicationId => "GithubLauncher";
|
||||
public override string Repository => "SirDiabo/GithubLauncher";
|
||||
public override string ExecutableName => "GithubLauncher";
|
||||
public override string DefaultInstallFolderName => "Apps";
|
||||
public override string UserAgent => "GithubLauncher/1.0";
|
||||
public override string CliUserAgent => "GithubLauncher-CLI";
|
||||
public override string UpdaterUserAgent => "GithubLauncher-Updater";
|
||||
public override string SteamTag => "Github Launcher";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
namespace Quiver.Services;
|
||||
|
||||
public interface IGameDownloadDialogs
|
||||
{
|
||||
Task<bool> ConfirmDownloadWithoutRunnerAsync();
|
||||
Task<bool> ConfirmDownloadWithRunnerAsync();
|
||||
Task ShowRateLimitExceededAsync();
|
||||
Task ShowErrorAsync(string message, string title);
|
||||
}
|
||||
|
||||
public sealed class AvaloniaGameDownloadDialogs : IGameDownloadDialogs
|
||||
{
|
||||
public static AvaloniaGameDownloadDialogs Instance { get; } = new();
|
||||
|
||||
public Task<bool> ConfirmDownloadWithoutRunnerAsync() =>
|
||||
GameDialogService.ShowWineNotFoundWarningAsync();
|
||||
|
||||
public Task<bool> ConfirmDownloadWithRunnerAsync() =>
|
||||
GameDialogService.ShowWineDownloadWarningAsync();
|
||||
|
||||
public Task ShowRateLimitExceededAsync() =>
|
||||
GameDialogService.ShowRateLimitErrorAsync();
|
||||
|
||||
public Task ShowErrorAsync(string message, string title) =>
|
||||
GameDialogService.ShowMessageBoxAsync(message, title);
|
||||
}
|
||||
|
||||
public sealed class HeadlessGameDownloadDialogs : IGameDownloadDialogs
|
||||
{
|
||||
public static HeadlessGameDownloadDialogs Instance { get; } = new();
|
||||
|
||||
public Task<bool> ConfirmDownloadWithoutRunnerAsync() => Task.FromResult(true);
|
||||
|
||||
public Task<bool> ConfirmDownloadWithRunnerAsync() => Task.FromResult(true);
|
||||
|
||||
public Task ShowRateLimitExceededAsync() => Task.CompletedTask;
|
||||
|
||||
public Task ShowErrorAsync(string message, string title) => Task.CompletedTask;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Quiver.Services;
|
||||
|
||||
public interface ISettingsStore
|
||||
{
|
||||
AppSettings Current { get; }
|
||||
|
||||
AppSettings Load();
|
||||
|
||||
void Save(AppSettings settings);
|
||||
}
|
||||
@@ -9,7 +9,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace GithubLauncher.Services
|
||||
namespace Quiver.Services
|
||||
{
|
||||
public class InputService : IDisposable
|
||||
{
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
using System.Text.Json;
|
||||
using Quiver.Core.Services;
|
||||
|
||||
namespace Quiver.Services;
|
||||
|
||||
public sealed class LauncherUpdateService
|
||||
{
|
||||
private static readonly QuiverProfile Profile = QuiverProfile.Instance;
|
||||
|
||||
public string ReadInstalledVersion(string? baseDirectory = null)
|
||||
{
|
||||
baseDirectory ??= AppDomain.CurrentDomain.BaseDirectory;
|
||||
var updateCheckFilePath = Path.Combine(baseDirectory, "update_check.json");
|
||||
|
||||
try
|
||||
{
|
||||
if (File.Exists(updateCheckFilePath))
|
||||
{
|
||||
var json = File.ReadAllText(updateCheckFilePath);
|
||||
var updateInfo = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(json);
|
||||
if (updateInfo != null &&
|
||||
updateInfo.TryGetValue("CurrentVersion", out var versionElement))
|
||||
{
|
||||
var version = versionElement.GetString();
|
||||
if (!string.IsNullOrWhiteSpace(version))
|
||||
return version;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Fall through to version.txt
|
||||
}
|
||||
|
||||
return LauncherVersionService.ReadInstalledVersion(baseDirectory);
|
||||
}
|
||||
|
||||
public async Task<string?> FetchLatestReleaseTagAsync(HttpClient? httpClient = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var ownsClient = httpClient == null;
|
||||
httpClient ??= CreateClient();
|
||||
|
||||
try
|
||||
{
|
||||
var response = await httpClient
|
||||
.GetStringAsync($"https://api.github.com/repos/{Profile.Repository}/releases/latest", cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
using var doc = JsonDocument.Parse(response);
|
||||
return doc.RootElement.GetProperty("tag_name").GetString();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (ownsClient)
|
||||
httpClient.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsUpdateAvailable(string installedVersion, string? latestTag) =>
|
||||
!string.IsNullOrWhiteSpace(latestTag) &&
|
||||
LauncherVersionService.IsNewerVersion(latestTag, installedVersion);
|
||||
|
||||
private static HttpClient CreateClient()
|
||||
{
|
||||
var client = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };
|
||||
client.DefaultRequestHeaders.Add("User-Agent", Profile.CliUserAgent);
|
||||
return client;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
namespace Quiver.Services;
|
||||
|
||||
public static class LauncherVersionService
|
||||
{
|
||||
public static string NormalizeVersionString(string? version)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(version))
|
||||
return "0.0.0";
|
||||
|
||||
var normalized = version.Trim().TrimStart('v', 'V');
|
||||
var segments = normalized.Split('.', StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
|
||||
while (segments.Count < 3)
|
||||
segments.Add("0");
|
||||
|
||||
return string.Join(".", segments.Take(4));
|
||||
}
|
||||
|
||||
public static bool IsNewerVersion(string candidateVersion, string baselineVersion)
|
||||
{
|
||||
try
|
||||
{
|
||||
var candidate = new Version(NormalizeVersionString(candidateVersion));
|
||||
var baseline = new Version(NormalizeVersionString(baselineVersion));
|
||||
return candidate.CompareTo(baseline) > 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return !candidateVersion.TrimStart('v', 'V').Equals(
|
||||
baselineVersion.TrimStart('v', 'V'),
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool AreVersionsEquivalent(string? firstVersion, string? secondVersion)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(firstVersion) || string.IsNullOrWhiteSpace(secondVersion))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
return new Version(NormalizeVersionString(firstVersion))
|
||||
.Equals(new Version(NormalizeVersionString(secondVersion)));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return firstVersion.TrimStart('v', 'V').Trim()
|
||||
.Equals(secondVersion.TrimStart('v', 'V').Trim(), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadInstalledVersion(string? baseDirectory = null)
|
||||
{
|
||||
baseDirectory ??= AppDomain.CurrentDomain.BaseDirectory;
|
||||
var versionFilePath = Path.Combine(baseDirectory, "version.txt");
|
||||
|
||||
try
|
||||
{
|
||||
return File.Exists(versionFilePath)
|
||||
? File.ReadAllText(versionFilePath).Trim()
|
||||
: "Version information not found";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error loading version: {ex.Message}");
|
||||
return "Version loading failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Quiver.Core.Services;
|
||||
|
||||
namespace Quiver.Services
|
||||
{
|
||||
public sealed class QuiverProfile : LauncherProfile
|
||||
{
|
||||
public static QuiverProfile Instance { get; } = new();
|
||||
|
||||
public override string DisplayName => "Quiver";
|
||||
public override string ApplicationId => "Quiver";
|
||||
public override string Repository => "tgeorgiadis/quiver";
|
||||
public override string ExecutableName => "Quiver";
|
||||
public override string DefaultInstallFolderName => "Apps";
|
||||
public override string UserAgent => "Quiver/1.0";
|
||||
public override string CliUserAgent => "Quiver-CLI";
|
||||
public override string UpdaterUserAgent => "Quiver-Updater";
|
||||
public override string SteamTag => "Quiver";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Quiver.Services;
|
||||
|
||||
public static class SettingsStoreProvider
|
||||
{
|
||||
public static ISettingsStore Default { get; set; } = new FileSettingsStore();
|
||||
}
|
||||
+20
-19
@@ -1,4 +1,4 @@
|
||||
using GithubLauncher.Models;
|
||||
using Quiver.Models;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
@@ -10,19 +10,19 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GithubLauncher.Services
|
||||
namespace Quiver.Services
|
||||
{
|
||||
public static class ShortcutHelper
|
||||
{
|
||||
private static readonly string LauncherSteamTag = GithubLauncherProfile.Instance.SteamTag;
|
||||
private static readonly string LauncherSteamTag = QuiverProfile.Instance.SteamTag;
|
||||
|
||||
public static void CreateGameShortcut(GameInfo game, string launcherPath, string? cacheDirectory)
|
||||
public static async Task CreateGameShortcutAsync(GameInfo game, string launcherPath, string? cacheDirectory)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(game?.Name))
|
||||
throw new ArgumentException("Game name is required.", nameof(game));
|
||||
|
||||
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
||||
string? iconPath = PrepareIcon(game, cacheDirectory);
|
||||
string? iconPath = await PrepareIconAsync(game, cacheDirectory).ConfigureAwait(false);
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
@@ -38,6 +38,11 @@ namespace GithubLauncher.Services
|
||||
}
|
||||
}
|
||||
|
||||
public static void CreateGameShortcut(GameInfo game, string launcherPath, string? cacheDirectory)
|
||||
{
|
||||
CreateGameShortcutAsync(game, launcherPath, cacheDirectory).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static string AddGameToSteam(GameInfo game, string launcherPath, string? cacheDirectory)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(game?.Name))
|
||||
@@ -55,7 +60,7 @@ namespace GithubLauncher.Services
|
||||
if (IsSteamRunning())
|
||||
throw new InvalidOperationException("Steam is still running.");
|
||||
|
||||
return AddGameToSteamInternal(game, launcherPath, cacheDirectory);
|
||||
return AddGameToSteamInternalAsync(game, launcherPath, cacheDirectory).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static string QueueGameAddToSteam(GameInfo game, string launcherPath)
|
||||
@@ -97,10 +102,10 @@ namespace GithubLauncher.Services
|
||||
throw new InvalidOperationException("Steam must be closed before modifying shortcuts.vdf.");
|
||||
}
|
||||
|
||||
return AddGameToSteamInternal(game, launcherPath, cacheDirectory);
|
||||
return await AddGameToSteamInternalAsync(game, launcherPath, cacheDirectory).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static string AddGameToSteamInternal(GameInfo game, string launcherPath, string? cacheDirectory)
|
||||
private static async Task<string> AddGameToSteamInternalAsync(GameInfo game, string launcherPath, string? cacheDirectory)
|
||||
{
|
||||
string? configDirectory = FindSteamConfigDirectory();
|
||||
if (string.IsNullOrWhiteSpace(configDirectory))
|
||||
@@ -111,7 +116,7 @@ namespace GithubLauncher.Services
|
||||
Directory.CreateDirectory(configDirectory);
|
||||
|
||||
string shortcutsPath = Path.Combine(configDirectory, "shortcuts.vdf");
|
||||
string? iconPath = PrepareIcon(game, cacheDirectory);
|
||||
string? iconPath = await PrepareIconAsync(game, cacheDirectory).ConfigureAwait(false);
|
||||
var root = File.Exists(shortcutsPath)
|
||||
? ReadSteamShortcuts(shortcutsPath)
|
||||
: CreateEmptySteamShortcutsRoot();
|
||||
@@ -163,7 +168,7 @@ namespace GithubLauncher.Services
|
||||
: "Added the game to Steam. Restart Steam or return to Game Mode to refresh your library.";
|
||||
}
|
||||
|
||||
private static string? PrepareIcon(GameInfo game, string? cacheDirectory)
|
||||
private static async Task<string?> PrepareIconAsync(GameInfo game, string? cacheDirectory)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(cacheDirectory))
|
||||
return null;
|
||||
@@ -173,12 +178,10 @@ namespace GithubLauncher.Services
|
||||
|
||||
string? sourcePath = null;
|
||||
|
||||
// Try cached default icon
|
||||
if (!string.IsNullOrEmpty(game.IconUrl) && File.Exists(game.IconUrl))
|
||||
{
|
||||
sourcePath = game.IconUrl;
|
||||
}
|
||||
// Download from URL if needed
|
||||
else if (!string.IsNullOrEmpty(game.DefaultIconUrl) &&
|
||||
(game.DefaultIconUrl.StartsWith("http://") || game.DefaultIconUrl.StartsWith("https://")))
|
||||
{
|
||||
@@ -186,20 +189,19 @@ namespace GithubLauncher.Services
|
||||
{
|
||||
var tempIconPath = Path.Combine(iconsDir, $"{game.FolderName}_temp.png");
|
||||
using var client = new System.Net.Http.HttpClient();
|
||||
var iconData = client.GetByteArrayAsync(game.DefaultIconUrl).Result;
|
||||
File.WriteAllBytes(tempIconPath, iconData);
|
||||
var iconData = await client.GetByteArrayAsync(game.DefaultIconUrl).ConfigureAwait(false);
|
||||
await File.WriteAllBytesAsync(tempIconPath, iconData).ConfigureAwait(false);
|
||||
sourcePath = tempIconPath;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null; // No icon available
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(sourcePath) || !File.Exists(sourcePath))
|
||||
return null;
|
||||
|
||||
// Convert to ICO for Windows
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
string icoPath = Path.Combine(iconsDir, $"{game.FolderName}.ico");
|
||||
@@ -212,7 +214,6 @@ namespace GithubLauncher.Services
|
||||
return icoPath;
|
||||
}
|
||||
|
||||
// Linux can use PNG directly
|
||||
return sourcePath;
|
||||
}
|
||||
|
||||
@@ -277,7 +278,7 @@ namespace GithubLauncher.Services
|
||||
$Shortcut.TargetPath = '{launcherPath}'
|
||||
$Shortcut.Arguments = '--run {gameName}'
|
||||
$Shortcut.WorkingDirectory = '{Path.GetDirectoryName(launcherPath)}'
|
||||
$Shortcut.Description = 'Launch {gameName} via Github Launcher'
|
||||
$Shortcut.Description = 'Launch {gameName} via Quiver'
|
||||
{(iconPath != null ? $"$Shortcut.IconLocation = '{iconPath},0'" : "")}
|
||||
$Shortcut.Save()
|
||||
";
|
||||
@@ -310,7 +311,7 @@ namespace GithubLauncher.Services
|
||||
Icon={iconPath ?? ""}
|
||||
Terminal=false
|
||||
Categories=Game;
|
||||
Comment=Launch {safeGameName} via Github Launcher
|
||||
Comment=Launch {safeGameName} via Quiver
|
||||
";
|
||||
|
||||
File.WriteAllText(desktopFilePath, desktopFileContent);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using Quiver;
|
||||
|
||||
namespace Quiver.Services
|
||||
{
|
||||
public class TagDisplayFilterListItem
|
||||
{
|
||||
public TagDisplayFilter Filter { get; init; } = null!;
|
||||
public string Id => Filter.Id;
|
||||
public string Name => Filter.Name;
|
||||
public bool IsSelected { get; init; }
|
||||
|
||||
public static TagDisplayFilterListItem FromFilter(TagDisplayFilter filter, bool isSelected) =>
|
||||
new()
|
||||
{
|
||||
Filter = filter,
|
||||
IsSelected = isSelected,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Quiver;
|
||||
|
||||
namespace Quiver.Services
|
||||
{
|
||||
public static class TagHelper
|
||||
{
|
||||
public static List<string> NormalizeTags(IEnumerable<string>? tags)
|
||||
{
|
||||
if (tags == null)
|
||||
return [];
|
||||
|
||||
return tags
|
||||
.Select(t => t?.Trim().ToLowerInvariant() ?? string.Empty)
|
||||
.Where(t => t.Length > 0)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public static List<string> ParseCommaSeparatedTags(string? input) =>
|
||||
NormalizeTags(input?.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries));
|
||||
|
||||
public static string FormatTagsForDisplay(IEnumerable<string>? tags)
|
||||
{
|
||||
var normalized = NormalizeTags(tags);
|
||||
return normalized.Count == 0 ? string.Empty : string.Join(", ", normalized);
|
||||
}
|
||||
|
||||
public static List<string> MergeTags(IEnumerable<string>? primary, IEnumerable<string>? secondary)
|
||||
{
|
||||
var merged = new List<string>();
|
||||
merged.AddRange(NormalizeTags(primary));
|
||||
merged.AddRange(NormalizeTags(secondary));
|
||||
return NormalizeTags(merged);
|
||||
}
|
||||
|
||||
public static bool MatchesAnyFilterTags(IEnumerable<string>? appTags, IEnumerable<string>? filterTags)
|
||||
{
|
||||
var normalizedAppTags = NormalizeTags(appTags);
|
||||
var normalizedFilterTags = NormalizeTags(filterTags);
|
||||
|
||||
if (normalizedFilterTags.Count == 0)
|
||||
return true;
|
||||
|
||||
if (normalizedAppTags.Count == 0)
|
||||
return false;
|
||||
|
||||
return normalizedFilterTags.Any(filterTag =>
|
||||
normalizedAppTags.Contains(filterTag, StringComparer.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public static bool MatchesAllFilterTags(IEnumerable<string>? appTags, IEnumerable<string>? filterTags)
|
||||
{
|
||||
var normalizedAppTags = NormalizeTags(appTags);
|
||||
var normalizedFilterTags = NormalizeTags(filterTags);
|
||||
|
||||
if (normalizedFilterTags.Count == 0)
|
||||
return true;
|
||||
|
||||
if (normalizedAppTags.Count == 0)
|
||||
return false;
|
||||
|
||||
return normalizedFilterTags.All(filterTag =>
|
||||
normalizedAppTags.Contains(filterTag, StringComparer.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public static bool MatchesFilterTags(
|
||||
IEnumerable<string>? appTags,
|
||||
IEnumerable<string>? filterTags,
|
||||
TagFilterMatchMode matchMode) =>
|
||||
matchMode == TagFilterMatchMode.All
|
||||
? MatchesAllFilterTags(appTags, filterTags)
|
||||
: MatchesAnyFilterTags(appTags, filterTags);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Quiver.Services;
|
||||
|
||||
public sealed class WindowsRunnerCommandSpec
|
||||
{
|
||||
public required string FileName { get; init; }
|
||||
public required List<string> Arguments { get; init; }
|
||||
public Dictionary<string, string> EnvironmentVariables { get; init; } = new(StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
public static class WindowsRunnerService
|
||||
{
|
||||
private sealed class ProtonInstallation
|
||||
{
|
||||
public required string ProtonExecutable { get; init; }
|
||||
public required string SteamRoot { get; init; }
|
||||
}
|
||||
|
||||
private static readonly Dictionary<string, Func<string, string, string>> RunnerPlaceholderResolvers = new(StringComparer.Ordinal)
|
||||
{
|
||||
["{exe}"] = (executablePath, _) => executablePath,
|
||||
["{gamePath}"] = (_, gamePath) => gamePath,
|
||||
["{exeDir}"] = (executablePath, gamePath) => Path.GetDirectoryName(executablePath) ?? gamePath,
|
||||
};
|
||||
|
||||
public static bool IsWindowsRunnerAvailable(AppSettings? settings = null)
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
return false;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(settings?.LinuxWindowsLaunchCommand))
|
||||
return true;
|
||||
|
||||
return IsWineOrProtonAvailable();
|
||||
}
|
||||
|
||||
public static WindowsRunnerCommandSpec BuildWindowsRunnerCommand(
|
||||
string commandTemplate,
|
||||
string executablePath,
|
||||
string gamePath)
|
||||
{
|
||||
var resolvedCommand = commandTemplate.Trim();
|
||||
|
||||
if (!resolvedCommand.Contains("{exe}", StringComparison.Ordinal) &&
|
||||
!resolvedCommand.Contains("{gamePath}", StringComparison.Ordinal) &&
|
||||
!resolvedCommand.Contains("{exeDir}", StringComparison.Ordinal))
|
||||
{
|
||||
resolvedCommand += " {exe}";
|
||||
}
|
||||
|
||||
var tokens = SplitRunnerCommand(resolvedCommand);
|
||||
if (tokens.Count == 0 || string.IsNullOrWhiteSpace(tokens[0]))
|
||||
throw new InvalidOperationException("The Linux Windows-runner command is empty.");
|
||||
|
||||
var resolvedTokens = tokens
|
||||
.Select(token => ReplaceRunnerPlaceholders(token, executablePath, gamePath))
|
||||
.ToList();
|
||||
|
||||
return new WindowsRunnerCommandSpec
|
||||
{
|
||||
FileName = resolvedTokens[0],
|
||||
Arguments = resolvedTokens.Skip(1).ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
public static WindowsRunnerCommandSpec? GetWindowsRunnerCommand(
|
||||
AppSettings settings,
|
||||
string executablePath,
|
||||
string gamePath)
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
return null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(settings.LinuxWindowsLaunchCommand))
|
||||
return BuildWindowsRunnerCommand(settings.LinuxWindowsLaunchCommand, executablePath, gamePath);
|
||||
|
||||
if (IsCommandAvailable("wine64"))
|
||||
return BuildWindowsRunnerCommand("wine64 {exe}", executablePath, gamePath);
|
||||
|
||||
if (IsCommandAvailable("wine"))
|
||||
return BuildWindowsRunnerCommand("wine {exe}", executablePath, gamePath);
|
||||
|
||||
foreach (var protonInstallation in GetProtonInstallations())
|
||||
{
|
||||
if (!File.Exists(protonInstallation.ProtonExecutable))
|
||||
continue;
|
||||
|
||||
var compatDataPath = GetProtonCompatDataPath(gamePath);
|
||||
var compatAppId = GetStableCompatAppId(executablePath);
|
||||
Directory.CreateDirectory(compatDataPath);
|
||||
|
||||
return new WindowsRunnerCommandSpec
|
||||
{
|
||||
FileName = protonInstallation.ProtonExecutable,
|
||||
Arguments = ["waitforexitandrun", executablePath],
|
||||
EnvironmentVariables = new Dictionary<string, string>(StringComparer.Ordinal)
|
||||
{
|
||||
["STEAM_COMPAT_CLIENT_INSTALL_PATH"] = protonInstallation.SteamRoot,
|
||||
["STEAM_COMPAT_DATA_PATH"] = compatDataPath,
|
||||
["STEAM_COMPAT_APP_ID"] = compatAppId,
|
||||
["SteamAppId"] = compatAppId,
|
||||
["SteamGameId"] = compatAppId,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static List<string> SplitRunnerCommand(string command)
|
||||
{
|
||||
var tokens = new List<string>();
|
||||
var current = new StringBuilder();
|
||||
var inSingleQuotes = false;
|
||||
var inDoubleQuotes = false;
|
||||
var escaping = false;
|
||||
|
||||
foreach (var character in command)
|
||||
{
|
||||
if (escaping)
|
||||
{
|
||||
current.Append(character);
|
||||
escaping = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (character == '\\' && !inSingleQuotes)
|
||||
{
|
||||
escaping = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (character == '"' && !inSingleQuotes)
|
||||
{
|
||||
inDoubleQuotes = !inDoubleQuotes;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (character == '\'' && !inDoubleQuotes)
|
||||
{
|
||||
inSingleQuotes = !inSingleQuotes;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char.IsWhiteSpace(character) && !inSingleQuotes && !inDoubleQuotes)
|
||||
{
|
||||
if (current.Length > 0)
|
||||
{
|
||||
tokens.Add(current.ToString());
|
||||
current.Clear();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
current.Append(character);
|
||||
}
|
||||
|
||||
if (escaping || inSingleQuotes || inDoubleQuotes)
|
||||
throw new InvalidOperationException("The Linux Windows-runner command contains an unmatched quote or trailing escape character.");
|
||||
|
||||
if (current.Length > 0)
|
||||
tokens.Add(current.ToString());
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
private static string ReplaceRunnerPlaceholders(string token, string executablePath, string gamePath)
|
||||
{
|
||||
var resolvedToken = token;
|
||||
|
||||
foreach (var placeholder in RunnerPlaceholderResolvers)
|
||||
{
|
||||
if (resolvedToken.Contains(placeholder.Key, StringComparison.Ordinal))
|
||||
{
|
||||
resolvedToken = resolvedToken.Replace(
|
||||
placeholder.Key,
|
||||
placeholder.Value(executablePath, gamePath),
|
||||
StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
|
||||
return resolvedToken;
|
||||
}
|
||||
|
||||
private static bool IsWineOrProtonAvailable()
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
return false;
|
||||
|
||||
if (IsCommandAvailable("wine") || IsCommandAvailable("wine64"))
|
||||
return true;
|
||||
|
||||
foreach (var protonInstallation in GetProtonInstallations())
|
||||
{
|
||||
if (File.Exists(protonInstallation.ProtonExecutable))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static IEnumerable<ProtonInstallation> GetProtonInstallations()
|
||||
{
|
||||
foreach (var steamRoot in GetSteamRoots())
|
||||
{
|
||||
var commonPath = Path.Combine(steamRoot, "steamapps", "common");
|
||||
foreach (var protonDir in GetExistingDirectories(commonPath, "Proton*").OrderByDescending(d => d, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
var protonExe = Path.Combine(protonDir, "proton");
|
||||
if (File.Exists(protonExe))
|
||||
{
|
||||
yield return new ProtonInstallation
|
||||
{
|
||||
ProtonExecutable = protonExe,
|
||||
SteamRoot = steamRoot,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var compatibilityToolsPath = Path.Combine(steamRoot, "compatibilitytools.d");
|
||||
foreach (var protonDir in GetExistingDirectories(compatibilityToolsPath, "*Proton*").OrderByDescending(d => d, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
var protonExe = Path.Combine(protonDir, "proton");
|
||||
if (File.Exists(protonExe))
|
||||
{
|
||||
yield return new ProtonInstallation
|
||||
{
|
||||
ProtonExecutable = protonExe,
|
||||
SteamRoot = steamRoot,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetSteamRoots()
|
||||
{
|
||||
var homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
var steamRoots = new[]
|
||||
{
|
||||
Path.Combine(homePath, ".steam", "root"),
|
||||
Path.Combine(homePath, ".steam", "steam"),
|
||||
Path.Combine(homePath, ".local", "share", "Steam"),
|
||||
Path.Combine(homePath, ".var", "app", "com.valvesoftware.Steam", ".local", "share", "Steam"),
|
||||
};
|
||||
|
||||
return steamRoots
|
||||
.Where(Directory.Exists)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetExistingDirectories(string parentPath, string searchPattern)
|
||||
{
|
||||
if (!Directory.Exists(parentPath))
|
||||
return [];
|
||||
|
||||
try
|
||||
{
|
||||
return Directory.GetDirectories(parentPath, searchPattern, SearchOption.TopDirectoryOnly);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetProtonCompatDataPath(string gamePath) =>
|
||||
Path.Combine(gamePath, ".steam-compat-data");
|
||||
|
||||
private static string GetStableCompatAppId(string executablePath)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
uint hash = 2166136261;
|
||||
foreach (var character in executablePath)
|
||||
{
|
||||
hash ^= character;
|
||||
hash *= 16777619;
|
||||
}
|
||||
|
||||
return (hash & 0x7FFFFFFF).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsCommandAvailable(string command)
|
||||
{
|
||||
try
|
||||
{
|
||||
var process = new ProcessStartInfo
|
||||
{
|
||||
FileName = "which",
|
||||
Arguments = command,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
CreateNoWindow = true,
|
||||
};
|
||||
|
||||
using var proc = Process.Start(process);
|
||||
if (proc != null)
|
||||
{
|
||||
proc.WaitForExit();
|
||||
return proc.ExitCode == 0;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.ViewModels;
|
||||
|
||||
public class CatalogViewModel
|
||||
{
|
||||
public IReadOnlyList<CatalogSourceListItem> BuildSourceListItems(AppSettings settings)
|
||||
{
|
||||
settings.EnsureInitialized();
|
||||
return settings.AppCatalogSources
|
||||
.Select(CatalogSourceListItem.FromSource)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void RefreshSourceList(ObservableCollection<CatalogSourceListItem> target, AppSettings settings)
|
||||
{
|
||||
var items = BuildSourceListItems(settings);
|
||||
target.Clear();
|
||||
foreach (var item in items)
|
||||
target.Add(item);
|
||||
}
|
||||
|
||||
public bool IsAlreadySubscribed(AppSettings settings, CommunityCatalogListEntry entry) =>
|
||||
settings.AppCatalogSources.Any(s =>
|
||||
(!string.IsNullOrWhiteSpace(entry.Id) &&
|
||||
string.Equals(s.CommunityListId, entry.Id, StringComparison.OrdinalIgnoreCase)) ||
|
||||
string.Equals(s.Location, entry.Location, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
public AppCatalogSource CreateSourceFromCommunityEntry(CommunityCatalogListEntry entry) =>
|
||||
new()
|
||||
{
|
||||
Name = string.IsNullOrWhiteSpace(entry.Name) ? entry.Id : entry.Name,
|
||||
Location = entry.Location,
|
||||
CommunityListId = entry.Id,
|
||||
Enabled = true,
|
||||
};
|
||||
|
||||
public AppCatalogSource CreateSource(string name, string location) =>
|
||||
new()
|
||||
{
|
||||
Name = name,
|
||||
Location = location,
|
||||
Enabled = true,
|
||||
LastFetchedUtc = DateTime.UtcNow,
|
||||
LastError = null,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.ViewModels;
|
||||
|
||||
public class GameGridViewModel
|
||||
{
|
||||
public IReadOnlyList<GameInfo> SortGames(IEnumerable<GameInfo> games, string sortMode, string gamesFolder)
|
||||
{
|
||||
var list = games.Where(g => g != null).Cast<GameInfo>().ToList();
|
||||
|
||||
return sortMode switch
|
||||
{
|
||||
"NameDesc" => list.OrderByDescending(g => g.Name ?? string.Empty).ToList(),
|
||||
"Installed" => list
|
||||
.OrderByDescending(g => g.IsInstalled)
|
||||
.ThenBy(g => g.Name ?? string.Empty)
|
||||
.ToList(),
|
||||
"NotInstalled" => list
|
||||
.OrderBy(g => g.IsInstalled)
|
||||
.ThenBy(g => g.Name ?? string.Empty)
|
||||
.ToList(),
|
||||
"LastPlayed" => list
|
||||
.OrderByDescending(g => GetLastPlayedTime(g, gamesFolder))
|
||||
.ThenBy(g => g.Name ?? string.Empty)
|
||||
.ToList(),
|
||||
_ => list.OrderBy(g => g.Name ?? string.Empty).ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
public void ApplySort(ObservableCollection<GameInfo> games, string sortMode, string gamesFolder)
|
||||
{
|
||||
if (games.Count == 0)
|
||||
return;
|
||||
|
||||
var sorted = SortGames(games, sortMode, gamesFolder);
|
||||
games.Clear();
|
||||
foreach (var game in sorted)
|
||||
games.Add(game);
|
||||
}
|
||||
|
||||
public static DateTime GetLastPlayedTime(GameInfo game, string gamesFolder)
|
||||
{
|
||||
if (string.IsNullOrEmpty(game.FolderName))
|
||||
return DateTime.MinValue;
|
||||
|
||||
try
|
||||
{
|
||||
var gamePath = game.GetInstallPath(gamesFolder);
|
||||
var lastPlayedPath = Path.Combine(gamePath, "LastPlayed.txt");
|
||||
|
||||
if (File.Exists(lastPlayedPath))
|
||||
{
|
||||
var content = File.ReadAllText(lastPlayedPath).Trim();
|
||||
if (DateTime.TryParseExact(content, "yyyy-MM-dd HH:mm:ss", null,
|
||||
System.Globalization.DateTimeStyles.None, out var lastPlayed))
|
||||
return lastPlayed;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Failed to read LastPlayed for {game.Name}: {ex.Message}");
|
||||
}
|
||||
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Quiver.Models;
|
||||
using Quiver.Services;
|
||||
|
||||
namespace Quiver.ViewModels;
|
||||
|
||||
public class SettingsViewModel
|
||||
{
|
||||
private readonly ISettingsStore _settingsStore;
|
||||
|
||||
public SettingsViewModel(ISettingsStore? settingsStore = null)
|
||||
{
|
||||
_settingsStore = settingsStore ?? SettingsStoreProvider.Default;
|
||||
}
|
||||
|
||||
public AppSettings Current => _settingsStore.Current;
|
||||
|
||||
public AppSettings Load() => _settingsStore.Load();
|
||||
|
||||
public void Save(AppSettings settings) => _settingsStore.Save(settings);
|
||||
|
||||
public void SaveCurrent() => _settingsStore.Save(_settingsStore.Current);
|
||||
}
|
||||
@@ -0,0 +1,545 @@
|
||||
{
|
||||
"apps": [
|
||||
{
|
||||
"name": "Animal Crossing (Decomp)",
|
||||
"repository": "flyngmt/ACGC-PC-Port",
|
||||
"folderName": "AnimalCrossing-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://github.com/flyngmt.png?size=256",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"gamecube",
|
||||
"nintendo",
|
||||
"gc",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"animal crossing"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Banjo-Kazooie (Recomp)",
|
||||
"repository": "BanjoRecomp/BanjoRecomp",
|
||||
"folderName": "BanjoKazooie-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/BanjoRecomp/BanjoRecomp/refs/heads/main/icons/app.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"banjo"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Bomberman 64 (Recomp)",
|
||||
"repository": "RevoSucks/BM64Recomp",
|
||||
"folderName": "Bomberman64-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/RevoSucks/BM64Recomp/refs/heads/master/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"bomberman"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Bomberman Hero (Recomp)",
|
||||
"repository": "RevoSucks/BMHeroRecomp",
|
||||
"folderName": "BombermanHero-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/RevoSucks/BMHeroRecomp/refs/heads/master/icons/app.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"bomberman"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Chameleon Twist (Recomp)",
|
||||
"repository": "Rainchus/ChameleonTwist1-JP-Recomp",
|
||||
"folderName": "ChameleonTwist-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://cdn2.steamgriddb.com/icon/c1f22f4c38899f51f1ed3ce20120bbd9.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"chameleon twist"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Dinosaur Planet (Recomp)",
|
||||
"repository": "DinosaurPlanetRecomp/dino-recomp",
|
||||
"folderName": "DinosaurPlanet-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/DinosaurPlanetRecomp/dino-recomp/refs/heads/main/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"dinosaur planet"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Dr. Mario 64 (Recomp)",
|
||||
"repository": "theboy181/drmario64_recomp_plus",
|
||||
"folderName": "DrMario64-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/theboy181/drmario64_recomp_plus/refs/heads/main/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"mario"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Driver 2 [REDRIVER2] (Decomp)",
|
||||
"repository": "OpenDriver2/REDRIVER2",
|
||||
"folderName": "Driver2-REDRIVER2-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://github.com/OpenDriver2.png?size=256",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"psx",
|
||||
"playstation",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"driver"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Duke Nukem: Zero Hour (Recomp)",
|
||||
"repository": "sonicdcer/DNZHRecomp",
|
||||
"folderName": "DukeNukemZeroHour-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/sonicdcer/DNZHRecomp/refs/heads/main/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"duke nukem"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Mario Kart 64 (Recomp)",
|
||||
"repository": "sonicdcer/MarioKart64Recomp",
|
||||
"folderName": "MarioKart64-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/sonicdcer/MarioKart64Recomp/refs/heads/main/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"mario",
|
||||
"mario kart"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Mario Kart 64 [SpaghettiKart] (Decomp)",
|
||||
"repository": "harbourmasters/spaghettikart",
|
||||
"folderName": "MarioKart64-SpaghettiKart-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://github.com/HarbourMasters/SpaghettiKart/blob/main/icon.png?raw=true",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"mario",
|
||||
"mario kart",
|
||||
"harbour masters"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Mega Man Legends (Recomp)",
|
||||
"repository": "MegaMan64Recomp/MegaMan64Recompiled",
|
||||
"folderName": "MegaManLegends-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/MegaMan64Recomp/MegaMan64Recompiled/refs/heads/main/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"mega man"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Mystical Ninja Starring Goemon (Recomp)",
|
||||
"repository": "klorfmorf/Goemon64Recomp",
|
||||
"folderName": "MysticalNinjaStarringGoemon-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/klorfmorf/Goemon64Recomp/refs/heads/dev/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"goemon"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Perfect Dark (Decomp)",
|
||||
"repository": "fgsfdsfgs/perfect_dark",
|
||||
"folderName": "PerfectDark-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/perfect-dark-pc-port/perfect_dark/refs/heads/port/dist/linux/io.github.perfect_dark_pc_port.perfect_dark.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"perfect dark"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Pokemon Stadium (Recomp)",
|
||||
"repository": "mstan/PokemonStadiumRecomp",
|
||||
"folderName": "PokemonStadium-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/mstan/PokemonStadiumRecomp/refs/heads/main/assets/carts/yellow.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"pokemon"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Quest 64 (Recomp)",
|
||||
"repository": "Rainchus/Quest64-Recomp",
|
||||
"folderName": "Quest64-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/Rainchus/Quest64-Recomp/refs/heads/main/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"quest"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Sonic Unleashed (Recomp)",
|
||||
"repository": "hedge-dev/UnleashedRecomp",
|
||||
"folderName": "SonicUnleashed-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/hedge-dev/UnleashedRecompResources/35322388006365a648f75f4981a496b12a7f7478/images/game_icon.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"xbox 360",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"sonic"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Star Fox 64 (Recomp)",
|
||||
"repository": "sonicdcer/Starfox64Recomp",
|
||||
"folderName": "StarFox64-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/sonicdcer/Starfox64Recomp/refs/heads/main/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"star fox"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Star Fox 64 [Starship] (Decomp)",
|
||||
"repository": "harbourmasters/starship",
|
||||
"folderName": "StarFox64-Starship-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/HarbourMasters/Starship/refs/heads/main/logo.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"star fox",
|
||||
"harbour masters"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Super Mario 64 [Ghostship] (Decomp)",
|
||||
"repository": "harbourmasters/ghostship",
|
||||
"folderName": "SuperMario64-Ghostship-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/HarbourMasters/Ghostship/refs/heads/develop/logo.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"mario",
|
||||
"harbour masters"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Super Mario 64 [Co-op DX] (Decomp)",
|
||||
"repository": "coop-deluxe/sm64coopdx",
|
||||
"folderName": "SuperMario64-CoopDX-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/coop-deluxe/sm64coopdx/refs/heads/main/res/icon.icon/Assets/icon.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"mario"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Super Mario Bros. Remastered (Recreation)",
|
||||
"repository": "JHDev2006/Super-Mario-Bros.-Remastered-Public",
|
||||
"folderName": "SuperMarioBrosRemastered-Recreation",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/JHDev2006/Super-Mario-Bros.-Remastered-Public/main/icon.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"nes",
|
||||
"nintendo",
|
||||
"recreation",
|
||||
"mario"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Super Mario World (Decomp)",
|
||||
"repository": "snesrev/smw",
|
||||
"folderName": "SuperMarioWorld-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/snesrev/smw/refs/heads/main/src/platform/switch/icon.jpg",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"snes",
|
||||
"nintendo",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"mario"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "The Legend of Zelda: A Link to the Past (Decomp)",
|
||||
"repository": "RadzPrower/Zelda-3-Launcher",
|
||||
"folderName": "TheLegendOfZeldaALinkToThePast-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/snesrev/zelda3/refs/heads/master/src/platform/win32/triforce.ico",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"snes",
|
||||
"nintendo",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"zelda"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "The Legend of Zelda: Link\u0027s Awakening DX [HD Updated] (Recreation)",
|
||||
"repository": "BigheadSMZ/Zelda-LA-DX-HD-Updated",
|
||||
"folderName": "TheLegendOfZeldaLinksAwakeningDX-HDUpdated-Recreation",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/BigheadSMZ/Zelda-LA-DX-HD-Updated/refs/heads/main/icon/windows/Icon.ico",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": "v1.9.2",
|
||||
"tags": [
|
||||
"gbc",
|
||||
"gameboy color",
|
||||
"nintendo",
|
||||
"recreation",
|
||||
"zelda"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "The Legend of Zelda: Majora\u0027s Mask [2 Ship 2 Harkinian] (Decomp)",
|
||||
"repository": "harbourmasters/2ship2harkinian",
|
||||
"folderName": "TheLegendOfZeldaMajorasMask-2Ship2Harkinian-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/HarbourMasters/2ship2harkinian/refs/heads/develop/mm/windows/2SHIP2HARKINIAN.ico",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"zelda",
|
||||
"harbour masters"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "The Legend of Zelda: Majora\u0027s Mask (Recomp)",
|
||||
"repository": "Zelda64Recomp/Zelda64Recomp",
|
||||
"folderName": "TheLegendOfZeldaMajorasMask-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/Zelda64Recomp/Zelda64Recomp/refs/heads/dev/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"recomp",
|
||||
"recompilation",
|
||||
"zelda"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "The Legend of Zelda: Ocarina of Time [Ship of Harkinian] (Decomp)",
|
||||
"repository": "harbourmasters/shipwright",
|
||||
"folderName": "TheLegendOfZeldaOcarinaOfTime-ShipOfHarkinian-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/HarbourMasters/Shipwright/refs/heads/develop/soh/SHIPOFHARKINIAN.ico",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"zelda",
|
||||
"harbour masters"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "The Legend of Zelda: The Minish Cap (Decomp)",
|
||||
"repository": "MatheoVignaud/tmc",
|
||||
"folderName": "TheLegendOfZeldaTheMinishCap-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/MatheoVignaud/tmc/refs/heads/master/docs/doxygen/beanstalk-bg.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"gba",
|
||||
"gameboy advance",
|
||||
"nintendo",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"zelda"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "The Legend of Zelda: Twilight Princess [Dusklight] (Decomp)",
|
||||
"repository": "TwilitRealm/dusklight",
|
||||
"folderName": "TheLegendOfZeldaTwilightPrincess-Dusklight-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/TwilitRealm/dusklight/refs/heads/main/res/icon.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": "v1.4.1",
|
||||
"tags": [
|
||||
"gamecube",
|
||||
"nintendo",
|
||||
"gc",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"zelda"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Skate 3 (Recomp)",
|
||||
"repository": "mchughalex/skate3recomp",
|
||||
"folderName": "Skate3-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/mchughalex/skate3recomp/refs/heads/main/banner.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": "v1.0.4",
|
||||
"tags": [
|
||||
"xbox 360",
|
||||
"recomp",
|
||||
"recompiled",
|
||||
"skate"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Super Smash Bros. [BattleShip] (Decomp)",
|
||||
"repository": "JRickey/BattleShip",
|
||||
"folderName": "SuperSmashBros-BattleShip-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/JRickey/BattleShip/refs/heads/main/assets/icon.ico",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null,
|
||||
"tags": [
|
||||
"n64",
|
||||
"nintendo",
|
||||
"nintendo 64",
|
||||
"decomp",
|
||||
"decompilation",
|
||||
"super smash bros"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
# Community App Lists
|
||||
|
||||
This folder contains a publishable registry of third-party `apps.json` catalogs for Quiver.
|
||||
|
||||
## Publishing
|
||||
|
||||
You can publish this folder as its own GitHub repository (for example `QuiverCommunityAppLists`). Users point **Settings → General → Community index URL** at your hosted `index.json`:
|
||||
|
||||
```
|
||||
https://raw.githubusercontent.com/YOUR_ORG/YOUR_REPO/main/index.json
|
||||
```
|
||||
|
||||
For local development, use a file path instead:
|
||||
|
||||
```
|
||||
C:\Projects\Quiver\community-app-lists\index.json
|
||||
```
|
||||
|
||||
## Adding a list
|
||||
|
||||
1. Add a new `*.json` file in this folder using the same schema as `apps.json` (an `apps` array of entries).
|
||||
2. Add an entry to `index.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "my-list",
|
||||
"name": "My List",
|
||||
"description": "Short description shown in the browse dialog",
|
||||
"location": "https://raw.githubusercontent.com/YOUR_ORG/YOUR_REPO/main/my-list.json",
|
||||
"listVersion": "1.0.0"
|
||||
}
|
||||
```
|
||||
|
||||
- **`id`** — stable identifier; used to detect duplicate subscriptions.
|
||||
- **`location`** — URL or path to the list file (same format as manual catalog sources).
|
||||
- **`listVersion`** — informational version for maintainers. The launcher detects updates via content hash, not `listVersion`.
|
||||
|
||||
## Update detection
|
||||
|
||||
When a user subscribes to a list, the launcher stores an **accepted snapshot** of that catalog. On each fetch, it compares a SHA-256 hash of the remote list to the accepted snapshot. If they differ, the user is prompted to:
|
||||
|
||||
- **Apply All** — sync to the new list (removals drop apps exclusive to that source)
|
||||
- **Apply New Only** — add/update entries but keep previously listed apps even if removed remotely
|
||||
- **Keep Current** — dismiss until the next startup or manual refresh
|
||||
|
||||
Installed files on disk are never deleted when apps are removed from the library.
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 1,
|
||||
"lists": [
|
||||
{
|
||||
"id": "n64-recomp",
|
||||
"name": "N64 Recomp Games",
|
||||
"description": "N64 recompilation ports and related Harbour Masters projects",
|
||||
"location": "community-app-lists/n64-recomp.json",
|
||||
"listVersion": "1.0.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
{
|
||||
"apps": [
|
||||
{
|
||||
"name": "The Legend of Zelda: Majora's Mask (Recomp)",
|
||||
"repository": "Zelda64Recomp/Zelda64Recomp",
|
||||
"folderName": "TheLegendOfZeldaMajorasMask-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/Zelda64Recomp/Zelda64Recomp/refs/heads/dev/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Mystical Ninja Starring Goemon (Recomp)",
|
||||
"repository": "klorfmorf/Goemon64Recomp",
|
||||
"folderName": "MysticalNinjaStarringGoemon-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/klorfmorf/Goemon64Recomp/refs/heads/dev/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Mario Kart 64 (Recomp)",
|
||||
"repository": "sonicdcer/MarioKart64Recomp",
|
||||
"folderName": "MarioKart64-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/sonicdcer/MarioKart64Recomp/refs/heads/main/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Dinosaur Planet (Recomp)",
|
||||
"repository": "DinosaurPlanetRecomp/dino-recomp",
|
||||
"folderName": "DinosaurPlanet-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/DinosaurPlanetRecomp/dino-recomp/refs/heads/main/icons/64.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Dr. Mario 64 (Recomp)",
|
||||
"repository": "theboy181/drmario64_recomp_plus",
|
||||
"folderName": "DrMario64-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/theboy181/drmario64_recomp_plus/refs/heads/main/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Duke Nukem: Zero Hour (Recomp)",
|
||||
"repository": "sonicdcer/DNZHRecomp",
|
||||
"folderName": "DukeNukemZeroHour-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/sonicdcer/DNZHRecomp/refs/heads/main/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Star Fox 64 (Recomp)",
|
||||
"repository": "sonicdcer/Starfox64Recomp",
|
||||
"folderName": "StarFox64-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/sonicdcer/Starfox64Recomp/refs/heads/main/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Banjo-Kazooie (Recomp)",
|
||||
"repository": "BanjoRecomp/BanjoRecomp",
|
||||
"folderName": "BanjoKazooie-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/BanjoRecomp/BanjoRecomp/refs/heads/main/icons/app.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Bomberman 64 (Recomp)",
|
||||
"repository": "RevoSucks/BM64Recomp",
|
||||
"folderName": "Bomberman64-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/RevoSucks/BM64Recomp/refs/heads/master/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Chameleon Twist (Recomp)",
|
||||
"repository": "Rainchus/ChameleonTwist1-JP-Recomp",
|
||||
"folderName": "ChameleonTwist-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://cdn2.steamgriddb.com/icon/c1f22f4c38899f51f1ed3ce20120bbd9.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Mega Man Legends (Recomp)",
|
||||
"repository": "MegaMan64Recomp/MegaMan64Recompiled",
|
||||
"folderName": "MegaManLegends-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://cdn2.steamgriddb.com/icon/850618e22f83f152773d2a3e51168812.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Quest 64 (Recomp)",
|
||||
"repository": "Rainchus/Quest64-Recomp",
|
||||
"folderName": "Quest64-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/Rainchus/Quest64-Recomp/refs/heads/main/icons/512.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Bomberman Hero (Recomp)",
|
||||
"repository": "RevoSucks/BMHeroRecomp",
|
||||
"folderName": "BombermanHero-Recomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/RevoSucks/BMHeroRecomp/refs/heads/master/icons/app.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "The Legend of Zelda: Ocarina of Time [Ship of Harkinian] (Decomp)",
|
||||
"repository": "harbourmasters/shipwright",
|
||||
"folderName": "TheLegendOfZeldaOcarinaOfTime-ShipOfHarkinian-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://cdn2.steamgriddb.com/icon/d1cd0a8c9b28f58703a097d5a25534e3/32/256x256.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "The Legend of Zelda: Majora's Mask [2 Ship 2 Harkinian] (Decomp)",
|
||||
"repository": "harbourmasters/2ship2harkinian",
|
||||
"folderName": "TheLegendOfZeldaMajorasMask-2Ship2Harkinian-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://cdn2.steamgriddb.com/icon/6c7dbdd98cd70f67f102524761f3b4d2/24/256x256.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Star Fox 64 [Starship] (Decomp)",
|
||||
"repository": "harbourmasters/starship",
|
||||
"folderName": "StarFox64-Starship-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://cdn2.steamgriddb.com/icon/dc2ee2a5add7154447a4644326e33386/32/256x256.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Mario Kart 64 [SpaghettiKart] (Decomp)",
|
||||
"repository": "harbourmasters/spaghettikart",
|
||||
"folderName": "MarioKart64-SpaghettiKart-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://cdn2.steamgriddb.com/icon_thumb/5e5e0bd5ad7c2ca72b0c5ff8b6debbba.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Super Mario 64 [Ghostship] (Decomp)",
|
||||
"repository": "harbourmasters/ghostship",
|
||||
"folderName": "SuperMario64-Ghostship-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://raw.githubusercontent.com/HarbourMasters/Ghostship/refs/heads/develop/nx-logo.jpg",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Perfect Dark (Decomp)",
|
||||
"repository": "fgsfdsfgs/perfect_dark",
|
||||
"folderName": "PerfectDark-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://cdn2.steamgriddb.com/icon/64314c17210c549a854f1f1c7adce8b6/32/256x256.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
},
|
||||
{
|
||||
"name": "Super Mario 64 Co-op DX (Decomp)",
|
||||
"repository": "coop-deluxe/sm64coopdx",
|
||||
"folderName": "SuperMario64CoopDX-Decomp",
|
||||
"installPath": null,
|
||||
"appIconUrl": "https://cdn2.steamgriddb.com/icon_thumb/e3dd863ef4277e82f712a5bd8fefe7d7.png",
|
||||
"preferredVersion": null,
|
||||
"skippedUpdateVersion": null
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 54 KiB |
Submodule lib/GitHubLauncher.Core deleted from ee3291b246.
@@ -0,0 +1,2 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
@@ -0,0 +1,411 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
|
||||
# Flatpak Build Directory
|
||||
.flatpak-builder/
|
||||
FlatpakBuild/
|
||||
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
# but not Directory.Build.rsp, as it configures directory-level build defaults
|
||||
!Directory.Build.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
#Blender Backup files and Renders
|
||||
Icon/frames/
|
||||
*.blend1
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
*.ncb
|
||||
*.aps
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
flatpak.bat
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 SirDiabo
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Quiver.Core.Models
|
||||
{
|
||||
public enum GameStatus
|
||||
{
|
||||
NotInstalled,
|
||||
Installed,
|
||||
UpdateAvailable,
|
||||
Downloading,
|
||||
Installing,
|
||||
Updating
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Quiver.Core.Models
|
||||
{
|
||||
public class GitHubRelease
|
||||
{
|
||||
public string tag_name { get; set; } = string.Empty;
|
||||
public GitHubAsset[] assets { get; set; } = [];
|
||||
public bool prerelease { get; set; }
|
||||
}
|
||||
|
||||
public class GitHubAsset
|
||||
{
|
||||
public string name { get; set; } = string.Empty;
|
||||
public string browser_download_url { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Quiver.Core.Models
|
||||
{
|
||||
public enum TargetOS
|
||||
{
|
||||
Auto,
|
||||
Windows,
|
||||
MacOS,
|
||||
LinuxX64,
|
||||
LinuxARM64,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">␍
|
||||
<PropertyGroup>␍
|
||||
<TargetFramework>net9.0</TargetFramework>␍
|
||||
<Nullable>enable</Nullable>␍
|
||||
<ImplicitUsings>enable</ImplicitUsings>␍
|
||||
<AssemblyName>Quiver.Core</AssemblyName>␍
|
||||
<RootNamespace>Quiver.Core</RootNamespace>␍
|
||||
<PublishSingleFile>false</PublishSingleFile>␍
|
||||
</PropertyGroup>␍
|
||||
</Project>␍
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Quiver.Core.Services;
|
||||
|
||||
public sealed class GameInstallationOptions
|
||||
{
|
||||
public static GameInstallationOptions Default { get; } = new();
|
||||
|
||||
public IReadOnlyCollection<string> AdditionalMetadataFileNames { get; init; } = Array.Empty<string>();
|
||||
|
||||
public Action<string>? Log { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,515 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Quiver.Core.Services;
|
||||
|
||||
public static class GameInstallationService
|
||||
{
|
||||
public static async Task InstallOrUpdateGameAsync(
|
||||
string downloadPath,
|
||||
string gamePath,
|
||||
string assetName,
|
||||
string version,
|
||||
GameInstallationOptions? options = null)
|
||||
{
|
||||
options ??= GameInstallationOptions.Default;
|
||||
Directory.CreateDirectory(gamePath);
|
||||
|
||||
if (assetName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) ||
|
||||
assetName.EndsWith(".appimage", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var destPath = Path.Combine(gamePath, assetName);
|
||||
File.Move(downloadPath, destPath, true);
|
||||
MakeExecutableIfNeeded(destPath);
|
||||
}
|
||||
else if (assetName.EndsWith(".zip", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
await ExtractZipAsync(downloadPath, gamePath).ConfigureAwait(false);
|
||||
}
|
||||
else if (assetName.EndsWith(".tar.gz", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
await ExtractTarGzAsync(downloadPath, gamePath).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
EnsureExecutableAtRoot(gamePath, options);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log(options, $"Warning: EnsureExecutableAtRoot failed: {ex.Message}");
|
||||
}
|
||||
|
||||
var versionFile = Path.Combine(gamePath, "version.txt");
|
||||
await File.WriteAllTextAsync(versionFile, version).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public static void EnsureExecutableAtRoot(string gamePath, GameInstallationOptions? options = null)
|
||||
{
|
||||
options ??= GameInstallationOptions.Default;
|
||||
|
||||
if (!Directory.Exists(gamePath))
|
||||
return;
|
||||
|
||||
while (!HasTopLevelExecutable(gamePath, options))
|
||||
{
|
||||
var topLevelDirs = Directory.GetDirectories(gamePath, "*", SearchOption.TopDirectoryOnly);
|
||||
var topLevelFiles = Directory.GetFiles(gamePath, "*", SearchOption.TopDirectoryOnly)
|
||||
.Where(f => !IsLauncherMetadataFile(f, options))
|
||||
.ToList();
|
||||
|
||||
var flattened = false;
|
||||
|
||||
if (topLevelDirs.Length == 1)
|
||||
{
|
||||
var singleDir = topLevelDirs[0];
|
||||
var singleDirCandidates = FindExecutableCandidates(singleDir, SearchOption.AllDirectories, options, out _);
|
||||
|
||||
if (singleDirCandidates.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.Move(singleDir, tempDir);
|
||||
MoveDirectoryContents(tempDir, gamePath);
|
||||
TryDeleteDirectory(tempDir);
|
||||
|
||||
Log(options, $"Moved contents from subdirectory to root: {singleDir}");
|
||||
flattened = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log(options, $"Failed to flatten directory structure: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flattened)
|
||||
continue;
|
||||
|
||||
var nestedCandidates = FindExecutableCandidates(gamePath, SearchOption.AllDirectories, options, out _)
|
||||
.Where(f => !IsInRootDirectory(f, gamePath))
|
||||
.ToList();
|
||||
|
||||
if (nestedCandidates.Count == 0)
|
||||
return;
|
||||
|
||||
var candidateFile = nestedCandidates[0];
|
||||
var parentDir = Path.GetDirectoryName(candidateFile);
|
||||
|
||||
if (!string.IsNullOrEmpty(parentDir) &&
|
||||
topLevelDirs.Contains(parentDir, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
try
|
||||
{
|
||||
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.Move(parentDir, tempDir);
|
||||
MoveDirectoryContents(tempDir, gamePath);
|
||||
TryDeleteDirectory(tempDir);
|
||||
|
||||
Log(options, $"Flattened directory containing executable: {parentDir}");
|
||||
continue;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log(options, $"Failed to flatten directory: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
if (topLevelFiles.Count > 0)
|
||||
{
|
||||
Log(options, "Leaving wrapper folder structure in place because nested executable cannot be safely flattened.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<string> FindExecutableCandidates(
|
||||
string path,
|
||||
SearchOption searchOption,
|
||||
GameInstallationOptions? options,
|
||||
out bool needsWine)
|
||||
{
|
||||
_ = options;
|
||||
needsWine = false;
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
return [];
|
||||
|
||||
var executables = new List<string>();
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
executables.AddRange(Directory.GetFiles(path, "*.exe", searchOption));
|
||||
executables.AddRange(Directory.GetFiles(path, "*.bat", searchOption));
|
||||
executables.AddRange(Directory.GetFiles(path, "*.cmd", searchOption));
|
||||
executables.AddRange(Directory.GetFiles(path, "launch.bat", searchOption));
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
executables.AddRange(Directory.GetDirectories(path, "*.app", searchOption));
|
||||
executables.AddRange(Directory.GetFiles(path, "*", searchOption)
|
||||
.Where(IsLikelyExtensionlessExecutable));
|
||||
}
|
||||
else
|
||||
{
|
||||
var allFiles = Directory.GetFiles(path, "*", searchOption);
|
||||
|
||||
executables.AddRange(allFiles.Where(f =>
|
||||
{
|
||||
var fileName = Path.GetFileName(f).ToLowerInvariant();
|
||||
return fileName.EndsWith(".x86_64") ||
|
||||
fileName.EndsWith(".appimage") ||
|
||||
fileName.EndsWith(".arm64") ||
|
||||
fileName.EndsWith(".aarch64");
|
||||
}));
|
||||
|
||||
executables.AddRange(allFiles.Where(f =>
|
||||
{
|
||||
var fileName = Path.GetFileName(f).ToLowerInvariant();
|
||||
|
||||
if (fileName.EndsWith(".appimage") || fileName.EndsWith(".x86_64") ||
|
||||
fileName.EndsWith(".arm64") || fileName.EndsWith(".aarch64") ||
|
||||
fileName.EndsWith(".txt") || fileName.EndsWith(".dll") ||
|
||||
fileName.EndsWith(".so") || fileName.EndsWith(".json") ||
|
||||
fileName.EndsWith(".sh") || fileName.EndsWith(".exe"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return IsLikelyExtensionlessExecutable(f);
|
||||
}));
|
||||
|
||||
if (executables.Count == 0)
|
||||
{
|
||||
var exeFiles = allFiles.Where(f => f.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
if (exeFiles.Count > 0)
|
||||
{
|
||||
executables.AddRange(exeFiles);
|
||||
needsWine = true;
|
||||
}
|
||||
}
|
||||
|
||||
executables.AddRange(allFiles.Where(f => f.EndsWith(".sh", StringComparison.OrdinalIgnoreCase)));
|
||||
}
|
||||
|
||||
return executables
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.OrderBy(f => GetPathDepth(path, f))
|
||||
.ThenBy(f => Path.GetFileName(f), StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public static bool IsLauncherMetadataFile(string path, GameInstallationOptions? options = null)
|
||||
{
|
||||
options ??= GameInstallationOptions.Default;
|
||||
|
||||
var fileName = Path.GetFileName(path);
|
||||
return fileName.Equals("version.txt", StringComparison.OrdinalIgnoreCase) ||
|
||||
fileName.Equals("LastPlayed.txt", StringComparison.OrdinalIgnoreCase) ||
|
||||
fileName.Equals("selected_executable.txt", StringComparison.OrdinalIgnoreCase) ||
|
||||
options.AdditionalMetadataFileNames.Any(name => fileName.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public static void MoveDirectoryContents(string sourceDir, string destDir)
|
||||
{
|
||||
Directory.CreateDirectory(destDir);
|
||||
|
||||
foreach (var file in Directory.GetFiles(sourceDir, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
var relative = Path.GetRelativePath(sourceDir, file);
|
||||
var destFile = Path.Combine(destDir, relative);
|
||||
|
||||
var destParent = Path.GetDirectoryName(destFile);
|
||||
if (!string.IsNullOrEmpty(destParent))
|
||||
Directory.CreateDirectory(destParent);
|
||||
|
||||
File.Move(file, destFile, true);
|
||||
}
|
||||
}
|
||||
|
||||
static async Task ExtractZipAsync(string downloadPath, string gamePath)
|
||||
{
|
||||
var tempExtractPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(tempExtractPath);
|
||||
|
||||
try
|
||||
{
|
||||
ZipFile.ExtractToDirectory(downloadPath, tempExtractPath, overwriteFiles: true);
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
ExtractNestedZips(tempExtractPath);
|
||||
|
||||
var appBundle = Directory.GetDirectories(tempExtractPath, "*.app", SearchOption.AllDirectories)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (!string.IsNullOrEmpty(appBundle))
|
||||
{
|
||||
var appName = Path.GetFileName(appBundle);
|
||||
var destAppPath = Path.Combine(gamePath, appName);
|
||||
|
||||
if (Directory.Exists(destAppPath))
|
||||
{
|
||||
Directory.Delete(destAppPath, true);
|
||||
}
|
||||
|
||||
CopyDirectory(appBundle, destAppPath);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
var tarGzFile = Directory.GetFiles(tempExtractPath, "*.tar.gz", SearchOption.AllDirectories)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (!string.IsNullOrEmpty(tarGzFile))
|
||||
{
|
||||
await ExtractTarGzAsync(tarGzFile, gamePath).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var sourcePath = GetEffectiveExtractionSource(tempExtractPath);
|
||||
MoveDirectoryContents(sourcePath, gamePath);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TryDeleteDirectory(tempExtractPath);
|
||||
}
|
||||
}
|
||||
|
||||
static string GetEffectiveExtractionSource(string extractPath)
|
||||
{
|
||||
var rootDirs = Directory.GetDirectories(extractPath, "*", SearchOption.TopDirectoryOnly);
|
||||
var rootFiles = Directory.GetFiles(extractPath, "*", SearchOption.TopDirectoryOnly);
|
||||
|
||||
if (rootDirs.Length == 1 && rootFiles.Length == 0)
|
||||
{
|
||||
return rootDirs[0];
|
||||
}
|
||||
|
||||
return extractPath;
|
||||
}
|
||||
|
||||
static void ExtractNestedZips(string tempExtractPath)
|
||||
{
|
||||
var nestedZips = Directory.GetFiles(tempExtractPath, "*.zip", SearchOption.AllDirectories);
|
||||
foreach (var nestedZip in nestedZips)
|
||||
{
|
||||
var nestedZipDirectory = Path.GetDirectoryName(nestedZip) ?? tempExtractPath;
|
||||
var nestedExtractPath = Path.Combine(nestedZipDirectory, Path.GetFileNameWithoutExtension(nestedZip));
|
||||
Directory.CreateDirectory(nestedExtractPath);
|
||||
ZipFile.ExtractToDirectory(nestedZip, nestedExtractPath, overwriteFiles: true);
|
||||
|
||||
try { File.Delete(nestedZip); } catch { }
|
||||
}
|
||||
}
|
||||
|
||||
static async Task ExtractTarGzAsync(string sourceFilePath, string destinationDirectoryPath)
|
||||
{
|
||||
Directory.CreateDirectory(destinationDirectoryPath);
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
ExtractTarGzWindows(sourceFilePath, destinationDirectoryPath);
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
|
||||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
await ExtractTarGzUnixAsync(sourceFilePath, destinationDirectoryPath).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PlatformNotSupportedException("Unsupported operating system for tar.gz extraction");
|
||||
}
|
||||
}
|
||||
|
||||
static void ExtractTarGzWindows(string sourceFilePath, string destinationDirectoryPath)
|
||||
{
|
||||
using var inputStream = File.OpenRead(sourceFilePath);
|
||||
using var gzipStream = new GZipStream(inputStream, CompressionMode.Decompress);
|
||||
ExtractTarFromStream(gzipStream, destinationDirectoryPath);
|
||||
}
|
||||
|
||||
static async Task ExtractTarGzUnixAsync(string sourceFilePath, string destinationDirectoryPath)
|
||||
{
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "tar",
|
||||
Arguments = $"-xzf \"{sourceFilePath}\" -C \"{destinationDirectoryPath}\"",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
CreateNoWindow = true
|
||||
};
|
||||
|
||||
using var process = Process.Start(startInfo) ?? throw new InvalidOperationException("Could not start tar extraction.");
|
||||
await process.WaitForExitAsync().ConfigureAwait(false);
|
||||
|
||||
if (process.ExitCode != 0)
|
||||
{
|
||||
var errorOutput = await process.StandardError.ReadToEndAsync().ConfigureAwait(false);
|
||||
throw new InvalidOperationException($"Tar extraction failed: {errorOutput}");
|
||||
}
|
||||
}
|
||||
|
||||
static string GetSafeExtractionPath(string destinationDirectoryPath, string archivePath)
|
||||
{
|
||||
var sanitizedArchivePath = archivePath.Replace('/', Path.DirectorySeparatorChar)
|
||||
.Replace('\\', Path.DirectorySeparatorChar);
|
||||
var fullDestinationRoot = Path.GetFullPath(destinationDirectoryPath)
|
||||
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
var fullDestinationPath = Path.GetFullPath(Path.Combine(fullDestinationRoot, sanitizedArchivePath));
|
||||
|
||||
if (!fullDestinationPath.StartsWith(fullDestinationRoot + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) &&
|
||||
!fullDestinationPath.Equals(fullDestinationRoot, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new InvalidDataException($"Archive entry escapes the destination directory: {archivePath}");
|
||||
}
|
||||
|
||||
return fullDestinationPath;
|
||||
}
|
||||
|
||||
static void ExtractTarFromStream(Stream tarStream, string destinationDirectoryPath)
|
||||
{
|
||||
using var reader = new BinaryReader(tarStream);
|
||||
while (true)
|
||||
{
|
||||
var headerBytes = reader.ReadBytes(512);
|
||||
if (headerBytes.Length < 512) break;
|
||||
|
||||
var fileName = Encoding.ASCII.GetString(headerBytes, 0, 100).TrimEnd('\0');
|
||||
if (string.IsNullOrWhiteSpace(fileName)) break;
|
||||
|
||||
var fileSizeStr = Encoding.ASCII.GetString(headerBytes, 124, 12).TrimEnd('\0');
|
||||
var fileSize = Convert.ToInt64(fileSizeStr, 8);
|
||||
var fileType = headerBytes[156];
|
||||
var destPath = GetSafeExtractionPath(destinationDirectoryPath, fileName);
|
||||
|
||||
if (fileType == '5')
|
||||
{
|
||||
Directory.CreateDirectory(destPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
var destinationDirectory = Path.GetDirectoryName(destPath);
|
||||
if (string.IsNullOrEmpty(destinationDirectory))
|
||||
{
|
||||
throw new InvalidDataException($"Invalid archive entry path: {fileName}");
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(destinationDirectory);
|
||||
|
||||
using var fileStream = File.Create(destPath);
|
||||
var blocksToRead = (int)Math.Ceiling((double)fileSize / 512);
|
||||
var fileBytes = new byte[blocksToRead * 512];
|
||||
reader.Read(fileBytes, 0, fileBytes.Length);
|
||||
fileStream.Write(fileBytes, 0, (int)fileSize);
|
||||
}
|
||||
|
||||
var paddingBytes = 512 - (int)(fileSize % 512);
|
||||
if (paddingBytes < 512)
|
||||
{
|
||||
reader.ReadBytes(paddingBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void CopyDirectory(string sourceDir, string destDir)
|
||||
{
|
||||
Directory.CreateDirectory(destDir);
|
||||
|
||||
foreach (var file in Directory.GetFiles(sourceDir))
|
||||
{
|
||||
var destFile = Path.Combine(destDir, Path.GetFileName(file));
|
||||
File.Copy(file, destFile, true);
|
||||
}
|
||||
|
||||
foreach (var dir in Directory.GetDirectories(sourceDir))
|
||||
{
|
||||
var destSubDir = Path.Combine(destDir, Path.GetFileName(dir));
|
||||
CopyDirectory(dir, destSubDir);
|
||||
}
|
||||
}
|
||||
|
||||
static void MakeExecutableIfNeeded(string path)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
var chmodProcess = new ProcessStartInfo
|
||||
{
|
||||
FileName = "chmod",
|
||||
Arguments = $"+x \"{path}\"",
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true
|
||||
};
|
||||
using var process = Process.Start(chmodProcess);
|
||||
process?.WaitForExit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
static bool HasTopLevelExecutable(string path, GameInstallationOptions options)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
return false;
|
||||
|
||||
return FindExecutableCandidates(path, SearchOption.TopDirectoryOnly, options, out _).Count > 0;
|
||||
}
|
||||
|
||||
static bool IsLikelyExtensionlessExecutable(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
return !Path.HasExtension(path) && new FileInfo(path).Length > 1024;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static int GetPathDepth(string rootPath, string targetPath)
|
||||
{
|
||||
var relativePath = Path.GetRelativePath(rootPath, targetPath);
|
||||
return relativePath.Count(c => c == Path.DirectorySeparatorChar || c == Path.AltDirectorySeparatorChar);
|
||||
}
|
||||
|
||||
static bool IsInRootDirectory(string path, string rootPath)
|
||||
{
|
||||
var parentDir = Path.GetDirectoryName(path);
|
||||
return parentDir != null &&
|
||||
Path.GetFullPath(parentDir).TrimEnd(Path.DirectorySeparatorChar)
|
||||
.Equals(Path.GetFullPath(rootPath).TrimEnd(Path.DirectorySeparatorChar),
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
static void TryDeleteDirectory(string path)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
return;
|
||||
|
||||
try { Directory.Delete(path, true); } catch { }
|
||||
}
|
||||
|
||||
static void Log(GameInstallationOptions options, string message)
|
||||
{
|
||||
if (options.Log is not null)
|
||||
{
|
||||
options.Log(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text.Json;
|
||||
using Quiver.Core.Models;
|
||||
|
||||
namespace Quiver.Core.Services
|
||||
{
|
||||
public class GameVersionCache
|
||||
{
|
||||
public string Version { get; set; } = string.Empty;
|
||||
public DateTime LastChecked { get; set; }
|
||||
public string ETag { get; set; } = string.Empty;
|
||||
public GitHubRelease? CachedRelease { get; set; }
|
||||
public DateTime LastUpdateCheck { get; set; }
|
||||
}
|
||||
|
||||
public static class GitHubApiCache
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, GameVersionCache> _cache = new();
|
||||
private static readonly TimeSpan CacheExpiry = TimeSpan.FromHours(24);
|
||||
private static readonly TimeSpan InstalledGameUpdateInterval = TimeSpan.FromHours(6);
|
||||
private static readonly TimeSpan NotInstalledGameUpdateInterval = TimeSpan.FromHours(24);
|
||||
private static string? _cacheFilePath;
|
||||
|
||||
public static void Initialize(string cacheDirectory)
|
||||
{
|
||||
_cacheFilePath = Path.Combine(cacheDirectory, "version_cache.json");
|
||||
LoadFromDisk();
|
||||
}
|
||||
|
||||
private static void LoadFromDisk()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_cacheFilePath) || !File.Exists(_cacheFilePath))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
var json = File.ReadAllText(_cacheFilePath);
|
||||
var diskCache = JsonSerializer.Deserialize<Dictionary<string, GameVersionCache>>(json);
|
||||
if (diskCache != null)
|
||||
{
|
||||
foreach (var kvp in diskCache)
|
||||
{
|
||||
_cache.TryAdd(kvp.Key, kvp.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Failed to load version cache: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveToDisk()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_cacheFilePath))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
var json = JsonSerializer.Serialize(_cache.ToDictionary(k => k.Key, v => v.Value), options);
|
||||
File.WriteAllText(_cacheFilePath, json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Failed to save version cache: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetCachedVersion(string repository, out GameVersionCache? cache)
|
||||
{
|
||||
if (_cache.TryGetValue(repository, out var foundCache))
|
||||
{
|
||||
if (DateTime.UtcNow - foundCache.LastChecked < CacheExpiry)
|
||||
{
|
||||
cache = foundCache;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
cache = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool NeedsUpdateCheck(string repository, bool isInstalledGame = true)
|
||||
{
|
||||
if (!_cache.TryGetValue(repository, out var cache))
|
||||
return true;
|
||||
|
||||
var interval = isInstalledGame ? InstalledGameUpdateInterval : NotInstalledGameUpdateInterval;
|
||||
return DateTime.UtcNow - cache.LastUpdateCheck >= interval;
|
||||
}
|
||||
|
||||
public static void SetCache(string repository, string version, string etag, GitHubRelease? release = null)
|
||||
{
|
||||
_cache.AddOrUpdate(repository,
|
||||
new GameVersionCache
|
||||
{
|
||||
Version = version,
|
||||
LastChecked = DateTime.UtcNow,
|
||||
LastUpdateCheck = DateTime.UtcNow,
|
||||
ETag = etag,
|
||||
CachedRelease = release
|
||||
},
|
||||
(key, old) => new GameVersionCache
|
||||
{
|
||||
Version = version,
|
||||
LastChecked = DateTime.UtcNow,
|
||||
LastUpdateCheck = DateTime.UtcNow,
|
||||
ETag = etag ?? old.ETag,
|
||||
CachedRelease = release ?? old.CachedRelease
|
||||
});
|
||||
|
||||
SaveToDisk();
|
||||
}
|
||||
|
||||
public static string GetETag(string repository)
|
||||
{
|
||||
return _cache.TryGetValue(repository, out var cache) ? cache.ETag : "";
|
||||
}
|
||||
|
||||
public static void RemoveCache(string repository)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(repository))
|
||||
return;
|
||||
|
||||
_cache.TryRemove(repository, out _);
|
||||
SaveToDisk();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Quiver.Core.Models;
|
||||
|
||||
namespace Quiver.Core.Services
|
||||
{
|
||||
public sealed class GitHubReleaseFetchResult
|
||||
{
|
||||
public HttpStatusCode StatusCode { get; init; }
|
||||
public IReadOnlyList<GitHubRelease> Releases { get; init; } = [];
|
||||
public string? ETag { get; init; }
|
||||
public bool IsNotModified => StatusCode == HttpStatusCode.NotModified;
|
||||
}
|
||||
|
||||
public static class GitHubReleaseService
|
||||
{
|
||||
public static async Task<GitHubReleaseFetchResult> FetchReleasesAsync(
|
||||
HttpClient httpClient,
|
||||
string repository,
|
||||
string? token = null,
|
||||
string? etag = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(repository))
|
||||
{
|
||||
return new GitHubReleaseFetchResult
|
||||
{
|
||||
StatusCode = HttpStatusCode.BadRequest
|
||||
};
|
||||
}
|
||||
|
||||
using var request = new HttpRequestMessage(HttpMethod.Get, $"https://api.github.com/repos/{repository}/releases");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(etag))
|
||||
{
|
||||
request.Headers.TryAddWithoutValidation("If-None-Match", etag);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(token))
|
||||
{
|
||||
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
}
|
||||
|
||||
var response = await httpClient.SendAsync(request).ConfigureAwait(false);
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.NotModified)
|
||||
{
|
||||
return new GitHubReleaseFetchResult
|
||||
{
|
||||
StatusCode = response.StatusCode,
|
||||
ETag = response.Headers.ETag?.Tag
|
||||
};
|
||||
}
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
var releases = JsonSerializer.Deserialize<List<GitHubRelease>>(responseContent) ?? [];
|
||||
|
||||
return new GitHubReleaseFetchResult
|
||||
{
|
||||
StatusCode = response.StatusCode,
|
||||
Releases = releases,
|
||||
ETag = response.Headers.ETag?.Tag
|
||||
};
|
||||
}
|
||||
|
||||
public static async Task<List<GitHubRelease>> FetchReleasesWithAssetsAsync(
|
||||
HttpClient httpClient,
|
||||
string repository,
|
||||
string? token = null)
|
||||
{
|
||||
var result = await FetchReleasesAsync(httpClient, repository, token).ConfigureAwait(false);
|
||||
return result.Releases
|
||||
.Where(release => release.assets != null && release.assets.Length > 0)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public static List<GitHubAsset> GetDownloadableAssets(GitHubRelease release)
|
||||
{
|
||||
return (release.assets ?? [])
|
||||
.Where(asset => !asset.name.Contains("flatpak", StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Quiver.Core.Services
|
||||
{
|
||||
public class LauncherProfile
|
||||
{
|
||||
public static LauncherProfile Default { get; } = new();
|
||||
|
||||
public virtual string DisplayName => "GitHub Launcher";
|
||||
public virtual string ApplicationId => "GitHubLauncher";
|
||||
public virtual string Repository => "SirDiabo/GitHubLauncher";
|
||||
public virtual string ExecutableName => "GitHubLauncher";
|
||||
public virtual string DefaultInstallFolderName => "Apps";
|
||||
public virtual string UserAgent => "GitHubLauncher/1.0";
|
||||
public virtual string CliUserAgent => "GitHubLauncher-CLI";
|
||||
public virtual string UpdaterUserAgent => "GitHubLauncher-Updater";
|
||||
public virtual string SteamTag => DisplayName;
|
||||
public virtual void ConfigureInstalledApp(string appPath)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using Quiver.Core.Models;
|
||||
|
||||
namespace Quiver.Core.Services
|
||||
{
|
||||
public static class PlatformAssetMatcher
|
||||
{
|
||||
public static string GetPlatformIdentifier(TargetOS platform)
|
||||
{
|
||||
if (platform == TargetOS.Auto)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
return "Windows";
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
return "macOS";
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
return RuntimeInformation.OSArchitecture switch
|
||||
{
|
||||
Architecture.Arm64 => "Linux-ARM64",
|
||||
Architecture.X64 => "Linux-X64",
|
||||
Architecture.X86 => "Linux-X86",
|
||||
Architecture.Arm => "Linux-ARM",
|
||||
_ => "Linux-X64"
|
||||
};
|
||||
}
|
||||
|
||||
throw new PlatformNotSupportedException("Unsupported operating system");
|
||||
}
|
||||
|
||||
return platform switch
|
||||
{
|
||||
TargetOS.Windows => "Windows",
|
||||
TargetOS.MacOS => "macOS",
|
||||
TargetOS.LinuxX64 => "Linux-X64",
|
||||
TargetOS.LinuxARM64 => "Linux-ARM64",
|
||||
_ => throw new PlatformNotSupportedException("Unsupported target OS in settings")
|
||||
};
|
||||
}
|
||||
|
||||
public static bool IsWindowsAsset(string assetName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(assetName))
|
||||
return false;
|
||||
|
||||
var assetNameLower = assetName.ToLowerInvariant();
|
||||
return HasAnyOf(assetNameLower, "windows", "win64", "win32", "win-x64", "win-x86", "-win.", "_win.", ".exe", ".msi") ||
|
||||
Regex.IsMatch(assetNameLower, @"[_-]win[_-]|[_-]win\d|^win[_-]");
|
||||
}
|
||||
|
||||
public static bool MatchesPlatform(string assetName, string platformIdentifier)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(assetName) || string.IsNullOrWhiteSpace(platformIdentifier))
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Invalid input: assetName or platformIdentifier is null/empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
var assetNameLower = assetName.ToLowerInvariant();
|
||||
var platformLower = platformIdentifier.ToLowerInvariant();
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"Checking asset: {assetName}");
|
||||
System.Diagnostics.Debug.WriteLine($"Platform identifier: {platformIdentifier}");
|
||||
|
||||
if (platformLower.Contains("windows"))
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Checking Windows patterns...");
|
||||
|
||||
if (HasAnyOf(assetNameLower, "linux", "macos", "osx", "darwin", "apple", ".deb", ".rpm", ".appimage", ".dmg", ".pkg", "switch"))
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Excluded: contains non-Windows platform marker");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isWindows = HasAnyOf(assetNameLower,
|
||||
"windows", "win64", "win32", "win-x64", "win-x86",
|
||||
"-win.", "_win.", ".exe", ".msi", "msvc", "mingw") ||
|
||||
Regex.IsMatch(assetNameLower, @"[_-]win[_-]|[_-]win\d|^win[_-]");
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"Windows match result: {isWindows}");
|
||||
return isWindows;
|
||||
}
|
||||
|
||||
if (platformLower.Contains("macos") || platformLower.Contains("mac"))
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Checking macOS patterns...");
|
||||
|
||||
if (HasAnyOf(assetNameLower, "linux", "windows", "win32", "win64", ".exe", ".msi", "switch"))
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Excluded: contains non-macOS platform marker");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isMac = HasAnyOf(assetNameLower, "macos", "osx", "darwin", ".dmg", ".pkg") ||
|
||||
(assetNameLower.Contains("mac") && !assetNameLower.Contains("machin"));
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"macOS match result: {isMac}");
|
||||
return isMac;
|
||||
}
|
||||
|
||||
if (platformLower.Contains("linux"))
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Checking Linux patterns...");
|
||||
|
||||
if (HasAnyOf(assetNameLower, "windows", "win32", "win64", "macos", "osx", "darwin", ".exe", ".msi", ".dmg", "switch"))
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Excluded: contains non-Linux platform marker");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hasLinux = HasAnyOf(assetNameLower, "linux", ".appimage", ".deb", ".rpm", "tar.gz", "tar.xz");
|
||||
|
||||
if (!hasLinux)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("No Linux markers found");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (platformLower.Contains("arm64") || platformLower.Contains("arm") || platformLower.Contains("aarch64"))
|
||||
{
|
||||
bool isArm = HasAnyOf(assetNameLower, "arm64", "aarch64", "armv7", "armhf", "arm-");
|
||||
System.Diagnostics.Debug.WriteLine($"Linux ARM64 match result: {isArm}");
|
||||
return isArm;
|
||||
}
|
||||
|
||||
if (!platformLower.Contains("arm"))
|
||||
{
|
||||
if (HasAnyOf(assetNameLower, "i686", "i386", "i586", "x86-linux", "-i686-"))
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Excluded: 32-bit Linux build");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isLinuxX64 = HasAnyOf(assetNameLower, "x86_64", "x64", "amd64", "x86-64") &&
|
||||
!HasAnyOf(assetNameLower, "arm64", "aarch64", "armv7", "armhf", "arm-");
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"Linux x64 match result: {isLinuxX64}");
|
||||
return isLinuxX64;
|
||||
}
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("Using fallback substring match");
|
||||
bool fallbackMatch = assetNameLower.Contains(platformLower);
|
||||
System.Diagnostics.Debug.WriteLine($"Fallback match result: {fallbackMatch}");
|
||||
return fallbackMatch;
|
||||
}
|
||||
|
||||
public static bool HasAnyOf(string input, params string[] substrings)
|
||||
{
|
||||
foreach (var substring in substrings)
|
||||
{
|
||||
if (input.Contains(substring))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
v2.0.0
|
||||
Reference in new issue
Block a user