diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-02-13 13:20:38 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-02-13 13:20:38 -0500 |
| commit | 4c77425dc56ec8a6804738992ffcd01fe8f71804 (patch) | |
| tree | 6eaf02aededc1fba33b2ad2b9af8377be5f3b06e | |
| parent | 4f504f5c11c8494d7186d993a497781e4f6ffb9e (diff) | |
| download | autosplitters-4c77425dc56ec8a6804738992ffcd01fe8f71804.tar.gz autosplitters-4c77425dc56ec8a6804738992ffcd01fe8f71804.tar.bz2 autosplitters-4c77425dc56ec8a6804738992ffcd01fe8f71804.zip | |
[Lingo 2] Added config files
| -rw-r--r-- | Lingo 2.asl | 124 |
1 files changed, 118 insertions, 6 deletions
| diff --git a/Lingo 2.asl b/Lingo 2.asl index 2b8be1a..6a9e22a 100644 --- a/Lingo 2.asl +++ b/Lingo 2.asl | |||
| @@ -33,6 +33,48 @@ startup | |||
| 33 | vars.visitedMaps = new HashSet<string>(); | 33 | vars.visitedMaps = new HashSet<string>(); |
| 34 | vars.collectedKeys = new HashSet<string>(); | 34 | vars.collectedKeys = new HashSet<string>(); |
| 35 | vars.latestKeyKey = null; | 35 | vars.latestKeyKey = null; |
| 36 | vars.importantPanels = new HashSet<string>(); | ||
| 37 | vars.importantMultiPanels = new HashSet<string>(); | ||
| 38 | vars.importantMaps = new HashSet<string>(); | ||
| 39 | vars.importantMultiMaps = new HashSet<string>(); | ||
| 40 | vars.importantKeys = new HashSet<string>(); | ||
| 41 | vars.importantCollectibles = new HashSet<string>(); | ||
| 42 | |||
| 43 | vars.configFiles = null; | ||
| 44 | vars.settings = settings; | ||
| 45 | var findConfigFiles = (Action<string>)((string folder) => { | ||
| 46 | var files = new List<string>(); | ||
| 47 | if (folder != null) | ||
| 48 | { | ||
| 49 | vars.log("Searching for config files in '" + folder + "'"); | ||
| 50 | files.AddRange(System.IO.Directory.GetFiles(folder, "*.lingo2_config")); | ||
| 51 | files.AddRange(System.IO.Directory.GetFiles(folder, "*.lingo2_config.txt")); | ||
| 52 | files.AddRange(System.IO.Directory.GetFiles(folder, "*.lingo2_conf")); | ||
| 53 | files.AddRange(System.IO.Directory.GetFiles(folder, "*.lingo2_confi")); | ||
| 54 | vars.log("Found " + files.Count + " config files"); | ||
| 55 | } | ||
| 56 | |||
| 57 | // Only add the parent setting the first time we call this function | ||
| 58 | if (vars.configFiles == null) | ||
| 59 | { | ||
| 60 | vars.configFiles = new Dictionary<string, string>(); | ||
| 61 | vars.settings.Add("configs", (files.Count > 0), "Split based on configuration file:"); | ||
| 62 | } | ||
| 63 | |||
| 64 | foreach (var file in files) | ||
| 65 | { | ||
| 66 | string fileName = file.Split('\\').Last(); | ||
| 67 | if (vars.configFiles.ContainsKey(fileName)) continue; | ||
| 68 | vars.configFiles[fileName] = file; | ||
| 69 | vars.settings.Add(fileName, false, null, "configs"); | ||
| 70 | } | ||
| 71 | }); | ||
| 72 | // Search for config files relative to LiveSplit.exe | ||
| 73 | findConfigFiles(Directory.GetCurrentDirectory()); | ||
| 74 | // Search for config files relative to the current layout | ||
| 75 | findConfigFiles(System.IO.Path.GetDirectoryName(timer.Layout.FilePath)); | ||
| 76 | // Search for config files relative to the current splits | ||
| 77 | findConfigFiles(System.IO.Path.GetDirectoryName(timer.Run.FilePath)); | ||
| 36 | 78 | ||
| 37 | vars.log("Autosplitter loaded"); | 79 | vars.log("Autosplitter loaded"); |
| 38 | } | 80 | } |
| @@ -73,6 +115,71 @@ init | |||
| 73 | vars.lastPanelPath = new StringWatcher(ptr + 135, 101); | 115 | vars.lastPanelPath = new StringWatcher(ptr + 135, 101); |
| 74 | 116 | ||
| 75 | vars.log(String.Format("Magic autosplitter array: {0}", ptr.ToString("X"))); | 117 | vars.log(String.Format("Magic autosplitter array: {0}", ptr.ToString("X"))); |
| 118 | |||
| 119 | if (settings["configs"]) | ||
| 120 | { | ||
| 121 | string[] lines = {""}; | ||
| 122 | foreach (var configFile in vars.configFiles.Keys) | ||
| 123 | { | ||
| 124 | if (settings[configFile]) | ||
| 125 | { | ||
| 126 | // Full path is saved in the dictionary. | ||
| 127 | lines = System.IO.File.ReadAllLines(vars.configFiles[configFile]); | ||
| 128 | vars.log("Selected config file: " + configFile); | ||
| 129 | break; | ||
| 130 | } | ||
| 131 | } | ||
| 132 | if (lines.Length == 0) | ||
| 133 | { | ||
| 134 | vars.log("Config file empty or no config file selected!"); | ||
| 135 | } | ||
| 136 | else | ||
| 137 | { | ||
| 138 | string mode = ""; | ||
| 139 | for (int i=0; i<lines.Length; i++) | ||
| 140 | { | ||
| 141 | var line = lines[i].Split('#')[0]; // Strip comments | ||
| 142 | line = line.Trim(); // Strip whitespace | ||
| 143 | if (line == "") | ||
| 144 | { | ||
| 145 | // No reason to process empty lines | ||
| 146 | continue; | ||
| 147 | } | ||
| 148 | |||
| 149 | if (line.Contains(':')) | ||
| 150 | { | ||
| 151 | var parts = line.Split(':'); | ||
| 152 | mode = parts[0]; | ||
| 153 | continue; | ||
| 154 | } | ||
| 155 | |||
| 156 | if (mode == "panels") | ||
| 157 | { | ||
| 158 | vars.importantPanels.Add(line); | ||
| 159 | } | ||
| 160 | else if (mode == "multipanels") | ||
| 161 | { | ||
| 162 | vars.importantMultiPanels.Add(line); | ||
| 163 | } | ||
| 164 | else if (mode == "maps") | ||
| 165 | { | ||
| 166 | vars.importantMaps.Add(line); | ||
| 167 | } | ||
| 168 | else if (mode == "multimaps") | ||
| 169 | { | ||
| 170 | vars.importantMultiMaps.Add(line); | ||
| 171 | } | ||
| 172 | else if (mode == "keys") | ||
| 173 | { | ||
| 174 | vars.importantKeys.Add(line); | ||
| 175 | } | ||
| 176 | else if (mode == "collectibles") | ||
| 177 | { | ||
| 178 | vars.importantCollectibles.Add(line); | ||
| 179 | } | ||
| 180 | } | ||
| 181 | } | ||
| 182 | } | ||
| 76 | } | 183 | } |
| 77 | 184 | ||
| 78 | update | 185 | update |
| @@ -130,12 +237,12 @@ split | |||
| 130 | 237 | ||
| 131 | if (vars.lastPanel != vars.prevPanel) | 238 | if (vars.lastPanel != vars.prevPanel) |
| 132 | { | 239 | { |
| 133 | if (settings["panels"]) | 240 | if (settings["panels"] || vars.importantPanels.Contains(vars.lastPanel) || vars.importantMultiPanels.Contains(vars.lastPanel)) |
| 134 | { | 241 | { |
| 135 | should_split = true; | 242 | should_split = true; |
| 136 | } | 243 | } |
| 137 | 244 | ||
| 138 | if (settings["panels_first"]) | 245 | if (settings["panels_first"] || vars.importantPanels.Contains(vars.lastPanel)) |
| 139 | { | 246 | { |
| 140 | if (vars.solvedPanels.Contains(vars.lastPanel)) | 247 | if (vars.solvedPanels.Contains(vars.lastPanel)) |
| 141 | { | 248 | { |
| @@ -157,12 +264,12 @@ split | |||
| 157 | } | 264 | } |
| 158 | else if (vars.currentMap.Current != vars.prevMap) | 265 | else if (vars.currentMap.Current != vars.prevMap) |
| 159 | { | 266 | { |
| 160 | if (settings["maps"]) | 267 | if (settings["maps"] || vars.importantMaps.Contains(vars.currentMap.Current) || vars.importantMultiMaps.Contains(vars.currentMap.Current)) |
| 161 | { | 268 | { |
| 162 | should_split = true; | 269 | should_split = true; |
| 163 | } | 270 | } |
| 164 | 271 | ||
| 165 | if (settings["maps_first"]) | 272 | if (settings["maps_first"] || vars.importantMaps.Contains(vars.currentMap.Current)) |
| 166 | { | 273 | { |
| 167 | if (vars.visitedMaps.Contains(vars.currentMap.Current)) | 274 | if (vars.visitedMaps.Contains(vars.currentMap.Current)) |
| 168 | { | 275 | { |
| @@ -189,7 +296,7 @@ split | |||
| 189 | } | 296 | } |
| 190 | else if (vars.latestKeyKey != null && !vars.collectedKeys.Contains(vars.latestKeyKey)) | 297 | else if (vars.latestKeyKey != null && !vars.collectedKeys.Contains(vars.latestKeyKey)) |
| 191 | { | 298 | { |
| 192 | if (settings["keys"]) | 299 | if (settings["keys"] || vars.importantKeys.Contains(vars.latestKeyKey)) |
| 193 | { | 300 | { |
| 194 | should_split = true; | 301 | should_split = true; |
| 195 | vars.log("Split on collected key: " + vars.latestKeyKey); | 302 | vars.log("Split on collected key: " + vars.latestKeyKey); |
| @@ -199,7 +306,12 @@ split | |||
| 199 | } | 306 | } |
| 200 | else if (vars.latestCollectible.Current != vars.latestCollectible.Old) | 307 | else if (vars.latestCollectible.Current != vars.latestCollectible.Old) |
| 201 | { | 308 | { |
| 202 | if (vars.latestCollectible.Current.EndsWith("Painting")) | 309 | if (vars.importantCollectibles.Contains(vars.latestCollectible.Current)) |
| 310 | { | ||
| 311 | should_split = true; | ||
| 312 | vars.log("Split on configured collectible: " + vars.latestCollectible.Current); | ||
| 313 | } | ||
| 314 | else if (vars.latestCollectible.Current.EndsWith("Painting")) | ||
| 203 | { | 315 | { |
| 204 | if (settings["paintings"]) | 316 | if (settings["paintings"]) |
| 205 | { | 317 | { |
