Skip to content

Commit

Permalink
More GameBanana changes
Browse files Browse the repository at this point in the history
  • Loading branch information
thesupersonic16 committed Nov 27, 2024
1 parent f1c3d3a commit bf04a30
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
1 change: 1 addition & 0 deletions Source/HedgeModManager.UI/GameBanana.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public static class GameBanana
Images = profilePage.PreviewMedia.Images.Select(x => $"{x.BaseURL}/{x.FilePath}").ToList(),
DownloadURL = downloadURL,
};
Logger.Information("Finished downloading item data");

return downloadInfo;
}
Expand Down
29 changes: 29 additions & 0 deletions Source/HedgeModManager.UI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Avalonia;
using HedgeModManager.UI.CLI;
using Microsoft.Win32;
using System;
using System.IO.Pipes;
using System.IO;
Expand All @@ -8,6 +9,7 @@
using System.Threading;
using System.Text.Json;
using System.Collections.Generic;
using System.Runtime.Versioning;

namespace HedgeModManager.UI;

Expand Down Expand Up @@ -70,6 +72,33 @@ public static void Main(string[] args)
CurrentMutex?.Dispose();
}

public static void InstallURIHandler()
{
if (OperatingSystem.IsWindows())
{
foreach (string schema in GameBanana.GameIDMapping.Keys)
installToRegistery(schema, "-gb \"%1\"");
}

[SupportedOSPlatform("windows")]
static void installToRegistery(string schema, string args)
{
if (Environment.ProcessPath is not string processPath)
return;

try
{
var reg = Registry.CurrentUser.CreateSubKey($"Software\\Classes\\{schema}");
reg.SetValue("", $"URL:{ApplicationName}");
reg.SetValue("URL Protocol", "");
reg = reg.CreateSubKey("shell\\open\\command");
reg.SetValue("", $"\"{processPath}\" {args}");
reg.Close();
}
catch { }
}
}

// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace HedgeModManager.UI.ViewModels;
public partial class ModDownloaderViewModel : ViewModelBase
{
[ObservableProperty] private bool _ready = false;
[ObservableProperty] private bool _loading = true;
[ObservableProperty] private string _title = "Common.Text.Loading";
[ObservableProperty] private string _description = "";
[ObservableProperty] private ModDownloadInfo? _downloadInfo;
Expand All @@ -37,6 +38,7 @@ public async Task StartInfoDownload()
if (DownloadInfo != null)
{
Ready = true;
Loading = false;
Update();
}
}
Expand Down
11 changes: 5 additions & 6 deletions Source/HedgeModManager.UI/ViewModels/Mods/ModConfigViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ public ValidatableConfigElement(ModConfig.ConfigElement element)

public IEnumerable GetErrors(string? propertyName)
{
switch (propertyName)
return propertyName switch
{
case nameof(Value):
return new[] { ErrorText };
default:
return Array.Empty<string?>();
}
nameof(Value) => [ErrorText],
_ => Array.Empty<string?>(),
};
}

protected override void OnPropertyChanged(PropertyChangedEventArgs e)
Expand Down Expand Up @@ -99,6 +97,7 @@ protected override void OnPropertyChanged(PropertyChangedEventArgs e)
default:
break;
}
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(e.PropertyName));
}
base.OnPropertyChanged(e);
}
Expand Down
3 changes: 3 additions & 0 deletions Source/HedgeModManager.UI/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ private async void Window_Loaded(object? sender, RoutedEventArgs e)
Logger.Information($"Initialising codes...");
CodeProvider.TryLoadRoslyn();

Logger.Information($"Loading URI handlers...");
Program.InstallURIHandler();

Logger.Information($"Locating games...");
ViewModel.Games = new(Games.GetUIGames(ModdableGameLocator.LocateGames()));
//ViewModel.Games = new();
Expand Down

0 comments on commit bf04a30

Please sign in to comment.