Ejemplo n.º 1
0
 public override void CreateEditor(PropertyGrid.PropertyGrid grid, PropertyGrid.PropertyGrid.Section section, PropertyGrid.PropertyGrid.Item item, Rectangle rect)
 {
     base.CreateEditor(grid, section, item, rect);
     if (this.mTextBox == null)
     {
         return;
     }
     this.mTextBox.Text     = this.getString((GameData.Instance)item.Value);
     this.mTextBox.ReadOnly = true;
 }
Ejemplo n.º 2
0
 public override void CreateEditor(PropertyGrid.PropertyGrid grid, PropertyGrid.PropertyGrid.Section section, PropertyGrid.PropertyGrid.Item item, Rectangle rect)
 {
     base.CreateEditor(grid, section, item, rect);
     foreach (KeyValuePair <string, int> keyValuePair in this.type)
     {
         //string newKey = NativeTranslte.getTransValue(keyValuePair.Key);
         //this.mList.Items.Add(newKey);
         //trans.Add(newKey, keyValuePair.Key);
         this.mList.Items.Add(keyValuePair.Key);
     }
     this.mList.SelectedItem = this.getAsString(item.Value);
     if (this.mList.SelectedItem == null)
     {
         this.mList.Text = item.Value.ToString();
     }
 }
Ejemplo n.º 3
0
 public override void CreateEditor(PropertyGrid.PropertyGrid grid, PropertyGrid.PropertyGrid.Section section, PropertyGrid.PropertyGrid.Item item, Rectangle rect)
 {
     base.CreateEditor(grid, section, item, rect);
     this.mList = new CheckedListBox()
     {
         CheckOnClick = true
     };
     this.mList.ItemCheck  += new ItemCheckEventHandler(this.itemChecked);
     this.mList.MinimumSize = new Size(rect.Width - 2, 16);
     this.mList.MaximumSize = new Size(400, 400);
     this.mList.BorderStyle = BorderStyle.None;
     foreach (KeyValuePair <string, int> value in this.values)
     {
         this.mList.Items.Add(value.Key);
     }
     this.mTextBox.KeyDown  += new KeyEventHandler(this.mTextBox_KeyDown);
     this.mTextBox.KeyPress += new KeyPressEventHandler(this.mTextBox_KeyPress);
     base.PopupControl       = this.mList;
 }
Ejemplo n.º 4
0
 public override void CreateEditor(PropertyGrid.PropertyGrid grid, PropertyGrid.PropertyGrid.Section section, PropertyGrid.PropertyGrid.Item item, Rectangle rect)
 {
     if (rect.Width < 3)
     {
         return;
     }
     base.CreateEditor(grid, section, item, rect);
     if (this.Type == ValueListProperty.ValueType.INT)
     {
         this.mTextBox.KeyPress += new KeyPressEventHandler(this.filter_int);
     }
     if (this.Type == ValueListProperty.ValueType.UINT)
     {
         this.mTextBox.KeyPress += new KeyPressEventHandler(this.filter_uint);
     }
     else if (this.Type == ValueListProperty.ValueType.FLOAT)
     {
         this.mTextBox.KeyPress += new KeyPressEventHandler(this.filter_float);
     }
     this.mTextBox.Text = this.ValueString(item.Value);
 }
 public override void CreateEditor(PropertyGrid.PropertyGrid grid, PropertyGrid.PropertyGrid.Section section, PropertyGrid.PropertyGrid.Item item, Rectangle rect)
 {
     base.CreateEditor(grid, section, item, rect);
     this.mTextBox.Text = this.getString(item.Value, true);
 }
        public void refresh(GameData.Item item)
        {
            GameData.Desc desc;
            Color?        nullable;
            SortedList <string, GameData.Desc> strs;

            this.Item = item;
            this.grid.clear();
            if (item == null)
            {
                return;
            }
            this.grid.addItem("Base", "Name", item.Name, "Item name", new Color?(StateColours.GetStateColor(item.getNameState())), item.getNameState() != GameData.State.LOCKED);
            this.grid.addItem("Base", "Object Type", item.type, "GameData Type", new Color?(SystemColors.GrayText), false);
            if (item.getState() != GameData.State.OWNED)
            {
                this.grid.addItem("Base", "String ID", item.stringID, "The string ID is a unique identifier for each item, it must never be the same for 2 objects.", new Color?(SystemColors.GrayText), false);
            }
            else
            {
                nullable = null;
                this.grid.addItem("Base", "String ID", item.stringID, "The string ID is a unique identifier for each item, it must never be the same for 2 objects. DO NOT CHANGE IT if already placed in the game world or if referenced by another mod (otherwise those references will vanish). Generally you can only change this for newly created items", nullable, true);
            }
            if (GameData.desc.ContainsKey(item.type))
            {
                strs = GameData.desc[item.type];
            }
            else
            {
                strs = null;
            }
            SortedList <string, GameData.Desc> strs1 = strs;

            foreach (KeyValuePair <string, object> keyValuePair in item)
            {
                object value = keyValuePair.Value;
                if (!item.isLooper(keyValuePair.Key, out desc))
                {
                    desc = (strs1 == null || !strs1.ContainsKey(keyValuePair.Key) ? GameData.nullDesc : strs1[keyValuePair.Key]);
                }
                if (desc.defaultValue != null && desc.defaultValue.GetType().IsEnum)
                {
                    value = (value is int || value.GetType().IsEnum ? Enum.ToObject(desc.defaultValue.GetType(), value) : desc.defaultValue);
                }
                if (desc.defaultValue is Color && keyValuePair.Value is int)
                {
                    value = Color.FromArgb(255, Color.FromArgb((int)keyValuePair.Value));
                }
                nullable = null;
                PropertyGrid.PropertyGrid.Item extendedText = this.grid.addItem(desc.category, keyValuePair.Key, value, desc.description, nullable, true);
                if (value is string && desc != null && desc.flags == 16)
                {
                    extendedText.Property = new ExtendedText();
                }
                if (item.getState(keyValuePair.Key) == GameData.State.LOCKED)
                {
                    extendedText.Editable = false;
                }
                else if (keyValuePair.Value is GameData.File)
                {
                    extendedText.Property = new FileProperty(keyValuePair.Key, desc.mask);
                }
                if (desc.defaultValue is EnumValue)
                {
                    extendedText.Property = new FCSEnumProperty((desc.defaultValue as EnumValue).Enum);
                }
                if (desc.defaultValue != null && (desc.defaultValue.GetType().IsEnum || desc.defaultValue is EnumValue) && desc.flags == 256)
                {
                    extendedText.Property = new BitSetProperty(desc.defaultValue, false);
                }
                GameData.State state = item.getState(keyValuePair.Key);
                extendedText.TextColour = StateColours.GetStateColor(state);
            }
            this.grid.AutosizeDivider();
            this.grid.SortItems = true;
            if (strs1 != null)
            {
                foreach (KeyValuePair <string, GameData.Desc> keyValuePair1 in strs1)
                {
                    if (keyValuePair1.Value.limit <= 0)
                    {
                        continue;
                    }
                    this.ProcessLooper(keyValuePair1.Key, keyValuePair1.Value);
                }
            }
            PropertyGrid.PropertyGrid.Section section = this.grid.getSection("Base");
            if (this.grid.Sections[0] != section)
            {
                this.grid.Sections.Remove(section);
                this.grid.Sections.Insert(0, section);
            }
        }