forked from fatalis/SourceSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSourceSplitFactory.cs
48 lines (40 loc) · 1.79 KB
/
SourceSplitFactory.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
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;
using LiveSplit.SourceSplit;
using LiveSplit.UI.Components;
using System;
using LiveSplit.Model;
[assembly: ComponentFactory(typeof(SourceSplitFactory))]
namespace LiveSplit.SourceSplit
{
public class SourceSplitFactory : IComponentFactory
{
private SourceSplitComponent _instance;
public string ComponentName => "SourceSplit";
public string Description => "Game Time / Auto-splitting for Source engine games.";
public ComponentCategory Category => ComponentCategory.Control;
public IComponent Create(LiveSplitState state)
{
// hack to prevent double loading
string caller = new StackFrame(1).GetMethod().Name;
bool createAsLayoutComponent = (caller == "LoadLayoutComponent" || caller == "AddComponent");
// if component is already loaded somewhere else
if (_instance != null && !_instance.Disposed)
{
MessageBox.Show(
"SourceSplit 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 SourceSplitComponent(state, createAsLayoutComponent));
}
public string UpdateName => this.ComponentName;
public string UpdateURL => "http://fatalis.pw/livesplit/update/";
public Version Version => Assembly.GetExecutingAssembly().GetName().Version;
public string XMLURL => this.UpdateURL + "Components/update.LiveSplit.SourceSplit.xml";
}
}