-
Notifications
You must be signed in to change notification settings - Fork 1
/
TheMessengerComponent.cs
75 lines (63 loc) · 2.44 KB
/
TheMessengerComponent.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
using LiveSplit.Model;
using LiveSplit.UI.Components;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Voxif.AutoSplitter;
using Voxif.IO;
[assembly: ComponentFactory(typeof(Factory))]
namespace LiveSplit.TheMessenger {
public partial class TheMessengerComponent : Voxif.AutoSplitter.Component {
public enum EStart {
[Description("Off")]
Off,
[Description("New Game")]
NewGame,
[Description("Any Level")]
AnyLevel
}
public enum EReset {
[Description("Off")]
Off,
[Description("Main Menu")]
MainMenu
}
public enum EOption {
[Description("Room Timer"), Type(typeof(OptionCheckBox))]
RoomTimer
}
protected override SettingsInfo? StartSettings => new SettingsInfo((int)EStart.NewGame, GetEnumDescriptions<EStart>());
protected override SettingsInfo? ResetSettings => new SettingsInfo((int)EReset.Off, GetEnumDescriptions<EReset>());
protected override OptionsInfo? OptionsSettings => new OptionsInfo(null, CreateControlsFromEnum<EOption>());
protected override EGameTime GameTimeType => EGameTime.Loading;
private TheMessengerMemory memory;
public TheMessengerComponent(LiveSplitState state) : base(state) {
#if DEBUG
logger = new ConsoleLogger();
#else
logger = new FileLogger("_" + Factory.ExAssembly.GetName().Name.Substring(10) + ".log");
#endif
logger.StartLogger();
memory = new TheMessengerMemory(logger);
settings = new TreeSettings(state, StartSettings, ResetSettings, OptionsSettings) {
convertableSettings = new Dictionary<string, string> { { "Unlock_Windmill", "UnlockWindmill" } }
};
settings.OptionChanged += OptionChanged;
remainingSplits = new RemainingDictionary(logger);
}
private void OptionChanged(object sender, OptionEventArgs e) {
switch(Enum.Parse(typeof(EOption), e.Name)) {
case EOption.RoomTimer:
RoomTimer = e.State == 1;
break;
}
}
public override void Dispose() {
settings.OptionChanged -= OptionChanged;
RoomTimer = false;
memory.Dispose();
memory = null;
base.Dispose();
}
}
}