Esempio n. 1
0
        //SB change. This is super hacky and super gross
        public void AddProperties(Actor actor)
        {
            bool agentFlag = false;
            string agents = "";
            //if (!actor.Equals(currentActor) && actor.Parm.GetCount() > 0)

            if (!actor.Equals(currentActor) || propertiesChanged)
            {
                propertiesChanged = false;
                this.currentActor = actor;
                this.PropertiesPanel.Controls.Clear();

                if (currentActor.Parm.HasParm("Agents"))
                    agents = currentActor.Parm.GetString("Agents");
                else
                    agents = "";

                var enumerator = actor.Parm.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    ExpandedTextBox textbox = new ExpandedTextBox(actor);
                    Label label = new Label();
                    label.Text = enumerator.Current.Key;
                    if (label.Text == "Agents")
                    {
                        agentFlag = true;
                        textbox.DoubleClick += new EventHandler(this.agentTextBox_DoubleClick);
                    }
                    label.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
                    string[] values = isAgentValue(agents, label.Text);
                    /*if (values != null && agents != "")
                    {
                        ComboBox combo = new ComboBox();
                        combo.Name = label.Text;
                        foreach (string value in values)
                        {
                            if (value == enumerator.Current.Value)
                                combo.SelectedIndex = combo.Items.Add(value);
                            else
                                combo.Items.Add(value);

                        }
                        combo.SelectedIndexChanged += new EventHandler(this.PropertyChangedCombo);

                        PropertiesPanel.Controls.Add(label);
                        PropertiesPanel.Controls.Add(combo);

                    }
                    else
                    {*/
                        textbox.Name = label.Text;
                        textbox.Text = enumerator.Current.Value;
                        textbox.LeaveWithChangedText += new EventHandler(this.PropertyChangedTextBox);

                        PropertiesPanel.Controls.Add(label);
                        PropertiesPanel.Controls.Add(textbox);
                    //}
                }

                //Add agents field if there wasn't one already
                if (!agentFlag)
                {
                    ExpandedTextBox textbox = new ExpandedTextBox(actor);
                    Label label = new Label();
                    label.Text = "Agents";
                    textbox.DoubleClick += new EventHandler(this.agentTextBox_DoubleClick);
                    label.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
                    textbox.Name = label.Text;
                    textbox.TextChanged += new EventHandler(this.PropertyChangedTextBox);
                    PropertiesPanel.Controls.Add(label);
                    PropertiesPanel.Controls.Add(textbox);
                }

                //position
                Vector3 pos = actor.PhysicsObject.Position;

                Label labelPos = new Label();
                labelPos.Text = "Position";
                ExpandedTextBox textBoxPos = new ExpandedTextBox(actor);
                textBoxPos.Name = labelPos.Text;
                textBoxPos.Text = pos.X.ToString() + ' ' + pos.Y.ToString() + ' ' + pos.Z.ToString();
                textBoxPos.TextChanged += new EventHandler(this.PropertyChangedTextBox);
                PropertiesPanel.Controls.Add(labelPos);
                PropertiesPanel.Controls.Add(textBoxPos);
                /*
                labelPos = new Label();
                labelPos.Text = "Position.Y";
                textBoxPos = new ExpandedTextBox(actor);
                textBoxPos.Name = labelPos.Text;
                textBoxPos.Text = pos.Y.ToString();
                textBoxPos.TextChanged += new EventHandler(this.PropertyChangedTextBox);
                PropertiesPanel.Controls.Add(labelPos);
                PropertiesPanel.Controls.Add(textBoxPos);

                labelPos = new Label();
                labelPos.Text = "Position.Z";
                textBoxPos = new ExpandedTextBox(actor);
                textBoxPos.Name = labelPos.Text;
                textBoxPos.Text = pos.Z.ToString();
                textBoxPos.TextChanged += new EventHandler(this.PropertyChangedTextBox);
                PropertiesPanel.Controls.Add(labelPos);
                PropertiesPanel.Controls.Add(textBoxPos);
                */
                //rotation
                Vector3 r;
                Quaternion q = actor.PhysicsObject.Orientation;
                PhysicsHelpers.QuaternionToEuler(ref q, out r);
                Label labelRot = new Label();
                labelRot.Text = "Rotation";
                ExpandedTextBox textBoxRot = new ExpandedTextBox(actor);
                textBoxRot.Name = labelRot.Text;
                textBoxRot.Text = r.X.ToString() + ' ' + r.Y.ToString() + ' ' + r.Z.ToString();
                textBoxRot.TextChanged += new EventHandler(this.PropertyChangedTextBox);
                PropertiesPanel.Controls.Add(labelRot);
                PropertiesPanel.Controls.Add(textBoxRot);

                /*
                labelRot = new Label();
                labelRot.Text = "Rotation.Y";
                textBoxRot = new ExpandedTextBox(actor);
                textBoxRot.Name = labelRot.Text;
                textBoxRot.Text = r.Y.ToString();
                textBoxRot.TextChanged += new EventHandler(this.PropertyChangedTextBox);
                PropertiesPanel.Controls.Add(labelRot);
                PropertiesPanel.Controls.Add(textBoxRot);

                labelRot = new Label();
                labelRot.Text = "Rotation.Z";
                textBoxRot = new ExpandedTextBox(actor);
                textBoxRot.Name = labelRot.Text;
                textBoxRot.Text = r.Z.ToString();
                textBoxRot.TextChanged += new EventHandler(this.PropertyChangedTextBox);
                PropertiesPanel.Controls.Add(labelRot);
                PropertiesPanel.Controls.Add(textBoxRot);
                */
            }
        }
 public PropertyEventArgs(ExpandedTextBox textbox)
 {
     this.textbox = textbox;
 }