private void ProcessLooper(string name, GameData.Desc desc)
        {
            if (this.Item.getState() == GameData.State.LOCKED)
            {
                return;
            }
            while (char.IsDigit(name[name.Length - 1]))
            {
                name = name.Remove(name.Length - 1);
            }
            if (desc.limit == 0)
            {
                return;
            }
            int num = 0;

            while (true)
            {
                PropertyGrid.PropertyGrid.Item item = this.grid.getItem(desc.category, string.Concat(name, num));
                if (item == null)
                {
                    Color?nullable = null;
                    this.grid.addItem(desc.category, string.Concat(name, num), desc.defaultValue, desc.description, nullable, true);
                    return;
                }
                if (item.Value.Equals(desc.defaultValue))
                {
                    break;
                }
                num++;
            }
        }
 public void refreshGrid()
 {
     this.grid.clear();
     if (this.Item == null)
     {
         return;
     }
     foreach (string str in this.Item.referenceLists())
     {
         GameData.Desc     desc = GameData.getDesc(this.Item.type, str);
         TripleIntProperty tripleIntProperty = new TripleIntProperty(desc.flags);
         foreach (KeyValuePair <string, GameData.TripleInt> keyValuePair in this.Item.referenceData(str, false))
         {
             if (this.Exclusions.Contains(str))
             {
                 continue;
             }
             GameData.Item  item                = this.nav.ou.gameData.getItem(keyValuePair.Key);
             GameData.State state               = this.Item.getState(str, keyValuePair.Key);
             string         str1                = (item != null ? item.Name : keyValuePair.Key);
             Color          stateColor          = StateColours.GetStateColor(state);
             PropertyGrid.PropertyGrid.Item key = this.grid.addItem(str, str1, keyValuePair.Value, desc.description, new Color?(stateColor), desc.flags > 0);
             key.Property = tripleIntProperty;
             key.Data     = keyValuePair.Key;
             key.Editable = state != GameData.State.LOCKED;
         }
     }
     foreach (KeyValuePair <string, GameData.Instance> keyValuePair1 in this.Item.instanceData())
     {
         bool  flag  = (keyValuePair1.Value.getState() == GameData.State.LOCKED ? false : !this.readOnly);
         Color color = StateColours.GetStateColor(keyValuePair1.Value.getState());
         this.grid.addItem("Instances", keyValuePair1.Key, keyValuePair1.Value, "Object instances", new Color?(color), flag);
     }
     this.grid.AutosizeDivider();
 }
 public override void Paint(PropertyGrid.PropertyGrid grid, PropertyGrid.PropertyGrid.Item item, Graphics g, Rectangle rect)
 {
     base.DrawText(this.getString(item.Value, false), grid.Font, g, rect, 2, 0, new Color?(this.getColour(item)));
     if (base.Editing == item)
     {
         rect.X     = this.mButton.X;
         rect.Width = this.mButton.Width;
         ButtonRenderer.DrawButton(g, rect, this.mState);
     }
 }
 private Color getColour(PropertyGrid.PropertyGrid.Item item)
 {
     if (item.Value == null || item.Value is GameData.Item)
     {
         return(item.TextColour);
     }
     if (this.Source.getItem(item.Value.ToString()) == null)
     {
         return(Color.Red);
     }
     return(item.TextColour);
 }
        protected override void ButtonPressed()
        {
            PropertyGrid.PropertyGrid.Item item         = this.mItem;
            PropertyGrid.PropertyGrid      propertyGrid = this.mGrid;
            ItemDialog itemDialog = new ItemDialog("Referenced item", this.Source, this.TypeFilter, false, this.CustomFilter, itemType.NULL_ITEM);

            if (itemDialog.ShowDialog() == DialogResult.OK)
            {
                this.mItem = item;
                this.mGrid = propertyGrid;
                base.setValue(itemDialog.Items[0]);
                this.mItem = null;
                this.mGrid = null;
            }
        }
Exemplo n.º 6
0
        protected override void ButtonPressed()
        {
            PropertyGrid.PropertyGrid.Item item         = this.mItem;
            PropertyGrid.PropertyGrid      propertyGrid = this.mGrid;
            TextDialog textDialog = new TextDialog(this.mItem.Name, this.mItem.Value.ToString(), null);

            if (textDialog.ShowDialog() == DialogResult.OK)
            {
                this.mItem = item;
                this.mGrid = propertyGrid;
                char[] chrArray = new char[] { ' ', '\n', '\r' };
                base.setValue(textDialog.Value.TrimEnd(chrArray));
                this.mItem = null;
                this.mGrid = null;
            }
        }
Exemplo n.º 7
0
        public override void Paint(PropertyGrid.PropertyGrid grid, PropertyGrid.PropertyGrid.Item item, Graphics g, Rectangle rect)
        {
            if (base.Editing == item)
            {
                base.Paint(grid, item, g, rect);
                return;
            }
            string str = item.Value.ToString();
            int    num = str.IndexOf('\n');

            if (num == 0)
            {
                str = "...";
            }
            else if (num > 0)
            {
                str = string.Concat(str.Substring(0, num - 1), "...");
            }
            base.DrawText(str, grid.Font, g, rect, 2, 0, new Color?(item.TextColour));
        }
 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);
 }
Exemplo n.º 9
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;
 }
        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);
            }
        }
Exemplo n.º 11
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();
     }
 }
Exemplo n.º 12
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;
 }
Exemplo n.º 13
0
 public override void Paint(PropertyGrid.PropertyGrid grid, PropertyGrid.PropertyGrid.Item item, Graphics g, Rectangle rect)
 {
     base.DrawText(this.ValueString(item.Value), grid.Font, g, rect, 2, 0, new Color?(item.TextColour));
 }
Exemplo n.º 14
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);
 }