OSDN Git Service

Added option to disable speech for objects, inventory and friends
authorLatif Khalifa <latifer@streamgrid.net>
Tue, 4 Mar 2014 16:33:02 +0000 (17:33 +0100)
committerLatif Khalifa <latifer@streamgrid.net>
Tue, 4 Mar 2014 16:33:02 +0000 (17:33 +0100)
Radegast/RadegastBuild.cs
plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Control.cs
plugins/Radegast.Plugin.Speech/RadSpeech/PluginControl.cs

index b01bb33..22f2669 100644 (file)
@@ -1,5 +1,5 @@
 // Autogenerated: run updatebuildnr.bat/sh to update 
 namespace Radegast 
 {
-    public static class RadegastBuild { public static int CurrentRev = 1404; } 
+    public static class RadegastBuild { public static int CurrentRev = 1408; } 
 } 
index e136c5a..ad58a8c 100644 (file)
@@ -48,7 +48,7 @@ namespace RadegastSpeech.Conversation
         {\r
             // Initialize the index to conversations and the list of pending interruptions.\r
             interruptions = new LinkedList<Mode>();\r
-            conversations = new Dictionary<string,Mode>();\r
+            conversations = new Dictionary<string, Mode>();\r
         }\r
 \r
         internal override void Start()\r
@@ -70,8 +70,8 @@ namespace RadegastSpeech.Conversation
             // Automatically handle notifications (blue dialogs)\r
             Notification.OnNotificationDisplayed +=\r
                 new Notification.NotificationCallback(OnNotificationDisplayed);\r
-//            Notification.OnNotificationClosed +=\r
-//                new Notification.NotificationCallback(OnNotificationClosed);\r
+            //            Notification.OnNotificationClosed +=\r
+            //                new Notification.NotificationCallback(OnNotificationClosed);\r
 \r
             // Announce connect and disconnect.\r
             control.instance.Netcom.ClientConnected +=\r
@@ -162,7 +162,7 @@ namespace RadegastSpeech.Conversation
                     Talker.SayMore("Connecting to region");\r
                     return;\r
 \r
-               case LoginStatus.Success:\r
+                case LoginStatus.Success:\r
                     LoginName = control.instance.Netcom.LoginOptions.FullName;\r
                     //Talker.SayMore("Logged in as " + LoginName);\r
                     //if (friends != null)\r
@@ -193,8 +193,10 @@ namespace RadegastSpeech.Conversation
         {\r
             System.Windows.Forms.Control sTabControl = Tab.Control;\r
 \r
-            if (sTabControl is InventoryConsole)\r
+            if (sTabControl is InventoryConsole && control.config["enabled_for_inventory"])\r
+            {\r
                 SelectConversation(inventory);\r
+            }\r
             else if (sTabControl is ChatConsole)\r
             {\r
                 if (chat == null)\r
@@ -205,10 +207,14 @@ namespace RadegastSpeech.Conversation
                 }\r
                 SelectConversation(chat);\r
             }\r
-            else if (sTabControl is FriendsConsole)\r
+            else if (sTabControl is FriendsConsole && control.config["enabled_for_friends"])\r
+            {\r
                 SelectConversation(friends);\r
+            }\r
             else if (sTabControl is VoiceConsole)\r
+            {\r
                 SelectConversation(voice);\r
+            }\r
             else if (sTabControl is GroupIMTabWindow)\r
             {\r
                 GroupIMTabWindow tab = (GroupIMTabWindow)sTabControl;\r
@@ -225,7 +231,7 @@ namespace RadegastSpeech.Conversation
                 IMTabWindow tab = (IMTabWindow)sTabControl;\r
                 SelectConversation(tab.TargetName);\r
             }\r
-            else if (sTabControl is ObjectsConsole)\r
+            else if (sTabControl is ObjectsConsole && control.config["enabled_for_objects"])\r
             {\r
                 SelectConversation(surroundings);\r
             }\r
@@ -249,17 +255,23 @@ namespace RadegastSpeech.Conversation
             Mode newConv = null;\r
 \r
             // Create a conversation on first appearance of its tab.\r
-            if (sTabControl is InventoryConsole)\r
+            if (sTabControl is InventoryConsole && control.config["enabled_for_inventory"])\r
+            {\r
                 newConv = inventory = new Closet(control);\r
+            }\r
             else if (sTabControl is ChatConsole)\r
             {\r
                 if (chat != null) return;\r
                 newConv = chat = new Chat(control);\r
             }\r
-            else if (sTabControl is FriendsConsole)\r
+            else if (sTabControl is FriendsConsole && control.config["enabled_for_friends"])\r
+            {\r
                 newConv = friends = new Friends(control);\r
+            }\r
             else if (sTabControl is VoiceConsole)\r
+            {\r
                 newConv = voice = new Voice(control);\r
+            }\r
             else if (sTabControl is GroupIMTabWindow)\r
             {\r
                 GroupIMTabWindow tab = (GroupIMTabWindow)sTabControl;\r
@@ -278,7 +290,7 @@ namespace RadegastSpeech.Conversation
                 AddConversation(new SingleIMSession(control, tab.TargetName, tab.TargetId, tab.SessionId));\r
                 return;\r
             }\r
-            else if (sTabControl is ObjectsConsole)\r
+            else if (sTabControl is ObjectsConsole && control.config["enabled_for_objects"])\r
             {\r
                 surroundings = new Surroundings(control);\r
                 AddConversation(surroundings);\r
@@ -405,7 +417,7 @@ namespace RadegastSpeech.Conversation
         /// <summary>\r
         /// Finish an interruption and resume normal conversation\r
         /// </summary>\r
-        internal void FinishInterruption( Mode m )\r
+        internal void FinishInterruption(Mode m)\r
         {\r
             lock (interruptions)\r
             {\r
@@ -427,7 +439,7 @@ namespace RadegastSpeech.Conversation
                 }\r
             }\r
         }\r
\r
+\r
         private void Network_ClientConnected(object sender, EventArgs e)\r
         {\r
             Talker.Say("You are connected.", Talk.BeepType.Good);\r
@@ -528,7 +540,7 @@ namespace RadegastSpeech.Conversation
             }\r
             return true;\r
         }\r
-        \r
+\r
         /// <summary>\r
         /// Dispatch recognized text to appropriate conversation.\r
         /// </summary>\r
@@ -547,7 +559,7 @@ namespace RadegastSpeech.Conversation
         {\r
             if (c == null)\r
             {\r
-                Talker.Say("Trying to start non-existant conversation", Talk.BeepType.Bad );\r
+                Logger.Log("Trying to start non-existant conversation", Helpers.LogLevel.Warning);\r
                 return;\r
             }\r
             // Avoid multiple starts.\r
@@ -645,11 +657,11 @@ namespace RadegastSpeech.Conversation
         internal void ChangeFocus(Mode toThis)\r
         {\r
             currentMode = toThis;\r
-             if (currentMode != null)\r
+            if (currentMode != null)\r
                 currentMode.Start();\r
         }\r
 \r
\r
+\r
         /// <summary>\r
         /// Event handler for new blue dialog boxes.\r
         /// </summary>\r
@@ -657,7 +669,7 @@ namespace RadegastSpeech.Conversation
         /// <param name="e"></param>\r
         void OnNotificationDisplayed(object sender, NotificationEventArgs e)\r
         {\r
-            AddInterruption(new Conversation.BlueMenu(control,e));\r
+            AddInterruption(new Conversation.BlueMenu(control, e));\r
         }\r
 \r
         /// <summary>\r
index 3e9e264..a0c7457 100644 (file)
@@ -79,6 +79,21 @@ namespace RadegastSpeech
                 instance.GlobalSettings["plugin.speech"] = config;
             }
 
+            if (!config.ContainsKey("enabled_for_inventory"))
+            {
+                config["enabled_for_inventory"] = true;
+            }
+
+            if (!config.ContainsKey("enabled_for_objects"))
+            {
+                config["enabled_for_objects"] = true;
+            }
+
+            if (!config.ContainsKey("enabled_for_friends"))
+            {
+                config["enabled_for_friends"] = true;
+            }
+
             OSDMap props = (OSDMap)config["properties"];
             if (props["voice_speed"] == "")
             {
@@ -112,7 +127,7 @@ namespace RadegastSpeech
                 ToolStripMenuItem slowButton = new ToolStripMenuItem("Slow");
                 slowButton.Name = "slow";
                 if (props["voice_speed"] == "slow") slowButton.Checked = true;
-                
+
                 ToolStripMenuItem mediumButton = new ToolStripMenuItem("Medium");
                 if (props["voice_speed"] == "medium") mediumButton.Checked = true;
                 mediumButton.Name = "medium";
@@ -161,6 +176,53 @@ namespace RadegastSpeech
 
             SpeechButton.DropDownItems.Add(new ToolStripSeparator());
 
+            // Enable / disable for inventory tab
+            {
+                ToolStripMenuItem button = new ToolStripMenuItem("Inventory", null, (sender, e) =>
+                {
+                    var me = (ToolStripMenuItem)sender;
+                    me.Checked = !me.Checked;
+                    config["enabled_for_inventory"] = me.Checked;
+                });
+                button.Name = "speech_for_inventory";
+                button.AccessibleName = "Speech for inventory";
+                button.Checked = config["enabled_for_inventory"].AsBoolean();
+
+                SpeechButton.DropDownItems.Add(button);
+            }
+
+            // Enable / disable for objects tab
+            {
+                ToolStripMenuItem button = new ToolStripMenuItem("Objects", null, (sender, e) =>
+                {
+                    var me = (ToolStripMenuItem)sender;
+                    me.Checked = !me.Checked;
+                    config["enabled_for_objects"] = me.Checked;
+                });
+                button.Name = "speech_for_objects";
+                button.AccessibleName = "Speech for objects";
+                button.Checked = config["enabled_for_objects"].AsBoolean();
+
+                SpeechButton.DropDownItems.Add(button);
+            }
+
+            // Enable / disable for friends tab
+            {
+                ToolStripMenuItem button = new ToolStripMenuItem("Friends", null, (sender, e) =>
+                {
+                    var me = (ToolStripMenuItem)sender;
+                    me.Checked = !me.Checked;
+                    config["enabled_for_friends"] = me.Checked;
+                });
+                button.Name = "speech_for_friends";
+                button.AccessibleName = "Speech for friends";
+                button.Checked = config["enabled_for_friends"].AsBoolean();
+
+                SpeechButton.DropDownItems.Add(button);
+            }
+
+            SpeechButton.DropDownItems.Add(new ToolStripSeparator());
+
             // 3D Sound sub menu
             {
                 ToolStripMenuItem button = new ToolStripMenuItem("3D Sound", null, (sender, e) =>