From bdc968f1fcd4008e9f2a6099a7d30edb075ca0f1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 9 Mar 2012 23:57:24 +0000 Subject: Factor out common default animations code into SLUtil. LLClientView now makes use of the SLUtil copy via a method rather than each LLClientView loading a separate copy. As per opensim-users mailing list discussion. --- OpenSim/Framework/SLUtil.cs | 52 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/SLUtil.cs') diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index b337e03..f9cb851 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Xml; using log4net; using OpenMetaverse; @@ -39,6 +40,13 @@ namespace OpenSim.Framework #region SL / file extension / content-type conversions + public static Dictionary DefaultAvatarAnimations = new Dictionary(); + + static SLUtil() + { + DefaultAvatarAnimations = LoadDefaultAvatarAnimations("data/avataranimations.xml"); + } + public static string SLAssetTypeToContentType(int assetType) { switch ((AssetType)assetType) @@ -374,5 +382,47 @@ namespace OpenSim.Framework return output; } + + /// + /// Load the default SL avatar animations. + /// + /// + public static Dictionary LoadDefaultAvatarAnimations(string path) + { + Dictionary animations = new Dictionary(); + + using (XmlTextReader reader = new XmlTextReader(path)) + { + XmlDocument doc = new XmlDocument(); + doc.Load(reader); + if (doc.DocumentElement != null) + { + foreach (XmlNode nod in doc.DocumentElement.ChildNodes) + { + if (nod.Attributes["name"] != null) + { + string name = nod.Attributes["name"].Value.ToLower(); + string id = nod.InnerText; + animations.Add(name, (UUID)id); + } + } + } + } + + return animations; + } + + /// + /// Get the default SL avatar animation with the given name. + /// + /// + /// + public static UUID GetDefaultAvatarAnimation(string name) + { + if (DefaultAvatarAnimations.ContainsKey(name)) + return DefaultAvatarAnimations[name]; + + return UUID.Zero; + } } -} +} \ No newline at end of file -- cgit v1.1 From 1a8769e6eff0eab750a528f27d127637edbd292b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 21 Mar 2012 23:57:39 +0000 Subject: Instead of loading default avatar animations in both SLUtil and AvatarAnimations, load just in AvatarAnimations instead. This lets us remove the dependency of OpenSim.Framework.dll on data/avataranimations.xml, which is not necessary for ROBUST. This commit also takes care of the odd situation where animations are stored and used internally with uppercase names (e.g. "STAND") but scripts refer to them with lowercase names (e.g. "sit"). --- OpenSim/Framework/SLUtil.cs | 50 +-------------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) (limited to 'OpenSim/Framework/SLUtil.cs') diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index f9cb851..db4541e 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Reflection; using System.Xml; using log4net; @@ -40,13 +41,6 @@ namespace OpenSim.Framework #region SL / file extension / content-type conversions - public static Dictionary DefaultAvatarAnimations = new Dictionary(); - - static SLUtil() - { - DefaultAvatarAnimations = LoadDefaultAvatarAnimations("data/avataranimations.xml"); - } - public static string SLAssetTypeToContentType(int assetType) { switch ((AssetType)assetType) @@ -382,47 +376,5 @@ namespace OpenSim.Framework return output; } - - /// - /// Load the default SL avatar animations. - /// - /// - public static Dictionary LoadDefaultAvatarAnimations(string path) - { - Dictionary animations = new Dictionary(); - - using (XmlTextReader reader = new XmlTextReader(path)) - { - XmlDocument doc = new XmlDocument(); - doc.Load(reader); - if (doc.DocumentElement != null) - { - foreach (XmlNode nod in doc.DocumentElement.ChildNodes) - { - if (nod.Attributes["name"] != null) - { - string name = nod.Attributes["name"].Value.ToLower(); - string id = nod.InnerText; - animations.Add(name, (UUID)id); - } - } - } - } - - return animations; - } - - /// - /// Get the default SL avatar animation with the given name. - /// - /// - /// - public static UUID GetDefaultAvatarAnimation(string name) - { - if (DefaultAvatarAnimations.ContainsKey(name)) - return DefaultAvatarAnimations[name]; - - return UUID.Zero; - } } } \ No newline at end of file -- cgit v1.1