Skip to content

Commit 29e4e4a

Browse files
authored
Merge pull request #521 from futureboxsystems/sound-upgrades
Sound upgrades
2 parents 50eac98 + aeacca0 commit 29e4e4a

File tree

76 files changed

+2797
-554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2797
-554
lines changed

VisualPinball.Unity/VisualPinball.Unity.Editor/AssetBrowser/AssetLibrary.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace VisualPinball.Unity.Editor
3030
/// This is the root node of the asset library.
3131
///
3232
/// The data itself is stored in a sub object, <see cref="_db"/>. This sub object contains
33-
/// references to the asset meta data, as well as the categories.
33+
/// references to the asset metadata, as well as the categories.
3434
/// </summary>
3535
[CreateAssetMenu(fileName = "Library", menuName = "Pinball/Asset Library", order = 300)]
3636
public class AssetLibrary : ScriptableObject, ISerializationCallbackReceiver

VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxSceneConverter.cs

+8
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ public GameObject Convert(bool applyPatch = true, string tableName = null)
163163

164164
ConfigurePlayer(componentLookup);
165165

166+
SetUpAudio();
167+
166168
// patch
167169
if (_applyPatch) {
168170
_patcher?.PostPatch(_tableGo);
@@ -523,6 +525,12 @@ private void CreateTrough(Dictionary<string, IMainComponent> components)
523525
InstantiateAndPersistPrefab(item, components);
524526
}
525527

528+
private void SetUpAudio()
529+
{
530+
_tableGo.AddComponent<CalloutCoordinator>();
531+
_tableGo.AddComponent<MusicCoordinator>();
532+
}
533+
526534
private void CreateFileHierarchy()
527535
{
528536
if (!Directory.Exists("Assets/Tables/")) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Visual Pinball Engine
2+
// Copyright (C) 2025 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 UnityEditor;
18+
using UnityEngine;
19+
using UnityEngine.UIElements;
20+
21+
namespace VisualPinball.Unity.Editor
22+
{
23+
[CanEditMultipleObjects]
24+
public class BinaryEventSoundInspector : SoundComponentInspector
25+
{
26+
[SerializeField]
27+
private VisualTreeAsset binaryEventSoundInspectorXml;
28+
29+
public override VisualElement CreateInspectorGUI()
30+
{
31+
var root = base.CreateInspectorGUI();
32+
var inspectorUi = binaryEventSoundInspectorXml.Instantiate();
33+
root.Add(inspectorUi);
34+
return root;
35+
}
36+
}
37+
}

VisualPinball.Unity/VisualPinball.Unity.Editor/Sound/BinaryEventSoundInspector.cs.meta

+15
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,4 @@
1+
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
2+
<uie:PropertyField binding-path="StartWhen" label="Start When" tooltip="When to start playing the sound" />
3+
<uie:PropertyField binding-path="StopWhen" label="Stop When" tooltip="When to stop playing the sound" />
4+
</ui:UXML>

VisualPinball.Unity/VisualPinball.Unity.Editor/Sound/BinaryEventSoundInspector.uxml.meta

+10
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,41 @@
1+
// Visual Pinball Engine
2+
// Copyright (C) 2025 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 InconsistentNaming
18+
19+
using UnityEditor;
20+
using UnityEngine;
21+
using UnityEngine.UIElements;
22+
23+
namespace VisualPinball.Unity.Editor
24+
{
25+
[CustomEditor(typeof(CalloutAsset)), CanEditMultipleObjects]
26+
public class CalloutAssetInspector : SoundAssetInspector
27+
{
28+
[SerializeField]
29+
private VisualTreeAsset _calloutAssetInspector;
30+
31+
public override VisualElement CreateInspectorGUI()
32+
{
33+
var root = new VisualElement();
34+
var baseUi = base.CreateInspectorGUI();
35+
root.Add(baseUi);
36+
var subUi = _calloutAssetInspector.Instantiate();
37+
root.Add(subUi);
38+
return root;
39+
}
40+
}
41+
}

VisualPinball.Unity/VisualPinball.Unity.Editor/Sound/CalloutAssetInspector.cs.meta

+15
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,3 @@
1+
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
2+
<uie:PropertyField binding-path="_volume" label="Volume" />
3+
</ui:UXML>

VisualPinball.Unity/VisualPinball.Unity.Editor/Sound/CalloutAssetInspector.uxml.meta

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

VisualPinball.Unity/VisualPinball.Unity.Editor/Sound/CoilSoundComponentInspector.cs VisualPinball.Unity/VisualPinball.Unity.Editor/Sound/CoilSoundInspector.cs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Visual Pinball Engine
2-
// Copyright (C) 2023 freezy and VPE Team
2+
// Copyright (C) 2025 freezy and VPE Team
33
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU General Public License as published by
@@ -23,15 +23,15 @@
2323
namespace VisualPinball.Unity.Editor
2424
{
2525
[CustomEditor(typeof(CoilSoundComponent)), CanEditMultipleObjects]
26-
public class CoilSoundComponentInspector : SoundComponentInspector
26+
public class CoilSoundInspector : BinaryEventSoundInspector
2727
{
2828
[SerializeField]
29-
private VisualTreeAsset inspectorXml;
29+
private VisualTreeAsset coilSoundInspectorXml;
3030

3131
public override VisualElement CreateInspectorGUI()
3232
{
3333
var root = base.CreateInspectorGUI();
34-
var inspectorUi = inspectorXml.Instantiate();
34+
var inspectorUi = coilSoundInspectorXml.Instantiate();
3535
root.Add(inspectorUi);
3636
var coilNameDropdown = root.Q<DropdownField>("coil-name");
3737
var coilNameProp = serializedObject.FindProperty(nameof(CoilSoundComponent.CoilName));
@@ -43,7 +43,11 @@ public override VisualElement CreateInspectorGUI()
4343
private Dictionary<string, string> GetAvailableCoils()
4444
{
4545
var targetComponent = target as Component;
46-
if (targetComponent != null && targetComponent.TryGetComponent<ICoilDeviceComponent>(out var coilDevice)) {
46+
if (
47+
targetComponent != null
48+
&& targetComponent.TryGetComponent<ICoilDeviceComponent>(out var coilDevice)
49+
)
50+
{
4751
return coilDevice.AvailableCoils.ToDictionary(
4852
i => i.Id,
4953
i => string.IsNullOrWhiteSpace(i.Description) ? i.Id : i.Description

VisualPinball.Unity/VisualPinball.Unity.Editor/Sound/CoilSoundInspector.cs.meta

+17
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,39 @@
1+
// Visual Pinball Engine
2+
// Copyright (C) 2025 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 UnityEditor;
18+
using UnityEngine;
19+
using UnityEngine.UIElements;
20+
21+
namespace VisualPinball.Unity.Editor
22+
{
23+
[CustomEditor(typeof(MusicAsset)), CanEditMultipleObjects]
24+
public class MusicAssetInspector : SoundAssetInspector
25+
{
26+
[SerializeField]
27+
private VisualTreeAsset _musicAssetInspectorAsset;
28+
29+
public override VisualElement CreateInspectorGUI()
30+
{
31+
var root = new VisualElement();
32+
var baseUi = base.CreateInspectorGUI();
33+
root.Add(baseUi);
34+
var subUi = _musicAssetInspectorAsset.Instantiate();
35+
root.Add(subUi);
36+
return root;
37+
}
38+
}
39+
}

VisualPinball.Unity/VisualPinball.Unity.Editor/Sound/MusicAssetInspector.cs.meta

+15
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,3 @@
1+
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
2+
<uie:PropertyField binding-path="_volume" label="Volume" />
3+
</ui:UXML>

VisualPinball.Unity/VisualPinball.Unity.Editor/Sound/MusicAssetInspector.uxml.meta

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

0 commit comments

Comments
 (0)