1
0
Fork 0
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:
StanR 2022-03-11 01:15:13 +03:00
parent 0d9bbd92ca
commit 5b08924bf3
3 changed files with 28 additions and 0 deletions

View 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);
}
}

View 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))]

View file

@ -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()