OSDN Git Service

RAD-261: Add Tools -> My attachments menu for easily seeing own attachments
authorLatif Khalifa <latifer@streamgrid.net>
Wed, 18 May 2011 20:15:59 +0000 (20:15 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Wed, 18 May 2011 20:15:59 +0000 (20:15 +0000)
Display attachments with saner camera view.

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

Radegast/GUI/Consoles/AttachmentDetail.Designer.cs
Radegast/GUI/Consoles/AttachmentDetail.cs
Radegast/GUI/Consoles/AttachmentTab.cs
Radegast/GUI/Consoles/ChatConsole.cs
Radegast/GUI/Consoles/ObjectsConsole.cs
Radegast/GUI/Consoles/TabsConsole.cs
Radegast/GUI/Dialogs/MainForm.Designer.cs
Radegast/GUI/Dialogs/MainForm.cs
Radegast/GUI/Dialogs/PrimWorkshop.Designer.cs
Radegast/GUI/Dialogs/PrimWorkshop.cs
Radegast/RadegastBuild.cs

index d727d47..9fb5cce 100644 (file)
@@ -151,7 +151,7 @@ namespace Radegast
             this.button1.Name = "button1";
             this.button1.Size = new System.Drawing.Size(75, 23);
             this.button1.TabIndex = 3;
-            this.button1.Text = "3D View";
+            this.button1.Text = "View";
             this.button1.UseVisualStyleBackColor = true;
             this.button1.Click += new System.EventHandler(this.button1_Click);
             // 
index da776d1..0cd8581 100644 (file)
@@ -84,7 +84,8 @@ namespace Radegast
 
         private void UpdateControls()
         {
-            if (InvokeRequired) {
+            if (InvokeRequired)
+            {
                 Invoke(new MethodInvoker(UpdateControls));
                 return;
             }
@@ -102,14 +103,15 @@ namespace Radegast
                 {
                     return (prim.LocalID == attachment.LocalID || prim.ParentID == attachment.LocalID);
                 }
-            ); 
+            );
 
             lblPrimCount.Text = "Prims: " + parts.Count.ToString();
         }
 
         void Objects_ObjectProperties(object sender, ObjectPropertiesEventArgs e)
         {
-            if (e.Properties.ObjectID == attachment.ID) {
+            if (e.Properties.ObjectID == attachment.ID)
+            {
                 attachment.Properties = e.Properties;
                 UpdateControls();
             }
@@ -157,27 +159,9 @@ namespace Radegast
 
         private void button1_Click(object sender, EventArgs e)
         {
-            var prims = instance.Client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => p.ParentID == attachment.LocalID || p.LocalID == attachment.LocalID);
-            var root = prims.Find((Primitive p) => p.LocalID == attachment.LocalID);
-            if (root != null)
-            {
-                prims.Remove(root);
-                root = new Primitive(root);
-                root.ParentID = 0;
-
-                frmPrimWorkshop pw = new frmPrimWorkshop(instance);
-                pw.Shown += (xsender, xe) =>
-                {
-                    Thread.Sleep(500);
-                    pw.SetupGLControl();
-                    if (pw.RenderingEnabled)
-                    {
-                        pw.LoadPrims(prims);
-                    }
-                };
-                pw.Show();
-
-            }
+            frmPrimWorkshop pw = new frmPrimWorkshop(instance, attachment.LocalID);
+            pw.Show();
+            pw.SetView(new Vector3(0f, 0.5f, 0f), 0, 0, 90, -10);
         }
     }
 }
index 8d6d98d..79d0e0a 100644 (file)
@@ -57,7 +57,7 @@ namespace Radegast
             RefreshList();
         }
 
-        private void RefreshList()
+        public void RefreshList()
         {
             List<Primitive> attachments = client.Network.CurrentSim.ObjectsPrimitives.FindAll(
                 delegate(Primitive prim)
index 92e65e2..15d9e3e 100644 (file)
@@ -670,11 +670,12 @@ namespace Radegast
             Avatar av = currentAvatar;
             if (av == null) return;
 
-            if (!instance.TabConsole.TabExists("AT: " + av.Name))
+            if (!instance.TabConsole.TabExists("AT: " + av.ID.ToString()))
             {
-                instance.TabConsole.AddATTab(av);
+               instance.TabConsole.AddTab("AT: " + av.ID.ToString(), "AT: " + av.Name, new AttachmentTab(instance, av));
+
             }
-            instance.TabConsole.SelectTab("AT: " + av.Name);
+            instance.TabConsole.SelectTab("AT: " + av.ID.ToString());
         }
 
         private void tbtnAnim_Click(object sender, EventArgs e)
index 5de769d..1d46ba7 100644 (file)
@@ -903,18 +903,7 @@ namespace Radegast
                 return;
             }
 
-            var prims = client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => p.LocalID == currentPrim.LocalID || p.ParentID == currentPrim.LocalID);
-
-            frmPrimWorkshop pw = new frmPrimWorkshop(instance);
-            pw.Shown += (xsender, xe) =>
-                {
-                    Thread.Sleep(500);
-                    pw.SetupGLControl();
-                    if (pw.RenderingEnabled)
-                    {
-                        pw.LoadPrims(prims);
-                    }
-                };
+            frmPrimWorkshop pw = new frmPrimWorkshop(instance, currentPrim.LocalID);
             pw.Show();
         }
 
index 170a720..696469a 100644 (file)
@@ -994,14 +994,6 @@ namespace Radegast
             return msTab;
         }
 
-        public AttachmentTab AddATTab(Avatar avatar)
-        {
-            AttachmentTab atTab = new AttachmentTab(instance, avatar);
-
-            RadegastTab tab = AddTab("AT: " + avatar.Name, "AT: " + avatar.Name, atTab);
-            return atTab;
-        }
-
         public AnimTab AddAnimTab(Avatar avatar)
         {
             AnimTab animTab = new AnimTab(instance, avatar);
index 574b5dd..ed89dc0 100644 (file)
@@ -75,6 +75,7 @@ namespace Radegast
             this.toolStrip1 = new System.Windows.Forms.ToolStrip();
             this.tbtnSLeek = new System.Windows.Forms.ToolStripDropDownButton();
             this.newWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.uploadImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.tmnuImport = new System.Windows.Forms.ToolStripMenuItem();
             this.scriptEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
@@ -147,7 +148,7 @@ namespace Radegast
             this.ctxTreyRestore = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
             this.ctxTreyExit = new System.Windows.Forms.ToolStripMenuItem();
-            this.uploadImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.myAttachmentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStrip1.SuspendLayout();
             this.statusStrip1.SuspendLayout();
             this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
@@ -212,6 +213,13 @@ namespace Radegast
             this.newWindowToolStripMenuItem.Text = "&New window...";
             this.newWindowToolStripMenuItem.Click += new System.EventHandler(this.newWindowToolStripMenuItem_Click);
             // 
+            // uploadImageToolStripMenuItem
+            // 
+            this.uploadImageToolStripMenuItem.Name = "uploadImageToolStripMenuItem";
+            this.uploadImageToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
+            this.uploadImageToolStripMenuItem.Text = "Upload image...";
+            this.uploadImageToolStripMenuItem.Click += new System.EventHandler(this.uploadImageToolStripMenuItem_Click);
+            // 
             // tmnuImport
             // 
             this.tmnuImport.Enabled = false;
@@ -417,7 +425,8 @@ namespace Radegast
             this.cleanCacheToolStripMenuItem,
             this.reloadInventoryToolStripMenuItem,
             this.setAppearanceToolStripMenuItem,
-            this.rebakeTexturesToolStripMenuItem});
+            this.rebakeTexturesToolStripMenuItem,
+            this.myAttachmentsToolStripMenuItem});
             this.tbnTools.Enabled = false;
             this.tbnTools.Image = ((System.Drawing.Image)(resources.GetObject("tbnTools.Image")));
             this.tbnTools.ImageTransparentColor = System.Drawing.Color.Magenta;
@@ -856,12 +865,12 @@ namespace Radegast
             this.ctxTreyExit.ToolTipText = "Loggs of and closes application";
             this.ctxTreyExit.Click += new System.EventHandler(this.ctxTreyExit_Click);
             // 
-            // uploadImageToolStripMenuItem
+            // myAttachmentsToolStripMenuItem
             // 
-            this.uploadImageToolStripMenuItem.Name = "uploadImageToolStripMenuItem";
-            this.uploadImageToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
-            this.uploadImageToolStripMenuItem.Text = "Upload image...";
-            this.uploadImageToolStripMenuItem.Click += new System.EventHandler(this.uploadImageToolStripMenuItem_Click);
+            this.myAttachmentsToolStripMenuItem.Name = "myAttachmentsToolStripMenuItem";
+            this.myAttachmentsToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
+            this.myAttachmentsToolStripMenuItem.Text = "My Attachments";
+            this.myAttachmentsToolStripMenuItem.Click += new System.EventHandler(this.myAttachmentsToolStripMenuItem_Click);
             // 
             // frmMain
             // 
@@ -974,6 +983,7 @@ namespace Radegast
         public System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
         public System.Windows.Forms.ToolStripMenuItem uploadImageToolStripMenuItem;
         public System.Windows.Forms.ToolStripMenuItem muteListToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem myAttachmentsToolStripMenuItem;
     }
 }
 
index ed5cf5c..d7da993 100644 (file)
@@ -1480,5 +1480,23 @@ namespace Radegast
         }
         #endregion
 
+        private void myAttachmentsToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            Avatar av = client.Network.CurrentSim.ObjectsAvatars.Find((Avatar a) => { return a.ID == client.Self.AgentID; });
+            
+            if (av == null)
+            {
+                tabsConsole.DisplayNotificationInChat("Unable to find my avatar!", ChatBufferTextStyle.Error);
+                return;
+            }
+
+            if (!instance.TabConsole.TabExists("AT: " + av.ID.ToString()))
+            {
+                instance.TabConsole.AddTab("AT: " + av.ID.ToString(), "My Attachments", new AttachmentTab(instance, av));
+            }
+            instance.TabConsole.SelectTab("AT: " + av.ID.ToString());
+
+        }
+
     }
 }
\ No newline at end of file
index c77d62b..a31e98d 100644 (file)
@@ -106,6 +106,7 @@ namespace Radegast
             this.scrollYaw.Name = "scrollYaw";
             this.scrollYaw.Size = new System.Drawing.Size(200, 16);
             this.scrollYaw.TabIndex = 11;
+            this.scrollYaw.Value = 90;
             this.scrollYaw.ValueChanged += new System.EventHandler(this.scroll_ValueChanged);
             // 
             // scrollZoom
@@ -117,7 +118,7 @@ namespace Radegast
             this.scrollZoom.Name = "scrollZoom";
             this.scrollZoom.Size = new System.Drawing.Size(200, 16);
             this.scrollZoom.TabIndex = 19;
-            this.scrollZoom.Value = -50;
+            this.scrollZoom.Value = -30;
             this.scrollZoom.ValueChanged += new System.EventHandler(this.scrollZoom_ValueChanged);
             // 
             // gbZoom
@@ -250,6 +251,7 @@ namespace Radegast
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.Name = "frmPrimWorkshop";
             this.Text = "Object Viewer";
+            this.Shown += new System.EventHandler(this.frmPrimWorkshop_Shown);
             this.gbZoom.ResumeLayout(false);
             this.gbZoom.PerformLayout();
             this.ctxObjects.ResumeLayout(false);
index 20f0e70..33168b2 100644 (file)
@@ -77,6 +77,16 @@ namespace Radegast
         /// List of prims in the scene
         /// </summary>
         Dictionary<uint, FacetedMesh> Prims = new Dictionary<uint, FacetedMesh>();
+
+        /// <summary>
+        /// Local ID of the root prim
+        /// </summary>
+        public uint RootPrimLocalID = 0;
+
+        /// <summary>
+        /// Camera center
+        /// </summary>
+        public Vector3 Center = Vector3.Zero;
         #endregion Public fields
 
         #region Private fields
@@ -88,15 +98,16 @@ namespace Radegast
         OpenTK.Graphics.GraphicsMode GLMode = null;
         AutoResetEvent TextureThreadContextReady = new AutoResetEvent(false);
         BlockingQueue<TextureLoadItem> PendingTextures = new BlockingQueue<TextureLoadItem>();
-        Vector3 Center = Vector3.Zero;
         float[] lightPos = new float[] { 0f, 0f, 1f, 0f };
 
         #endregion Private fields
 
         #region Construction and disposal
-        public frmPrimWorkshop(RadegastInstance instance)
+        public frmPrimWorkshop(RadegastInstance instance, uint rootLocalID)
             : base(instance)
         {
+            this.RootPrimLocalID = rootLocalID;
+
             InitializeComponent();
             Disposed += new EventHandler(frmPrimWorkshop_Disposed);
             AutoSavePosition = true;
@@ -187,7 +198,7 @@ namespace Radegast
                 GLMode = null;
             }
 
-            
+
             try
             {
                 if (GLMode == null)
@@ -511,17 +522,32 @@ namespace Radegast
         }
         #endregion Texture thread
 
-        #region Public methods
-        public void LoadPrims(List<Primitive> primList)
+        private void frmPrimWorkshop_Shown(object sender, EventArgs e)
         {
-            if (!RenderingEnabled) return;
+            SetupGLControl();
+
+            ThreadPool.QueueUserWorkItem(sync =>
+                {
+                    if (Client.Network.CurrentSim.ObjectsPrimitives.ContainsKey(RootPrimLocalID))
+                    {
+                        UpdatePrimBlocking(Client.Network.CurrentSim.ObjectsPrimitives[RootPrimLocalID]);
+                        var children = Client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => { return p.ParentID == RootPrimLocalID; });
+                        children.ForEach(p => UpdatePrimBlocking(p));
+                    }
+                }
+            );
 
-            ThreadPool.QueueUserWorkItem((object sync) =>
-            {
-                primList.ForEach(p => UpdatePrimBlocking(p));
-            });
         }
 
+        #region Public methods
+        public void SetView(Vector3 center, int roll, int pitch, int yaw, int zoom)
+        {
+            this.Center = center;
+            scrollRoll.Value = roll;
+            scrollPitch.Value = pitch;
+            scrollYaw.Value = yaw;
+            scrollZoom.Value = zoom;
+        }
 
         public FacetedMesh GenerateFacetedMesh(Primitive prim, OSDMap MeshData, DetailLevel LOD)
         {
@@ -693,13 +719,14 @@ namespace Radegast
                         string text = System.Text.RegularExpressions.Regex.Replace(prim.Text, "(\r?\n)+", "\n");
                         OpenTK.Vector3 screenPos = OpenTK.Vector3.Zero;
                         OpenTK.Vector3 primPos = OpenTK.Vector3.Zero;
-                        
-                        if (prim.ParentID != 0)
+
+                        // Is it child prim
+                        if (prim.ParentID == RootPrimLocalID)
                         {
                             primPos = new OpenTK.Vector3(prim.Position.X, prim.Position.Y, prim.Position.Z);
                         }
-                        
-                        primPos.Z += prim.Scale.Z * 0.7f; 
+
+                        primPos.Z += prim.Scale.Z * 0.7f;
                         screenPos = WorldToScreen(primPos);
                         Printer.Begin();
 
@@ -710,7 +737,7 @@ namespace Radegast
                             var size = Printer.Measure(text, f);
                             screenPos.X -= size.BoundingBox.Width / 2;
                             screenPos.Y -= size.BoundingBox.Height;
-                            
+
                             // Shadow
                             if (color != Color.Black)
                             {
@@ -736,7 +763,7 @@ namespace Radegast
                     // Individual prim matrix
                     GL.PushMatrix();
 
-                    if (prim.ParentID != 0)
+                    if (prim.ParentID == RootPrimLocalID)
                     {
                         FacetedMesh parent = null;
                         if (Prims.TryGetValue(prim.ParentID, out parent))
@@ -772,33 +799,31 @@ namespace Radegast
 
                             if (belongToAlphaPass && pass != RenderPass.Alpha) continue;
                             if (!belongToAlphaPass && pass == RenderPass.Alpha) continue;
-                        }
-                        // Don't render transparent faces
-                        if (teFace.RGBA.A <= 0.01f) continue;
 
-                        switch (teFace.Shiny)
-                        {
-                            case Shininess.High:
-                                GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 94f);
-                                break;
+                            // Don't render transparent faces
+                            if (teFace.RGBA.A <= 0.01f) continue;
 
-                            case Shininess.Medium:
-                                GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 64f);
-                                break;
+                            switch (teFace.Shiny)
+                            {
+                                case Shininess.High:
+                                    GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 94f);
+                                    break;
 
-                            case Shininess.Low:
-                                GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 24f);
-                                break;
+                                case Shininess.Medium:
+                                    GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 64f);
+                                    break;
 
+                                case Shininess.Low:
+                                    GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 24f);
+                                    break;
 
-                            case Shininess.None:
-                            default:
-                                GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 0f);
-                                break;
-                        }
 
-                        if (pass != RenderPass.Picking)
-                        {
+                                case Shininess.None:
+                                default:
+                                    GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 0f);
+                                    break;
+                            }
+
                             var faceColor = new float[] { teFace.RGBA.R, teFace.RGBA.G, teFace.RGBA.B, teFace.RGBA.A };
 
                             GL.Color4(faceColor);
@@ -1152,6 +1177,8 @@ namespace Radegast
 
         private void SafeInvalidate()
         {
+            if (glControl == null || !RenderingEnabled) return;
+
             if (InvokeRequired)
             {
                 if (!instance.MonoRuntime || IsHandleCreated)
@@ -1185,10 +1212,10 @@ namespace Radegast
 
         private void btnReset_Click(object sender, EventArgs e)
         {
-            scrollYaw.Value = 0;
+            scrollYaw.Value = 90;
             scrollPitch.Value = 0;
             scrollRoll.Value = 0;
-            scrollZoom.Value = -50;
+            scrollZoom.Value = -30;
             Center = Vector3.Zero;
 
             SafeInvalidate();
@@ -1293,6 +1320,7 @@ namespace Radegast
         #endregion Context menu
 
 
+
     }
 
     #region Helper classes
index 79fa93b..03eed58 100644 (file)
@@ -1,5 +1,5 @@
 // Autogenerated: run updatebuildnr.bat/sh to update 
 namespace Radegast 
 { 
-    public static class RadegastBuild { public static int CurrentRev = 821; } 
+    public static class RadegastBuild { public static int CurrentRev = 870; } 
 }