OSDN Git Service

RAD-241: Added UI sounds on incoming IM, object rez, delete, money balance changes.
authorLatif Khalifa <latifer@streamgrid.net>
Sat, 12 Feb 2011 16:53:56 +0000 (16:53 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Sat, 12 Feb 2011 16:53:56 +0000 (16:53 +0000)
Also closes RAD-139 and RAD-166

git-svn-id: https://radegast.googlecode.com/svn/trunk@804 f7a694da-4d33-11de-9ad6-1127a62b9fcd

15 files changed:
Radegast/Core/Media/MediaManager.cs
Radegast/Core/Media/UISounds.cs [new file with mode: 0644]
Radegast/GUI/Consoles/ChatConsole.cs
Radegast/GUI/Consoles/FriendsConsole.cs
Radegast/GUI/Consoles/GroupsConsole.cs
Radegast/GUI/Consoles/Inventory/InventoryConsole.cs
Radegast/GUI/Consoles/MediaConsole.Designer.cs
Radegast/GUI/Consoles/MediaConsole.cs
Radegast/GUI/Consoles/MediaConsole.resx
Radegast/GUI/Consoles/ObjectsConsole.cs
Radegast/GUI/Consoles/TabsConsole.cs
Radegast/GUI/Dialogs/MainForm.Designer.cs
Radegast/GUI/Dialogs/MainForm.cs
Radegast/GUI/Dialogs/Profile.cs
Radegast/Radegast.csproj

index 647f962..f4c7d7e 100644 (file)
@@ -562,6 +562,11 @@ namespace Radegast.Media
             get { return AllObjectVolume; }
         }
 
+        /// <summary>
+        /// UI sounds volume
+        /// </summary>
+        public float UIVolume = 0.5f;
+
         private bool m_objectEnabled = true;
         /// <summary>
         /// Enable and Disable inworld sounds
@@ -596,7 +601,7 @@ namespace Radegast.Media
             {
                 new BufferSound(
                     UUID.Random(),
-                    new UUID("5e191c7b-8996-9ced-a177-b2ac32bfea06"),
+                    UISounds.Typing,
                     false,
                     true,
                     e.Position,
@@ -614,6 +619,21 @@ namespace Radegast.Media
             BufferSound.KillAll();
         }
 
+        /// <summary>
+        /// Plays a sound
+        /// </summary>
+        /// <param name="sound">UUID of the sound to play</param>
+        public void PlayUISound(UUID sound)
+        {
+            new BufferSound(
+                UUID.Random(),
+                sound,
+                false,
+                true,
+                Instance.Client.Self.SimPosition,
+                UIVolume);
+        }
+
 
     }
 
diff --git a/Radegast/Core/Media/UISounds.cs b/Radegast/Core/Media/UISounds.cs
new file mode 100644 (file)
index 0000000..8110ce2
--- /dev/null
@@ -0,0 +1,67 @@
+// 
+// Radegast Metaverse Client
+// Copyright (c) 2009-2011, Radegast Development Team
+// All rights reserved.
+// 
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// 
+//     * Redistributions of source code must retain the above copyright notice,
+//       this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above copyright
+//       notice, this list of conditions and the following disclaimer in the
+//       documentation and/or other materials provided with the distribution.
+//     * Neither the name of the application "Radegast", nor the names of its
+//       contributors may be used to endorse or promote products derived from
+//       this software without specific prior written permission.
+// 
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// $Id$
+//
+
+using OpenMetaverse;
+
+namespace Radegast
+{
+    /// <summary>
+    /// Predefined UI sounds
+    /// Source: https://wiki.secondlife.com/wiki/Client_sounds
+    /// </summary>
+    public static class UISounds
+    {
+        /// <summary>Sound of incoming IM</summary>
+        public static UUID IM = new UUID("67cc2844-00f3-2b3c-b991-6418d01e1bb7");
+        
+        /// <summary>Typing sound</summary>
+        public static UUID Typing = new UUID("5e191c7b-8996-9ced-a177-b2ac32bfea06");
+
+        /// <summary>When user opens new IM window</summary>
+        public static UUID IMWindow = new UUID("c825dfbc-9827-7e02-6507-3713d18916c1");
+
+        /// <summary>When money balance is increased</summary>
+        public static UUID MoneyIn = new UUID("104974e3-dfda-428b-99ee-b0d4e748d3a3");
+
+        /// <summary>When money balance is decreased</summary>
+        public static UUID MoneyOut = new UUID("77a018af-098e-c037-51a6-178f05877c6f");
+
+        /// <summary>Object rezzed from inventory</summary>
+        public static UUID ObjectRez = new UUID("f4a0660f-5446-dea2-80b7-6482a082803c");
+
+        /// <summary>Object create</summary>
+        public static UUID ObjectCreate = new UUID("3c8fc726-1fd6-862d-fa01-16c5b2568db6");
+
+        /// <summary>Object deleted</summary>
+        public static UUID ObjectDelete = new UUID("0cb7b00a-4c10-6948-84de-a93c09af2ba9");
+
+    }
+}
index 73e48ca..0032ce5 100644 (file)
@@ -554,6 +554,8 @@ namespace Radegast
                 return;
             }
 
+            instance.MediaManager.PlayUISound(UISounds.IMWindow);
+
             tabConsole.AddIMTab(av, client.Self.AgentID ^ av, name);
             tabConsole.SelectTab((client.Self.AgentID ^ av).ToString());
         }
index 3c16d71..5b491d8 100644 (file)
@@ -257,6 +257,8 @@ namespace Radegast
                     return;
                 }
 
+                instance.MediaManager.PlayUISound(UISounds.IMWindow);
+
                 instance.TabConsole.AddIMTab(selectedFriend.UUID, client.Self.AgentID ^ selectedFriend.UUID, selectedFriend.Name);
                 instance.TabConsole.SelectTab((client.Self.AgentID ^ selectedFriend.UUID).ToString());
             }
index d84a2a4..60c86a7 100644 (file)
@@ -155,6 +155,7 @@ namespace Radegast
 
             if (!instance.TabConsole.TabExists(g.ID.ToString()))
             {
+                instance.MediaManager.PlayUISound(UISounds.IMWindow);
                 instance.TabConsole.AddGroupIMTab(g.ID, g.Name);
                 instance.TabConsole.Tabs[g.ID.ToString()].Highlight();
                 instance.TabConsole.Tabs[g.ID.ToString()].Select();
index 6170f47..21bc1a2 100644 (file)
@@ -1618,6 +1618,7 @@ namespace Radegast
                         break;
 
                     case "rez_inworld":
+                        instance.MediaManager.PlayUISound(UISounds.ObjectRez);
                         Vector3 rezpos = new Vector3(2, 0, 0);
                         rezpos = client.Self.SimPosition + rezpos * client.Self.Movement.BodyRotation;
                         client.Inventory.RequestRezFromInventory(client.Network.CurrentSim, Quaternion.Identity, rezpos, item);
index a4e504d..e6b4e3b 100644 (file)
@@ -74,10 +74,14 @@ namespace Radegast
             this.cbObjSoundEnable = new System.Windows.Forms.CheckBox();
             this.ObjSoundGroup = new System.Windows.Forms.GroupBox();
             this.objVolume = new System.Windows.Forms.TrackBar();
+            this.UISoundsGroup = new System.Windows.Forms.GroupBox();
+            this.UIVolume = new System.Windows.Forms.TrackBar();
             ((System.ComponentModel.ISupportInitialize)(this.volAudioStream)).BeginInit();
             this.pnlParcelAudio.SuspendLayout();
             this.ObjSoundGroup.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.objVolume)).BeginInit();
+            this.UISoundsGroup.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.UIVolume)).BeginInit();
             this.SuspendLayout();
             // 
             // volAudioStream
@@ -243,20 +247,48 @@ namespace Radegast
             this.objVolume.TabIndex = 0;
             this.objVolume.Value = 40;
             // 
+            // UISoundsGroup
+            // 
+            this.UISoundsGroup.AccessibleName = "UI sounds volume";
+            this.UISoundsGroup.Controls.Add(this.UIVolume);
+            this.UISoundsGroup.Location = new System.Drawing.Point(4, 220);
+            this.UISoundsGroup.Name = "UISoundsGroup";
+            this.UISoundsGroup.Size = new System.Drawing.Size(358, 53);
+            this.UISoundsGroup.TabIndex = 3;
+            this.UISoundsGroup.TabStop = false;
+            this.UISoundsGroup.Text = "UI Sounds";
+            // 
+            // UIVolume
+            // 
+            this.UIVolume.AccessibleName = "Object sounds volume";
+            this.UIVolume.LargeChange = 10;
+            this.UIVolume.Location = new System.Drawing.Point(4, 12);
+            this.UIVolume.Maximum = 50;
+            this.UIVolume.Name = "UIVolume";
+            this.UIVolume.Size = new System.Drawing.Size(347, 45);
+            this.UIVolume.SmallChange = 2;
+            this.UIVolume.TabIndex = 0;
+            this.UIVolume.Value = 20;
+            this.UIVolume.Scroll += new System.EventHandler(this.UIVolume_Scroll);
+            // 
             // MediaConsole
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.Controls.Add(this.UISoundsGroup);
             this.Controls.Add(this.ObjSoundGroup);
             this.Controls.Add(this.pnlParcelAudio);
             this.Name = "MediaConsole";
-            this.Size = new System.Drawing.Size(368, 217);
+            this.Size = new System.Drawing.Size(368, 275);
             ((System.ComponentModel.ISupportInitialize)(this.volAudioStream)).EndInit();
             this.pnlParcelAudio.ResumeLayout(false);
             this.pnlParcelAudio.PerformLayout();
             this.ObjSoundGroup.ResumeLayout(false);
             this.ObjSoundGroup.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.objVolume)).EndInit();
+            this.UISoundsGroup.ResumeLayout(false);
+            this.UISoundsGroup.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.UIVolume)).EndInit();
             this.ResumeLayout(false);
 
         }
@@ -278,6 +310,8 @@ namespace Radegast
         private System.Windows.Forms.GroupBox ObjSoundGroup;
         public System.Windows.Forms.CheckBox cbObjSoundEnable;
         public System.Windows.Forms.TrackBar objVolume;
+        private System.Windows.Forms.GroupBox UISoundsGroup;
+        public System.Windows.Forms.TrackBar UIVolume;
 
     }
 }
index 745fa7d..64240c7 100644 (file)
@@ -75,6 +75,11 @@ namespace Radegast
                 instance.MediaManager.ObjectVolume = (float)s["object_audio_vol"].AsReal();
                 objVolume.Value = (int)(50f * instance.MediaManager.ObjectVolume);
             }
+            if (s["ui_audio_vol"].Type != OSDType.Unknown)
+            {
+                instance.MediaManager.UIVolume = (float)s["ui_audio_vol"].AsReal();
+                UIVolume.Value = (int)(50f * instance.MediaManager.UIVolume);
+            }
 
             volAudioStream.Value = (int)(audioVolume * 50);
             instance.MediaManager.ObjectEnable = cbObjSoundEnable.Checked;
@@ -212,6 +217,7 @@ namespace Radegast
             s["parcel_audio_keep_url"] = OSD.FromBoolean(cbKeep.Checked);
             s["object_audio_vol"] = OSD.FromReal(this.instance.MediaManager.ObjectVolume);
             s["object_audio_enable"] = OSD.FromBoolean(cbObjSoundEnable.Checked);
+            s["ui_audio_vol"] = OSD.FromReal(this.instance.MediaManager.UIVolume);
         }
 
         #region GUI event handlers
@@ -275,6 +281,12 @@ namespace Radegast
                     Stop();
                 }
         }
+
+        private void UIVolume_Scroll(object sender, EventArgs e)
+        {
+            instance.MediaManager.UIVolume = UIVolume.Value / 50f;
+            configTimer.Change(saveConfigTimeout, System.Threading.Timeout.Infinite);
+        }
         #endregion GUI event handlers
     }
 }
index 7ce03af..e641aef 100644 (file)
   <metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>17, 17</value>\r
   </metadata>\r
+  <metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>17, 17</value>\r
+  </metadata>\r
 </root>
\ No newline at end of file
index 1fd81a7..f976dac 100644 (file)
@@ -955,6 +955,7 @@ namespace Radegast
 
         private void btnTake_Click(object sender, EventArgs e)
         {
+            instance.MediaManager.PlayUISound(UISounds.ObjectDelete);
             client.Inventory.RequestDeRezToInventory(currentPrim.LocalID);
         }
 
@@ -963,11 +964,15 @@ namespace Radegast
             if (currentPrim.Properties != null && currentPrim.Properties.OwnerID != client.Self.AgentID)
                 btnReturn_Click(sender, e);
             else
+            {
+                instance.MediaManager.PlayUISound(UISounds.ObjectDelete);
                 client.Inventory.RequestDeRezToInventory(currentPrim.LocalID, DeRezDestination.AgentInventoryTake, client.Inventory.FindFolderForType(AssetType.TrashFolder), UUID.Random());
+            }
         }
 
         private void btnReturn_Click(object sender, EventArgs e)
         {
+            instance.MediaManager.PlayUISound(UISounds.ObjectDelete);
             client.Inventory.RequestDeRezToInventory(currentPrim.LocalID, DeRezDestination.ReturnToOwner, UUID.Zero, UUID.Random());
         }
 
index e5b6fba..85257ad 100644 (file)
@@ -477,6 +477,8 @@ namespace Radegast
                 if (!tab.Selected) tab.Highlight();
                 return;
             }
+            
+            instance.MediaManager.PlayUISound(UISounds.IM);
 
             IMTabWindow imTab = AddIMTab(e);
             tabs[e.IM.IMSessionID.ToString()].Highlight();
@@ -491,6 +493,8 @@ namespace Radegast
                 return;
             }
 
+            instance.MediaManager.PlayUISound(UISounds.IM);
+
             ConferenceIMTabWindow imTab = AddConferenceIMTab(e);
             tabs[e.IM.IMSessionID.ToString()].Highlight();
         }
@@ -504,6 +508,8 @@ namespace Radegast
                 return;
             }
 
+            instance.MediaManager.PlayUISound(UISounds.IM);
+
             GroupIMTabWindow imTab = AddGroupIMTab(e);
             tabs[e.IM.IMSessionID.ToString()].Highlight();
         }
index 16013e6..87b7e59 100644 (file)
@@ -90,6 +90,7 @@ namespace Radegast
             this.groundSitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.standToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.stopAllAnimationsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.changeMyDisplayNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
             this.tmnuCreateLandmark = new System.Windows.Forms.ToolStripMenuItem();
             this.tmnuSetHome = new System.Windows.Forms.ToolStripMenuItem();
@@ -143,7 +144,6 @@ namespace Radegast
             this.ctxTreyRestore = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
             this.ctxTreyExit = new System.Windows.Forms.ToolStripMenuItem();
-            this.changeMyDisplayNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStrip1.SuspendLayout();
             this.statusStrip1.SuspendLayout();
             this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
@@ -333,6 +333,13 @@ namespace Radegast
             this.stopAllAnimationsToolStripMenuItem.Text = "Stop All Animations";
             this.stopAllAnimationsToolStripMenuItem.Click += new System.EventHandler(this.stopAllAnimationsToolStripMenuItem_Click);
             // 
+            // changeMyDisplayNameToolStripMenuItem
+            // 
+            this.changeMyDisplayNameToolStripMenuItem.Name = "changeMyDisplayNameToolStripMenuItem";
+            this.changeMyDisplayNameToolStripMenuItem.Size = new System.Drawing.Size(223, 22);
+            this.changeMyDisplayNameToolStripMenuItem.Text = "Change My Display Name";
+            this.changeMyDisplayNameToolStripMenuItem.Click += new System.EventHandler(this.changeMyDisplayNameToolStripMenuItem_Click);
+            // 
             // toolStripMenuItem4
             // 
             this.toolStripMenuItem4.Name = "toolStripMenuItem4";
@@ -823,13 +830,6 @@ namespace Radegast
             this.ctxTreyExit.ToolTipText = "Loggs of and closes application";
             this.ctxTreyExit.Click += new System.EventHandler(this.ctxTreyExit_Click);
             // 
-            // changeMyDisplayNameToolStripMenuItem
-            // 
-            this.changeMyDisplayNameToolStripMenuItem.Name = "changeMyDisplayNameToolStripMenuItem";
-            this.changeMyDisplayNameToolStripMenuItem.Size = new System.Drawing.Size(223, 22);
-            this.changeMyDisplayNameToolStripMenuItem.Text = "Change My Display Name";
-            this.changeMyDisplayNameToolStripMenuItem.Click += new System.EventHandler(this.changeMyDisplayNameToolStripMenuItem_Click);
-            // 
             // frmMain
             // 
             this.AutoSavePosition = true;
index 4ba0904..0cd5c54 100644 (file)
@@ -190,12 +190,14 @@ namespace Radegast
         {
             client.Parcels.ParcelProperties += new EventHandler<ParcelPropertiesEventArgs>(Parcels_ParcelProperties);
             client.Self.MoneyBalanceReply += new EventHandler<MoneyBalanceReplyEventArgs>(Self_MoneyBalanceReply);
+            client.Self.MoneyBalance += new EventHandler<BalanceEventArgs>(Self_MoneyBalance);
         }
 
         private void UnregisterClientEvents(GridClient client)
         {
             client.Parcels.ParcelProperties -= new EventHandler<ParcelPropertiesEventArgs>(Parcels_ParcelProperties);
             client.Self.MoneyBalanceReply -= new EventHandler<MoneyBalanceReplyEventArgs>(Self_MoneyBalanceReply);
+            client.Self.MoneyBalance -= new EventHandler<BalanceEventArgs>(Self_MoneyBalance);
         }
 
         void instance_ClientChanged(object sender, ClientChangedEventArgs e)
@@ -229,6 +231,25 @@ namespace Radegast
         #endregion
 
         #region Event handlers
+        void Self_MoneyBalance(object sender, BalanceEventArgs e)
+        {
+            int oldBalance = 0;
+            int.TryParse(tlblMoneyBalance.Text, out oldBalance);
+            int delta = Math.Abs(oldBalance - e.Balance);
+
+            if (delta > 50)
+            {
+                if (oldBalance > e.Balance)
+                {
+                    instance.MediaManager.PlayUISound(UISounds.MoneyIn);
+                }
+                else
+                {
+                    instance.MediaManager.PlayUISound(UISounds.MoneyOut);
+                }
+            }
+        }
+
         void Names_NameUpdated(object sender, UUIDNameReplyEventArgs e)
         {
             if (!e.Names.ContainsKey(client.Self.AgentID)) return;
@@ -1323,33 +1344,10 @@ namespace Radegast
             }
         }
 
-        int nr_reg = 0;
-        int nr_agent = 0;
-
         // Menu item for testing out stuff
         private void testToolStripMenuItem_Click(object sender, EventArgs e)
         {
-            if (nr_reg > 0)
-            {
-                Logger.Log("Number of regions: " + nr_reg.ToString() + " agents: " + nr_agent.ToString(), Helpers.LogLevel.Info);
-                nr_reg = 0;
-                nr_agent = 0;
-                client.Grid.GridRegion -= new EventHandler<GridRegionEventArgs>(Grid_GridRegion);
-                return;
-            }
-
-            client.Grid.GridRegion += new EventHandler<GridRegionEventArgs>(Grid_GridRegion);
-            client.Grid.RequestMainlandSims(GridLayerType.Objects);
-        }
-
-        void Grid_GridRegion(object sender, GridRegionEventArgs e)
-        {
-            nr_reg++;
-            if ((nr_reg % 100) == 0)
-            {
-                nr_agent += e.Region.Agents;
-                Logger.Log("Number of regions: " + nr_reg.ToString() + " agents: " + nr_agent.ToString(), Helpers.LogLevel.Info);
-            }
+            instance.MediaManager.PlayUISound(UISounds.IM);
         }
 
         private void reloadInventoryToolStripMenuItem_Click(object sender, EventArgs e)
index 1debef0..16afb2b 100644 (file)
@@ -474,6 +474,7 @@ namespace Radegast
                 return;
             }
 
+            instance.MediaManager.PlayUISound(UISounds.IMWindow);
             instance.TabConsole.AddIMTab(agentID, client.Self.AgentID ^ agentID, fullName);
             instance.TabConsole.SelectTab((client.Self.AgentID ^ agentID).ToString());
         }
index 193b893..8b31e86 100644 (file)
     <Compile Include="Core\Media\MediaObject.cs" />\r
     <Compile Include="Core\Media\Speech.cs" />\r
     <Compile Include="Core\Media\Stream.cs" />\r
+    <Compile Include="Core\Media\UISounds.cs" />\r
     <Compile Include="Core\NameManager.cs" />\r
     <Compile Include="Core\PluginInterface\IRadegastPlugin.cs" />\r
     <Compile Include="Core\PluginInterface\PluginAttribute.cs" />\r