From daae4ff300cc345c78e517356a30c610e53cb0f3 Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Wed, 17 Jul 2013 15:51:10 +0200 Subject: [PATCH] Fixup speech plugins to work with the recent changes on the object manager --- Radegast/GUI/Consoles/ObjectsConsole.cs | 3 ++- .../RadSpeech/Conversation/Surroundings.cs | 21 ++++++++++++--------- .../RadSpeech/Conversation/Voice.cs | 7 +++++-- .../RadSpeech/Environment/People.cs | 2 ++ 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Radegast/GUI/Consoles/ObjectsConsole.cs b/Radegast/GUI/Consoles/ObjectsConsole.cs index 1cc5240..3cb2ef5 100644 --- a/Radegast/GUI/Consoles/ObjectsConsole.cs +++ b/Radegast/GUI/Consoles/ObjectsConsole.cs @@ -49,6 +49,8 @@ namespace Radegast { public partial class ObjectsConsole : UserControl, IContextMenuProvider { + public List Prims = new List(); + 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 Prims = new List(); private ObjectSorter PrimSorter; public Primitive CurrentPrim { get { return currentPrim; } } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Surroundings.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Surroundings.cs index 3cd2833..235c5d2 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Surroundings.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Surroundings.cs @@ -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; } /// @@ -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 /// 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 ) ); } /// diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Voice.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Voice.cs index 4bb6a7a..445c98c 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Voice.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Voice.cs @@ -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 diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Environment/People.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Environment/People.cs index 2c0cc76..6ae0d32 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Environment/People.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Environment/People.cs @@ -112,6 +112,8 @@ namespace RadegastSpeech.Environment /// 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. -- 2.11.0