Skip to content

Commit 62c7e88

Browse files
jsm174freezy
authored andcommitted
units: added coil units to mirror what we have for switches
1 parent a2a347c commit 62c7e88

27 files changed

+751
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Visual Pinball Engine
2+
// Copyright (C) 2022 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+
// ReSharper disable UnusedType.Global
18+
19+
using Unity.VisualScripting;
20+
21+
namespace VisualPinball.Unity.VisualScripting.Editor
22+
{
23+
[Descriptor(typeof(AllCoilsEnabledEventUnit))]
24+
public class AllCoilsEnabledEventUnitDescriptor : MultiUnitDescriptor<AllCoilsEnabledEventUnit>
25+
{
26+
public AllCoilsEnabledEventUnitDescriptor(AllCoilsEnabledEventUnit target) : base(target) { }
27+
protected override string ItemLabel(int id) => $"Coil ID {id}";
28+
protected override string ItemDescription(int id) => $"Coil ID {id} to look for enabled status.";
29+
protected override string DefinedSummary() => "This node triggers an event when the last coil in the list gets enabled.";
30+
protected override EditorTexture DefinedIcon() => EditorTexture.Single(Unity.Editor.Icons.CoilEvent);
31+
}
32+
}

Editor/Descriptors/AllCoilsEnabledEventUnitDescriptor.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Visual Pinball Engine
2+
// Copyright (C) 2022 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+
// ReSharper disable UnusedType.Global
18+
19+
using Unity.VisualScripting;
20+
21+
namespace VisualPinball.Unity.VisualScripting.Editor
22+
{
23+
[Descriptor(typeof(CoilEnabledEventUnit))]
24+
public class CoilEnabledEventUnitDescriptor : UnitDescriptor<CoilEnabledEventUnit>
25+
{
26+
public CoilEnabledEventUnitDescriptor(CoilEnabledEventUnit target) : base(target)
27+
{
28+
}
29+
30+
protected override string DefinedSummary()
31+
{
32+
return "This node triggers an event when a coil in the list of given ID is enabled.";
33+
}
34+
35+
protected override EditorTexture DefinedIcon() => EditorTexture.Single(Unity.Editor.Icons.CoilEvent);
36+
37+
protected override void DefinedPort(IUnitPort port, UnitPortDescription desc)
38+
{
39+
base.DefinedPort(port, desc);
40+
41+
if (int.TryParse(port.key, out int id)) {
42+
id += 1;
43+
44+
desc.label = $"Coil ID {id}";
45+
desc.summary = $"Coil ID {id} to look for enabled status.";
46+
}
47+
}
48+
}
49+
}

Editor/Descriptors/CoilEnabledEventUnitDescriptor.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Visual Pinball Engine
2+
// Copyright (C) 2022 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+
// ReSharper disable UnusedType.Global
18+
19+
using Unity.VisualScripting;
20+
21+
namespace VisualPinball.Unity.VisualScripting.Editor
22+
{
23+
[Descriptor(typeof(CoilEventUnit))]
24+
public class CoilEventUnitDescriptor : UnitDescriptor<CoilEventUnit>
25+
{
26+
public CoilEventUnitDescriptor(CoilEventUnit target) : base(target)
27+
{
28+
}
29+
30+
protected override string DefinedSummary()
31+
{
32+
return "This node triggers an event when a coil with a given ID changes.";
33+
}
34+
35+
protected override EditorTexture DefinedIcon() => EditorTexture.Single(Unity.Editor.Icons.CoilEvent);
36+
37+
protected override void DefinedPort(IUnitPort port, UnitPortDescription desc)
38+
{
39+
base.DefinedPort(port, desc);
40+
41+
if (port.key == nameof(CoilEventUnit.IsEnabled)) {
42+
desc.summary = "The new value of the coil, true if enabled, false otherwise.";
43+
}
44+
else if (int.TryParse(port.key, out int id)) {
45+
id += 1;
46+
47+
desc.label = $"Coil ID {id}";
48+
desc.summary = $"Coil ID {id} to look for a change status.";
49+
}
50+
}
51+
}
52+
}

Editor/Descriptors/CoilEventUnitDescriptor.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Visual Pinball Engine
2+
// Copyright (C) 2022 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+
// ReSharper disable UnusedType.Global
18+
19+
using Unity.VisualScripting;
20+
using VisualPinball.Unity.Editor;
21+
using IconSize = VisualPinball.Unity.Editor.IconSize;
22+
23+
namespace VisualPinball.Unity.VisualScripting.Editor
24+
{
25+
[Descriptor(typeof(GetCoilUnit))]
26+
public class GetCoilUnitDescriptor : UnitDescriptor<GetCoilUnit>
27+
{
28+
public GetCoilUnitDescriptor(GetCoilUnit target) : base(target)
29+
{
30+
}
31+
32+
protected override string DefinedSummary()
33+
{
34+
return "This node retrieves the current status of the coil.";
35+
}
36+
37+
protected override EditorTexture DefinedIcon() => EditorTexture.Single(Unity.Editor.Icons.Coil(IconSize.Large, IconColor.Orange));
38+
39+
protected override void DefinedPort(IUnitPort port, UnitPortDescription desc)
40+
{
41+
base.DefinedPort(port, desc);
42+
43+
switch (port.key) {
44+
case nameof(GetCoilUnit.Id):
45+
desc.summary = "Coil ID to check if enabled.";
46+
break;
47+
case nameof(GetCoilUnit.IsEnabled):
48+
desc.summary = "Whether the coil is enabled.";
49+
break;
50+
}
51+
}
52+
}
53+
}

Editor/Descriptors/GetCoilUnitDescriptor.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using Unity.VisualScripting;
4+
5+
namespace VisualPinball.Unity.VisualScripting.Editor
6+
{
7+
[Widget(typeof(AllCoilsEnabledEventUnit))]
8+
public sealed class AllCoilsEnabledEventUnitWidget : GleMultiUnitWidget<AllCoilsEnabledEventUnit>
9+
{
10+
public AllCoilsEnabledEventUnitWidget(FlowCanvas canvas, AllCoilsEnabledEventUnit unit) : base(canvas, unit)
11+
{
12+
}
13+
14+
protected override IEnumerable<string> IdSuggestions(IGamelogicEngine gle) => gle.RequestedCoils.Select(coil => coil.Id);
15+
}
16+
}

Editor/Widgets/AllCoilsEnabledEventUnitWidget.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Widgets/AllSwitchesEnabledEventUnitWidget.cs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public sealed class AllSwitchesEnabledEventUnitWidget : GleMultiUnitWidget<AllSw
1010
public AllSwitchesEnabledEventUnitWidget(FlowCanvas canvas, AllSwitchesEnabledEventUnit unit) : base(canvas, unit)
1111
{
1212
}
13+
1314
protected override IEnumerable<string> IdSuggestions(IGamelogicEngine gle) => gle.RequestedSwitches.Select(sw => sw.Id);
1415
}
1516
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Visual Pinball Engine
2+
// Copyright (C) 2022 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+
// ReSharper disable UnusedType.Global
18+
19+
using System.Collections.Generic;
20+
using System.Linq;
21+
using Unity.VisualScripting;
22+
23+
namespace VisualPinball.Unity.VisualScripting.Editor
24+
{
25+
[Widget(typeof(CoilEnabledEventUnit))]
26+
public sealed class CoilEnabledEventUnitWidget : GleMultiUnitWidget<CoilEnabledEventUnit>
27+
{
28+
public CoilEnabledEventUnitWidget(FlowCanvas canvas, CoilEnabledEventUnit unit) : base(canvas, unit)
29+
{
30+
}
31+
32+
protected override IEnumerable<string> IdSuggestions(IGamelogicEngine gle) => gle.RequestedCoils.Select(coil => coil.Id);
33+
}
34+
}

Editor/Widgets/CoilEnabledEventUnitWidget.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Widgets/CoilEventUnitWidget.cs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Visual Pinball Engine
2+
// Copyright (C) 2022 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+
// ReSharper disable UnusedType.Global
18+
19+
using System.Collections.Generic;
20+
using System.Linq;
21+
using Unity.VisualScripting;
22+
23+
namespace VisualPinball.Unity.VisualScripting.Editor
24+
{
25+
[Widget(typeof(CoilEventUnit))]
26+
public sealed class CoilEventUnitWidget : GleMultiUnitWidget<CoilEventUnit>
27+
{
28+
public CoilEventUnitWidget(FlowCanvas canvas, CoilEventUnit unit) : base(canvas, unit)
29+
{
30+
}
31+
32+
protected override IEnumerable<string> IdSuggestions(IGamelogicEngine gle) => gle.RequestedCoils.Select(coil => coil.Id);
33+
}
34+
}

Editor/Widgets/CoilEventUnitWidget.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)