forked from LiveSplit/LiveSplit.ScriptableAutoSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComponent.cs
More file actions
128 lines (106 loc) · 3.43 KB
/
Component.cs
File metadata and controls
128 lines (106 loc) · 3.43 KB
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
#define GAME_TIME
using LiveSplit.ASL;
using LiveSplit.Model;
using LiveSplit.Options;
using LiveSplit.TimeFormatters;
using LiveSplit.UI.Components;
using LiveSplit.Web;
using LiveSplit.Web.Share;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Dynamic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Timers;
namespace LiveSplit.UI.Components
{
class Component : IComponent
{
public ComponentSettings Settings { get; set; }
public string ComponentName
{
get { return "Scriptable Auto Splitter"; }
}
public float PaddingBottom { get { return 0; } }
public float PaddingTop { get { return 0; } }
public float PaddingLeft { get { return 0; } }
public float PaddingRight { get { return 0; } }
protected String OldScriptPath { get; set; }
protected FileSystemWatcher FSWatcher { get; set; }
protected bool DoReload { get; set; }
public bool Refresh { get; set; }
public IDictionary<string, Action> ContextMenuControls { get; protected set; }
public ASLScript Script { get; set; }
public Component(String scriptPath)
{
Settings = new ComponentSettings()
{
ScriptPath = scriptPath
};
}
public Component()
{
Settings = new ComponentSettings();
FSWatcher = new FileSystemWatcher();
FSWatcher.Changed += (sender, args) => DoReload = true;
}
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode)
{
if ((Settings.ScriptPath != OldScriptPath && !String.IsNullOrEmpty(Settings.ScriptPath)) || DoReload)
{
Script = ASLParser.Parse(File.ReadAllText(Settings.ScriptPath));
OldScriptPath = Settings.ScriptPath;
FSWatcher.Path = Path.GetDirectoryName(Settings.ScriptPath);
FSWatcher.Filter = Path.GetFileName(Settings.ScriptPath);
FSWatcher.EnableRaisingEvents = true;
DoReload = false;
}
if (Script != null)
Script.Update(state);
}
public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion)
{
}
public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion)
{
}
public float VerticalHeight
{
get { return 0; }
}
public float MinimumWidth
{
get { return 0; }
}
public float HorizontalWidth
{
get { return 0; }
}
public float MinimumHeight
{
get { return 0; }
}
public System.Xml.XmlNode GetSettings(System.Xml.XmlDocument document)
{
return Settings.GetSettings(document);
}
public System.Windows.Forms.Control GetSettingsControl(UI.LayoutMode mode)
{
return Settings;
}
public void SetSettings(System.Xml.XmlNode settings)
{
Settings.SetSettings(settings);
}
public void Dispose()
{
if (FSWatcher != null)
FSWatcher.Dispose();
}
}
}