1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 18:52:55 +08:00

Refactor public methods

This commit is contained in:
Susko3 2024-02-07 22:17:13 +01:00
parent 6bdb076027
commit 738c28755c
2 changed files with 42 additions and 3 deletions

View File

@ -174,10 +174,11 @@ namespace osu.Desktop
{
tools.CreateShortcutForThisExe();
tools.CreateUninstallerRegistryEntry();
WindowsAssociationManager.InstallAssociations(null);
WindowsAssociationManager.InstallAssociations();
}, onAppUpdate: (_, tools) =>
{
tools.CreateUninstallerRegistryEntry();
WindowsAssociationManager.UpdateAssociations();
}, onAppUninstall: (_, tools) =>
{
tools.RemoveShortcutForThisExe();

View File

@ -51,12 +51,18 @@ namespace osu.Desktop.Windows
new UriAssociation(@"osump", WindowsAssociationManagerStrings.OsuMultiplayer, Icons.Lazer),
};
public static void InstallAssociations(LocalisationManager? localisation)
/// <summary>
/// Installs file and URI associations.
/// </summary>
/// <remarks>
/// Call <see cref="UpdateDescriptions"/> in a timely fashion to keep descriptions up-to-date and localised.
/// </remarks>
public static void InstallAssociations()
{
try
{
updateAssociations();
updateDescriptions(localisation);
updateDescriptions(null); // write default descriptions in case `UpdateDescriptions()` is not called.
NotifyShellUpdate();
}
catch (Exception e)
@ -65,6 +71,38 @@ namespace osu.Desktop.Windows
}
}
/// <summary>
/// Updates associations with latest definitions.
/// </summary>
/// <remarks>
/// Call <see cref="UpdateDescriptions"/> in a timely fashion to keep descriptions up-to-date and localised.
/// </remarks>
public static void UpdateAssociations()
{
try
{
updateAssociations();
NotifyShellUpdate();
}
catch (Exception e)
{
Logger.Log(@$"Failed to update file and URI associations: {e.Message}");
}
}
public static void UpdateDescriptions(LocalisationManager localisationManager)
{
try
{
updateDescriptions(localisationManager);
NotifyShellUpdate();
}
catch (Exception e)
{
Logger.Log(@$"Failed to update file and URI association descriptions: {e.Message}");
}
}
/// <summary>
/// Installs or updates associations.
/// </summary>