Skip to content

Commit

Permalink
v3.24.2
Browse files Browse the repository at this point in the history
support legacy TAS.Manager.Running
  • Loading branch information
LozenChen committed Jan 26, 2025
1 parent a2c475f commit 533238e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
26 changes: 19 additions & 7 deletions SpeedrunTool/Source/Utils/TasUtils.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using TAS;
using TAS.Module;

namespace Celeste.Mod.SpeedrunTool.Utils;

internal static class TasUtils {
private static bool installed;
private static bool running {
private static bool hasGameplay;

private static bool hasRunning_Latest; // CelesteTAS >= v3.42.0

private static bool hasRunning_Legacy; // CelesteTAS < v3.42.0
private static bool running_Latest {
[MethodImpl(MethodImplOptions.NoInlining)]
get => (bool)(ModUtils.GetType("CelesteTAS", "TAS.Manager")?.GetPropertyValue("Running") ?? false);
get => Manager.Running; // it's a property instead of a field now
}

private static bool running_Legacy {
get => (bool)running_LegacyFieldInfo.GetValue(null);
}

}
private static FieldInfo running_LegacyFieldInfo;

private static bool showGamePlay {
[MethodImpl(MethodImplOptions.NoInlining)]
get => CelesteTasSettings.Instance?.ShowGameplay ?? true;
}

public static bool Running => installed && running;
public static bool HideGamePlay => installed && !showGamePlay;
public static bool Running => hasRunning_Latest ? running_Latest : (hasRunning_Legacy && running_Legacy);
public static bool HideGamePlay => hasGameplay && !showGamePlay;

[Initialize]
private static void Initialize() {
installed = ModUtils.GetType("CelesteTAS", "TAS.Module.CelesteTasSettings")?.GetPropertyInfo("ShowGameplay") != null;
hasGameplay = ModUtils.GetType("CelesteTAS", "TAS.Module.CelesteTasSettings")?.GetPropertyInfo("ShowGameplay") != null;
hasRunning_Latest = ModUtils.GetType("CelesteTAS", "TAS.Manager")?.GetPropertyInfo("Running") != null;
running_LegacyFieldInfo = ModUtils.GetType("CelesteTAS", "TAS.Manager")?.GetFieldInfo("Running");
hasRunning_Legacy = running_LegacyFieldInfo != null;
}
}
2 changes: 1 addition & 1 deletion SpeedrunTool/everest.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- Name: SpeedrunTool
Version: 3.24.1
Version: 3.24.2
DLL: SpeedrunTool.dll
Dependencies:
- Name: Everest
Expand Down

0 comments on commit 533238e

Please sign in to comment.