Also store names of assets in the AnimationSet

avinationmerge
Melanie Thielker 2014-10-03 18:27:14 +02:00
parent dbc0dfa606
commit c66e4eeb7d
1 changed files with 36 additions and 6 deletions

View File

@ -38,13 +38,43 @@ namespace OpenSim.Framework
private bool m_parseError = false; private bool m_parseError = false;
public int AnimationCount { get; private set; } public int AnimationCount { get; private set; }
private Dictionary<string, UUID> m_animations = new Dictionary<string, UUID>(); private Dictionary<string, KeyValuePair<string, UUID>> m_animations = new Dictionary<string, KeyValuePair<string, UUID>>();
public UUID GetAnimation(string index)
{
KeyValuePair<string, UUID> val;
if (m_animations.TryGetValue(index, out val))
return val.Value;
return UUID.Zero;
}
public string GetAnimationName(string index)
{
KeyValuePair<string, UUID> val;
if (m_animations.TryGetValue(index, out val))
return val.Key;
return String.Empty;
}
public void SetAnimation(string index, string name, UUID anim)
{
if (anim == UUID.Zero)
{
m_animations.Remove(index);
return;
}
m_animations[index] = new KeyValuePair<string, UUID>(name, anim);
}
public AnimationSet(Byte[] data) public AnimationSet(Byte[] data)
{ {
string assetData = System.Text.Encoding.ASCII.GetString(data); string assetData = System.Text.Encoding.ASCII.GetString(data);
Console.WriteLine("--------------------"); Console.WriteLine("--------------------");
Console.WriteLine("AnimationSet length {0} bytes", assetData.Length); Console.WriteLine("AnimationSet length {0} bytes", assetData.Length);
Console.WriteLine("Data: {0}", assetData); Console.WriteLine(assetData);
Console.WriteLine("--------------------"); Console.WriteLine("--------------------");
} }
@ -59,8 +89,8 @@ namespace OpenSim.Framework
} }
string assetData = String.Format("version 1\ncount {0}\n", m_animations.Count); string assetData = String.Format("version 1\ncount {0}\n", m_animations.Count);
foreach (KeyValuePair<string, UUID> kvp in m_animations) foreach (KeyValuePair<string, KeyValuePair<string, UUID>> kvp in m_animations)
assetData += String.Format("{0} {1}\n", kvp.Key, kvp.Value.ToString()); assetData += String.Format("{0} {1} {2}\n", kvp.Key, kvp.Value.Value.ToString(), kvp.Value.Key);
return System.Text.Encoding.ASCII.GetBytes(assetData); return System.Text.Encoding.ASCII.GetBytes(assetData);
} }
@ -72,9 +102,9 @@ namespace OpenSim.Framework
List<string> badAnims = new List<string>(); List<string> badAnims = new List<string>();
bool allOk = true; bool allOk = true;
foreach (KeyValuePair<string, UUID> kvp in m_animations) foreach (KeyValuePair<string, KeyValuePair<string, UUID>> kvp in m_animations)
{ {
if (!val(kvp.Value)) if (!val(kvp.Value.Value))
{ {
allOk = false; allOk = false;
badAnims.Add(kvp.Key); badAnims.Add(kvp.Key);