OSDN Git Service

Fixup speech plugins to work with the recent changes on the object manager
authorLatif Khalifa <latifer@streamgrid.net>
Wed, 17 Jul 2013 13:51:10 +0000 (15:51 +0200)
committerLatif Khalifa <latifer@streamgrid.net>
Wed, 17 Jul 2013 13:51:10 +0000 (15:51 +0200)
Radegast/GUI/Consoles/ObjectsConsole.cs
plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Surroundings.cs
plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Voice.cs
plugins/Radegast.Plugin.Speech/RadSpeech/Environment/People.cs

index 1cc5240..3cb2ef5 100644 (file)
@@ -49,6 +49,8 @@ namespace Radegast
 {
     public partial class ObjectsConsole : UserControl, IContextMenuProvider
     {
+        public List<Primitive> Prims = new List<Primitive>();
+
         private RadegastInstance instance;
         private GridClient client { get { return instance.Client; } }
         private Primitive currentPrim = new Primitive();
@@ -57,7 +59,6 @@ namespace Radegast
         PropertiesQueue propRequester;
         private Thread ContentsThread;
         private ObjectConsoleFilter filter;
-        private List<Primitive> Prims = new List<Primitive>();
         private ObjectSorter PrimSorter;
 
         public Primitive CurrentPrim { get { return currentPrim; } }
index 3cd2833..235c5d2 100644 (file)
@@ -42,7 +42,6 @@ namespace RadegastSpeech.Conversation
     {
         private Radegast.ObjectsConsole obTab;
         public bool Announce { get; set; }
-        private ListViewNoFlicker objects;
         private Primitive currentPrim = new Primitive();
         private ListViewItem currentItem ;
         
@@ -53,7 +52,6 @@ namespace RadegastSpeech.Conversation
             Title = "surroundings";
             Announce = false;
             obTab = (ObjectsConsole)control.instance.TabConsole.Tabs["objects"].Control;
-            objects = obTab.lstPrims;
         }
 
         /// <summary>
@@ -62,7 +60,7 @@ namespace RadegastSpeech.Conversation
         internal override void Start()
         {
             base.Start();
-            objects.SelectedIndexChanged += Objects_SelectedIndexChanged;
+            obTab.lstPrims.SelectedIndexChanged += Objects_SelectedIndexChanged;
             Talker.SayMore("Surroundings");
             Objects_SelectedIndexChanged(null, null);
         }
@@ -72,7 +70,7 @@ namespace RadegastSpeech.Conversation
         /// </summary>
         internal override void Stop()
         {
-            objects.SelectedIndexChanged -= Objects_SelectedIndexChanged;
+            obTab.lstPrims.SelectedIndexChanged -= Objects_SelectedIndexChanged;
             base.Stop();
         }
         #endregion
@@ -108,11 +106,16 @@ namespace RadegastSpeech.Conversation
         {
             string description;
 
-            if (objects.SelectedItems.Count != 1)
+            if (obTab.lstPrims.SelectedIndices.Count != 1)
                 return;
 
-            currentItem = objects.SelectedItems[0];
-            currentPrim = currentItem.Tag as Primitive;
+            currentPrim = obTab.Prims[obTab.lstPrims.SelectedIndices[0]];
+
+            Vector3 pos = Vector3.Zero;
+            if (currentPrim.ParentID == 0)
+            {
+                pos = currentPrim.Position;
+            }
 
             if (currentPrim.Properties == null)
             {
@@ -121,7 +124,7 @@ namespace RadegastSpeech.Conversation
             }
             else
             {
-                description = control.env.people.Location(currentPrim.Position);
+                description = control.env.people.Location(pos);
 
                 if ((currentPrim.Flags & PrimFlags.Scripted) != 0)
                     description += " scripted,";
@@ -134,7 +137,7 @@ namespace RadegastSpeech.Conversation
             Talker.SayObject(
                 currentPrim.Properties.Name,
                 description,
-                control.env.people.SameDirection( currentPrim.Position ) );
+                control.env.people.SameDirection( pos ) );
       }
 
         /// <summary>
index 4bb6a7a..445c98c 100644 (file)
@@ -35,8 +35,11 @@ namespace RadegastSpeech.Conversation
 
         internal override void Stop()
         {
-            vTab.gateway.OnSessionCreate -= new EventHandler(OnSessionCreate);
-            vTab.gateway.OnSessionRemove -= new EventHandler(gateway_OnSessionRemove);
+            if (vTab.gateway != null)
+            {
+                vTab.gateway.OnSessionCreate -= new EventHandler(OnSessionCreate);
+                vTab.gateway.OnSessionRemove -= new EventHandler(gateway_OnSessionRemove);
+            }
             vTab.chkVoiceEnable.CheckStateChanged -= new EventHandler(chkVoiceEnable_CheckStateChanged);
         }
 #endregion
index 2c0cc76..6ae0d32 100644 (file)
@@ -112,6 +112,8 @@ namespace RadegastSpeech.Environment
         /// <returns></returns>
         internal string Location(Vector3 theirpos)
         {
+            if (theirpos == Vector3.Zero)
+                return string.Empty;
             AgentManager my = control.instance.Client.Self;
 
             // Get the vector to the object, and distance.