-
Notifications
You must be signed in to change notification settings - Fork 0
/
DXIWFactory.cs
92 lines (78 loc) · 3.09 KB
/
DXIWFactory.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
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;
using System.Xml;
using LiveSplit.UI;
using LiveSplit.UI.Components;
using System;
using LiveSplit.Model;
namespace LiveSplit.DXIW
{
public class DXIWFactory : IComponentFactory
{
private DXIWComponent _instance;
public string ComponentName
{
get { return "DXIW"; }
}
public string Description
{
get { return "Automates load removal for DXIW."; }
}
public ComponentCategory Category
{
get { return ComponentCategory.Control; }
}
public IComponent Create(LiveSplitState state)
{
// workaround for livesplit 1.4 oversight where components can be loaded from two places at once
// remove all this junk when they fix it
string caller = new StackFrame(1).GetMethod().Name;
string callercaller = new StackFrame(2).GetMethod().Name;
bool createAsLayoutComponent = (caller == "LoadLayoutComponent" || caller == "AddComponent");
// if component is already loaded somewhere else
if (_instance != null && !_instance.Disposed)
{
// "autosplit components" can't throw exceptions for some reason, so return a dummy component
if (callercaller == "CreateAutoSplitter")
{
return new DummyComponent();
}
MessageBox.Show(
"LiveSplit.DXIW is already loaded in the " +
(_instance.IsLayoutComponent ? "Layout Editor" : "Splits Editor") + "!",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
throw new Exception("Component already loaded.");
}
return (_instance = new DXIWComponent(state, createAsLayoutComponent));
}
public string UpdateName
{
get { return this.ComponentName; }
}
public string UpdateURL
{
get { return "https://raw.githubusercontent.com/SuiMachine/LiveSplit.DXIW/master/"; }
}
public Version Version
{
get { return Assembly.GetExecutingAssembly().GetName().Version; }
}
public string XMLURL
{
get { return this.UpdateURL + "Components/update.LiveSplit.DXIW.xml"; }
}
}
class DummyComponent : LogicComponent
{
public override string ComponentName { get { return "Dummy Component"; } }
public override void Dispose() { }
public override XmlNode GetSettings(XmlDocument document) { return document.CreateElement("Settings"); }
public override Control GetSettingsControl(LayoutMode mode) { return null; }
//public override void RenameComparison(string oldName, string newName) { }
public override void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { }
public override void SetSettings(XmlNode settings) { }
}
}