diff --git a/Source/ClassLibraryCommon/ClassLibraryCommon.csproj b/Source/ClassLibraryCommon/ClassLibraryCommon.csproj index f8ad2bb86..cdb23269f 100644 --- a/Source/ClassLibraryCommon/ClassLibraryCommon.csproj +++ b/Source/ClassLibraryCommon/ClassLibraryCommon.csproj @@ -1,4 +1,4 @@ - + net6.0-windows Library diff --git a/Source/ClassLibraryCommon/DCSAircraft.cs b/Source/ClassLibraryCommon/DCSAircraft.cs index c549f6340..48434d654 100644 --- a/Source/ClassLibraryCommon/DCSAircraft.cs +++ b/Source/ClassLibraryCommon/DCSAircraft.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; + using System.Reflection; /// /// Holds information about currently selected aircraft / module (DCS aircraft/helicopter). @@ -105,13 +106,13 @@ private static void AddInternalModules() public static void FillModulesListFromDcsBios(string dcsbiosJsonFolder, bool loadMetaFiles = false, bool loadInternalModules = true) { - var biosLua = Path.Combine(dcsbiosJsonFolder, "..\\..\\", "BIOS.lua"); - - if (!File.Exists(biosLua)) + var dcsbiosConfigFile = $"{AppDomain.CurrentDomain.BaseDirectory}dcs-bios_modules.txt"; + if (!File.Exists(dcsbiosConfigFile)) { + LogErrorAndThrowException($"Failed to find {dcsbiosConfigFile}"); return; } - + lock (Lock) { ModulesList.Clear(); @@ -121,50 +122,34 @@ public static void FillModulesListFromDcsBios(string dcsbiosJsonFolder, bool loa } } - var stringArray = File.ReadAllLines(biosLua); + var stringArray = File.ReadAllLines(dcsbiosConfigFile); - var searchFilterList = new List() - { - "MetadataEnd", - "MetadataStart", - "CommonData" - }; + //Inject these static DCS-BIOS modules - var metaFileId = 500; + lock (Lock) + { + ModulesList.Add(new DCSAircraft(500, "MetadataEnd", "MetadataEnd.json")); + ModulesList.Add(new DCSAircraft(501, "MetadataStart", "MetadataStart.json")); + ModulesList.Add(new DCSAircraft(502, "CommonData", "CommonData.json")); + } - // dofile(lfs.writedir()..[[Scripts\DCS-BIOS\lib\A-10C.lua]]) -- ID = 5, ProperName = A-10C Thunderbolt II + // A-10C|5|A-10C Thunderbolt/II foreach (var s in stringArray) { - if (!s.StartsWith("--") && s.ToLower().Contains(@"dofile(lfs.writedir()..[[Scripts\DCS-BIOS\lib\".ToLower()) && s.Contains("ProperName")) + if (!s.StartsWith("--") && s.Contains('|')) { - var parts = s.Split(new string[] { "--" }, StringSplitOptions.RemoveEmptyEntries); + var parts = s.Split(new [] { "|" }, StringSplitOptions.RemoveEmptyEntries); - // dofile(lfs.writedir()..[[Scripts\DCS-BIOS\lib\A-10C.lua]]) - var json = parts[0].ToLower().Replace(@"dofile(lfs.writedir()..[[Scripts\DCS-BIOS\lib\".ToLower(), string.Empty).Replace(".lua]])", string.Empty).Trim() + ".json"; - // ID = 5, ProperName = A-10C Thunderbolt II - var info = parts[1].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); - - // ID = 5 - var id = int.Parse(info[0].Split(new[] { "=" }, StringSplitOptions.None)[1]); - - // ProperName = A-10C Thunderbolt II - var properName = info[1].Split(new[] { "=" }, StringSplitOptions.None)[1].Trim(); + var json = parts[0]+ ".json"; + var id = int.Parse(parts[1]); + var properName = parts[2]; lock (Lock) { ModulesList.Add(new DCSAircraft(id, properName, json)); } } - else if (loadMetaFiles && searchFilterList.Any(o => s.Contains(o))) - { - var json = s.ToLower().Replace(@"dofile(lfs.writedir()..[[Scripts\DCS-BIOS\lib\".ToLower(), string.Empty).Replace(".lua]])", string.Empty).Trim() + ".json"; - var properName = json.Replace(".json", ""); - lock (Lock) - { - ModulesList.Add(new DCSAircraft(metaFileId++, properName, json)); - } - } } } diff --git a/Source/DCS-BIOS/DCSBIOSConstants.cs b/Source/DCS-BIOS/DCSBIOSConstants.cs index eafb8c221..0a2f769e5 100644 --- a/Source/DCS-BIOS/DCSBIOSConstants.cs +++ b/Source/DCS-BIOS/DCSBIOSConstants.cs @@ -1,7 +1,8 @@ namespace DCS_BIOS { - internal class DCSBIOSConstants + public static class DCSBIOSConstants { - internal const int MAX_VALUE = 65535; + public const int MAX_VALUE = 65535; + public const int META_MODULE_START_RANGE = 500; } } diff --git a/Source/DCSFlightpanels/DCSFlightpanels.csproj b/Source/DCSFlightpanels/DCSFlightpanels.csproj index 57a04f9c0..7ad9e417e 100644 --- a/Source/DCSFlightpanels/DCSFlightpanels.csproj +++ b/Source/DCSFlightpanels/DCSFlightpanels.csproj @@ -89,6 +89,9 @@ + + Always + @@ -110,6 +113,7 @@ + diff --git a/Source/DCSFlightpanels/Windows/ChooseProfileModuleWindow.xaml.cs b/Source/DCSFlightpanels/Windows/ChooseProfileModuleWindow.xaml.cs index 7b8c08c4f..5b5e906e2 100644 --- a/Source/DCSFlightpanels/Windows/ChooseProfileModuleWindow.xaml.cs +++ b/Source/DCSFlightpanels/Windows/ChooseProfileModuleWindow.xaml.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -66,12 +67,12 @@ private void PopulateAirframeCombobox() ComboBoxAirframe.Items.Clear(); foreach (var module in DCSAircraft.Modules) { - if (!DCSAircraft.IsNoFrameLoadedYet(module)) //!DCSAircraft.IsNS430(module) && + if (!DCSAircraft.IsNoFrameLoadedYet(module) && module.ID < DCSBIOSConstants.META_MODULE_START_RANGE) //!DCSAircraft.IsNS430(module) && { itemsSource.Add(module); } } - + itemsSource = itemsSource.OrderBy(o => o.Description).ToList(); ComboBoxAirframe.DisplayMemberPath = "Description"; ComboBoxAirframe.ItemsSource = itemsSource; ComboBoxAirframe.SelectedIndex = 0; diff --git a/Source/DCSFlightpanels/dcs-bios_modules.txt b/Source/DCSFlightpanels/dcs-bios_modules.txt new file mode 100644 index 000000000..2d494749f --- /dev/null +++ b/Source/DCSFlightpanels/dcs-bios_modules.txt @@ -0,0 +1,49 @@ +-- Following text is used by DCSFlightpanels GUI to pick up DCS-BIOS modules. +-- ID range 1-3 is used internally in DCSFlightpanels. New modules must have an uniques ID. + +-- Format: +-- Module(JSON Name)|ID|Pretty Name + +FC3|4|Flaming Cliffs 3 +A-10C|5|A-10C Thunderbolt/II +A-4E-C|6|A-4E Skyhawk +AH-6J|7|AH-6J Littlebird +AJS37|8|AJS-37 Viggen +Alphajet|9|Alphajet +AV8BNA|10|AV-8B Night Attack +Bf-109K-4|11|Bf 109 K-4 Kurfurst +C-101|12|C-101 Aviojet +MirageF1|13|Mirage F1 +Christen Eagle II|14|Christen Eagle II +Edge540|15|Edge 540 +F-14|16|F-14A/B Tomcat +F-16C_50|17|F-16C Viper +F-5E-3|18|F-5E Tiger II +F-86F Sabre|19|F-86F Sabre +FA-18C_hornet|20|F/A-18C Hornet +FW-190A8|21|Fw 190 A-8 Anton +FW-190D9|22|Fw 190 D-9 Dora +I-16|23|I-16 +JF-17|24|JF-17 Thunder +Ka-50|25|Ka-50 Black Shark/III +L-39|26|L-39 Albatros +M-2000C|27|M-2000C +MB-339|28|MB-339A/PAN +Mi-8MT|29|Mi-8MT +Mig-15bis|30|MiG-15bis +Mig-19P|31|MiG-19P Farmer +Mig-21Bis|32|MiG-21bis +NS430|33|NS 430 GPS +P-47D|34|P-47D Thunderbolt +P-51D|35|TF/P-51D Mustang +SA342|36|SA342 Gazelle +SpitfireLFMkIX|37|Spitfire LF Mk. IX +UH-1H|38|UH-1H Huey +Yak-52|39|Yak-52 +F-22A|40|F-22A Raptor +A-29B|41|A-29B Super Tucano +Mi-24P|42|Mi-24P HIND +VNAO_T-45|43|T-45 Goshawk +F-15E|44|F-15E Strike Eagle +Mosquito|45|Mosquito FB Mk. VI +AH-64D|46|AH-64D Apache \ No newline at end of file