removed all the sound junk from Game; removed spurious loose files

This commit is contained in:
Chris Forbes
2009-12-05 18:27:00 +13:00
parent 522bf234b8
commit 3ff9c2383a
20 changed files with 124 additions and 1674 deletions

View File

@@ -111,10 +111,10 @@ namespace OpenRa.Game
Game.world.AddFrameEndTask(w => w.Remove(this));
if (Owner == Game.LocalPlayer && !traits.Contains<Building>())
Game.PlaySound("unitlst1.aud", false);
Sound.Play("unitlst1.aud");
if (traits.Contains<Building>())
Game.PlaySound("kaboom22.aud", false);
Sound.Play("kaboom22.aud");
}
var halfStrength = unitInfo.Strength * Rules.General.ConditionYellow;

View File

@@ -1,5 +1,4 @@
using IjwFramework.Types;
using OpenRa.Game.GameRules;
using OpenRa.Game.GameRules;
using OpenRa.Game.Traits;
namespace OpenRa.Game
@@ -8,7 +7,6 @@ namespace OpenRa.Game
{
bool[,] blocked = new bool[128, 128];
Actor[,] influence = new Actor[128, 128];
static readonly Pair<Actor, float> NoClaim = Pair.New((Actor)null, float.MaxValue);
public BuildingInfluenceMap()
{

View File

@@ -54,7 +54,7 @@ namespace OpenRa.Game
public void Tick()
{
if (t == 0)
Game.PlaySound(Weapon.Report + ".aud", false);
Sound.Play(Weapon.Report + ".aud");
t += 40;
@@ -77,7 +77,7 @@ namespace OpenRa.Game
impact = Warhead.WaterImpactSound;
if (impact != null)
Game.PlaySound(impact+ ".aud", false);
Sound.Play(impact+ ".aud");
if (!isWater)
switch( Warhead.Explosion ) /* todo: push the scorch/crater behavior into data */
@@ -119,7 +119,7 @@ namespace OpenRa.Game
if (Projectile.High || Projectile.Arcing)
{
if (Projectile.Shadow)
yield return Tuple.New(anim.Image, pos, 8); /* todo: shadow pal */
yield return Tuple.New(anim.Image, pos, 8);
var at = (float)t / TotalTime();
var highPos = pos - new float2(0, (VisualDest - Src).Length * height * 4 * at * (1 - at));

View File

@@ -54,7 +54,7 @@ namespace OpenRa.Game
public void AddLine(Color c, string from, string text)
{
recentLines.Add(Tuple.New(c, from, text));
Game.PlaySound("rabeep1.aud", false);
Sound.Play("rabeep1.aud");
while (recentLines.Count > logLength) recentLines.RemoveAt(0);
}
}

View File

@@ -240,14 +240,14 @@ namespace OpenRa.Game
var group = Rules.UnitCategory[item];
var producing = player.Producing(group);
Game.PlaySound("ramenu1.aud", false);
Sound.Play("ramenu1.aud");
if (isLmb)
{
if (producing == null)
{
Game.controller.AddOrder(Order.StartProduction(player, item));
Game.PlaySound("abldgin1.aud", false);
Sound.Play("abldgin1.aud");
}
else if (producing.Item == item)
{
@@ -261,7 +261,7 @@ namespace OpenRa.Game
}
else
{
Game.PlaySound("progres1.aud", false);
Sound.Play("progres1.aud");
}
}
else
@@ -271,12 +271,12 @@ namespace OpenRa.Game
if (producing.Paused || producing.Done)
{
Game.PlaySound("cancld1.aud", false);
Sound.Play("cancld1.aud");
Game.controller.AddOrder(Order.CancelProduction(player, item));
}
else
{
Game.PlaySound("onhold1.aud", false);
Sound.Play("onhold1.aud");
Game.controller.AddOrder(Order.PauseProduction(player, item, true));
}
}

View File

@@ -26,28 +26,7 @@ namespace OpenRa.Game
}
if (doVoice != null && doVoice.traits.Contains<Unit>())
PlayVoiceClip("Move", doVoice);
}
static void PlayVoiceClip(string phrase, Actor voicedUnit)
{
if (voicedUnit == null) return;
var mi = voicedUnit.unitInfo as MobileInfo;
if (mi == null) return;
var vi = Rules.VoiceInfo[ mi.Voice ];
var clip = vi.Pools.Value[phrase].GetNext();
if (clip == null)
return;
var variants = (voicedUnit.Owner.Race == Race.Soviet)
? vi.SovietVariants : vi.AlliedVariants;
var variant = variants[ voicedUnit.ActorID % variants.Length ];
Game.PlaySound(clip + variant, false);
Sound.PlayVoice("Move", doVoice);
}
public void AddOrder(Order o) { recentOrders.Add(o); }
@@ -68,12 +47,6 @@ namespace OpenRa.Game
}
}
static string GetVoiceSuffix(Actor unit)
{
var suffixes = new[] { ".r01", ".r03" };
return suffixes[unit.ActorID % suffixes.Length];
}
float2 dragStart, dragEnd;
public bool HandleInput(MouseInput mi)
{
@@ -107,7 +80,7 @@ namespace OpenRa.Game
&& a.Owner == Game.LocalPlayer)
.FirstOrDefault();
PlayVoiceClip("Select", voicedUnit);
Sound.PlayVoice("Select", voicedUnit);
}
dragStart = dragEnd = xy;

View File

@@ -1,59 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="OpenRa.Game.Game">
<Position X="6" Y="2.5" Width="1.5" />
<Position X="6.75" Y="3.25" Width="1.5" />
<Members>
<Method Name="FindUnits" Hidden="true" />
<Field Name="lastTime" Hidden="true" />
<Method Name="LoadMapBuildings" Hidden="true" />
<Method Name="LoadMapUnits" Hidden="true" />
<Method Name="LoadSound" Hidden="true" />
<Field Name="localPlayerIndex" Hidden="true" />
<Field Name="treeCache" Hidden="true" />
<Field Name="oreFrequency" Hidden="true" />
<Field Name="oreTicks" Hidden="true" />
<Field Name="soundEngine" Hidden="true" />
<Field Name="sounds" Hidden="true" />
</Members>
<TypeIdentifier>
<HashCode>AAAAEAAAAIAAAAEEBAEAIAAQQAAAAAAAJIAAAABAQAA=</HashCode>
<HashCode>AAbAkDQAABBAAQEEBEECEggYQUBEAAAAIYALBCAA0iA=</HashCode>
<FileName>Game.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
<Field Name="controller" />
<Field Name="viewport" />
<Field Name="world" />
<Field Name="viewport" />
<Field Name="controller" />
</ShowAsAssociation>
</Class>
<Class Name="OpenRa.Game.Controller">
<Position X="8.5" Y="3" Width="1.75" />
<Position X="3.5" Y="6.5" Width="1.75" />
<Members>
<Method Name="ApplyOrders" Hidden="true" />
<Field Name="dragEnd" Hidden="true" />
<Field Name="dragStart" Hidden="true" />
<Field Name="game" Hidden="true" />
<Field Name="recentOrders" Hidden="true" />
</Members>
<TypeIdentifier>
<HashCode>AAAAAAAIAAAAAAAAAAACAgAAABAAAAAIAAAAAIAAAAA=</HashCode>
<HashCode>AAACAACoAAAAAAAAAAQCEgQAABAAAAAAAAAABAACCAA=</HashCode>
<FileName>Controller.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
<Field Name="game" />
<Field Name="orderGenerator" />
</ShowAsAssociation>
<Lollipop Position="0.2" />
</Class>
<Class Name="OpenRa.Game.Graphics.Viewport">
<Position X="3.5" Y="2.5" Width="1.5" />
<Position X="3.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAABAAAiABAAIYAAEAAAABCAAAAAABgAAAAgBE=</HashCode>
<HashCode>AAIAAAAABAAACABCAAYAEEAAAABAAAAAAAAgAEEAwBE=</HashCode>
<FileName>Graphics\Viewport.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="OpenRa.Game.World">
<Position X="8.5" Y="5.5" Width="1.5" />
<Position X="12.75" Y="7.25" Width="1.5" />
<Members>
<Field Name="actors" Hidden="true" />
<Field Name="effects" Hidden="true" />
<Field Name="frameEndActions" Hidden="true" />
<Field Name="game" Hidden="true" />
<Field Name="lastTime" Hidden="true" />
<Field Name="timestep" Hidden="true" />
<Field Name="nextAID" Hidden="true" />
</Members>
<TypeIdentifier>
<HashCode>AAYAACABABAAgAAAAIAABgAAAAAAAAAIAAAAAAAAAAA=</HashCode>
<HashCode>AAIAACABAAABgAAAAYQABAAEAAAAAAAAAAAAAAAAQBA=</HashCode>
<FileName>World.cs</FileName>
</TypeIdentifier>
<ShowAsCollectionAssociation>
<Property Name="Actors" />
<Property Name="Effects" />
</ShowAsCollectionAssociation>
</Class>
<Class Name="OpenRa.Game.Actor">
<Position X="15.75" Y="6.75" Width="1.5" />
<Members>
<Field Name="currentActivity" Hidden="true" />
</Members>
<TypeIdentifier>
<HashCode>AgEACAiAAAAAAAAAAQIAEIAkAQQAAAAAABAgAAAAQgA=</HashCode>
<FileName>Actor.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
<Field Name="game" />
<Field Name="unitInfo" />
<Field Name="Owner" />
</ShowAsAssociation>
</Class>
<Class Name="OpenRa.Game.GameRules.UnitInfo" Collapsed="true">
<Position X="18.75" Y="10.75" Width="1.5" />
<TypeIdentifier>
<HashCode>ACAAAAKAAJAgwiAAgAAAgFQAJAhQAHAAGCACAADIRAA=</HashCode>
<FileName>GameRules\UnitInfo.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="OpenRa.Game.Player" Collapsed="true">
<Position X="15.75" Y="5.25" Width="1.5" />
<TypeIdentifier>
<HashCode>QEEEgAQEAEIAQQQACAIAACAAAQAAAAAACAEBAAARQAA=</HashCode>
<FileName>Player.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="OpenRa.Game.GameRules.MobileInfo" Collapsed="true">
<Position X="17.5" Y="12" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAQAAAAAAAAAAAABAQAAAAAAAAAAAAAAAAg=</HashCode>
<FileName>GameRules\UnitInfo.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="OpenRa.Game.GameRules.BuildingInfo" Collapsed="true">
<Position X="21" Y="12" Width="1.5" />
<TypeIdentifier>
<HashCode>AAJQAAAIAAAAgAAACAAAABIAAAICAAABAAAAQAAAAgA=</HashCode>
<FileName>GameRules\UnitInfo.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="OpenRa.Game.GameRules.InfantryInfo" Collapsed="true">
<Position X="16.5" Y="13.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAEEAAAAABIAAAAAAAAAAAAAAAACAAAQA=</HashCode>
<FileName>GameRules\UnitInfo.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="OpenRa.Game.GameRules.VehicleInfo" Collapsed="true">
<Position X="18.75" Y="13.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAEAAAAAAAAAAAAAEAAAAAAAAAAAAAAA=</HashCode>
<FileName>GameRules\UnitInfo.cs</FileName>
</TypeIdentifier>
</Class>
<Interface Name="OpenRa.Game.IEffect">
<Position X="9.75" Y="7" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAQAA=</HashCode>
<FileName>IEffect.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="OpenRa.Game.IOrderGenerator" Collapsed="true">
<Position X="3.75" Y="10.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAQAA=</HashCode>
<FileName>IOrderGenerator.cs</FileName>
</TypeIdentifier>
</Interface>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@@ -3,9 +3,6 @@ using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using IjwFramework.Collections;
using IjwFramework.Types;
using IrrKlang;
using OpenRa.FileFormats;
using OpenRa.Game.GameRules;
using OpenRa.Game.Graphics;
@@ -43,8 +40,6 @@ namespace OpenRa.Game
public static BuildingInfluenceMap BuildingInfluence;
public static UnitInfluenceMap UnitInfluence;
static ISoundEngine soundEngine;
public static string Replay;
public static string NetworkHost;
@@ -70,6 +65,7 @@ namespace OpenRa.Game
viewport = new Viewport( clientSize, Rules.Map.Offset, Rules.Map.Offset + Rules.Map.Size, renderer );
world = new World();
Sound.Initialize();
BuildingInfluence = new BuildingInfluenceMap();
UnitInfluence = new UnitInfluenceMap();
@@ -79,13 +75,14 @@ namespace OpenRa.Game
new int2(treeReference.Location),
null));
LoadMapBuildings(Rules.AllRules);
LoadMapUnits(Rules.AllRules);
PathFinder = new PathFinder(Rules.Map);
soundEngine = new ISoundEngine();
sounds = new Cache<string, ISoundSource>(LoadSound);
if (Replay != "")
orderManager = new OrderManager(new IOrderSource[] { new ReplayOrderSource(Replay) });
@@ -97,8 +94,6 @@ namespace OpenRa.Game
orderManager = new OrderManager(orderSources, "replay.rep");
}
PlaySound("intro.aud", false);
skipMakeAnims = false;
PerfHistory.items["render"].hasNormalTick = false;
PerfHistory.items["batches"].hasNormalTick = false;
@@ -130,28 +125,6 @@ namespace OpenRa.Game
}
}
static Cache<string, ISoundSource> sounds;
static ISoundSource LoadSound(string filename)
{
var data = AudLoader.LoadSound(FileSystem.Open(filename));
return soundEngine.AddSoundSourceFromPCMData(data, filename,
new AudioFormat()
{
ChannelCount = 1,
FrameCount = data.Length / 2,
Format = SampleFormat.Signed16Bit,
SampleRate = 22050
});
}
public static void PlaySound(string name, bool loop)
{
var sound = sounds[name];
// todo: positioning
soundEngine.Play2D(sound, loop, false, false);
}
static int lastTime = Environment.TickCount;
public static int timestep = 40;

View File

@@ -94,6 +94,7 @@
<Compile Include="ProductionItem.cs" />
<Compile Include="ReplayOrderSource.cs" />
<Compile Include="Smudge.cs" />
<Compile Include="Sound.cs" />
<Compile Include="Support\Stopwatch.cs" />
<Compile Include="Support\PerfHistory.cs" />
<Compile Include="Traits\AcceptsOre.cs" />

View File

@@ -75,13 +75,13 @@ namespace OpenRa.Game
{
DisplayCash += Math.Min(displayCashDeltaPerFrame,
Cash - DisplayCash);
Game.PlaySound("cashup1.aud", false);
Sound.Play("cashup1.aud");
}
else if (DisplayCash > Cash)
{
DisplayCash -= Math.Min(displayCashDeltaPerFrame,
DisplayCash - Cash);
Game.PlaySound("cashdn1.aud", false);
Sound.Play("cashdn1.aud");
}
}
}

View File

@@ -73,7 +73,7 @@ namespace OpenRa.Game.Traits
break;
case DamageState.Half:
anim.PlayRepeating("damaged-idle");
Game.PlaySound("kaboom1.aud", false);
Sound.Play("kaboom1.aud");
break;
case DamageState.Dead:
DoBib(self, true);

View File

@@ -24,7 +24,7 @@ namespace OpenRa.Game.Traits
break;
case DamageState.Half:
PlayTurretAnim(self, "damaged-idle");
Game.PlaySound("kaboom1.aud", false);
Sound.Play("kaboom1.aud");
break;
}
}

View File

@@ -20,7 +20,7 @@ namespace OpenRa.Game
SanityCheck();
}
[System.Diagnostics.Conditional( "SANITY_CHECKS" )]
[Conditional( "SANITY_CHECKS" )]
void SanityCheck()
{
for( int y = 0 ; y < 128 ; y++ )

View File

@@ -43,8 +43,8 @@ namespace OpenRa.Game
Game.world.Add( new Actor( building.Name, order.TargetLocation - GameRules.Footprint.AdjustForBuildingSize( building ), order.Player ) );
if (order.Player == Game.LocalPlayer)
{
Game.PlaySound("placbldg.aud", false);
Game.PlaySound("build5.aud", false);
Sound.Play("placbldg.aud");
Sound.Play("build5.aud");
}
order.Player.FinishProduction(Rules.UnitCategory[building.Name]);
@@ -75,7 +75,7 @@ namespace OpenRa.Game
var isBuilding = group == "Building" || group == "Defense";
if (!hasPlayedSound && order.Player == Game.LocalPlayer)
{
Game.PlaySound(isBuilding ? "conscmp1.aud" : "unitrdy1.aud", false);
Sound.Play(isBuilding ? "conscmp1.aud" : "unitrdy1.aud");
hasPlayedSound = true;
}
if (!isBuilding)