OSDN Git Service

RAD-259: Ability to change name, description, and permissions of rezzed objects
authorLatif Khalifa <latifer@streamgrid.net>
Sun, 15 May 2011 20:03:51 +0000 (20:03 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Sun, 15 May 2011 20:03:51 +0000 (20:03 +0000)
RAD-257: Ability to look into linked objects

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

Radegast/GUI/Consoles/ObjectsConsole.Designer.cs
Radegast/GUI/Consoles/ObjectsConsole.cs

index 0b74bc9..c457952 100644 (file)
@@ -92,6 +92,7 @@ namespace Radegast
             this.cbOwnerCopy = new System.Windows.Forms.CheckBox();
             this.cbOwnerModify = new System.Windows.Forms.CheckBox();
             this.txtPrims = new System.Windows.Forms.TextBox();
+            this.txtCreator = new Radegast.AgentNameTextBox();
             this.txtOwner = new Radegast.AgentNameTextBox();
             this.txtHover = new System.Windows.Forms.TextBox();
             this.txtDescription = new System.Windows.Forms.TextBox();
@@ -115,13 +116,16 @@ namespace Radegast
             this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
             this.ctxMenuObjects = new Radegast.RadegastContextMenuStrip(this.components);
             this.ctxopen = new Radegast.RadegastContextMenuStrip(this.components);
-            this.txtCreator = new Radegast.AgentNameTextBox();
+            this.pnlList = new System.Windows.Forms.Panel();
+            this.lstChildren = new Radegast.ListViewNoFlicker();
+            this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
             this.gbxInworld.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.nudRadius)).BeginInit();
             this.groupBox1.SuspendLayout();
             this.statusStrip1.SuspendLayout();
             this.gbxObjectDetails.SuspendLayout();
             this.gbxContents.SuspendLayout();
+            this.pnlList.SuspendLayout();
             this.SuspendLayout();
             // 
             // gbxInworld
@@ -428,26 +432,31 @@ namespace Radegast
             // cbNextOwnTransfer
             // 
             this.cbNextOwnTransfer.AutoSize = true;
+            this.cbNextOwnTransfer.Enabled = false;
             this.cbNextOwnTransfer.Location = new System.Drawing.Point(195, 164);
             this.cbNextOwnTransfer.Name = "cbNextOwnTransfer";
             this.cbNextOwnTransfer.Size = new System.Drawing.Size(54, 17);
             this.cbNextOwnTransfer.TabIndex = 61;
             this.cbNextOwnTransfer.Text = "Resell";
             this.cbNextOwnTransfer.UseVisualStyleBackColor = true;
+            this.cbNextOwnTransfer.CheckedChanged += new System.EventHandler(this.cbNextOwnerUpdate_CheckedChanged);
             // 
             // cbNextOwnCopy
             // 
             this.cbNextOwnCopy.AutoSize = true;
+            this.cbNextOwnCopy.Enabled = false;
             this.cbNextOwnCopy.Location = new System.Drawing.Point(140, 164);
             this.cbNextOwnCopy.Name = "cbNextOwnCopy";
             this.cbNextOwnCopy.Size = new System.Drawing.Size(51, 17);
             this.cbNextOwnCopy.TabIndex = 60;
             this.cbNextOwnCopy.Text = "Copy";
             this.cbNextOwnCopy.UseVisualStyleBackColor = true;
+            this.cbNextOwnCopy.CheckedChanged += new System.EventHandler(this.cbNextOwnerUpdate_CheckedChanged);
             // 
             // cbOwnerTransfer
             // 
             this.cbOwnerTransfer.AutoSize = true;
+            this.cbOwnerTransfer.Enabled = false;
             this.cbOwnerTransfer.Location = new System.Drawing.Point(195, 143);
             this.cbOwnerTransfer.Name = "cbOwnerTransfer";
             this.cbOwnerTransfer.Size = new System.Drawing.Size(54, 17);
@@ -458,16 +467,19 @@ namespace Radegast
             // cbNextOwnModify
             // 
             this.cbNextOwnModify.AutoSize = true;
+            this.cbNextOwnModify.Enabled = false;
             this.cbNextOwnModify.Location = new System.Drawing.Point(90, 164);
             this.cbNextOwnModify.Name = "cbNextOwnModify";
             this.cbNextOwnModify.Size = new System.Drawing.Size(46, 17);
             this.cbNextOwnModify.TabIndex = 59;
             this.cbNextOwnModify.Text = "Mod";
             this.cbNextOwnModify.UseVisualStyleBackColor = true;
+            this.cbNextOwnModify.CheckedChanged += new System.EventHandler(this.cbNextOwnerUpdate_CheckedChanged);
             // 
             // cbOwnerCopy
             // 
             this.cbOwnerCopy.AutoSize = true;
+            this.cbOwnerCopy.Enabled = false;
             this.cbOwnerCopy.Location = new System.Drawing.Point(140, 143);
             this.cbOwnerCopy.Name = "cbOwnerCopy";
             this.cbOwnerCopy.Size = new System.Drawing.Size(51, 17);
@@ -478,6 +490,7 @@ namespace Radegast
             // cbOwnerModify
             // 
             this.cbOwnerModify.AutoSize = true;
+            this.cbOwnerModify.Enabled = false;
             this.cbOwnerModify.Location = new System.Drawing.Point(90, 143);
             this.cbOwnerModify.Name = "cbOwnerModify";
             this.cbOwnerModify.Size = new System.Drawing.Size(46, 17);
@@ -494,6 +507,16 @@ namespace Radegast
             this.txtPrims.Size = new System.Drawing.Size(54, 21);
             this.txtPrims.TabIndex = 55;
             // 
+            // txtCreator
+            // 
+            this.txtCreator.AgentID = ((OpenMetaverse.UUID)(resources.GetObject("txtCreator.AgentID")));
+            this.txtCreator.BackColor = System.Drawing.SystemColors.Window;
+            this.txtCreator.Location = new System.Drawing.Point(61, 116);
+            this.txtCreator.Name = "txtCreator";
+            this.txtCreator.ReadOnly = true;
+            this.txtCreator.Size = new System.Drawing.Size(130, 21);
+            this.txtCreator.TabIndex = 54;
+            // 
             // txtOwner
             // 
             this.txtOwner.AgentID = ((OpenMetaverse.UUID)(resources.GetObject("txtOwner.AgentID")));
@@ -515,17 +538,23 @@ namespace Radegast
             // 
             // txtDescription
             // 
+            this.txtDescription.BackColor = System.Drawing.SystemColors.Window;
             this.txtDescription.Location = new System.Drawing.Point(61, 41);
             this.txtDescription.Name = "txtDescription";
+            this.txtDescription.ReadOnly = true;
             this.txtDescription.Size = new System.Drawing.Size(188, 21);
             this.txtDescription.TabIndex = 51;
+            this.txtDescription.Leave += new System.EventHandler(this.txtDescription_Leave);
             // 
             // txtObjectName
             // 
+            this.txtObjectName.BackColor = System.Drawing.SystemColors.Window;
             this.txtObjectName.Location = new System.Drawing.Point(61, 16);
             this.txtObjectName.Name = "txtObjectName";
+            this.txtObjectName.ReadOnly = true;
             this.txtObjectName.Size = new System.Drawing.Size(188, 21);
             this.txtObjectName.TabIndex = 50;
+            this.txtObjectName.Leave += new System.EventHandler(this.txtObjectName_Leave);
             // 
             // label8
             // 
@@ -680,21 +709,19 @@ namespace Radegast
             // lstPrims
             // 
             this.lstPrims.AccessibleName = "Objects";
-            this.lstPrims.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
-                        | System.Windows.Forms.AnchorStyles.Left)
-                        | System.Windows.Forms.AnchorStyles.Right)));
             this.lstPrims.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
             this.columnHeader1});
             this.lstPrims.ContextMenuStrip = this.ctxMenuObjects;
+            this.lstPrims.Dock = System.Windows.Forms.DockStyle.Fill;
             this.lstPrims.FullRowSelect = true;
             this.lstPrims.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
             this.lstPrims.HideSelection = false;
             this.lstPrims.LabelWrap = false;
-            this.lstPrims.Location = new System.Drawing.Point(12, 39);
+            this.lstPrims.Location = new System.Drawing.Point(0, 0);
             this.lstPrims.MultiSelect = false;
             this.lstPrims.Name = "lstPrims";
             this.lstPrims.ShowGroups = false;
-            this.lstPrims.Size = new System.Drawing.Size(365, 392);
+            this.lstPrims.Size = new System.Drawing.Size(358, 258);
             this.lstPrims.TabIndex = 0;
             this.lstPrims.UseCompatibleStateImageBehavior = false;
             this.lstPrims.View = System.Windows.Forms.View.Details;
@@ -715,25 +742,53 @@ namespace Radegast
             this.ctxopen.Name = "ctxMenuObjects";
             this.ctxopen.Size = new System.Drawing.Size(61, 4);
             // 
-            // txtCreator
+            // pnlList
             // 
-            this.txtCreator.AgentID = ((OpenMetaverse.UUID)(resources.GetObject("txtCreator.AgentID")));
-            this.txtCreator.BackColor = System.Drawing.SystemColors.Window;
-            this.txtCreator.Location = new System.Drawing.Point(61, 116);
-            this.txtCreator.Name = "txtCreator";
-            this.txtCreator.ReadOnly = true;
-            this.txtCreator.Size = new System.Drawing.Size(130, 21);
-            this.txtCreator.TabIndex = 54;
+            this.pnlList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+                        | System.Windows.Forms.AnchorStyles.Left)
+                        | System.Windows.Forms.AnchorStyles.Right)));
+            this.pnlList.Controls.Add(this.lstPrims);
+            this.pnlList.Controls.Add(this.lstChildren);
+            this.pnlList.Location = new System.Drawing.Point(15, 39);
+            this.pnlList.Name = "pnlList";
+            this.pnlList.Size = new System.Drawing.Size(358, 390);
+            this.pnlList.TabIndex = 74;
+            // 
+            // lstChildren
+            // 
+            this.lstChildren.AccessibleName = "Objects";
+            this.lstChildren.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+            this.columnHeader2});
+            this.lstChildren.ContextMenuStrip = this.ctxMenuObjects;
+            this.lstChildren.Dock = System.Windows.Forms.DockStyle.Bottom;
+            this.lstChildren.FullRowSelect = true;
+            this.lstChildren.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
+            this.lstChildren.HideSelection = false;
+            this.lstChildren.LabelWrap = false;
+            this.lstChildren.Location = new System.Drawing.Point(0, 258);
+            this.lstChildren.MultiSelect = false;
+            this.lstChildren.Name = "lstChildren";
+            this.lstChildren.ShowGroups = false;
+            this.lstChildren.Size = new System.Drawing.Size(358, 132);
+            this.lstChildren.TabIndex = 1;
+            this.lstChildren.UseCompatibleStateImageBehavior = false;
+            this.lstChildren.View = System.Windows.Forms.View.Details;
+            this.lstChildren.Visible = false;
+            this.lstChildren.SelectedIndexChanged += new System.EventHandler(this.lstChildren_SelectedIndexChanged);
+            // 
+            // columnHeader2
+            // 
+            this.columnHeader2.Width = 340;
             // 
             // ObjectsConsole
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.Controls.Add(this.pnlList);
             this.Controls.Add(this.gbxObjectDetails);
             this.Controls.Add(this.statusStrip1);
             this.Controls.Add(this.groupBox1);
             this.Controls.Add(this.nudRadius);
-            this.Controls.Add(this.lstPrims);
             this.Controls.Add(this.btnRefresh);
             this.Controls.Add(this.btnClear);
             this.Controls.Add(this.lblDistance);
@@ -754,6 +809,7 @@ namespace Radegast
             this.gbxObjectDetails.ResumeLayout(false);
             this.gbxObjectDetails.PerformLayout();
             this.gbxContents.ResumeLayout(false);
+            this.pnlList.ResumeLayout(false);
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -817,6 +873,9 @@ namespace Radegast
         private System.Windows.Forms.Button btnOpen;
         public System.Windows.Forms.Button btnMute;
         public AgentNameTextBox txtCreator;
+        private System.Windows.Forms.Panel pnlList;
+        public ListViewNoFlicker lstChildren;
+        public System.Windows.Forms.ColumnHeader columnHeader2;
 
     }
 }
\ No newline at end of file
index d4ce39b..08b1275 100644 (file)
@@ -227,6 +227,16 @@ namespace Radegast
                 }
             }
 
+            lock (lstChildren.Items)
+            {
+                if (lstChildren.Items.ContainsKey(e.Properties.ObjectID.ToString()))
+                {
+                    Primitive prim = lstChildren.Items[e.Properties.ObjectID.ToString()].Tag as Primitive;
+                    prim.Properties = e.Properties;
+                    lstChildren.Items[e.Properties.ObjectID.ToString()].Text = prim.Properties.Name;
+                }
+            }
+
             if (e.Properties.ObjectID == currentPrim.ID)
             {
                 UpdateCurrentObject(false);
@@ -334,8 +344,7 @@ namespace Radegast
 
             ctxContents.Items.Clear();
             Primitive prim = (Primitive)lstContents.Tag;
-            bool myObject = prim.Properties != null && prim.Properties.OwnerID == client.Self.AgentID;
-
+            bool canModify = (prim.Flags & PrimFlags.ObjectModify) == PrimFlags.ObjectModify;
 
             if (lstContents.SelectedItems.Count == 1)
             {
@@ -345,7 +354,7 @@ namespace Radegast
                 {
                     InventoryItem item = (InventoryItem)entry.Tag;
 
-                    if (myObject)
+                    if (canModify)
                     {
                         switch (item.InventoryType)
                         {
@@ -387,7 +396,7 @@ namespace Radegast
                 ctxContents.Items.Add(new ToolStripSeparator());
             }
 
-            if (myObject && instance.InventoryClipboard != null)
+            if (canModify && instance.InventoryClipboard != null)
             {
                 if (instance.InventoryClipboard.Item is InventoryItem)
                 {
@@ -425,7 +434,7 @@ namespace Radegast
                 }
             }
 
-            if (myObject)
+            if (canModify)
             {
                 ctxContents.Items.Add("Open (copy all to inventory)", null, OpenObject);
             }
@@ -476,10 +485,21 @@ namespace Radegast
                 return;
             }
 
-            currentItem.Text = GetObjectName(currentPrim);
+            // currentItem.Text = GetObjectName(currentPrim);
 
             txtObjectName.Text = currentPrim.Properties.Name;
             txtDescription.Text = currentPrim.Properties.Description;
+            if ((currentPrim.Flags & PrimFlags.ObjectModify) == PrimFlags.ObjectModify)
+            {
+                txtObjectName.ReadOnly = txtDescription.ReadOnly = false;
+                gbxObjectDetails.Text = "Object details (you can modify)";
+            }
+            else
+            {
+                txtObjectName.ReadOnly = txtDescription.ReadOnly = true;
+                gbxObjectDetails.Text = "Object details";
+            }
+
             txtHover.Text = currentPrim.Text;
             txtOwner.AgentID = currentPrim.Properties.OwnerID;
             txtCreator.AgentID = currentPrim.Properties.CreatorID;
@@ -488,10 +508,28 @@ namespace Radegast
             cbOwnerModify.Checked = (p.OwnerMask & PermissionMask.Modify) != 0;
             cbOwnerCopy.Checked = (p.OwnerMask & PermissionMask.Copy) != 0;
             cbOwnerTransfer.Checked = (p.OwnerMask & PermissionMask.Transfer) != 0;
+
+            cbNextOwnModify.CheckedChanged -= cbNextOwnerUpdate_CheckedChanged;
+            cbNextOwnCopy.CheckedChanged -= cbNextOwnerUpdate_CheckedChanged;
+            cbNextOwnTransfer.CheckedChanged -= cbNextOwnerUpdate_CheckedChanged;
+
             cbNextOwnModify.Checked = (p.NextOwnerMask & PermissionMask.Modify) != 0;
             cbNextOwnCopy.Checked = (p.NextOwnerMask & PermissionMask.Copy) != 0;
             cbNextOwnTransfer.Checked = (p.NextOwnerMask & PermissionMask.Transfer) != 0;
 
+            cbNextOwnModify.CheckedChanged += cbNextOwnerUpdate_CheckedChanged;
+            cbNextOwnCopy.CheckedChanged += cbNextOwnerUpdate_CheckedChanged;
+            cbNextOwnTransfer.CheckedChanged += cbNextOwnerUpdate_CheckedChanged;
+
+            if (currentPrim.Properties.OwnerID == client.Self.AgentID)
+            {
+                cbNextOwnModify.Enabled = cbNextOwnCopy.Enabled = cbNextOwnTransfer.Enabled = true;
+            }
+            else
+            {
+                cbNextOwnModify.Enabled = cbNextOwnCopy.Enabled = cbNextOwnTransfer.Enabled = false;
+            }
+
             txtPrims.Text = (client.Network.CurrentSim.ObjectsPrimitives.FindAll(
                 delegate(Primitive prim)
                 {
@@ -550,7 +588,7 @@ namespace Radegast
 
             if (prim.Properties == null)
             {
-                if (prim.ParentID != 0) throw new Exception("Requested properties for non root prim");
+                //if (prim.ParentID != 0) throw new Exception("Requested properties for non root prim");
                 propRequester.RequestProps(prim.LocalID);
             }
             else
@@ -789,6 +827,29 @@ namespace Radegast
                 }
 
                 UpdateCurrentObject();
+                UpdateChildren();
+            }
+            else
+            {
+                lstChildren.Visible = false;
+                gbxInworld.Enabled = false;
+            }
+        }
+
+        private void lstChildren_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            if (lstChildren.SelectedItems.Count == 1)
+            {
+                gbxInworld.Enabled = true;
+                currentPrim = lstChildren.SelectedItems[0].Tag as Primitive;
+                btnBuy.Tag = currentPrim;
+
+                if (currentPrim.Properties == null)
+                {
+                    client.Objects.SelectObject(client.Network.CurrentSim, currentPrim.LocalID);
+                }
+
+                UpdateCurrentObject();
             }
             else
             {
@@ -796,6 +857,39 @@ namespace Radegast
             }
         }
 
+        void UpdateChildren()
+        {
+            if (currentPrim == null) return;
+            var prims = client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => p.ParentID == currentPrim.LocalID);
+            if (prims == null || prims.Count == 0) return;
+
+            lstChildren.BeginUpdate();
+            lock (lstChildren.Items)
+            {
+                lstChildren.Items.Clear();
+                foreach (var prim in prims)
+                {
+                    var item = new ListViewItem();
+
+                    if (prim.Properties != null)
+                    {
+                        item.Text = prim.Properties.Name;
+                    }
+                    else
+                    {
+                        item.Text = "Loading...";
+                        propRequester.RequestProps(prim.LocalID);
+                    }
+
+                    item.Tag = prim;
+                    item.Name = prim.ID.ToString();
+                    lstChildren.Items.Add(item);
+                }
+            }
+            lstChildren.EndUpdate();
+            lstChildren.Visible = true;
+        }
+
         private void btnPay_Click(object sender, EventArgs e)
         {
             (new frmPay(instance, currentPrim.ID, currentPrim.Properties.Name, true)).ShowDialog();
@@ -1129,6 +1223,38 @@ namespace Radegast
                 client.Self.RemoveMuteListEntry(currentPrim.ID, currentPrim.Properties.Name);
             }
         }
+
+        private void txtObjectName_Leave(object sender, EventArgs e)
+        {
+            if (currentPrim == null) return;
+            if (currentPrim.Properties == null || (currentPrim.Properties != null && currentPrim.Properties.Name != txtObjectName.Text))
+            {
+                client.Objects.SetName(client.Network.CurrentSim, currentPrim.LocalID, txtObjectName.Text);
+            }
+        }
+
+        private void txtDescription_Leave(object sender, EventArgs e)
+        {
+            if (currentPrim == null) return;
+            if (currentPrim.Properties == null || (currentPrim.Properties != null && currentPrim.Properties.Description != txtDescription.Text))
+            {
+                client.Objects.SetDescription(client.Network.CurrentSim, currentPrim.LocalID, txtDescription.Text);
+            }
+        }
+
+        private void cbNextOwnerUpdate_CheckedChanged(object sender, EventArgs e)
+        {
+            CheckBox cb = (CheckBox)sender;
+            PermissionMask pm = PermissionMask.None;
+
+            if (cb == cbNextOwnCopy) pm = PermissionMask.Copy;
+            if (cb == cbNextOwnModify) pm = PermissionMask.Modify;
+            if (cb == cbNextOwnTransfer) pm = PermissionMask.Transfer;
+
+            if (pm == PermissionMask.None) return;
+
+            client.Objects.SetPermissions(client.Network.CurrentSim, new List<uint>() { currentPrim.LocalID }, PermissionWho.NextOwner, pm, cb.Checked);
+        }
     }
 
     public class ObjectSorter : IComparer