Add Voices and DisableVariants to VoiceInfo, remove the ".aud" for die sounds.

This commit is contained in:
alzeih
2010-08-15 00:06:37 +12:00
parent fe481d7445
commit 271be551b0
4 changed files with 90 additions and 83 deletions

View File

@@ -11,35 +11,33 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using System;
namespace OpenRA.GameRules namespace OpenRA.GameRules
{ {
public class VoiceInfo public class VoiceInfo
{ {
public readonly Dictionary<string,string[]> Variants; public readonly Dictionary<string,string[]> Variants;
public readonly Dictionary<string,string[]> Voices;
public readonly string DefaultVariant = ".aud" ; public readonly string DefaultVariant = ".aud" ;
public readonly string[] Select = { }; public readonly string[] DisableVariants = { };
public readonly string[] Move = { };
public readonly string[] Attack = null; Func<MiniYaml, string, Dictionary<string, string[]>> Load = (y,name) => (y.Nodes.ContainsKey(name))? y.Nodes[name].Nodes.ToDictionary(a => a.Key,
public readonly string[] Die = { }; a => (string[])FieldLoader.GetValue( "(value)", typeof(string[]), a.Value.Value ))
: new Dictionary<string, string[]>();
public readonly Lazy<Dictionary<string, VoicePool>> Pools; public readonly Lazy<Dictionary<string, VoicePool>> Pools;
public VoiceInfo( MiniYaml y ) public VoiceInfo( MiniYaml y )
{ {
FieldLoader.LoadFields(this, y.Nodes, new string[] { "Select", "Move", "Attack", "Die" }); FieldLoader.LoadFields(this, y.Nodes, new string[] { "DisableVariants" });
Variants = (y.Nodes.ContainsKey("Variants"))? y.Nodes["Variants"].Nodes.ToDictionary(a => a.Key, Variants = Load(y, "Variants");
a => (string[])FieldLoader.GetValue( "(value)", typeof(string[]), a.Value.Value )) Voices = Load(y, "Voices");
: new Dictionary<string, string[]>();
if (!Voices.ContainsKey("Attack"))
Pools = Lazy.New(() => Voices.Add("Attack", Voices["Move"]);
new Dictionary<string, VoicePool>
{ Pools = Lazy.New(() => Voices.ToDictionary( a => a.Key, a => new VoicePool(a.Value) ));
{ "Select", new VoicePool(Select) },
{ "Move", new VoicePool(Move) },
{ "Attack", new VoicePool( Attack ?? Move ) },
{ "Die", new VoicePool(Die) },
});
} }
} }

View File

@@ -184,6 +184,7 @@ namespace OpenRA
// Returns true if it played a phrase // Returns true if it played a phrase
public static bool PlayVoice(string phrase, Actor voicedUnit, string variant) public static bool PlayVoice(string phrase, Actor voicedUnit, string variant)
{ {
Console.WriteLine(" Foo: `{0}`", phrase);
if (voicedUnit == null) return false; if (voicedUnit == null) return false;
if (phrase == null) return false; if (phrase == null) return false;
@@ -196,20 +197,8 @@ namespace OpenRA
var clip = vi.Pools.Value[phrase].GetNext(); var clip = vi.Pools.Value[phrase].GetNext();
if (clip == null) if (clip == null)
return false; return false;
if (clip.Contains(".")) /* no variants! */
{
Play(clip);
return true;
}
if (vi.Variants.Count == 0) var variantext = (vi.Variants.ContainsKey(variant) && !vi.DisableVariants.Contains(phrase))?
{
Play(clip + vi.DefaultVariant);
return true;
}
var variantext = vi.Variants.ContainsKey(variant)?
vi.Variants[variant][voicedUnit.ActorID % vi.Variants.Count] : vi.DefaultVariant; vi.Variants[variant][voicedUnit.ActorID % vi.Variants.Count] : vi.DefaultVariant;
Play(clip + variantext); Play(clip + variantext);
return true; return true;

View File

@@ -2,27 +2,33 @@ GenericVoice:
Variants: Variants:
nod: .v01,.v03 nod: .v01,.v03
gdi: .v01,.v03 gdi: .v01,.v03
Select: await1,ready,report1,yessir1 Voices:
Move: ackno,affirm1,noprob,ritaway,roger,ugotit Select: await1,ready,report1,yessir1
Die: nuyell1.aud,nuyell3.aud,nuyell4.aud,nuyell5.aud Move: ackno,affirm1,noprob,ritaway,roger,ugotit
Die: nuyell1,nuyell3,nuyell4,nuyell5
DisableVariants: Die
VehicleVoice: VehicleVoice:
Variants: Variants:
nod: .v00,.v02 nod: .v00,.v02
gdi: .v00,.v02 gdi: .v00,.v02
Select: vehic1,yessir1,report1,await1,unit1 Voices:
Move: ackno,affirm1,movout1 Select: vehic1,yessir1,report1,await1,unit1
Move: ackno,affirm1,movout1
CivilianMaleVoice: CivilianMaleVoice:
Select: guyyeah1 Voices:
Move: guyokay1 Select: guyyeah1
Move: guyokay1
CivilianFemaleVoice: CivilianFemaleVoice:
Select: girlyeah Voices:
Move: girlokay Select: girlyeah
Move: girlokay
CommandoVoice: CommandoVoice:
Select: rokroll1,yeah1,yes1,yo1 Voices:
Move: cmon1,onit1,gotit1 Select: rokroll1,yeah1,yes1,yo1
Attack: keepem1,laugh1,bombit1,lefty1 Move: cmon1,onit1,gotit1
Die: ramyell1 Attack: keepem1,laugh1,bombit1,lefty1
Die: ramyell1

View File

@@ -4,73 +4,87 @@ GenericVoice:
Variants: Variants:
soviet: .r01,.r03 soviet: .r01,.r03
allies: .v01,.v03 allies: .v01,.v03
Select: await1,ready,report1,yessir1 Voices:
Move: ackno,affirm1,noprob,overout,ritaway,roger,ugotit Select: await1,ready,report1,yessir1
Die: dedman1.aud,dedman2.aud,dedman3.aud,dedman4.aud,dedman5.aud,dedman6.aud,dedman7.aud,dedman8.aud,dedman10.aud Move: ackno,affirm1,noprob,overout,ritaway,roger,ugotit
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10
DisableVariants: Die
VehicleVoice: VehicleVoice:
Variants: Variants:
soviet: .r00,.r02 soviet: .r00,.r02
allies: .v00,.v02 allies: .v00,.v02
Select: vehic1,yessir1,report1,await1 Voices:
Move: ackno,affirm1 Select: vehic1,yessir1,report1,await1
Move: ackno,affirm1
ShipVoice: ShipVoice:
Variants: Variants:
soviet: .r00,.r02 soviet: .r00,.r02
allies: .v00,.v02 allies: .v00,.v02
Select: vehic1,yessir1,report1,await1 Voices:
Move: ackno,affirm1 Select: vehic1,yessir1,report1,await1
Move: ackno,affirm1
EngineerVoice: EngineerVoice:
Select: eengin1,eyessir1 Voices:
Move: eaffirm1,emovout1 Select: eengin1,eyessir1
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 Move: eaffirm1,emovout1
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10
MedicVoice: MedicVoice:
Select: mrespon1,myessir1 Voices:
Move: maffirm1,mmovout1 Select: mrespon1,myessir1
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 Move: maffirm1,mmovout1
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10
TanyaVoice: TanyaVoice:
Select: yo1,yes1,yeah1 Voices:
Move: rokroll1,onit1,cmon1 Select: yo1,yes1,yeah1
Attack: tuffguy1,bombit1,gotit1 Move: rokroll1,onit1,cmon1
Die: tandeth1 Attack: tuffguy1,bombit1,gotit1
Die: tandeth1
DogVoice: DogVoice:
Select: Voices:
Move: dogy1 Select:
Attack: dogg5p,dogw3px Move: dogy1
Die: dogw5,dogw6,dogw7 Attack: dogg5p,dogw3px
Die: dogw5,dogw6,dogw7
SpyVoice: SpyVoice:
Select: syessir1,scomnd1 Voices:
Move: sonway1,sindeed1 Select: syessir1,scomnd1
Attack: sking1 Move: sonway1,sindeed1
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 Attack: sking1
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10
ThiefVoice: ThiefVoice:
Select: swhat1,syeah1 Voices:
Move: saffirm1,smout1,sokay1 Select: swhat1,syeah1
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 Move: saffirm1,smout1,sokay1
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10
CivilianMaleVoice: CivilianMaleVoice:
Select: guyyeah1 Voices:
Move: guyokay1 Select: guyyeah1
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 Move: guyokay1
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10
CivilianFemaleVoice: CivilianFemaleVoice:
Select: girlyeah Voices:
Move: girlokay Select: girlyeah
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 Move: girlokay
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10
EinsteinVoice: EinsteinVoice:
Select: einah1,einok1,einyes1 Voices:
Move: einah1,einok1,einyes1 Select: einah1,einok1,einyes1
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 Move: einah1,einok1,einyes1
Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10
ShokVoice: ShokVoice:
Select: jchrge1,jjuice1,jjump1,jpower1 Voices:
Move: jdance1,jyes1 Select: jchrge1,jjuice1,jjump1,jpower1
Attack: jburn1,jcrisp1,jshock1,jlight1 Move: jdance1,jyes1
Attack: jburn1,jcrisp1,jshock1,jlight1