-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathTRRandomizerCoord.cs
91 lines (74 loc) · 3.44 KB
/
TRRandomizerCoord.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using TRRandomizerCore.Editors;
using TRRandomizerCore.Helpers;
using TRGE.Coord;
using TRGE.Core;
namespace TRRandomizerCore;
public class TRRandomizerCoord
{
private static TRRandomizerCoord _instance;
public static TRRandomizerCoord Instance
{
get => _instance ??= new();
}
public static IReadOnlyList<string> History => TRCoord.Instance.History;
public event EventHandler HistoryChanged;
public event EventHandler<TROpenRestoreEventArgs> OpenProgressChanged;
private TROpenRestoreEventArgs _openEventArgs;
public static string ConfigDirectory => TRCoord.Instance.ConfigDirectory;
public static string ConfigFilePath => TRCoord.Instance.ConfigFilePath;
private TRRandomizerCoord() { }
private void TRCoord_HistoryChanged(object sender, EventArgs e)
{
HistoryChanged?.Invoke(this, e);
}
private void TRCoord_BackupProgressChanged(object sender, TRBackupRestoreEventArgs e)
{
_openEventArgs.Copy(e);
OpenProgressChanged.Invoke(this, _openEventArgs);
}
/// <summary>
/// Initialises the interop values between this application and TRGE.
/// </summary>
/// <param name="applicationID">The ID for this application, used in the application config file name.</param>
/// <param name="version">The current version of the executing assembly e.g. 1.0.0</param>
/// <param name="taggedVersion">The tagged version of the current release e.g. 1.0.0-beta</param>
/// <param name="modificationStamp">The text to inject into the passport and inventory titles to show that this application has modified the game.</param>
public void Initialise(string applicationID, string version, string taggedVersion, ModificationStamp modificationStamp)
{
TRInterop.ExecutingVersionName = applicationID;
modificationStamp.ApplyTo(TRInterop.ScriptModificationStamp);
TRInterop.ExecutingVersion = version;
TRInterop.TaggedVersion = taggedVersion;
TRInterop.RandomisationSupported = true;
TRInterop.SecretRewardsSupported = true;
TRInterop.ChecksumTester = new ChecksumTester();
TRLevelEditorFactory.RegisterEditor(TREdition.TR1PC, typeof(TR1ClassicEditor));
TRLevelEditorFactory.RegisterEditor(TREdition.TR2PC, typeof(TR2ClassicEditor));
TRLevelEditorFactory.RegisterEditor(TREdition.TR3PC, typeof(TR3ClassicEditor));
TRLevelEditorFactory.RegisterEditor(TREdition.TR1RM, typeof(TR1RemasteredEditor));
TRLevelEditorFactory.RegisterEditor(TREdition.TR2RM, typeof(TR2RemasteredEditor));
TRLevelEditorFactory.RegisterEditor(TREdition.TR3RM, typeof(TR3RemasteredEditor));
// #125 Invoke TRCoord.Instance after defining TRInterop.ExecutingVersionName otherwise
// TRGE will not know the config file name to look for.
TRCoord.Instance.HistoryChanged += TRCoord_HistoryChanged;
TRCoord.Instance.HistoryAdded += TRCoord_HistoryChanged;
TRCoord.Instance.BackupProgressChanged += TRCoord_BackupProgressChanged;
}
public TRRandomizerController Open(string directoryPath)
{
_openEventArgs = new();
return new(directoryPath);
}
public static void ClearHistory()
{
TRCoord.Instance.ClearHistory();
}
public static void CheckBackupIntegrity()
{
TRCoord.Instance.CheckBackupIntegrity();
}
public static void ClearCurrentBackup()
{
TRCoord.Instance.ClearCurrentBackup();
}
}