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[]>();
Pools = Lazy.New(() => if (!Voices.ContainsKey("Attack"))
new Dictionary<string, VoicePool> Voices.Add("Attack", Voices["Move"]);
{
{ "Select", new VoicePool(Select) }, Pools = Lazy.New(() => Voices.ToDictionary( a => a.Key, a => new VoicePool(a.Value) ));
{ "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;
@@ -197,19 +198,7 @@ namespace OpenRA
if (clip == null) if (clip == null)
return false; return false;
if (clip.Contains(".")) /* no variants! */ var variantext = (vi.Variants.ContainsKey(variant) && !vi.DisableVariants.Contains(phrase))?
{
Play(clip);
return true;
}
if (vi.Variants.Count == 0)
{
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,26 +2,32 @@ GenericVoice:
Variants: Variants:
nod: .v01,.v03 nod: .v01,.v03
gdi: .v01,.v03 gdi: .v01,.v03
Voices:
Select: await1,ready,report1,yessir1 Select: await1,ready,report1,yessir1
Move: ackno,affirm1,noprob,ritaway,roger,ugotit Move: ackno,affirm1,noprob,ritaway,roger,ugotit
Die: nuyell1.aud,nuyell3.aud,nuyell4.aud,nuyell5.aud Die: nuyell1,nuyell3,nuyell4,nuyell5
DisableVariants: Die
VehicleVoice: VehicleVoice:
Variants: Variants:
nod: .v00,.v02 nod: .v00,.v02
gdi: .v00,.v02 gdi: .v00,.v02
Voices:
Select: vehic1,yessir1,report1,await1,unit1 Select: vehic1,yessir1,report1,await1,unit1
Move: ackno,affirm1,movout1 Move: ackno,affirm1,movout1
CivilianMaleVoice: CivilianMaleVoice:
Voices:
Select: guyyeah1 Select: guyyeah1
Move: guyokay1 Move: guyokay1
CivilianFemaleVoice: CivilianFemaleVoice:
Voices:
Select: girlyeah Select: girlyeah
Move: girlokay Move: girlokay
CommandoVoice: CommandoVoice:
Voices:
Select: rokroll1,yeah1,yes1,yo1 Select: rokroll1,yeah1,yes1,yo1
Move: cmon1,onit1,gotit1 Move: cmon1,onit1,gotit1
Attack: keepem1,laugh1,bombit1,lefty1 Attack: keepem1,laugh1,bombit1,lefty1

View File

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