-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support legacy TAS.Manager.Running
- Loading branch information
Showing
2 changed files
with
20 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|