Skip to content

Commit 96006ea

Browse files
committed
data: Add switches to FG.
1 parent d7722c2 commit 96006ea

File tree

6 files changed

+94
-8
lines changed

6 files changed

+94
-8
lines changed

Editor/PinMameGamelogicEngineInspector.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
using UnityEditor;
1919
using UnityEngine;
2020
using VisualPinball.Engine.PinMAME.Games;
21+
using VisualPinball.Unity;
2122

2223
namespace VisualPinball.Engine.PinMAME.Editor
2324
{
2425
[CustomEditor(typeof(PinMameGamelogicEngine))]
2526
public class PinMameGamelogicEngineInspector : UnityEditor.Editor
2627
{
28+
private bool IsGameSet => _gle.Game != null;
29+
2730
private PinMameGamelogicEngine _gle;
2831
private PinMameGame[] _games;
2932
private string[] _gameNames;
@@ -32,6 +35,8 @@ public class PinMameGamelogicEngineInspector : UnityEditor.Editor
3235
private int _selectedGameIndex;
3336
private int _selectedRomIndex;
3437

38+
private TableAuthoring _tableAuthoring;
39+
3540
private PinMameRom Rom => _gle.Game.Roms[_selectedRomIndex];
3641

3742
private void OnEnable()
@@ -46,7 +51,11 @@ private void OnEnable()
4651
.Concat(_games.Select(g => g.Name))
4752
.ToArray();
4853

49-
if (_gle.Game != null) {
54+
if (_gle != null) {
55+
_tableAuthoring = _gle.gameObject.GetComponentInParent<TableAuthoring>();
56+
}
57+
58+
if (IsGameSet) {
5059
for (var i = 0; i < _games.Length; i++) {
5160
if (_games[i].Id == _gle.Game.Id) {
5261
_selectedGameIndex = i + 1;
@@ -101,6 +110,16 @@ public override void OnInspectorGUI()
101110
}
102111
EditorGUI.EndDisabledGroup();
103112

113+
EditorGUI.BeginDisabledGroup(!IsGameSet);
114+
if (GUILayout.Button("Populate Hardware")) {
115+
if (EditorUtility.DisplayDialog("Mission Pinball Framework", "This will clear all linked switches, coils and lamps and re-populate them. You sure you want to do that?", "Yes", "No")) {
116+
_tableAuthoring.RepopulateHardware(_gle);
117+
TableSelector.Instance.TableUpdated();
118+
SceneView.RepaintAll();
119+
}
120+
}
121+
EditorGUI.EndDisabledGroup();
122+
104123
// initial switches button
105124
EditorGUI.BeginDisabledGroup(!Application.isPlaying);
106125
EditorGUILayout.Space();

Editor/VisualPinball.Engine.PinMAME.Editor.asmdef

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"name": "VisualPinball.Engine.PinMAME.Editor",
33
"rootNamespace": "VisualPinball.Engine.PinMAME.Editor",
44
"references": [
5+
"VisualPinball.Engine",
6+
"VisualPinball.Unity",
7+
"VisualPinball.Unity.Editor",
58
"VisualPinball.Engine.PinMAME"
69
],
710
"includePlatforms": [ "Editor" ],

Runtime/Games/FlashGordon.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,49 @@ public class FlashGordon : Bally
4343
};
4444

4545
protected override GamelogicEngineSwitch[] Switches { get; } = {
46+
new GamelogicEngineSwitch("01") { Description = "2 Left & Right R.O. Buttons" },
47+
new GamelogicEngineSwitch("02") { Description = "3 Shooter Lane R.O. Buttons" },
48+
new GamelogicEngineSwitch("03") { Description = "Top Single Drop Target" },
49+
new GamelogicEngineSwitch("04") { Description = "Shooter Lane Rollover" },
50+
new GamelogicEngineSwitch("05") { Description = "Drop Target 50 Point Reb. (2)" },
51+
new GamelogicEngineSwitch("06") { Description = "Credit Button" },
52+
new GamelogicEngineSwitch("07") { Description = "Tilt (3)" },
53+
new GamelogicEngineSwitch("08") { Description = "Outhole" },
54+
new GamelogicEngineSwitch("09") { Description = "Coin III (right)" },
55+
new GamelogicEngineSwitch("10") { Description = "Coin I (left)" },
56+
new GamelogicEngineSwitch("11") { Description = "Coin II (middle)" },
57+
new GamelogicEngineSwitch("12") { Description = "Lower Right Side Target" },
58+
new GamelogicEngineSwitch("13") { Description = "Flip Feed Lane (right)" },
59+
new GamelogicEngineSwitch("14") { Description = "Flip Feed Lane (left)" },
60+
new GamelogicEngineSwitch("15") { Description = "Upper Right Side Target" },
61+
new GamelogicEngineSwitch("16") { Description = "Slam (2)" },
62+
new GamelogicEngineSwitch("17") { Description = "4 Drop Target A (bottom)" },
63+
new GamelogicEngineSwitch("18") { Description = "4 Drop Target B" },
64+
new GamelogicEngineSwitch("19") { Description = "4 Drop Target C" },
65+
new GamelogicEngineSwitch("20") { Description = "4 Drop Target D (top)" },
66+
new GamelogicEngineSwitch("21") { Description = "1 Drop Target (top)" },
67+
new GamelogicEngineSwitch("22") { Description = "2 Drop Target (middle)" },
68+
new GamelogicEngineSwitch("23") { Description = "3 Drop Target (bottom)" },
69+
new GamelogicEngineSwitch("24") { Description = "Top Target" },
70+
new GamelogicEngineSwitch("25") { Description = "1st Inline Drop Target" },
71+
new GamelogicEngineSwitch("26") { Description = "2nd Inline Drop Target" },
72+
new GamelogicEngineSwitch("27") { Description = "3rd Inline Drop Target" },
73+
new GamelogicEngineSwitch("28") { Description = "Inline Back Target" },
74+
new GamelogicEngineSwitch("29") { Description = "10 Point Rebound (2)" },
75+
new GamelogicEngineSwitch("30") { Description = "Saucer" },
76+
new GamelogicEngineSwitch("31") { Description = "Right Outlane" },
77+
new GamelogicEngineSwitch("32") { Description = "Left Outlane" },
78+
new GamelogicEngineSwitch("33") { Description = "Right Spinner" },
79+
new GamelogicEngineSwitch("34") { Description = "Left Spinner" },
80+
new GamelogicEngineSwitch("35") { Description = "Right Slingshot" },
81+
new GamelogicEngineSwitch("36") { Description = "Left Slingshot" },
82+
new GamelogicEngineSwitch("37") { Description = "Top Thumper Bumper" },
83+
new GamelogicEngineSwitch("39") { Description = "Right Thumper Bumper" },
84+
new GamelogicEngineSwitch("40") { Description = "Left Thumper Bumper" },
4685
};
4786

4887
public override GamelogicEngineLamp[] AvailableLamps { get; } = {
88+
4989
};
5090

5191
protected override GamelogicEngineCoil[] GameCoils { get; } = {

Runtime/Games/Terminator2.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ public class Terminator2 : Wpc
4747
protected override GamelogicEngineSwitch[] Switches { get; } = {
4848
new GamelogicEngineSwitch("13") { Description = "Start Button", InputActionHint = InputConstants.ActionStartGame },
4949
new GamelogicEngineSwitch("14") { Description = "Plumb Bob Tilt" },
50-
new GamelogicEngineSwitch("15") { Description = "Trough Left", DeviceHint = "^Trough\\s*\\d?", DeviceItemHint = "1" },
51-
new GamelogicEngineSwitch("16") { Description = "Trough Center", DeviceHint = "^Trough\\s*\\d?", DeviceItemHint = "2" },
52-
new GamelogicEngineSwitch("17") { Description = "Trough Right", DeviceHint = "^Trough\\s*\\d?", DeviceItemHint = "3" },
53-
new GamelogicEngineSwitch("18") { Description = "Outhole" },
50+
new GamelogicEngineSwitch("15") { Description = "Trough Left", DeviceHint = "^Trough\\s*\\d?", DeviceItemHint = "2" },
51+
new GamelogicEngineSwitch("16") { Description = "Trough Center", DeviceHint = "^Trough\\s*\\d?", DeviceItemHint = "3" },
52+
new GamelogicEngineSwitch("17") { Description = "Trough Right", DeviceHint = "^Trough\\s*\\d?", DeviceItemHint = "4" },
53+
new GamelogicEngineSwitch("18") { Description = "Outhole", DeviceHint = "^Trough\\s*\\d?", DeviceItemHint = "1" },
5454

5555
//new GamelogicEngineSwitch("21") { Description = "Slam Tilt" },
5656
new GamelogicEngineSwitch("22") { Description = "Coin Door Closed", NormallyClosed = true, InputActionHint = InputConstants.ActionCoinDoorOpenClose },
@@ -205,6 +205,12 @@ public class Terminator2 : Wpc
205205
new GamelogicEngineCoil("26") { Description = "Left Popper Flashlamps", IsLamp = true },
206206
new GamelogicEngineCoil("27") { Description = "Right Popper" },
207207
new GamelogicEngineCoil("28") { Description = "Flashlamps Drop Target" },
208+
209+
new GamelogicEngineCoil(CoilFlipperLowerRight, 46) { Description = "Lower Right Flipper", PlayfieldItemHint = "^RightFlipper$"},
210+
new GamelogicEngineCoil(CoilFlipperLowerLeft, 48) { Description = "Lower Left Flipper", PlayfieldItemHint = "^LeftFlipper$"},
211+
212+
new GamelogicEngineCoil(CoilFlipperUpperRight, 34) { IsUnused = true },
213+
new GamelogicEngineCoil(CoilFlipperUpperLeft, 36) { IsUnused = true },
208214
};
209215
}
210216
}

Runtime/MPUs/Wpc.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ namespace VisualPinball.Engine.PinMAME.MPUs
2222
{
2323
public abstract class Wpc : PinMameGame
2424
{
25-
public override GamelogicEngineSwitch[] AvailableSwitches => Switches.Concat(_switches).ToArray();
25+
public override GamelogicEngineSwitch[] AvailableSwitches => Concat(_switches, Switches);
2626

27-
protected override GamelogicEngineCoil[] Coils => GameCoils.Concat(_coils).ToArray();
27+
protected override GamelogicEngineCoil[] Coils => Concat(_coils, GameCoils);
2828
protected abstract GamelogicEngineCoil[] GameCoils { get; }
2929

3030

Runtime/PinMameGame.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

1717
using System;
18+
using System.Collections.Generic;
1819
using System.Linq;
1920
using VisualPinball.Engine.Game.Engines;
2021

@@ -65,7 +66,7 @@ public abstract class PinMameGame
6566
/// <summary>
6667
/// All available coils for that game
6768
/// </summary>
68-
public GamelogicEngineCoil[] AvailableCoils => Coils.Concat(_coils).ToArray();
69+
public GamelogicEngineCoil[] AvailableCoils => Concat(_coils, Coils);
6970

7071
/// <summary>
7172
/// Coils specific to the MPU
@@ -84,5 +85,22 @@ public abstract class PinMameGame
8485
new GamelogicEngineCoil(CoilFlipperUpperLeft, 36) { Description = "Upper Left Flipper"},
8586
};
8687

88+
protected GamelogicEngineCoil[] Concat(IEnumerable<GamelogicEngineCoil> parent, IEnumerable<GamelogicEngineCoil> children)
89+
{
90+
var c = parent.ToDictionary(s => s.InternalId, s => s);
91+
foreach (var child in children) {
92+
c[child.InternalId] = child;
93+
}
94+
return c.Values.ToArray();
95+
}
96+
97+
protected GamelogicEngineSwitch[] Concat(IEnumerable<GamelogicEngineSwitch> parent, IEnumerable<GamelogicEngineSwitch> children)
98+
{
99+
var c = parent.ToDictionary(s => s.InternalId, s => s);
100+
foreach (var child in children) {
101+
c[child.InternalId] = child;
102+
}
103+
return c.Values.ToArray();
104+
}
87105
}
88106
}

0 commit comments

Comments
 (0)