Skip to content

Commit b71a688

Browse files
committed
display: Add 9-segment support.
1 parent 7877d3b commit b71a688

File tree

2 files changed

+49
-34
lines changed

2 files changed

+49
-34
lines changed

VisualPinball.Engine.PinMAME.Unity/Editor/PinMameGamelogicEngineInspector.cs

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,15 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

17-
using System;
17+
// ReSharper disable CheckNamespace
18+
1819
using System.Collections.Generic;
1920
using System.Linq;
20-
using System.Threading;
21-
using System.Threading.Tasks;
22-
using PinMame;
2321
using UnityEditor;
2422
using UnityEngine;
2523
using VisualPinball.Engine.PinMAME.Games;
2624
using VisualPinball.Unity;
2725
using VisualPinball.Unity.Editor;
28-
using Object = UnityEngine.Object;
2926

3027
namespace VisualPinball.Engine.PinMAME.Editor
3128
{
@@ -43,7 +40,6 @@ public class PinMameGamelogicEngineInspector : UnityEditor.Editor
4340
private int _selectedRomIndex;
4441

4542
private TableAuthoring _tableAuthoring;
46-
private PinMame.PinMame _pinMame;
4743

4844
private PinMameRom Rom => _gle.Game.Roms[_selectedRomIndex];
4945

@@ -85,21 +81,23 @@ private void OnEnable()
8581
public override void OnInspectorGUI()
8682
{
8783
// game dropdown
88-
EditorGUI.BeginChangeCheck();
89-
_selectedGameIndex = EditorGUILayout.Popup("Game", _selectedGameIndex, _gameNames);
90-
if (EditorGUI.EndChangeCheck()) {
91-
_selectedRomIndex = 0;
92-
if (_selectedGameIndex > 0) {
93-
_gle.Game = _games[_selectedGameIndex - 1];
94-
_gle.romId = Rom.Id;
95-
_romNames = _gle.Game.Roms.Select(g => g.ToString()).ToArray();
96-
97-
} else {
98-
_gle.Game = null;
99-
_gle.romId = string.Empty;
100-
_romNames = new string[0];
101-
}
102-
}
84+
_gle.romId = EditorGUILayout.TextField("ROM ID", _gle.romId);
85+
86+
// EditorGUI.BeginChangeCheck();
87+
// _selectedGameIndex = EditorGUILayout.Popup("Game", _selectedGameIndex, _gameNames);
88+
// if (EditorGUI.EndChangeCheck()) {
89+
// _selectedRomIndex = 0;
90+
// if (_selectedGameIndex > 0) {
91+
// _gle.Game = _games[_selectedGameIndex - 1];
92+
// _gle.romId = Rom.Id;
93+
// _romNames = _gle.Game.Roms.Select(g => g.ToString()).ToArray();
94+
//
95+
// } else {
96+
// _gle.Game = null;
97+
// _gle.romId = string.Empty;
98+
// _romNames = new string[0];
99+
// }
100+
// }
103101

104102
// rom dropdown
105103
EditorGUI.BeginDisabledGroup(_gle.Game == null);
@@ -191,8 +189,8 @@ private void CreateDisplays(IEnumerable<DisplayAuthoring> sceneDisplays)
191189

192190
if (layout.IsDmd) {
193191
var auth = !displayGameObjects.ContainsKey(id)
194-
? go.AddComponent<DmdAuthoring>()
195-
: go.GetComponent<DmdAuthoring>();
192+
? go.AddComponent<DotMatrixDisplayAuthoring>()
193+
: go.GetComponent<DotMatrixDisplayAuthoring>();
196194

197195
auth.Id = id;
198196
auth.Width = layout.width;

VisualPinball.Engine.PinMAME.Unity/Runtime/PinMameGamelogicEngine.cs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

17+
// ReSharper disable CheckNamespace
18+
// ReSharper disable InconsistentNaming
19+
// ReSharper disable PossibleNullReferenceException
20+
1721
using System;
1822
using System.Collections.Generic;
1923
using System.Linq;
@@ -311,13 +315,6 @@ private Dictionary<byte, byte> GetMap(PinMameDisplayLayout displayLayout)
311315
private static DisplayFrameFormat GetDisplayType(PinMameDisplayType dp)
312316
{
313317
switch (dp) {
314-
case PinMameDisplayType.SEG16: // 16 segments
315-
case PinMameDisplayType.SEG16R: // 16 segments with comma and period reversed
316-
case PinMameDisplayType.SEG16N: // 16 segments without commas
317-
case PinMameDisplayType.SEG16D: // 16 segments with periods only
318-
case PinMameDisplayType.SEG16S: // 16 segments with split top and bottom line
319-
return DisplayFrameFormat.Segment16;
320-
321318
case PinMameDisplayType.SEG8: // 7 segments and comma
322319
case PinMameDisplayType.SEG8D: // 7 segments and period
323320
case PinMameDisplayType.SEG7: // 7 segments
@@ -328,19 +325,39 @@ private static DisplayFrameFormat GetDisplayType(PinMameDisplayType dp)
328325
return DisplayFrameFormat.Segment7;
329326

330327
case PinMameDisplayType.SEG10: // 9 segments and comma
331-
break;
332328
case PinMameDisplayType.SEG9: // 9 segments
333-
break;
334329
case PinMameDisplayType.SEG98: // 9 segments, comma every three
335-
break;
336330
case PinMameDisplayType.SEG98F: // 9 segments, forced comma every three
337-
break;
331+
return DisplayFrameFormat.Segment9;
332+
333+
case PinMameDisplayType.SEG16: // 16 segments
334+
case PinMameDisplayType.SEG16R: // 16 segments with comma and period reversed
335+
case PinMameDisplayType.SEG16N: // 16 segments without commas
336+
case PinMameDisplayType.SEG16D: // 16 segments with periods only
337+
case PinMameDisplayType.SEG16S: // 16 segments with split top and bottom line
338+
return DisplayFrameFormat.Segment16;
338339

339340
case PinMameDisplayType.DMD:
340341
return DisplayFrameFormat.Dmd2;
341342

342343
case PinMameDisplayType.VIDEO:
343344
break;
345+
346+
case PinMameDisplayType.SEGALL:
347+
case PinMameDisplayType.IMPORT:
348+
case PinMameDisplayType.SEGMASK:
349+
case PinMameDisplayType.SEGHIBIT:
350+
case PinMameDisplayType.SEGREV:
351+
case PinMameDisplayType.DMDNOAA:
352+
case PinMameDisplayType.NODISP:
353+
case PinMameDisplayType.SEG8H:
354+
case PinMameDisplayType.SEG7H:
355+
case PinMameDisplayType.SEG87H:
356+
case PinMameDisplayType.SEG87FH:
357+
case PinMameDisplayType.SEG7SH:
358+
case PinMameDisplayType.SEG7SCH:
359+
throw new ArgumentOutOfRangeException(nameof(dp), dp, null);
360+
344361
default:
345362
throw new ArgumentOutOfRangeException(nameof(dp), dp, null);
346363
}

0 commit comments

Comments
 (0)