123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using log4net;
- using Mono.Addins;
- using Nini.Config;
- using OpenMetaverse;
- using OpenSim.Framework;
- using OpenSim.Framework.Console;
- using OpenSim.Framework.Monitoring;
- using OpenSim.Region.ClientStack.LindenUDP;
- using OpenSim.Region.Framework.Interfaces;
- using OpenSim.Region.Framework.Scenes;
- using OpenSim.Region.Framework.Scenes.Animation;
- using OpenSim.Services.Interfaces;
- namespace OpenSim.Region.OptionalModules.Avatar.Animations
- {
-
-
-
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AnimationsCommandModule")]
- public class AnimationsCommandModule : ISharedRegionModule
- {
- private List<Scene> m_scenes = new List<Scene>();
- public string Name { get { return "Animations Command Module"; } }
-
- public Type ReplaceableInterface { get { return null; } }
-
- public void Initialise(IConfigSource source)
- {
- }
-
- public void PostInitialise()
- {
- }
-
- public void Close()
- {
- }
-
- public void AddRegion(Scene scene)
- {
- }
-
- public void RemoveRegion(Scene scene)
- {
-
- lock (m_scenes)
- m_scenes.Remove(scene);
- }
-
- public void RegionLoaded(Scene scene)
- {
-
- lock (m_scenes)
- m_scenes.Add(scene);
- scene.AddCommand(
- "Users", this, "show animations",
- "show animations [<first-name> <last-name>]",
- "Show animation information for avatars in this simulator.",
- "If no name is supplied then information for all avatars is shown.\n"
- + "Please note that for inventory animations, the animation name is the name under which the animation was originally uploaded\n"
- + ", which is not necessarily the current inventory name.",
- HandleShowAnimationsCommand);
- }
- protected void HandleShowAnimationsCommand(string module, string[] cmd)
- {
- if (cmd.Length != 2 && cmd.Length < 4)
- {
- MainConsole.Instance.OutputFormat("Usage: show animations [<first-name> <last-name>]");
- return;
- }
- bool targetNameSupplied = false;
- string optionalTargetFirstName = null;
- string optionalTargetLastName = null;
- if (cmd.Length >= 4)
- {
- targetNameSupplied = true;
- optionalTargetFirstName = cmd[2];
- optionalTargetLastName = cmd[3];
- }
- StringBuilder sb = new StringBuilder();
- lock (m_scenes)
- {
- foreach (Scene scene in m_scenes)
- {
- if (targetNameSupplied)
- {
- ScenePresence sp = scene.GetScenePresence(optionalTargetFirstName, optionalTargetLastName);
- if (sp != null && !sp.IsChildAgent)
- GetAttachmentsReport(sp, sb);
- }
- else
- {
- scene.ForEachRootScenePresence(sp => GetAttachmentsReport(sp, sb));
- }
- }
- }
- MainConsole.Instance.Output(sb.ToString());
- }
- private void GetAttachmentsReport(ScenePresence sp, StringBuilder sb)
- {
- sb.AppendFormat("Animations for {0}\n", sp.Name);
- ConsoleDisplayList cdl = new ConsoleDisplayList() { Indent = 2 };
- ScenePresenceAnimator spa = sp.Animator;
- AnimationSet anims = sp.Animator.Animations;
- string cma = spa.CurrentMovementAnimation;
- cdl.AddRow(
- "Current movement anim",
- string.Format("{0}, {1}", DefaultAvatarAnimations.GetDefaultAnimation(cma), cma));
- UUID defaultAnimId = anims.DefaultAnimation.AnimID;
- cdl.AddRow(
- "Default anim",
- string.Format("{0}, {1}", defaultAnimId, sp.Animator.GetAnimName(defaultAnimId)));
- UUID implicitDefaultAnimId = anims.ImplicitDefaultAnimation.AnimID;
- cdl.AddRow(
- "Implicit default anim",
- string.Format("{0}, {1}",
- implicitDefaultAnimId, sp.Animator.GetAnimName(implicitDefaultAnimId)));
- cdl.AddToStringBuilder(sb);
- ConsoleDisplayTable cdt = new ConsoleDisplayTable() { Indent = 2 };
- cdt.AddColumn("Animation ID", 36);
- cdt.AddColumn("Name", 20);
- cdt.AddColumn("Seq", 3);
- cdt.AddColumn("Object ID", 36);
- UUID[] animIds;
- int[] sequenceNumbers;
- UUID[] objectIds;
- sp.Animator.Animations.GetArrays(out animIds, out sequenceNumbers, out objectIds);
- for (int i = 0; i < animIds.Length; i++)
- {
- UUID animId = animIds[i];
- string animName = sp.Animator.GetAnimName(animId);
- int seq = sequenceNumbers[i];
- UUID objectId = objectIds[i];
- cdt.AddRow(animId, animName, seq, objectId);
- }
- cdt.AddToStringBuilder(sb);
- sb.Append("\n");
- }
- }
- }
|