Skip to content

Commit 1c007c2

Browse files
committed
api: Adapt to upstream changes.
1 parent 3dd69b1 commit 1c007c2

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

VisualPinball.Engine.Mpf.Unity/Editor/MpfGamelogicEngineInspector.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class MpfGamelogicEngineInspector : UnityEditor.Editor
2929
private bool _foldoutCoils;
3030
private bool _foldoutLamps;
3131

32-
private bool HasData => _mpfEngine.AvailableSwitches.Length + _mpfEngine.AvailableCoils.Length + _mpfEngine.AvailableLamps.Length > 0;
32+
private bool HasData => _mpfEngine.RequestedSwitches.Length + _mpfEngine.RequestedCoils.Length + _mpfEngine.RequestedLamps.Length > 0;
3333

3434
private void OnEnable()
3535
{
@@ -82,32 +82,32 @@ public override void OnInspectorGUI()
8282
};
8383

8484
// list switches, coils and lamps
85-
if (_mpfEngine.AvailableCoils.Length + _mpfEngine.AvailableSwitches.Length + _mpfEngine.AvailableLamps.Length > 0) {
85+
if (_mpfEngine.RequestedCoils.Length + _mpfEngine.RequestedSwitches.Length + _mpfEngine.RequestedLamps.Length > 0) {
8686
if (_foldoutSwitches = EditorGUILayout.BeginFoldoutHeaderGroup(_foldoutSwitches, "Switches")) {
87-
foreach (var sw in _mpfEngine.AvailableSwitches) {
87+
foreach (var sw in _mpfEngine.RequestedSwitches) {
8888
EditorGUILayout.LabelField(new GUIContent($" [{sw.InternalId}] {sw.Id} ", Icons.Switch(sw.NormallyClosed, IconSize.Small)));
8989
}
90-
if (_mpfEngine.AvailableSwitches.Length == 0) {
90+
if (_mpfEngine.RequestedSwitches.Length == 0) {
9191
EditorGUILayout.LabelField("No switches in this machine.", naStyle);
9292
}
9393
}
9494
EditorGUILayout.EndFoldoutHeaderGroup();
9595

9696
if (_foldoutCoils = EditorGUILayout.BeginFoldoutHeaderGroup(_foldoutCoils, "Coils")) {
97-
foreach (var sw in _mpfEngine.AvailableCoils) {
97+
foreach (var sw in _mpfEngine.RequestedCoils) {
9898
EditorGUILayout.LabelField(new GUIContent($" [{sw.InternalId}] {sw.Id} ", Icons.Coil(IconSize.Small)));
9999
}
100-
if (_mpfEngine.AvailableCoils.Length == 0) {
100+
if (_mpfEngine.RequestedCoils.Length == 0) {
101101
EditorGUILayout.LabelField("No coils in this machine.", naStyle);
102102
}
103103
}
104104
EditorGUILayout.EndFoldoutHeaderGroup();
105105

106106
if (_foldoutLamps = EditorGUILayout.BeginFoldoutHeaderGroup(_foldoutLamps, "Lamps")) {
107-
foreach (var sw in _mpfEngine.AvailableLamps) {
107+
foreach (var sw in _mpfEngine.RequestedLamps) {
108108
EditorGUILayout.LabelField(new GUIContent($" [{sw.InternalId}] {sw.Id} ", Icons.Light(IconSize.Small)));
109109
}
110-
if (_mpfEngine.AvailableLamps.Length == 0) {
110+
if (_mpfEngine.RequestedLamps.Length == 0) {
111111
EditorGUILayout.LabelField("No lamps in this machine.", naStyle);
112112
}
113113
}

VisualPinball.Engine.Mpf.Unity/Runtime/MpfGamelogicEngine.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ public class MpfGamelogicEngine : MonoBehaviour, IGamelogicEngine
2929
{
3030
public string Name { get; } = "Mission Pinball Framework";
3131

32-
public GamelogicEngineSwitch[] AvailableSwitches => availableSwitches;
33-
public GamelogicEngineCoil[] AvailableCoils => availableCoils;
34-
public GamelogicEngineLamp[] AvailableLamps => availableLamps;
32+
public GamelogicEngineSwitch[] RequestedSwitches => requiredSwitches;
33+
public GamelogicEngineCoil[] RequestedCoils => requiredCoils;
34+
public GamelogicEngineLamp[] RequestedLamps => requiredLamps;
3535
public GamelogicEngineWire[] AvailableWires => availableWires;
36+
3637
public event EventHandler<EventArgs> OnStarted;
3738
public event EventHandler<LampEventArgs> OnLampChanged;
3839
public event EventHandler<LampsEventArgs> OnLampsChanged;
3940
public event EventHandler<LampColorEventArgs> OnLampColorChanged;
4041
public event EventHandler<CoilEventArgs> OnCoilChanged;
41-
public event EventHandler<AvailableDisplays> OnDisplaysAvailable;
42+
public event EventHandler<RequestedDisplays> OnDisplaysRequested;
4243
public event EventHandler<DisplayFrameData> OnDisplayFrame;
4344
public event EventHandler<SwitchEventArgs2> OnSwitchChanged;
4445

@@ -47,9 +48,9 @@ public class MpfGamelogicEngine : MonoBehaviour, IGamelogicEngine
4748

4849
public string machineFolder;
4950

50-
[SerializeField] private GamelogicEngineSwitch[] availableSwitches = Array.Empty<GamelogicEngineSwitch>();
51-
[SerializeField] private GamelogicEngineCoil[] availableCoils = Array.Empty<GamelogicEngineCoil>();
52-
[SerializeField] private GamelogicEngineLamp[] availableLamps = Array.Empty<GamelogicEngineLamp>();
51+
[SerializeField] private GamelogicEngineSwitch[] requiredSwitches = Array.Empty<GamelogicEngineSwitch>();
52+
[SerializeField] private GamelogicEngineCoil[] requiredCoils = Array.Empty<GamelogicEngineCoil>();
53+
[SerializeField] private GamelogicEngineLamp[] requiredLamps = Array.Empty<GamelogicEngineLamp>();
5354
[SerializeField] private GamelogicEngineWire[] availableWires = Array.Empty<GamelogicEngineWire>();
5455

5556
private Player _player;
@@ -68,16 +69,16 @@ public void OnInit(Player player, TableApi tableApi, BallManager ballManager)
6869
{
6970
_player = player;
7071
_switchIds.Clear();
71-
foreach (var sw in availableSwitches) {
72+
foreach (var sw in requiredSwitches) {
7273
_switchIds[sw.Id] = sw.InternalId;
7374
_switchNames[sw.InternalId.ToString()] = sw.Id;
7475
}
7576
_coilNames.Clear();
76-
foreach (var coil in availableCoils) {
77+
foreach (var coil in requiredCoils) {
7778
_coilNames[coil.InternalId.ToString()] = coil.Id;
7879
}
7980
_lampNames.Clear();
80-
foreach (var lamp in availableLamps) {
81+
foreach (var lamp in requiredLamps) {
8182
_lampNames[lamp.InternalId.ToString()] = lamp.Id;
8283
}
8384
_api = new MpfApi(machineFolder);
@@ -144,9 +145,9 @@ public void GetMachineDescription()
144145
}
145146

146147
if (md != null) {
147-
availableSwitches = md.GetSwitches().ToArray();
148-
availableCoils = md.GetCoils().ToArray();
149-
availableLamps = md.GetLights().ToArray();
148+
requiredSwitches = md.GetSwitches().ToArray();
149+
requiredCoils = md.GetCoils().ToArray();
150+
requiredLamps = md.GetLights().ToArray();
150151
}
151152
}
152153

@@ -271,8 +272,8 @@ private void OnDmdFrame(object sender, SetDmdFrameRequest frame)
271272
foreach (var dmd in config.Dmds) {
272273
Logger.Info($"[MPF] Announcing display \"{dmd.Name}\" @ {dmd.Width}x{dmd.Height}");
273274
lock (_dispatchQueue) {
274-
_dispatchQueue.Enqueue(() => OnDisplaysAvailable?.Invoke(this,
275-
new AvailableDisplays(new DisplayConfig(dmd.Name, dmd.Width, dmd.Height, true))));
275+
_dispatchQueue.Enqueue(() => OnDisplaysRequested?.Invoke(this,
276+
new RequestedDisplays(new DisplayConfig(dmd.Name, dmd.Width, dmd.Height, true))));
276277
}
277278
}
278279
Logger.Info("[MPF] Displays announced.");

0 commit comments

Comments
 (0)