|
1 | | -using System; |
| 1 | +// Visual Pinball Engine |
| 2 | +// Copyright (C) 2021 freezy and VPE Team |
| 3 | +// |
| 4 | +// This program is free software: you can redistribute it and/or modify |
| 5 | +// it under the terms of the GNU General Public License as published by |
| 6 | +// the Free Software Foundation, either version 3 of the License, or |
| 7 | +// (at your option) any later version. |
| 8 | +// |
| 9 | +// This program is distributed in the hope that it will be useful, |
| 10 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +// GNU General Public License for more details. |
| 13 | +// |
| 14 | +// You should have received a copy of the GNU General Public License |
| 15 | +// along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +using System; |
2 | 18 | using System.Collections.Generic; |
3 | 19 | using Unity.VisualScripting; |
4 | 20 | using VisualPinball.Unity; |
5 | 21 |
|
6 | 22 | namespace VisualPinball.Unity.VisualScripting |
7 | 23 | { |
8 | | - [Widget(typeof(GetLampValueUnit))] |
9 | | - public sealed class GetLampValueUnitWidget : UnitWidget<GetLampValueUnit> |
10 | | - { |
11 | | - public GetLampValueUnitWidget(FlowCanvas canvas, GetLampValueUnit unit) : base(canvas, unit) |
12 | | - { |
13 | | - lampIdInspectorConstructor = (metadata) => new VariableNameInspector(metadata, GetNameSuggestions); |
14 | | - } |
| 24 | + [Widget(typeof(GetLampValueUnit))] |
| 25 | + public sealed class GetLampValueUnitWidget : UnitWidget<GetLampValueUnit> |
| 26 | + { |
| 27 | + public GetLampValueUnitWidget(FlowCanvas canvas, GetLampValueUnit unit) : base(canvas, unit) |
| 28 | + { |
| 29 | + lampIdInspectorConstructor = (metadata) => new VariableNameInspector(metadata, GetNameSuggestions); |
| 30 | + } |
15 | 31 |
|
16 | | - protected override NodeColorMix baseColor => NodeColorMix.TealReadable; |
| 32 | + protected override NodeColorMix baseColor => NodeColorMix.TealReadable; |
17 | 33 |
|
18 | | - private VariableNameInspector lampIdInspector; |
19 | | - private Func<Metadata, VariableNameInspector> lampIdInspectorConstructor; |
| 34 | + private VariableNameInspector lampIdInspector; |
| 35 | + private Func<Metadata, VariableNameInspector> lampIdInspectorConstructor; |
20 | 36 |
|
21 | | - public override Inspector GetPortInspector(IUnitPort port, Metadata metadata) |
22 | | - { |
23 | | - if (port == unit.id) { |
24 | | - InspectorProvider.instance.Renew(ref lampIdInspector, metadata, lampIdInspectorConstructor); |
| 37 | + public override Inspector GetPortInspector(IUnitPort port, Metadata metadata) |
| 38 | + { |
| 39 | + if (port == unit.id) { |
| 40 | + InspectorProvider.instance.Renew(ref lampIdInspector, metadata, lampIdInspectorConstructor); |
25 | 41 |
|
26 | | - return lampIdInspector; |
27 | | - } |
| 42 | + return lampIdInspector; |
| 43 | + } |
28 | 44 |
|
29 | | - return base.GetPortInspector(port, metadata); |
30 | | - } |
| 45 | + return base.GetPortInspector(port, metadata); |
| 46 | + } |
31 | 47 |
|
32 | | - private IEnumerable<string> GetNameSuggestions() |
33 | | - { |
34 | | - var list = new List<string>(); |
| 48 | + private IEnumerable<string> GetNameSuggestions() |
| 49 | + { |
| 50 | + var list = new List<string>(); |
35 | 51 |
|
36 | | - var tableComponent = TableSelector.Instance.SelectedTable; |
| 52 | + var tableComponent = TableSelector.Instance.SelectedTable; |
37 | 53 |
|
38 | | - if (tableComponent != null) { |
39 | | - var gle = tableComponent.gameObject.GetComponent<IGamelogicEngine>(); |
| 54 | + if (tableComponent != null) { |
| 55 | + var gle = tableComponent.gameObject.GetComponent<IGamelogicEngine>(); |
40 | 56 |
|
41 | | - if (gle != null) { |
42 | | - foreach (var lamp in gle.AvailableLamps) { |
43 | | - list.Add(lamp.Id); |
44 | | - } |
45 | | - } |
46 | | - } |
| 57 | + if (gle != null) { |
| 58 | + foreach (var lamp in gle.AvailableLamps) { |
| 59 | + list.Add(lamp.Id); |
| 60 | + } |
| 61 | + } |
| 62 | + } |
47 | 63 |
|
48 | | - return list; |
49 | | - } |
50 | | - } |
| 64 | + return list; |
| 65 | + } |
| 66 | + } |
51 | 67 | } |
0 commit comments