DirectOutputR1
DirectOutput framework R1 for virtual pinball cabinets.
Go to:
Overview 
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros Pages
LedControlConfigList.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
2 using System.Linq;
3 using DirectOutput.Cab;
4 using DirectOutput.Cab.Toys;
5 using DirectOutput.GlobalConfiguration;
6 using DirectOutput.Table;
7 using DirectOutput.Cab.Toys.LWEquivalent;
8 namespace DirectOutput.LedControl.Loader
9 {
10 
14  public class LedControlConfigList : List<LedControlConfig>
15  {
21  public Dictionary<int, TableConfig> GetTableConfigDictonary(string RomName)
22  {
23  Dictionary<int, TableConfig> D = new Dictionary<int, TableConfig>();
24 
25  bool FoundMatch = false;
26  foreach (LedControlConfig LCC in this)
27  {
28 
29  foreach (TableConfig TC in LCC.TableConfigurations)
30  {
31  if (RomName.ToUpper() == TC.ShortRomName.ToUpper())
32  {
33  D.Add(LCC.LedWizNumber, TC);
34  FoundMatch = true;
35  break;
36  }
37  }
38  }
39 
40  if (FoundMatch) return D;
41 
42  foreach (LedControlConfig LCC in this)
43  {
44 
45  foreach (TableConfig TC in LCC.TableConfigurations)
46  {
47  if (RomName.ToUpper().StartsWith("{0}_".Build(TC.ShortRomName.ToUpper())))
48  {
49  D.Add(LCC.LedWizNumber, TC);
50  FoundMatch = true;
51  break;
52  }
53  }
54  }
55 
56  if (FoundMatch) return D;
57 
58  foreach (LedControlConfig LCC in this)
59  {
60 
61  foreach (TableConfig TC in LCC.TableConfigurations)
62  {
63  if (RomName.StartsWith(TC.ShortRomName))
64  {
65  D.Add(LCC.LedWizNumber, TC);
66 
67  break;
68  }
69  }
70  }
71  return D;
72  }
73 
74 
82  public bool ContainsConfig(string RomName)
83  {
84  return GetTableConfigDictonary(RomName).Count > 0;
85 
86  }
87 
88 
94  public void LoadLedControlFiles(IList<string> LedControlFilenames, bool ThrowExceptions = false)
95  {
96  for (int i = 0; i < LedControlFilenames.Count; i++)
97  {
98  LoadLedControlFile(LedControlFilenames[i], i + 1, ThrowExceptions);
99  }
100  }
101 
107  public void LoadLedControlFiles(LedControlIniFileList LedControlIniFiles, bool ThrowExceptions = false)
108  {
109  foreach (LedControlIniFile F in LedControlIniFiles)
110  {
111  LoadLedControlFile(F.Filename, F.LedWizNumber, ThrowExceptions);
112  }
113  }
114 
115 
122  public void LoadLedControlFile(string LedControlFilename, int LedWizNumber, bool ThrowExceptions = false)
123  {
124  Log.Write("Loading LedControl file {0}".Build(LedControlFilename));
125 
126  LedControlConfig LCC = new LedControlConfig(LedControlFilename, LedWizNumber, ThrowExceptions);
127  Add(LCC);
128  }
129 
133  public LedControlConfigList() { }
134 
140  public LedControlConfigList(IList<string> LedControlFilenames, bool ThrowExceptions = false)
141  : this()
142  {
143  LoadLedControlFiles(LedControlFilenames, ThrowExceptions);
144  }
145 
151  public LedControlConfigList(LedControlIniFileList LedControlIniFiles, bool ThrowExceptions = false)
152  : this()
153  {
154  LoadLedControlFiles(LedControlIniFiles, ThrowExceptions);
155  }
156 
157  }
158 }