Allow cash ticking sound to overlap
This commit is contained in:
committed by
Matthias Mailänder
parent
fde4f8d0e5
commit
347148e02f
@@ -33,7 +33,7 @@ namespace OpenRA.GameRules
|
|||||||
{
|
{
|
||||||
FieldLoader.Load(this, y);
|
FieldLoader.Load(this, y);
|
||||||
|
|
||||||
VoicePools = Exts.Lazy(() => Voices.ToDictionary(a => a.Key, a => new SoundPool(1f, false, a.Value)));
|
VoicePools = Exts.Lazy(() => Voices.ToDictionary(a => a.Key, a => new SoundPool(1f, SoundPool.DefaultInterruptType, a.Value)));
|
||||||
NotificationsPools = Exts.Lazy(() => ParseSoundPool(y, "Notifications"));
|
NotificationsPools = Exts.Lazy(() => ParseSoundPool(y, "Notifications"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,17 +44,17 @@ namespace OpenRA.GameRules
|
|||||||
foreach (var t in classifiction.Value.Nodes)
|
foreach (var t in classifiction.Value.Nodes)
|
||||||
{
|
{
|
||||||
var volumeModifier = 1f;
|
var volumeModifier = 1f;
|
||||||
var volumeModifierNode = t.Value.Nodes.FirstOrDefault(x => x.Key == "VolumeModifier");
|
var volumeModifierNode = t.Value.Nodes.FirstOrDefault(x => x.Key == nameof(SoundPool.VolumeModifier));
|
||||||
if (volumeModifierNode != null)
|
if (volumeModifierNode != null)
|
||||||
volumeModifier = FieldLoader.GetValue<float>(volumeModifierNode.Key, volumeModifierNode.Value.Value);
|
volumeModifier = FieldLoader.GetValue<float>(volumeModifierNode.Key, volumeModifierNode.Value.Value);
|
||||||
|
|
||||||
var allowInterrupt = false;
|
var interruptType = SoundPool.DefaultInterruptType;
|
||||||
var allowInterruptNode = t.Value.Nodes.FirstOrDefault(x => x.Key == "AllowInterrupt");
|
var interruptTypeNode = t.Value.Nodes.FirstOrDefault(x => x.Key == nameof(SoundPool.InterruptType));
|
||||||
if (allowInterruptNode != null)
|
if (interruptTypeNode != null)
|
||||||
allowInterrupt = FieldLoader.GetValue<bool>(allowInterruptNode.Key, allowInterruptNode.Value.Value);
|
interruptType = FieldLoader.GetValue<SoundPool.InterruptType>(interruptTypeNode.Key, interruptTypeNode.Value.Value);
|
||||||
|
|
||||||
var names = FieldLoader.GetValue<string[]>(t.Key, t.Value.Value);
|
var names = FieldLoader.GetValue<string[]>(t.Key, t.Value.Value);
|
||||||
var sp = new SoundPool(volumeModifier, allowInterrupt, names);
|
var sp = new SoundPool(volumeModifier, interruptType, names);
|
||||||
ret.Add(t.Key, sp);
|
ret.Add(t.Key, sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,15 +64,17 @@ namespace OpenRA.GameRules
|
|||||||
|
|
||||||
public class SoundPool
|
public class SoundPool
|
||||||
{
|
{
|
||||||
|
public enum InterruptType { DoNotPlay, Interrupt, Overlap }
|
||||||
|
public const InterruptType DefaultInterruptType = InterruptType.DoNotPlay;
|
||||||
public readonly float VolumeModifier;
|
public readonly float VolumeModifier;
|
||||||
public readonly bool AllowInterrupt;
|
public readonly InterruptType Type;
|
||||||
readonly string[] clips;
|
readonly string[] clips;
|
||||||
readonly List<string> liveclips = new List<string>();
|
readonly List<string> liveclips = new List<string>();
|
||||||
|
|
||||||
public SoundPool(float volumeModifier, bool allowInterrupt, params string[] clips)
|
public SoundPool(float volumeModifier, InterruptType interruptType, params string[] clips)
|
||||||
{
|
{
|
||||||
VolumeModifier = volumeModifier;
|
VolumeModifier = volumeModifier;
|
||||||
AllowInterrupt = allowInterrupt;
|
Type = interruptType;
|
||||||
this.clips = clips;
|
this.clips = clips;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -401,36 +401,49 @@ namespace OpenRA
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(name) && (p == null || p == p.World.LocalPlayer))
|
if (!string.IsNullOrEmpty(name) && (p == null || p == p.World.LocalPlayer))
|
||||||
{
|
{
|
||||||
if (currentNotifications.TryGetValue(name, out var currentNotification))
|
ISound PlaySound()
|
||||||
{
|
{
|
||||||
if (!currentNotification.Complete)
|
var volume = InternalSoundVolume * volumeModifier * pool.VolumeModifier;
|
||||||
|
return soundEngine.Play2D(sounds[name], false, relative, pos, volume, attenuateVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pool.Type == SoundPool.InterruptType.Overlap)
|
||||||
|
{
|
||||||
|
if (PlaySound() == null)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (voicedActor == null)
|
||||||
|
{
|
||||||
|
if (currentNotifications.TryGetValue(name, out var currentNotification) && !currentNotification.Complete)
|
||||||
{
|
{
|
||||||
if (pool.AllowInterrupt)
|
if (pool.Type == SoundPool.InterruptType.Interrupt)
|
||||||
soundEngine.StopSound(currentNotification);
|
soundEngine.StopSound(currentNotification);
|
||||||
else
|
else if (pool.Type == SoundPool.InterruptType.DoNotPlay)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (currentSounds.TryGetValue(actorId, out var currentSound))
|
|
||||||
{
|
|
||||||
if (!currentSound.Complete)
|
|
||||||
{
|
|
||||||
if (pool.AllowInterrupt)
|
|
||||||
soundEngine.StopSound(currentSound);
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var volume = InternalSoundVolume * volumeModifier * pool.VolumeModifier;
|
var sound = PlaySound();
|
||||||
var sound = soundEngine.Play2D(sounds[name], false, relative, pos, volume, attenuateVolume);
|
if (sound == null)
|
||||||
if (sound == null)
|
return false;
|
||||||
return false;
|
else
|
||||||
|
currentNotifications[name] = sound;
|
||||||
if (voicedActor != null)
|
}
|
||||||
currentSounds[actorId] = sound;
|
|
||||||
else
|
else
|
||||||
currentNotifications[name] = sound;
|
{
|
||||||
|
if (currentSounds.TryGetValue(actorId, out var currentSound) && !currentSound.Complete)
|
||||||
|
{
|
||||||
|
if (pool.Type == SoundPool.InterruptType.Interrupt)
|
||||||
|
soundEngine.StopSound(currentSound);
|
||||||
|
else if (pool.Type == SoundPool.InterruptType.DoNotPlay)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sound = PlaySound();
|
||||||
|
if (sound == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
currentSounds[actorId] = sound;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -54,19 +54,21 @@ Sounds:
|
|||||||
Notifications:
|
Notifications:
|
||||||
Appear: appear1
|
Appear: appear1
|
||||||
Beacon: bleep2
|
Beacon: bleep2
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
Beepy2: beepy2
|
Beepy2: beepy2
|
||||||
Beepy3: beepy3
|
Beepy3: beepy3
|
||||||
Beepy6: beepy6
|
Beepy6: beepy6
|
||||||
CashTickDown: tone16
|
CashTickDown: tone16
|
||||||
|
InterruptType: Overlap
|
||||||
CashTickUp: tone15
|
CashTickUp: tone15
|
||||||
VolumeModifier: 0.33
|
VolumeModifier: 0.33
|
||||||
|
InterruptType: Overlap
|
||||||
ChatLine: scold1
|
ChatLine: scold1
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
ClickDisabledSound: scold2
|
ClickDisabledSound: scold2
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
ClickSound: button
|
ClickSound: button
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
Cloak: trans1
|
Cloak: trans1
|
||||||
Clock: clock1
|
Clock: clock1
|
||||||
Construction: constru2
|
Construction: constru2
|
||||||
|
|||||||
@@ -67,17 +67,19 @@ Sounds:
|
|||||||
DisablePower: POWRDN1
|
DisablePower: POWRDN1
|
||||||
EnablePower: POWRUP1
|
EnablePower: POWRUP1
|
||||||
CashTickUp: CASHTIK1
|
CashTickUp: CASHTIK1
|
||||||
|
InterruptType: Overlap
|
||||||
CashTickDown: CASHTIK1
|
CashTickDown: CASHTIK1
|
||||||
|
InterruptType: Overlap
|
||||||
LevelUp: SCORTIK1
|
LevelUp: SCORTIK1
|
||||||
ChatLine: CHAT1
|
ChatLine: CHAT1
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
BuildPaletteOpen: BUTTON1
|
BuildPaletteOpen: BUTTON1
|
||||||
BuildPaletteClose: BUTTON1
|
BuildPaletteClose: BUTTON1
|
||||||
TabClick: SIDEBAR1
|
TabClick: SIDEBAR1
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
ClickSound: BUTTON1
|
ClickSound: BUTTON1
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
ClickDisabledSound: ENDLIST1
|
ClickDisabledSound: ENDLIST1
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
Beacon: CHAT1
|
Beacon: CHAT1
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
|
|||||||
@@ -120,18 +120,20 @@ Sounds:
|
|||||||
RadarDown: radardn1
|
RadarDown: radardn1
|
||||||
CashTickUp: cashup1
|
CashTickUp: cashup1
|
||||||
VolumeModifier: 0.33
|
VolumeModifier: 0.33
|
||||||
|
InterruptType: Overlap
|
||||||
CashTickDown: cashdn1
|
CashTickDown: cashdn1
|
||||||
VolumeModifier: 0.33
|
VolumeModifier: 0.33
|
||||||
|
InterruptType: Overlap
|
||||||
LevelUp: hydrod1
|
LevelUp: hydrod1
|
||||||
DisablePower: bleep11
|
DisablePower: bleep11
|
||||||
EnablePower: bleep12
|
EnablePower: bleep12
|
||||||
ChatLine: rabeep1
|
ChatLine: rabeep1
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
ClickSound: ramenu1
|
ClickSound: ramenu1
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
ClickDisabledSound:
|
ClickDisabledSound:
|
||||||
Beacon: beepslct
|
Beacon: beepslct
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
AlertBuzzer: buzzy1
|
AlertBuzzer: buzzy1
|
||||||
AlertBleep: bleep6
|
AlertBleep: bleep6
|
||||||
BaseSetup: bleep9
|
BaseSetup: bleep9
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Sounds:
|
|||||||
Notifications:
|
Notifications:
|
||||||
Bargraph: bargraph
|
Bargraph: bargraph
|
||||||
Beacon: message1
|
Beacon: message1
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
Bestbox: bestbox
|
Bestbox: bestbox
|
||||||
Blip: blip
|
Blip: blip
|
||||||
BuildPaletteClose: emblem
|
BuildPaletteClose: emblem
|
||||||
@@ -11,14 +11,16 @@ Sounds:
|
|||||||
CantPushButtonSound: scold8
|
CantPushButtonSound: scold8
|
||||||
CashTickDown: creddwn1
|
CashTickDown: creddwn1
|
||||||
VolumeModifier: 0.33
|
VolumeModifier: 0.33
|
||||||
|
InterruptType: Overlap
|
||||||
CashTickUp: credup1
|
CashTickUp: credup1
|
||||||
VolumeModifier: 0.33
|
VolumeModifier: 0.33
|
||||||
|
InterruptType: Overlap
|
||||||
ChatLine: message1
|
ChatLine: message1
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
ClickDisabledSound: wrong1
|
ClickDisabledSound: wrong1
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
ClickSound: clicky1
|
ClickSound: clicky1
|
||||||
AllowInterrupt: true
|
InterruptType: Interrupt
|
||||||
GameForming: gamefrm1
|
GameForming: gamefrm1
|
||||||
Gdiclose: gdiclose
|
Gdiclose: gdiclose
|
||||||
Gdiopen: gdiopen
|
Gdiopen: gdiopen
|
||||||
|
|||||||
Reference in New Issue
Block a user