9
9
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
10
10
// SOFTWARE.
11
11
12
+ // ReSharper disable AssignmentInConditionalExpression
13
+
12
14
using System . IO ;
13
15
using UnityEditor ;
14
16
using UnityEngine ;
17
+ using VisualPinball . Unity . Editor ;
15
18
16
19
namespace VisualPinball . Engine . Mpf . Unity . Editor
17
20
{
18
21
[ CustomEditor ( typeof ( MpfGamelogicEngine ) ) ]
19
22
public class MpfGamelogicEngineInspector : UnityEditor . Editor
20
23
{
21
24
private MpfGamelogicEngine _mpfEngine ;
25
+ private bool _foldoutSwitches ;
26
+ private bool _foldoutCoils ;
27
+ private bool _foldoutLamps ;
22
28
23
29
private void OnEnable ( )
24
30
{
@@ -30,35 +36,59 @@ public override void OnInspectorGUI()
30
36
var pos = EditorGUILayout . GetControlRect ( true , 18f ) ;
31
37
pos = EditorGUI . PrefixLabel ( pos , new GUIContent ( "Machine Folder" ) ) ;
32
38
33
- if ( GUI . Button ( pos , _mpfEngine . MachineFolder , EditorStyles . objectField ) ) {
34
- var path = EditorUtility . OpenFolderPanel ( "Mission Pinball Framework: Choose machine folder" , _mpfEngine . MachineFolder , "" ) ;
39
+ if ( GUI . Button ( pos , _mpfEngine . machineFolder , EditorStyles . objectField ) ) {
40
+ var path = EditorUtility . OpenFolderPanel ( "Mission Pinball Framework: Choose machine folder" , _mpfEngine . machineFolder , "" ) ;
35
41
if ( ! string . IsNullOrWhiteSpace ( path ) ) {
36
- _mpfEngine . MachineFolder = path ;
42
+ _mpfEngine . machineFolder = path ;
37
43
}
38
44
}
39
45
40
46
if ( GUILayout . Button ( "Synchronize" ) ) {
41
- if ( ! Directory . Exists ( _mpfEngine . MachineFolder ) ) {
47
+ if ( ! Directory . Exists ( _mpfEngine . machineFolder ) ) {
42
48
EditorUtility . DisplayDialog ( "Mission Pinball Framework" , "Gotta choose a valid machine folder first!" , "Okay" ) ;
43
- } else if ( ! Directory . Exists ( Path . Combine ( _mpfEngine . MachineFolder , "config" ) ) ) {
44
- EditorUtility . DisplayDialog ( "Mission Pinball Framework" , $ "{ _mpfEngine . MachineFolder } doesn't seem a valid machine folder. We expect a \" config\" subfolder in there!", "Okay" ) ;
49
+ } else if ( ! Directory . Exists ( Path . Combine ( _mpfEngine . machineFolder , "config" ) ) ) {
50
+ EditorUtility . DisplayDialog ( "Mission Pinball Framework" , $ "{ _mpfEngine . machineFolder } doesn't seem a valid machine folder. We expect a \" config\" subfolder in there!", "Okay" ) ;
45
51
} else {
46
52
_mpfEngine . GetMachineDescription ( ) ;
47
53
}
48
54
}
49
55
50
- EditorGUILayout . LabelField ( "Switches" , new GUIStyle ( GUI . skin . label ) { fontStyle = FontStyle . Bold } ) ;
51
- foreach ( var switchDescription in _mpfEngine . MachineDescription . Switches ) {
52
- EditorGUILayout . LabelField ( switchDescription . HardwareNumber , switchDescription . Name ) ;
53
- }
56
+ var naStyle = new GUIStyle ( GUI . skin . label ) {
57
+ fontStyle = FontStyle . Italic
58
+ } ;
54
59
60
+ // list switches, coils and lamps
61
+ if ( _mpfEngine . AvailableCoils . Length + _mpfEngine . AvailableSwitches . Length + _mpfEngine . AvailableLamps . Length > 0 ) {
62
+ if ( _foldoutSwitches = EditorGUILayout . BeginFoldoutHeaderGroup ( _foldoutSwitches , "Switches" ) ) {
63
+ foreach ( var sw in _mpfEngine . AvailableSwitches ) {
64
+ EditorGUILayout . LabelField ( new GUIContent ( $ " [{ sw . InternalId } ] { sw . Id } ", Icons . Switch ( sw . NormallyClosed , IconSize . Small ) ) ) ;
65
+ }
66
+ if ( _mpfEngine . AvailableSwitches . Length == 0 ) {
67
+ EditorGUILayout . LabelField ( "No switches in this machine." , naStyle ) ;
68
+ }
69
+ }
70
+ EditorGUILayout . EndFoldoutHeaderGroup ( ) ;
55
71
56
- // if (GUILayout.Button("StartGame")) {
57
- // _mpfEngine.Client.Play();
58
- // }
59
- // if (GUILayout.Button("GetMachineDescription")) {
60
- // Debug.Log(_mpfEngine.Client.GetMachineDescription());
61
- // }
72
+ if ( _foldoutCoils = EditorGUILayout . BeginFoldoutHeaderGroup ( _foldoutCoils , "Coils" ) ) {
73
+ foreach ( var sw in _mpfEngine . AvailableCoils ) {
74
+ EditorGUILayout . LabelField ( new GUIContent ( $ " [{ sw . InternalId } ] { sw . Id } ", Icons . Coil ( IconSize . Small ) ) ) ;
75
+ }
76
+ if ( _mpfEngine . AvailableCoils . Length == 0 ) {
77
+ EditorGUILayout . LabelField ( "No coils in this machine." , naStyle ) ;
78
+ }
79
+ }
80
+ EditorGUILayout . EndFoldoutHeaderGroup ( ) ;
81
+
82
+ if ( _foldoutLamps = EditorGUILayout . BeginFoldoutHeaderGroup ( _foldoutLamps , "Lamps" ) ) {
83
+ foreach ( var sw in _mpfEngine . AvailableLamps ) {
84
+ EditorGUILayout . LabelField ( new GUIContent ( $ " [{ sw . InternalId } ] { sw . Id } ", Icons . Light ( IconSize . Small ) ) ) ;
85
+ }
86
+ if ( _mpfEngine . AvailableLamps . Length == 0 ) {
87
+ EditorGUILayout . LabelField ( "No lamps in this machine." , naStyle ) ;
88
+ }
89
+ }
90
+ EditorGUILayout . EndFoldoutHeaderGroup ( ) ;
91
+ }
62
92
}
63
93
}
64
94
}
0 commit comments