Ejemplo n.º 1
0
        private MetaControl CreateControl(HaloPlugins.Objects.MetaNode field)
        {
            // Check the field type and handle accordingly.
            switch (field.FieldType)
            {
            case HaloPlugins.Objects.FieldType.Flags:       return(new Bitmask((HaloPlugins.Objects.Data.Flags)field));

            case HaloPlugins.Objects.FieldType.Enum:        return(new Enum((HaloPlugins.Objects.Data.Enum)field));

            case HaloPlugins.Objects.FieldType.Value:       return(new Value((HaloPlugins.Objects.Data.Value)field));

            case HaloPlugins.Objects.FieldType.LongString:
            case HaloPlugins.Objects.FieldType.ShortString:
            case HaloPlugins.Objects.FieldType.StringId:
            case HaloPlugins.Objects.FieldType.Tag:         return(new HaloControls.String(field));

            default:
            {
                // Display a warning to the console
                Console.WriteLine("WARNING: Field type \"{0}\" in tag type \"{1}\" does not have a gui element!",
                                  field.FieldType.ToString(), plugin.DefaultExtension);

                // Return null.
                return(null);
            }
            }
        }
Ejemplo n.º 2
0
        public override void Update(HaloPlugins.Objects.MetaNode node)
        {
            // Check to see if the new node is of the correct type.
            if (node.FieldType != HaloPlugins.Objects.FieldType.Enum)
            {
                throw new Exception("Tried to bind an incompatible MetaNode object to Enum control!");
            }

            // Bind to the new MetaNode object.
            this.enumerator = (HaloPlugins.Objects.Data.Enum)node;

            // Get the drop down menu control from the combo box button.
            DXPopupMenu menu = (DXPopupMenu)dropDownButton1.DropDownControl;

            // Check to see if the select enum option is within range of the options list.
            if (this.enumerator.Value < this.enumerator.Options.Length)
            {
                // Set the text of the drop down button to the select option name.
                this.dropDownButton1.Text = this.enumerator.Options[this.enumerator.Value].Replace("_", " ").Replace("OP", "");
                this.dropDownButton1.Tag  = this.enumerator.Value;
            }
            else
            {
                // Set the drop down button selection to default values.
                this.dropDownButton1.Text = "";
                this.dropDownButton1.Tag  = this.enumerator.Value;
            }
        }
Ejemplo n.º 3
0
        public override void Update(HaloPlugins.Objects.MetaNode node)
        {
            // Check to see if the new node is of the correct type.
            if (node.FieldType != HaloPlugins.Objects.FieldType.Value)
            {
                throw new Exception("Tried to bind an incompatible MetaNode object to Value control!");
            }

            // Bind to the new Value object.
            this.value = (HaloPlugins.Objects.Data.Value)node;

            // Update the value in the textbox.
            this.txtValue.Text = this.value.DataValue.ToString();
        }
Ejemplo n.º 4
0
        public override void Update(HaloPlugins.Objects.MetaNode node)
        {
            // Check to see if the new node is of the correct type.
            if (this.node.FieldType != HaloPlugins.Objects.FieldType.ShortString &&
                this.node.FieldType != HaloPlugins.Objects.FieldType.LongString &&
                this.node.FieldType != HaloPlugins.Objects.FieldType.StringId &&
                this.node.FieldType != HaloPlugins.Objects.FieldType.Tag)
            {
                throw new Exception("Tried to bind an incompatible MetaNode object to String control!");
            }

            // Bind to the new string object.
            this.node = node;

            // Update the value of the textbox.
            textBox1.Text = this.node.GetValue(null).ToString();
        }
Ejemplo n.º 5
0
        public String(HaloPlugins.Objects.MetaNode node)
        {
            // Initialize form controls.
            InitializeComponent();

            // Set a custom OnDefaultWidthChanged handler.
            this.DefaultWidthChanged += new DefaultWidthChangedHandler(String_DefaultWidthChanged);

            // Save the MetaNode object.
            this.node = node;

            // Setup the name label.
            label1.Text = this.node.Name;

            // Check what type of string object this to set the max length for the textbox.
            if (this.node.FieldType == HaloPlugins.Objects.FieldType.ShortString)
            {
                textBox1.MaxLength = 32;
            }
            else if (this.node.FieldType == HaloPlugins.Objects.FieldType.LongString ||
                     this.node.FieldType == HaloPlugins.Objects.FieldType.StringId)
            {
                textBox1.MaxLength = 128;
            }
            else if (this.node.FieldType == HaloPlugins.Objects.FieldType.Tag)
            {
                textBox1.MaxLength = 4;
            }
            else
            {
                // Not sure what type of string this is.
                throw new Exception(string.Format("Maximum length not set for unknown string type {0}!",
                                                  this.node.FieldType.ToString()));
            }

            // Setup the value of the textbox.
            textBox1.Text = this.node.GetValue(null).ToString();
        }
Ejemplo n.º 6
0
        public override void Update(HaloPlugins.Objects.MetaNode node)
        {
            // Check to see if the new node is of the correct type.
            if (node.FieldType != HaloPlugins.Objects.FieldType.Flags)
            {
                throw new Exception("Tried to bind an incompatible MetaNode object to Bitmask control!");
            }

            // Bind to the new MetaNode object.
            this.bitmask = (HaloPlugins.Objects.Data.Flags)node;

            // Loop through the options for the bitmask, but keep a secondary
            // counter because the list options are different than the bitmask options.
            for (int i = 0, x = 0; i < this.bitmask.Options.Length; i++)
            {
                // Check if the bit is unused.
                if (this.bitmask.Options[i] != "")
                {
                    // Update the checked state of the option.
                    this.checkedListBox1.SetItemChecked(x, this.bitmask[i]);
                    x++;
                }
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Gives the control a new MetaNode object to bind to.
 /// </summary>
 /// <param name="node">The new MetaNode object to bind to.</param>
 public abstract void Update(HaloPlugins.Objects.MetaNode node);
Ejemplo n.º 8
0
 public override void Update(HaloPlugins.Objects.MetaNode node)
 {
     throw new NotImplementedException();
 }