-
Notifications
You must be signed in to change notification settings - Fork 8
/
SplitterComponent.cs
414 lines (388 loc) · 28.2 KB
/
SplitterComponent.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
#if !DebugInfo
using LiveSplit.Model;
using LiveSplit.UI;
using LiveSplit.UI.Components;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using System.Xml;
namespace LiveSplit.Celeste {
public class SplitterComponent : IComponent {
public string ComponentName { get { return "Celeste Autosplitter"; } }
public TimerModel Model { get; set; }
public IDictionary<string, Action> ContextMenuControls { get; protected set; }
private static string LOGFILE = "_Celeste.txt";
private Dictionary<LogObject, string> currentValues = new Dictionary<LogObject, string>();
private ISplitterMemory mem;
private SplitterSettings settings;
private int currentSplit = -1, lastLogCheck, lastHeartGems, lastCassettes;
private bool hasLog = false, lastChapterStarted, lastCompleted, exitingChapter, autoAdding, autoAddingExit;
private double lastElapsed, levelTimer, elapsedOffset;
private string lastLevelName, levelStarted;
private Area lastAreaID = (Area)(-2);
private AreaMode lastAreaDifficulty = (AreaMode)(-2);
public SplitterComponent(LiveSplitState state) {
mem = new SplitterMemoryDispatch();
settings = new SplitterSettings();
foreach (LogObject key in Enum.GetValues(typeof(LogObject))) {
currentValues[key] = "";
}
if (state != null) {
Model = new TimerModel() { CurrentState = state };
Model.InitializeGameTime();
Model.CurrentState.IsGameTimePaused = true;
if (settings.SetGameTime) {
Model.CurrentState.CurrentTimingMethod = TimingMethod.GameTime;
}
state.OnReset += OnReset;
state.OnPause += OnPause;
state.OnResume += OnResume;
state.OnStart += OnStart;
state.OnSplit += OnSplit;
state.OnUndoSplit += OnUndoSplit;
state.OnSkipSplit += OnSkipSplit;
}
ContextMenuControls = new Dictionary<string, Action>();
ContextMenuControls.Add("Add enter split", () => AddLevelSplit(false));
ContextMenuControls.Add("Add exit split", () => AddLevelSplit(true));
ContextMenuControls.Add("Auto add enter splits", () => { autoAdding = true; autoAddingExit = false; });
ContextMenuControls.Add("Auto add exit splits", () => { autoAdding = true; autoAddingExit = true; });
}
public void GetValues() {
if (!mem.HookProcess()) { return; }
mem.SetHighPriority(settings.SetHighPriority);
if (Model != null) {
HandleSplits();
}
LogValues();
}
private void HandleSplits() {
bool shouldSplit = false;
if (currentSplit == -1 && (settings.Splits.Count == 0 || settings.ChapterSplits)) {
if (settings.Splits.Count == 0) {
string levelName = mem.LevelName();
shouldSplit = !string.IsNullOrEmpty(levelName) && !string.IsNullOrEmpty(lastLevelName) && levelName != lastLevelName;
if (shouldSplit) {
levelStarted = lastLevelName;
levelTimer = mem.LevelTime();
}
lastLevelName = levelName;
} else if (!settings.ILSplits) {
shouldSplit = mem.StartingNewFile();
} else {
bool chapterStarted = mem.ChapterStarted();
shouldSplit = chapterStarted && !lastChapterStarted && DateTime.Now > mem.LastHooked.AddSeconds(3);
lastChapterStarted = chapterStarted;
}
} else {
bool completed = mem.ChapterCompleted();
Area areaID = mem.AreaID();
double elapsed = settings.FileTimeOffset ? mem.GameTime() - elapsedOffset : (settings.ILSplits ? (areaID == Area.Menu ? lastElapsed : mem.LevelTime()) : mem.GameTime());
AreaMode areaDifficulty = mem.AreaDifficulty();
int addAmount = settings.Splits.Count > 0 && !settings.ChapterSplits ? 1 : 0;
SplitInfo split = currentSplit + addAmount < settings.Splits.Count ? settings.Splits[currentSplit + addAmount] : null;
string levelName = mem.LevelName();
if (string.IsNullOrEmpty(levelName) && areaID != Area.Menu) { levelName = lastLevelName; }
int cassettes = mem.Cassettes();
int heartGems = mem.HeartGems();
bool chapterCassette = mem.ChapterCassetteCollected();
bool chapterHeart = mem.ChapterHeartCollected();
if (split != null && split.Type != SplitType.Manual) {
switch (split.Type) {
case SplitType.LevelEnter: shouldSplit = areaID != Area.Menu && levelName != lastLevelName && levelName.Equals(split.Value, StringComparison.OrdinalIgnoreCase); break;
case SplitType.LevelExit: shouldSplit = areaID != Area.Menu && levelName != lastLevelName && lastLevelName.Equals(split.Value, StringComparison.OrdinalIgnoreCase); break;
case SplitType.ChapterA: shouldSplit = ChapterSplit(Area.Prologue, Area.Prologue, levelName, completed, elapsed); break;
case SplitType.AreaComplete: shouldSplit = AreaCompleteSplit(split, areaID, levelName, completed, elapsed); break;
case SplitType.AreaOnEnter: shouldSplit = AreaChangeSplit(split, areaID, areaID, areaDifficulty, areaDifficulty); break;
case SplitType.AreaOnExit: shouldSplit = AreaChangeSplit(split, areaID, lastAreaID, areaDifficulty, lastAreaDifficulty); break;
case SplitType.Prologue: shouldSplit = ChapterSplit(areaID, Area.Prologue, levelName, completed, elapsed); break;
case SplitType.Chapter1: shouldSplit = ChapterSplit(areaID, Area.ForsakenCity, levelName, completed, elapsed); break;
case SplitType.Chapter2: shouldSplit = ChapterSplit(areaID, Area.OldSite, levelName, completed, elapsed); break;
case SplitType.Chapter3: shouldSplit = ChapterSplit(areaID, Area.CelestialResort, levelName, completed, elapsed); break;
case SplitType.Chapter4: shouldSplit = ChapterSplit(areaID, Area.GoldenRidge, levelName, completed, elapsed); break;
case SplitType.Chapter5: shouldSplit = ChapterSplit(areaID, Area.MirrorTemple, levelName, completed, elapsed); break;
case SplitType.Chapter6: shouldSplit = ChapterSplit(areaID, Area.Reflection, levelName, completed, elapsed); break;
case SplitType.Chapter7: shouldSplit = ChapterSplit(areaID, Area.TheSummit, levelName, completed, elapsed); break;
case SplitType.Epilogue: shouldSplit = ChapterSplit(areaID, Area.Epilogue, levelName, completed, elapsed); break;
case SplitType.Chapter8: shouldSplit = ChapterSplit(areaID, Area.Core, levelName, completed, elapsed); break;
case SplitType.Chapter9: shouldSplit = ChapterSplit(areaID, Area.Farewell, levelName, completed, elapsed); break;
case SplitType.Chapter1Checkpoint1: shouldSplit = areaID == Area.ForsakenCity && levelName == (areaDifficulty == AreaMode.ASide ? "6" : "04"); break;
case SplitType.Chapter1Checkpoint2: shouldSplit = areaID == Area.ForsakenCity && levelName == (areaDifficulty == AreaMode.ASide ? "9b" : "08"); break;
case SplitType.Chapter2Checkpoint1: shouldSplit = areaID == Area.OldSite && levelName == (areaDifficulty == AreaMode.ASide ? "3" : "03"); break;
case SplitType.Chapter2Checkpoint2: shouldSplit = areaID == Area.OldSite && levelName == (areaDifficulty == AreaMode.ASide ? "end_3" : "08b"); break;
case SplitType.Chapter3Checkpoint1: shouldSplit = areaID == Area.CelestialResort && levelName == (areaDifficulty == AreaMode.ASide ? "08-a" : "06"); break;
case SplitType.Chapter3Checkpoint2: shouldSplit = areaID == Area.CelestialResort && levelName == (areaDifficulty == AreaMode.ASide ? "09-d" : "11"); break;
case SplitType.Chapter3Checkpoint3: shouldSplit = areaID == Area.CelestialResort && levelName == (areaDifficulty == AreaMode.ASide ? "00-d" : "16"); break;
case SplitType.Chapter4Checkpoint1: shouldSplit = areaID == Area.GoldenRidge && levelName == "b-00"; break;
case SplitType.Chapter4Checkpoint2: shouldSplit = areaID == Area.GoldenRidge && levelName == "c-00"; break;
case SplitType.Chapter4Checkpoint3: shouldSplit = areaID == Area.GoldenRidge && levelName == "d-00"; break;
case SplitType.Chapter5Checkpoint1: shouldSplit = areaID == Area.MirrorTemple && levelName == "b-00"; break;
case SplitType.Chapter5Checkpoint2: shouldSplit = areaID == Area.MirrorTemple && levelName == "c-00"; break;
case SplitType.Chapter5Checkpoint3: shouldSplit = areaID == Area.MirrorTemple && levelName == "d-00"; break;
case SplitType.Chapter5Checkpoint4: shouldSplit = areaID == Area.MirrorTemple && levelName == "e-00"; break;
case SplitType.Chapter6Checkpoint1: shouldSplit = areaID == Area.Reflection && levelName == (areaDifficulty == AreaMode.ASide ? "00" : "b-00"); break;
case SplitType.Chapter6Checkpoint2: shouldSplit = areaID == Area.Reflection && levelName == (areaDifficulty == AreaMode.ASide ? "04" : "c-00"); break;
case SplitType.Chapter6Checkpoint3: shouldSplit = areaID == Area.Reflection && levelName == (areaDifficulty == AreaMode.ASide ? "b-00" : "d-00"); break;
case SplitType.Chapter6Checkpoint4: shouldSplit = areaID == Area.Reflection && levelName == "boss-00"; break;
case SplitType.Chapter6Checkpoint5: shouldSplit = areaID == Area.Reflection && levelName == "after-00"; break;
case SplitType.Chapter7Checkpoint1: shouldSplit = areaID == Area.TheSummit && levelName == "b-00"; break;
case SplitType.Chapter7Checkpoint2: shouldSplit = areaID == Area.TheSummit && levelName == (areaDifficulty == AreaMode.ASide ? "c-00" : "c-01"); break;
case SplitType.Chapter7Checkpoint3: shouldSplit = areaID == Area.TheSummit && levelName == "d-00"; break;
case SplitType.Chapter7Checkpoint4: shouldSplit = areaID == Area.TheSummit && levelName == (areaDifficulty == AreaMode.ASide ? "e-00b" : "e-00"); break;
case SplitType.Chapter7Checkpoint5: shouldSplit = areaID == Area.TheSummit && levelName == "f-00"; break;
case SplitType.Chapter7Checkpoint6: shouldSplit = areaID == Area.TheSummit && levelName == "g-00"; break;
case SplitType.Chapter8Checkpoint1: shouldSplit = areaID == Area.Core && levelName == "a-00"; break;
case SplitType.Chapter8Checkpoint2: shouldSplit = areaID == Area.Core && levelName == (areaDifficulty == AreaMode.ASide ? "c-00" : "b-00"); break;
case SplitType.Chapter8Checkpoint3: shouldSplit = areaID == Area.Core && levelName == (areaDifficulty == AreaMode.ASide ? "d-00" : "c-01"); break;
case SplitType.Chapter9Checkpoint1: shouldSplit = areaID == Area.Farewell && levelName == "a-00"; break;
case SplitType.Chapter9Checkpoint2: shouldSplit = areaID == Area.Farewell && levelName == "c-00"; break;
case SplitType.Chapter9Checkpoint3: shouldSplit = areaID == Area.Farewell && levelName == "e-00z"; break;
case SplitType.Chapter9Checkpoint4: shouldSplit = areaID == Area.Farewell && levelName == "f-door"; break;
case SplitType.Chapter9Checkpoint5: shouldSplit = areaID == Area.Farewell && levelName == "h-00b"; break;
case SplitType.Chapter9Checkpoint6: shouldSplit = areaID == Area.Farewell && levelName == "i-00"; break;
case SplitType.Chapter9Checkpoint7: shouldSplit = areaID == Area.Farewell && levelName == "j-00"; break;
case SplitType.Chapter9Checkpoint8: shouldSplit = areaID == Area.Farewell && levelName == "j-16"; break;
case SplitType.HeartGemAny: shouldSplit = ((settings.ILSplits || settings.FileTimeOffset) && chapterHeart) || heartGems == lastHeartGems + 1; break;
case SplitType.Chapter1Cassette: shouldSplit = areaID == Area.ForsakenCity && (((settings.ILSplits || settings.FileTimeOffset) && chapterCassette) || cassettes == lastCassettes + 1); break;
case SplitType.Chapter1HeartGem: shouldSplit = areaID == Area.ForsakenCity && (((settings.ILSplits || settings.FileTimeOffset) && chapterHeart) || heartGems == lastHeartGems + 1); break;
case SplitType.Chapter2Cassette: shouldSplit = areaID == Area.OldSite && (((settings.ILSplits || settings.FileTimeOffset) && chapterCassette) || cassettes == lastCassettes + 1); break;
case SplitType.Chapter2HeartGem: shouldSplit = areaID == Area.OldSite && (((settings.ILSplits || settings.FileTimeOffset) && chapterHeart) || heartGems == lastHeartGems + 1); break;
case SplitType.Chapter3Cassette: shouldSplit = areaID == Area.CelestialResort && (((settings.ILSplits || settings.FileTimeOffset) && chapterCassette) || cassettes == lastCassettes + 1); break;
case SplitType.Chapter3HeartGem: shouldSplit = areaID == Area.CelestialResort && (((settings.ILSplits || settings.FileTimeOffset) && chapterHeart) || heartGems == lastHeartGems + 1); break;
case SplitType.Chapter4Cassette: shouldSplit = areaID == Area.GoldenRidge && (((settings.ILSplits || settings.FileTimeOffset) && chapterCassette) || cassettes == lastCassettes + 1); break;
case SplitType.Chapter4HeartGem: shouldSplit = areaID == Area.GoldenRidge && (((settings.ILSplits || settings.FileTimeOffset) && chapterHeart) || heartGems == lastHeartGems + 1); break;
case SplitType.Chapter5Cassette: shouldSplit = areaID == Area.MirrorTemple && (((settings.ILSplits || settings.FileTimeOffset) && chapterCassette) || cassettes == lastCassettes + 1); break;
case SplitType.Chapter5HeartGem: shouldSplit = areaID == Area.MirrorTemple && (((settings.ILSplits || settings.FileTimeOffset) && chapterHeart) || heartGems == lastHeartGems + 1); break;
case SplitType.Chapter6Cassette: shouldSplit = areaID == Area.Reflection && (((settings.ILSplits || settings.FileTimeOffset) && chapterCassette) || cassettes == lastCassettes + 1); break;
case SplitType.Chapter6HeartGem: shouldSplit = areaID == Area.Reflection && (((settings.ILSplits || settings.FileTimeOffset) && chapterHeart) || heartGems == lastHeartGems + 1); break;
case SplitType.Chapter7Cassette: shouldSplit = areaID == Area.TheSummit && (((settings.ILSplits || settings.FileTimeOffset) && chapterCassette) || cassettes == lastCassettes + 1); break;
case SplitType.Chapter7HeartGem: shouldSplit = areaID == Area.TheSummit && (((settings.ILSplits || settings.FileTimeOffset) && chapterHeart) || heartGems == lastHeartGems + 1); break;
case SplitType.Chapter8Cassette: shouldSplit = areaID == Area.Core && (((settings.ILSplits || settings.FileTimeOffset) && chapterCassette) || cassettes == lastCassettes + 1); break;
case SplitType.Chapter8HeartGem: shouldSplit = areaID == Area.Core && (((settings.ILSplits || settings.FileTimeOffset) && chapterHeart) || heartGems == lastHeartGems + 1); break;
}
lastCassettes = cassettes;
lastHeartGems = heartGems;
lastAreaID = areaID;
lastAreaDifficulty = areaDifficulty;
} else if (split == null && Model.CurrentState.Run.Count == 1) {
if (levelName == levelStarted && elapsed - levelTimer < 2.5) {
levelStarted = lastLevelName;
levelTimer = elapsed;
} else {
shouldSplit = areaID != Area.Menu && levelName != lastLevelName;
}
}
if (shouldSplit && addAmount > 0 && currentSplit < 0) {
levelTimer = mem.LevelTime();
}
if (autoAdding && !shouldSplit && levelName != lastLevelName) {
AddLevelSplit(autoAddingExit, levelName);
}
lastCompleted = completed;
lastLevelName = levelName;
if (elapsed > 0 || lastElapsed == elapsed) {
Model.CurrentState.SetGameTime(TimeSpan.FromSeconds(settings.Splits.Count == 0 || addAmount > 0 ? elapsed - levelTimer : elapsed));
}
Model.CurrentState.IsGameTimePaused = Model.CurrentState.CurrentPhase != TimerPhase.Running || elapsed == lastElapsed;
lastElapsed = elapsed;
}
HandleSplit(shouldSplit, settings.AutoReset && settings.ILSplits && mem.AreaID() == Area.Menu);
}
private bool ChapterSplit(Area areaID, Area chapterArea, string level, bool completed, double elapsed) {
if (!exitingChapter) {
string levelName = chapterArea == Area.TheSummit ? level : null;
exitingChapter = areaID == chapterArea && completed && !lastCompleted && (chapterArea != Area.TheSummit || (!string.IsNullOrEmpty(levelName) && !levelName.StartsWith("credits", StringComparison.OrdinalIgnoreCase)));
return exitingChapter && settings.ILSplits;
}
return !completed && lastCompleted;
}
private bool AreaCompleteSplit(SplitInfo split, Area areaID, string level, bool completed, double elapsed) {
string[] splitInfo = split.Value.Split('-');
if (Enum.TryParse(splitInfo[0].Trim(), true, out Area splitAreaID)) {
return ChapterSplit(areaID, splitAreaID, level, completed, elapsed) &&
(splitInfo.Length == 1 || (Enum.TryParse(splitInfo[1].Trim(), true, out AreaMode splitAreaDifficulty) && lastAreaDifficulty == splitAreaDifficulty));
}
return false;
}
private bool AreaChangeSplit(SplitInfo split, Area currAreaID, Area areaIDToCheck, AreaMode currAreaDifficulty, AreaMode areaDifficultyToCheck) {
string[] splitInfo = split.Value.Split('-');
return Enum.TryParse(splitInfo[0].Trim(), true, out Area splitAreaID) && currAreaID != lastAreaID && areaIDToCheck == splitAreaID &&
(splitInfo.Length == 1 || (Enum.TryParse(splitInfo[1].Trim(), true, out AreaMode splitAreaDifficulty) && currAreaDifficulty != lastAreaDifficulty && areaDifficultyToCheck == splitAreaDifficulty));
}
private void HandleSplit(bool shouldSplit, bool shouldReset = false) {
if (shouldReset) {
if (currentSplit >= 0) {
Model.Reset();
}
} else if (shouldSplit) {
if (currentSplit == -1) {
Model.Start();
} else {
Model.Split();
}
}
}
private void AddLevelSplit(bool exit, string levelName = null) {
if (!mem.IsHooked) { return; }
if (levelName == null) { levelName = mem.LevelName(); }
if (string.IsNullOrEmpty(levelName)) { return; }
int idx = currentSplit;
if (idx < 0) {
if (Model.CurrentState.Run.Count == 1 && settings.Splits.Count == 0) {
Model.CurrentState.Run[0].Name = "-" + levelName;
} else {
Model.CurrentState.Run.Add(new Segment("-" + levelName));
}
} else {
Model.CurrentState.Run.Insert(idx, new Segment("-" + levelName));
}
Model.CurrentState.CallRunManuallyModified();
if (idx < 0 || idx >= settings.Splits.Count) {
settings.Splits.Add(new SplitInfo() {
Type = exit ? SplitType.LevelExit : SplitType.LevelEnter,
Value = levelName
});
} else {
settings.Splits.Insert(idx, new SplitInfo() {
Type = exit ? SplitType.LevelExit : SplitType.LevelEnter,
Value = levelName
});
}
Model.SkipSplit();
}
private void LogValues() {
if (lastLogCheck == 0) {
hasLog = File.Exists(LOGFILE);
lastLogCheck = 300;
}
lastLogCheck--;
if (hasLog || !Console.IsOutputRedirected) {
string prev = string.Empty, curr = string.Empty;
foreach (LogObject key in Enum.GetValues(typeof(LogObject))) {
prev = currentValues[key];
switch (key) {
case LogObject.CurrentSplit: curr = currentSplit.ToString(); break;
case LogObject.Pointers: curr = mem.RAMPointers(); break;
case LogObject.PointerVersion: curr = mem.RAMPointerVersion(); break;
case LogObject.CelesteFieldOffs: curr = mem.CelesteFieldOffs().ToString("X"); break;
case LogObject.GameTime: curr = mem.GameTime().ToString("0"); break;
case LogObject.LevelTime: curr = mem.LevelTime().ToString("0"); break;
case LogObject.StartingNewFile: curr = mem.StartingNewFile().ToString(); break;
case LogObject.Started: curr = mem.ChapterStarted().ToString(); break;
case LogObject.Completed: curr = mem.ChapterCompleted().ToString(); break;
case LogObject.AreaID: curr = mem.AreaID().ToString(); break;
case LogObject.AreaMode: curr = mem.AreaDifficulty().ToString(); break;
case LogObject.LevelName: curr = mem.LevelName(); break;
case LogObject.Strawberries: curr = mem.Strawberries().ToString(); break;
case LogObject.Cassettes: curr = mem.Cassettes().ToString(); break;
case LogObject.ChapterCassette: curr = mem.ChapterCassetteCollected().ToString(); break;
case LogObject.HeartGems: curr = mem.HeartGems().ToString(); break;
case LogObject.ChapterHeart: curr = mem.ChapterHeartCollected().ToString(); break;
case LogObject.HighPriority:
bool? highPriority = mem.IsHighPriority();
curr = highPriority.HasValue ? highPriority.Value.ToString() : "N/A";
break;
default: curr = string.Empty; break;
}
if (string.IsNullOrEmpty(prev)) { prev = string.Empty; }
if (string.IsNullOrEmpty(curr)) { curr = string.Empty; }
if (!prev.Equals(curr)) {
WriteLog(DateTime.Now.ToString(@"HH\:mm\:ss.fff") + (Model != null ? " | " + Model.CurrentState.CurrentTime.RealTime.Value.ToString("G").Substring(3, 11) : "") + ": " + key.ToString() + ": ".PadRight(22 - key.ToString().Length, ' ') + prev.PadLeft(25, ' ') + " -> " + curr);
currentValues[key] = curr;
}
}
}
}
public void Update(IInvalidator invalidator, LiveSplitState lvstate, float width, float height, LayoutMode mode) {
GetValues();
}
public void OnReset(object sender, TimerPhase e) {
currentSplit = -1;
exitingChapter = false;
autoAdding = false;
lastAreaID = (Area)(-2);
lastAreaDifficulty = (AreaMode)(-2);
Model.CurrentState.IsGameTimePaused = true;
WriteLog("---------Reset----------------------------------");
}
public void OnResume(object sender, EventArgs e) {
WriteLog("---------Resumed--------------------------------");
}
public void OnPause(object sender, EventArgs e) {
WriteLog("---------Paused---------------------------------");
}
public void OnStart(object sender, EventArgs e) {
currentSplit = 0;
Model.CurrentState.IsGameTimePaused = true;
elapsedOffset = mem.GameTime();
WriteLog("---------New Game " + Assembly.GetExecutingAssembly().GetName().Version.ToString(3) + "-------------------------");
SplitInfo split = currentSplit < settings.Splits.Count ? settings.Splits[currentSplit] : null;
if (split != null) {
WriteLog("---------" + split.Type.ToString());
}
}
public void OnUndoSplit(object sender, EventArgs e) {
currentSplit--;
exitingChapter = false;
WriteLog("---------Undo-----------------------------------");
}
public void OnSkipSplit(object sender, EventArgs e) {
currentSplit++;
exitingChapter = false;
WriteLog("---------Skip-----------------------------------");
}
public void OnSplit(object sender, EventArgs e) {
currentSplit++;
exitingChapter = false;
WriteLog("---------Split-----------------------------------");
if (currentSplit == Model.CurrentState.Run.Count) {
ISegment segment = Model.CurrentState.Run[currentSplit - 1];
segment.SplitTime = new Time(segment.SplitTime.RealTime, TimeSpan.FromSeconds(settings.Splits.Count == 0 ? lastElapsed - levelTimer : lastElapsed));
} else {
SplitInfo split = currentSplit < settings.Splits.Count ? settings.Splits[currentSplit] : null;
if (split != null) {
WriteLog("---------" + split.Type.ToString());
}
}
}
private void WriteLog(string data) {
if (hasLog || !Console.IsOutputRedirected) {
if (Console.IsOutputRedirected) {
using (StreamWriter wr = new StreamWriter(LOGFILE, true)) {
wr.WriteLine(data);
}
} else {
Console.WriteLine(data);
}
}
}
public Control GetSettingsControl(LayoutMode mode) { return settings; }
public void SetSettings(XmlNode document) { settings.SetSettings(document); }
public XmlNode GetSettings(XmlDocument document) { return settings.UpdateSettings(document); }
public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion) { }
public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion) { }
public float HorizontalWidth { get { return 0; } }
public float MinimumHeight { get { return 0; } }
public float MinimumWidth { get { return 0; } }
public float PaddingBottom { get { return 0; } }
public float PaddingLeft { get { return 0; } }
public float PaddingRight { get { return 0; } }
public float PaddingTop { get { return 0; } }
public float VerticalHeight { get { return 0; } }
public void Dispose() {
if (Model != null) {
Model.CurrentState.OnReset -= OnReset;
Model.CurrentState.OnPause -= OnPause;
Model.CurrentState.OnResume -= OnResume;
Model.CurrentState.OnStart -= OnStart;
Model.CurrentState.OnSplit -= OnSplit;
Model.CurrentState.OnUndoSplit -= OnUndoSplit;
Model.CurrentState.OnSkipSplit -= OnSkipSplit;
}
}
}
}
#endif