about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Lingo.asl81
1 files changed, 67 insertions, 14 deletions
diff --git a/Lingo.asl b/Lingo.asl index e918857..b448010 100644 --- a/Lingo.asl +++ b/Lingo.asl
@@ -24,6 +24,39 @@ startup
24 24
25 vars.prevPanel = ""; 25 vars.prevPanel = "";
26 26
27 vars.configFiles = null;
28 vars.settings = settings;
29 var findConfigFiles = (Action<string>)((string folder) => {
30 var files = new List<string>();
31 if (folder != null) {
32 vars.log("Searching for config files in '" + folder + "'");
33 files.AddRange(System.IO.Directory.GetFiles(folder, "*.lingo_config"));
34 files.AddRange(System.IO.Directory.GetFiles(folder, "*.lingo_config.txt"));
35 files.AddRange(System.IO.Directory.GetFiles(folder, "*.lingo_conf"));
36 files.AddRange(System.IO.Directory.GetFiles(folder, "*.lingo_confi"));
37 vars.log("Found " + files.Count + " config files");
38 }
39
40 // Only add the parent setting the first time we call this function
41 if (vars.configFiles == null) {
42 vars.configFiles = new Dictionary<string, string>();
43 vars.settings.Add("configs", (files.Count > 0), "Split based on configuration file:");
44 }
45
46 foreach (var file in files) {
47 string fileName = file.Split('\\').Last();
48 if (vars.configFiles.ContainsKey(fileName)) continue;
49 vars.configFiles[fileName] = file;
50 vars.settings.Add(fileName, false, null, "configs");
51 }
52 });
53 // Search for config files relative to LiveSplit.exe
54 findConfigFiles(Directory.GetCurrentDirectory());
55 // Search for config files relative to the current layout
56 findConfigFiles(System.IO.Path.GetDirectoryName(timer.Layout.FilePath));
57 // Search for config files relative to the current splits
58 findConfigFiles(System.IO.Path.GetDirectoryName(timer.Run.FilePath));
59
27 vars.log("Autosplitter loaded"); 60 vars.log("Autosplitter loaded");
28 61
29 vars.levelOneThePanels = new List<String>{ 62 vars.levelOneThePanels = new List<String>{
@@ -85,17 +118,7 @@ init
85 vars.log(String.Format("Magic autosplitter array: {0}", ptr.ToString("X"))); 118 vars.log(String.Format("Magic autosplitter array: {0}", ptr.ToString("X")));
86 119
87 vars.updateText = false; 120 vars.updateText = false;
88 if (settings["showLastPanel"]) { 121 vars.configWaypoints = null;
89 foreach (LiveSplit.UI.Components.IComponent component in timer.Layout.Components) {
90 if (component.GetType().Name == "TextComponent") {
91 vars.tc = component;
92 vars.tcs = vars.tc.Settings;
93 vars.updateText = true;
94 vars.log("Found text component at " + component);
95 break;
96 }
97 }
98 }
99} 122}
100 123
101update 124update
@@ -117,9 +140,36 @@ onStart
117{ 140{
118 vars.prevPanel = vars.panel.Current; 141 vars.prevPanel = vars.panel.Current;
119 142
120 if (settings["showLastPanel"] && vars.updateText) { 143 vars.updateText = false;
121 vars.tcs.Text1 = "Last Panel:"; 144 if (settings["showLastPanel"]) {
122 vars.tcs.Text2 = ""; 145 foreach (LiveSplit.UI.Components.IComponent component in timer.Layout.Components) {
146 if (component.GetType().Name == "TextComponent") {
147 vars.tc = component;
148 vars.tcs = vars.tc.Settings;
149 vars.tcs.Text1 = "Last Panel:";
150 vars.tcs.Text2 = "";
151 vars.updateText = true;
152 vars.log("Found text component at " + component);
153 break;
154 }
155 }
156 }
157
158 vars.configWaypoints = null;
159 if (settings["configs"]) {
160 string[] lines = {""};
161 foreach (var configFile in vars.configFiles.Keys) {
162 if (settings[configFile]) {
163 // Full path is saved in the dictionary.
164 var splitlist = System.IO.File.ReadAllLines(vars.configFiles[configFile]);
165 if (splitlist != null) {
166 vars.configWaypoints = new List<string>(splitlist);
167 }
168 vars.log("Selected config file: " + configFile);
169 vars.log("Config contains " + splitlist.Length + " lines");
170 break;
171 }
172 }
123 } 173 }
124} 174}
125 175
@@ -149,6 +199,9 @@ split
149 } else if (settings["levelOneOranges"] && vars.levelOneOranges.Contains(vars.panel.Current)) { 199 } else if (settings["levelOneOranges"] && vars.levelOneOranges.Contains(vars.panel.Current)) {
150 action = "SPLIT"; 200 action = "SPLIT";
151 vars.log("Split on LL1 tower orange"); 201 vars.log("Split on LL1 tower orange");
202 } else if (settings["configs"] && vars.configWaypoints != null && vars.configWaypoints.Contains(vars.panel.Current)) {
203 action = "SPLIT";
204 vars.log("Split on config file");
152 } 205 }
153 206
154 vars.prevPanel = vars.panel.Current; 207 vars.prevPanel = vars.panel.Current;