コード例 #1
0
        static void PrintDuplicateControlIdentifiers(List <DCSBIOSControl> dcsbiosControls, bool printAll = false)
        {
            var result = new List <string>();
            var dupes  = new List <string>();

            foreach (var dcsbiosControl in dcsbiosControls)
            {
                if (printAll)
                {
                    result.Add(dcsbiosControl.identifier);
                }

                //Debug.Print(dcsbiosControl.identifier);
                var found = false;
                foreach (var str in result)
                {
                    if (str.Trim() == dcsbiosControl.identifier.Trim())
                    {
                        found = true;
                    }
                }
                if (!found)
                {
                    result.Add(dcsbiosControl.identifier);
                }
                if (found)
                {
                    dupes.Add(dcsbiosControl.identifier);
                }
            }
            if (dupes.Count > 0)
            {
                var message = "Below is a list of duplicate identifiers found in the " + Airframe.GetDescription() + ".json profile (DCS-BIOS)\n";
                message = message + "The identifier must be unique, please correct the profile " + Airframe.GetDescription() + ".lua in the DCS-BIOS lib folder\n";
                message = message + "---------------------------------------------\n";
                foreach (var dupe in dupes)
                {
                    message = message + dupe + "\n";
                }
                message = message + "---------------------------------------------\n";
                Common.LogError(2000, message);
            }
        }
コード例 #2
0
 public static DCSBIOSControl GetControl(string controlId)
 {
     lock (LockObject)
     {
         if (Common.IsOperationModeFlagSet(OperationFlag.KeyboardEmulationOnly))
         {
             return(null);
         }
         try
         {
             LoadControls();
             if (_listOnce)
             {
                 /*_listOnce = false;
                  * foreach (var dcsbiosControl in _dcsbiosControls)
                  * {
                  *  if (dcsbiosControl.outputs.Count > 0)
                  *  {
                  *      Console.WriteLine(dcsbiosControl.identifier + " " + dcsbiosControl.outputs[0].address);
                  *  }
                  *  else
                  *  {
                  *      Console.WriteLine(dcsbiosControl.identifier);
                  *  }
                  * }*/
             }
             //PrintDuplicateControlIdentifiers(_dcsbiosControls, true);
             if (!_dcsbiosControls.Exists(controlObject => controlObject.identifier.Equals(controlId)))
             {
                 throw new Exception("Error, control " + controlId + " does not exist. (" + Airframe.GetDescription() + ".json");
             }
             return(_dcsbiosControls.Single(controlObject => controlObject.identifier.Equals(controlId)));
         }
         catch (InvalidOperationException ioe)
         {
             throw new Exception("Check DCS-BIOS version. Failed to find control " + controlId + " for airframe " + Airframe.GetDescription() + " (" + Airframe.GetDescription() + ".json). Did you switch airframe type for the profile and have existing control(s) for the previous type saved?" + Environment.NewLine + ioe.Message);
         }
     }
 }
コード例 #3
0
 public static DCSBIOSOutput GetDCSBIOSOutput(string controlId)
 {
     lock (_lockObject)
     {
         if (_airframe == DCSAirframe.NONE)
         {
             return(null);
         }
         try
         {
             var control       = GetControl(controlId);
             var dcsBIOSOutput = new DCSBIOSOutput();
             dcsBIOSOutput.Consume(control);
             return(dcsBIOSOutput);
         }
         catch (InvalidOperationException ioe)
         {
             throw new Exception("Failed to create DCSBIOSOutput based on control " + controlId + " for airframe " + Airframe.GetDescription() + "." + Environment.NewLine + ioe.Message);
         }
     }
 }
コード例 #4
0
 public static DCSBIOSOutput GetDCSBIOSOutput(string controlId)
 {
     lock (LockObject)
     {
         if (Common.IsOperationModeFlagSet(OperationFlag.KeyboardEmulationOnly))
         {
             throw new Exception("DCSBIOSControlLocator.GetDCSBIOSOutput() Should not be called when only key emulator is active");
         }
         try
         {
             var control       = GetControl(controlId);
             var dcsBIOSOutput = new DCSBIOSOutput();
             dcsBIOSOutput.Consume(control);
             return(dcsBIOSOutput);
         }
         catch (InvalidOperationException ioe)
         {
             throw new Exception("Check DCS-BIOS version. Failed to create DCSBIOSOutput based on control " + controlId + " for airframe " + Airframe.GetDescription() + " ( " + Airframe.GetDescription() + ".json)." + Environment.NewLine + ioe.Message);
         }
     }
 }
コード例 #5
0
 public static DCSBIOSControl GetControl(string controlId)
 {
     lock (_lockObject)
     {
         if (_airframe == DCSAirframe.NONE)
         {
             return(null);
         }
         try
         {
             LoadControls();
             return(_dcsbiosControls.Single(controlObject => controlObject.identifier.Equals(controlId)));
         }
         catch (InvalidOperationException ioe)
         {
             throw new Exception("Failed to find control " + controlId + " for airframe " + Airframe.GetDescription() + ". Did you switch airframe type for the profile and have existing control(s) for the previous type saved?" + Environment.NewLine + ioe.Message);
         }
     }
 }