now correctly prioritizing binds files

4.0 > 3.0 > plain
This commit is contained in:
alterNERDtive 2021-05-22 18:40:50 +02:00
parent b99c857ccc
commit 0652fc84ab
2 changed files with 11 additions and 6 deletions

View file

@ -4,19 +4,20 @@
* optional `~bindsFile` parameter for the `loadbinds` plugin context: use that
to specify a binds file instead of auto-detecting it from the currently active
preset.
preset. (#18)
## Changed
* Updated the README to reflect that you need to load the game once, and that
you need to have changed at least a single bind.
you need to have changed at least a single bind. (#19)
* Updated the README to reflect that you have to use a single preset for all
sections if youre playing Odyssey.
## Fixed
* Now only reading the first line of `startPreset.start` to work correctly with
Odyssey.
Odyssey. (#15)
* Now correctly prioritizing `.4.0.binds` > `.3.0.binds` > `.binds`. (#20)
# 4.0 (2021-05-19)

View file

@ -299,12 +299,16 @@ namespace bindEDplugin
{
DirectoryInfo dirInfo = new DirectoryInfo(_bindingsDir);
FileInfo[] bindFiles = dirInfo.GetFiles()
.Where(i => Regex.Match(i.Name, $@"^{preset}(\.[34]\.0)?\.binds$").Success)
.OrderByDescending(p => p.LastWriteTime).ToArray();
.Where(i => Regex.Match(i.Name, $@"^{preset}\.[34]\.0\.binds$").Success)
.OrderByDescending(p => p.Name).ToArray();
if (bindFiles.Count() == 0)
{
throw new FileNotFoundException($"No bindings file found for preset '{preset}'. If this is a default preset, please change anything in Elites controls options.");
bindFiles = dirInfo.GetFiles($"{preset}.binds");
if (bindFiles.Count() == 0)
{
throw new FileNotFoundException($"No bindings file found for preset '{preset}'. If this is a default preset, please change anything in Elites controls options.");
}
}
return bindFiles[0].FullName;