mirror of
https://github.com/ppy/osu-tools.git
synced 2025-06-07 23:07:01 +09:00
Add hot reload support
This commit is contained in:
parent
0d9bbd92ca
commit
5b08924bf3
3 changed files with 28 additions and 0 deletions
17
PerformanceCalculatorGUI/HotReloadCallbackReceiver.cs
Normal file
17
PerformanceCalculatorGUI/HotReloadCallbackReceiver.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace PerformanceCalculatorGUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Receives callbacks upon .NET Hot Reloads.
|
||||
/// </summary>
|
||||
internal static class HotReloadCallbackReceiver
|
||||
{
|
||||
public static event Action<Type[]> CompilationFinished;
|
||||
public static void UpdateApplication([CanBeNull] Type[] updatedTypes) => CompilationFinished?.Invoke(updatedTypes);
|
||||
}
|
||||
}
|
7
PerformanceCalculatorGUI/Properties/AssemblyInfo.cs
Normal file
7
PerformanceCalculatorGUI/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Reflection.Metadata;
|
||||
using PerformanceCalculatorGUI;
|
||||
|
||||
[assembly: MetadataUpdateHandler(typeof(HotReloadCallbackReceiver))]
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using Humanizer;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
|
@ -264,6 +265,9 @@ namespace PerformanceCalculatorGUI.Screens
|
|||
appliedMods.Value = Array.Empty<Mod>();
|
||||
calculateDifficulty();
|
||||
});
|
||||
|
||||
if (RuntimeInfo.IsDesktop)
|
||||
HotReloadCallbackReceiver.CompilationFinished += _ => Schedule(calculateDifficulty);
|
||||
}
|
||||
|
||||
public override void Hide()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue