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();
 }
        private void addButton_Click(object sender, EventArgs e)
        {
            string str = this.addList.SelectedItem.ToString();

            GameData.Desc desc       = GameData.getDesc(this.Item.type, str);
            ItemDialog    itemDialog = new ItemDialog(string.Concat("选择 ", str, " 的关联"), this.nav.ou.gameData, desc.list, true, "", itemType.NULL_ITEM);

            if (itemDialog.ShowDialog() == DialogResult.OK)
            {
                foreach (GameData.Item item in itemDialog.Items)
                {
                    int?nullable  = null;
                    int?nullable1 = nullable;
                    nullable = null;
                    int?nullable2 = nullable;
                    nullable = null;
                    this.Item.addReference(str, item, nullable1, nullable2, nullable);
                }
                if (itemDialog.Items.Count > 0)
                {
                    this.refresh(this.Item);
                    this.nav.refreshState(this.Item);
                    this.nav.HasChanges = true;
                    if (this.ChangeEvent != null)
                    {
                        this.ChangeEvent(this);
                    }
                }
            }
        }
        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++;
            }
        }
Beispiel #4
0
        private string FormatTripleInt(object value, GameData.Desc desc)
        {
            if (value == null || desc == null)
            {
                return(null);
            }
            GameData.TripleInt tripleInt = (GameData.TripleInt)value;
            switch (desc.flags)
            {
            case 0:
            {
                return(null);
            }

            case 1:
            {
                return(tripleInt.v0.ToString());
            }

            case 2:
            {
                return(string.Format("{0,-4} {1}", tripleInt.v0, tripleInt.v1));
            }

            case 3:
            {
                return(string.Format("{0,-4} {1,-4} {2}", tripleInt.v0, tripleInt.v1, tripleInt.v2));
            }
            }
            return(null);
        }
 private object getDefaultValue(string key)
 {
     GameData.Desc desc = this.getDesc(key);
     if (desc == null)
     {
         return(null);
     }
     return(desc.defaultValue);
 }
 private void bExtra_Click(object sender, EventArgs e)
 {
     GameData.Desc desc = this.getDesc(this.fieldName.Text);
     if (desc == null)
     {
         return;
     }
     if (desc.flags == 16)
     {
         TextDialog textDialog = new TextDialog(this.fieldName.Text, this.fieldValue.Text, null);
         if (textDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             this.fieldValue.Text = textDialog.Text;
             return;
         }
     }
     else if (desc.defaultValue is GameData.TripleInt)
     {
         string   str       = "";
         itemType _itemType = desc.list;
         if (_itemType == itemType.NULL_ITEM)
         {
             _itemType = itemType.BUILDING;
             str       = "is node=true";
         }
         ItemDialog itemDialog = new ItemDialog(string.Concat("选择 ", this.fieldName.Text, " 的关联"), this.nav.ou.gameData, _itemType, true, str, _itemType);
         if (itemDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             List <string> strs = new List <string>();
             foreach (GameData.Item item in itemDialog.Items)
             {
                 string str1 = item.stringID;
                 if (desc.flags > 0)
                 {
                     str1 = string.Concat(str1, " ", (desc.defaultValue as GameData.TripleInt).v0.ToString());
                 }
                 if (desc.flags > 1)
                 {
                     str1 = string.Concat(str1, " ", (desc.defaultValue as GameData.TripleInt).v1.ToString());
                 }
                 if (desc.flags > 2)
                 {
                     str1 = string.Concat(str1, " ", (desc.defaultValue as GameData.TripleInt).v2.ToString());
                 }
                 strs.Add(str1);
             }
             this.fieldValue.Text = string.Join("; ", strs);
         }
     }
 }
        private void fieldName_SelectedIndexChanged(object sender, EventArgs e)
        {
            int num;

            GameData.Desc desc         = this.getDesc(this.fieldName.Text);
            object        defaultValue = this.getDefaultValue(this.fieldName.Text);
            object        currentValue = this.getCurrentValue(this.fieldName.Text) ?? defaultValue;

            if (defaultValue.GetType().IsEnum&& desc.flags != 256)
            {
                this.fieldValue.Visible = false;
                this.enumValue.Visible  = true;
                this.enumValue.Items.Clear();
                foreach (object value in Enum.GetValues(defaultValue.GetType()))
                {
                    this.enumValue.Items.Add(value);
                }
                this.enumValue.SelectedItem = Enum.ToObject(defaultValue.GetType(), currentValue);
                return;
            }
            if (defaultValue is bool)
            {
                this.fieldValue.Visible = false;
                this.enumValue.Visible  = true;
                this.enumValue.Items.Clear();
                this.enumValue.Items.Add("False");
                this.enumValue.Items.Add("True");
                this.enumValue.SelectedItem = ((bool)currentValue ? "True" : "False");
                return;
            }
            if (desc != null && GameData.isListType(desc))
            {
                this.fieldValue.Visible = true;
                this.enumValue.Visible  = false;
                this.bExtra.Visible     = true;
                this.fieldValue.Width   = this.bExtra.Left - this.fieldValue.Left;
                this.fieldValue.Text    = "";
                return;
            }
            this.fieldValue.Visible = true;
            this.enumValue.Visible  = false;
            this.fieldValue.Text    = currentValue.ToString();
            this.bExtra.Visible     = (desc == null ? false : (desc.flags & 16) > 0);
            num = (this.bExtra.Visible ? this.bExtra.Left : this.bExtra.Right);
            this.fieldValue.Width = num - this.fieldValue.Left;
        }
        private void bAddReference_Click(object sender, EventArgs e)
        {
            if (this.referenceTypes.SelectedItem == null)
            {
                return;
            }
            string str = this.referenceTypes.SelectedItem.ToString();

            GameData.Desc desc      = GameData.getDesc(this.Item.type, str);
            itemType      _itemType = desc.list;
            string        str1      = "";

            if (_itemType == itemType.NULL_ITEM)
            {
                _itemType = itemType.BUILDING;
                str1      = "is node=true";
            }
            ItemDialog itemDialog = new ItemDialog(string.Concat("选择 ", str, " 的引用"), this.nav.ou.gameData, _itemType, true, str1, _itemType);

            if (itemDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (!(desc.defaultValue is GameData.Instance))
                {
                    foreach (GameData.Item item in itemDialog.Items)
                    {
                        int?nullable  = null;
                        int?nullable1 = nullable;
                        nullable = null;
                        int?nullable2 = nullable;
                        nullable = null;
                        this.Item.addReference(str, item, nullable1, nullable2, nullable);
                    }
                }
                else
                {
                    foreach (GameData.Item item1 in itemDialog.Items)
                    {
                        this.Item.addInstance(item1, (GameData.Instance)desc.defaultValue);
                    }
                }
                this.refreshReferenceList();
                this.nav.refreshState(this.Item);
                this.nav.HasChanges = true;
            }
        }
        private object castItemValue(string key)
        {
            object bah = this.Item[key];

            if (!GameData.desc.ContainsKey(this.Item.type))
            {
                return(bah);
            }
            GameData.Desc item = GameData.desc[this.Item.type][key];
            if (item.defaultValue != null && item.defaultValue.GetType().IsEnum)
            {
                bah = (bah is int || bah.GetType().IsEnum ? Enum.ToObject(item.defaultValue.GetType(), bah) : item.defaultValue);
            }
            if (item.defaultValue is Color && bah is int)
            {
                bah = Color.FromArgb(255, Color.FromArgb((int)bah));
            }
            return(bah);
        }
        private ListViewItem createItem(GameData.Item item)
        {
            ListViewItem listViewItem = new ListViewItem(item.Name)
            {
                ForeColor = StateColours.GetStateColor(item.getState())
            };

            foreach (ColumnHeader column in base.Columns)
            {
                if (column.Index == 0)
                {
                    continue;
                }
                if (column.Tag == null)
                {
                    column.Tag = "Name";
                }
                string str = column.Tag.ToString();
                if (str == "Name")
                {
                    listViewItem.SubItems.Add(item.Name);
                }
                else if (str == "StringID")
                {
                    listViewItem.SubItems.Add(item.stringID);
                }
                else if (str == "Type")
                {
                    listViewItem.SubItems.Add(item.type.ToString());
                }
                else if (str == "Ref")
                {
                    listViewItem.SubItems.Add(item.refCount.ToString());
                }
                else if (column.Tag is GameDataList.ColumnInfo && item.hasReference(str))
                {
                    GameDataList.ColumnInfo tag = column.Tag as GameDataList.ColumnInfo;
                    string str1 = "";
                    if (tag.showNames || tag.showValues)
                    {
                        GameData.Desc desc = GameData.getDesc(item.type, str);
                        foreach (KeyValuePair <string, GameData.TripleInt> keyValuePair in item.referenceData(str, false))
                        {
                            GameData.Item item1 = this.Source.getItem(keyValuePair.Key);
                            if (tag.showNames)
                            {
                                str1 = string.Concat(str1, (item1 == null ? keyValuePair.Key : item1.Name));
                            }
                            if (!tag.showValues)
                            {
                                if (!tag.showNames)
                                {
                                    continue;
                                }
                                str1 = string.Concat(str1, "; ");
                            }
                            else
                            {
                                if (desc.flags == 1)
                                {
                                    str1 = string.Concat(new object[] { str1, " ", keyValuePair.Value.v0, "; " });
                                }
                                if (desc.flags == 2)
                                {
                                    str1 = string.Concat(new object[] { str1, " ", keyValuePair.Value.v0, " ", keyValuePair.Value.v1, "; " });
                                }
                                if (desc.flags != 3)
                                {
                                    continue;
                                }
                                str1 = string.Concat(new object[] { str1, " ", keyValuePair.Value.v0, " ", keyValuePair.Value.v1, " ", keyValuePair.Value.v2, "; " });
                            }
                        }
                    }
                    else
                    {
                        str1 = string.Concat("Size: ", item.getReferenceCount(str));
                    }
                    listViewItem.SubItems.Add(str1);
                }
                else if (str == "Data")
                {
                    int referenceValue = 0;
                    if (item.hasReference("cost"))
                    {
                        referenceValue = item.getReferenceValue("cost", 0).v0;
                    }
                    listViewItem.SubItems.Add(referenceValue.ToString());
                }
                else if (!item.ContainsKey(str))
                {
                    listViewItem.SubItems.Add("-");
                }
                else
                {
                    object bah = item[str];
                    if (bah is int)
                    {
                        GameData.Desc desc1 = GameData.getDesc(item.type, str);
                        if (desc1 != GameData.nullDesc && desc1.defaultValue.GetType().IsEnum)
                        {
                            if (desc1.flags != 256)
                            {
                                string name = Enum.GetName(desc1.defaultValue.GetType(), bah);
                                if (name != null)
                                {
                                    bah = name;
                                }
                            }
                            else
                            {
                                bah = (new BitSetProperty(desc1.defaultValue.GetType(), false)).getAsString(bah);
                            }
                        }
                    }
                    listViewItem.SubItems.Add(bah.ToString());
                }
            }
            return(listViewItem);
        }
 private void addList_SelectedIndexChanged(object sender, EventArgs e)
 {
     GameData.Desc desc = GameData.getDesc(this.Item.type, this.addList.Text);
     this.SelectionControl.Text   = this.addList.Text;
     this.DescriptionControl.Text = desc.description;
 }
        private List <KeyValuePair <GameData.Item, GameData.TripleInt> > parseReferences(GameData.Desc desc, string s)
        {
            GameData.Item j;
            List <KeyValuePair <GameData.Item, GameData.TripleInt> > keyValuePairs = new List <KeyValuePair <GameData.Item, GameData.TripleInt> >();

            string[] strArrays = s.Split(new char[] { ';' });
            for (int i = 0; i < (int)strArrays.Length; i++)
            {
                string   str        = strArrays[i];
                string[] strArrays1 = str.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
                string   str1       = strArrays1[0];
                int      num        = 1;
                for (j = this.nav.ou.gameData.getItem(str1); j == null && num < (int)strArrays1.Length; j = this.nav.ou.gameData.getItem(str1))
                {
                    str1 = string.Concat(str1, " ", strArrays1[num]);
                    num++;
                }
                if (j == null)
                {
                    MessageBox.Show(string.Concat("无效的引用 ", str));
                    return(null);
                }
                if (j.type != desc.list)
                {
                    MessageBox.Show("不正确的引用项类型");
                    return(null);
                }
                GameData.TripleInt tripleInt = new GameData.TripleInt(desc.defaultValue as GameData.TripleInt);
                if ((int)strArrays1.Length > num)
                {
                    int.TryParse(strArrays1[num], out tripleInt.v0);
                }
                if ((int)strArrays1.Length > num + 1)
                {
                    int.TryParse(strArrays1[num + 1], out tripleInt.v1);
                }
                if ((int)strArrays1.Length > num + 2)
                {
                    int.TryParse(strArrays1[num + 2], out tripleInt.v2);
                }
                keyValuePairs.Add(new KeyValuePair <GameData.Item, GameData.TripleInt>(j, tripleInt));
            }
            return(keyValuePairs);
        }
        private static void parseItem(StreamReader r, List <itemType> types)
        {
            itemType _itemType;

            float[] singleArray;
            float[] singleArray1;
            string  str = "General";

            while (!r.EndOfStream && r.Peek() != 91)
            {
                string str1 = Definitions.readLine(r);
                int    num  = str1.IndexOf("//");
                if (num >= 0)
                {
                    str1 = str1.Remove(num);
                }
                str1 = str1.Trim();
                if (str1.Length == 0 || Definitions.parseEnum(r, str1) || Definitions.parseCondition(str1, types))
                {
                    continue;
                }
                string[] strArrays = str1.Split(new char[] { ':' }, 2);
                if ((int)strArrays.Length != 2)
                {
                    Definitions.error(string.Concat("Invalid line ", str1));
                }
                else if (strArrays[1].Length != 0)
                {
                    GameData.Desc desc = new GameData.Desc();
                    List <string> strs = Definitions.tokenise(strArrays[1], 999);
                    string        str2 = strArrays[0].Trim();
                    if (strs.Count > 1 && strs[strs.Count - 1][0] == '\"')
                    {
                        desc.description = Definitions.stripQuotes(strs[strs.Count - 1]).Replace("\\n", "\n");
                    }
                    desc.category = str;
                    if (strs[0] == "null")
                    {
                        desc.defaultValue = null;
                    }
                    else if (strs[0] == "TEXTURE_DDS")
                    {
                        desc.defaultValue = new GameData.File("");
                        desc.mask         = "Nvidia dds| *.dds";
                    }
                    else if (strs[0] == "TEXTURE_ANY")
                    {
                        desc.defaultValue = new GameData.File("");
                        desc.mask         = "Nvidia dds|*.dds|tga|*.tga|jpg|*.jpg|png|*.png|bmp|*.bmp";
                    }
                    else if (strs[0].Contains("*.") || strs[0].Contains("|"))
                    {
                        desc.defaultValue = new GameData.File("");
                        desc.mask         = Definitions.stripQuotes(strs[0]);
                    }
                    else if (strs[0] != "multiline")
                    {
                        object obj  = Definitions.parseValue(strs[0]);
                        object obj1 = obj;
                        desc.defaultValue = obj;
                        if (obj1 == null)
                        {
                            if (!Enum.TryParse <itemType>(strs[0], out _itemType))
                            {
                                Definitions.error(string.Concat("Invalid type ", strs[0]));
                                continue;
                            }
                            else
                            {
                                if (strs.Count > 1)
                                {
                                    singleArray = Definitions.parseVector(strs[1]);
                                }
                                else
                                {
                                    singleArray = null;
                                }
                                float[] singleArray2 = singleArray;
                                if (strs.Count > 2)
                                {
                                    singleArray1 = Definitions.parseVector(strs[2]);
                                }
                                else
                                {
                                    singleArray1 = null;
                                }
                                float[] singleArray3 = singleArray1;
                                if (singleArray2 == null || singleArray3 == null)
                                {
                                    GameData.TripleInt tripleInt = new GameData.TripleInt(0, 0, 0);
                                    if (singleArray2 != null)
                                    {
                                        if (singleArray2.Length != 0)
                                        {
                                            tripleInt.v0 = (int)singleArray2[0];
                                        }
                                        if ((int)singleArray2.Length > 1)
                                        {
                                            tripleInt.v1 = (int)singleArray2[1];
                                        }
                                        if ((int)singleArray2.Length > 2)
                                        {
                                            tripleInt.v2 = (int)singleArray2[2];
                                        }
                                        desc.flags = (int)singleArray2.Length;
                                    }
                                    desc.list         = _itemType;
                                    desc.defaultValue = tripleInt;
                                }
                                else if ((int)singleArray2.Length != 3 || (int)singleArray3.Length != 4)
                                {
                                    Definitions.error("Invalid instance values");
                                    continue;
                                }
                                else
                                {
                                    GameData.Instance instance = new GameData.Instance();
                                    instance["x"]     = singleArray2[0];
                                    instance["y"]     = singleArray2[1];
                                    instance["z"]     = singleArray2[2];
                                    instance["qx"]    = singleArray3[0];
                                    instance["qy"]    = singleArray3[1];
                                    instance["qz"]    = singleArray3[2];
                                    instance["qw"]    = singleArray3[3];
                                    desc.list         = _itemType;
                                    desc.defaultValue = instance;
                                }
                            }
                        }
                    }
                    else
                    {
                        desc.defaultValue = "";
                    }
                    if (desc.defaultValue is string && strs.Contains("multiline"))
                    {
                        desc.flags |= 16;
                    }
                    if ((desc.defaultValue is EnumValue || desc.GetType().IsEnum) && strs.Contains("bitset"))
                    {
                        desc.flags |= 256;
                    }
                    if (strs.Contains("looped"))
                    {
                        desc.limit = 9999;
                    }
                    foreach (itemType type in types)
                    {
                        GameData.Desc desc1 = new GameData.Desc()
                        {
                            category     = desc.category,
                            condition    = GameData.getDesc(type, str2).condition,
                            defaultValue = desc.defaultValue,
                            description  = desc.description,
                            flags        = desc.flags,
                            limit        = desc.limit,
                            list         = desc.list,
                            mask         = desc.mask
                        };
                        GameData.setDesc(type, str2, desc1);
                    }
                }
                else
                {
                    str = strArrays[0].Trim();
                }
            }
        }
        public void refreshReferenceList()
        {
            KeyValuePair <string, GameData.Desc> keyValuePair;

            this.referenceList.clear();
            foreach (string str in this.Item.referenceLists())
            {
                GameData.Desc     desc = GameData.getDesc(this.Item.type, str);
                int               num  = (desc == GameData.nullDesc ? 3 : desc.flags);
                TripleIntProperty tripleIntProperty = new TripleIntProperty(num);
                foreach (KeyValuePair <string, GameData.TripleInt> keyValuePair1 in this.Item.referenceData(str, false))
                {
                    GameData.Item  item                = this.nav.ou.gameData.getItem(keyValuePair1.Key);
                    GameData.State state               = this.Item.getState(str, keyValuePair1.Key);
                    string         str1                = (item != null ? item.Name : keyValuePair1.Key);
                    Color          stateColor          = StateColours.GetStateColor(state);
                    PropertyGrid.PropertyGrid.Item key = this.referenceList.addItem(str, str1, keyValuePair1.Value, desc.description, new Color?(stateColor), num > 0);
                    key.Property = tripleIntProperty;
                    key.Data     = keyValuePair1.Key;
                    key.Editable = state != GameData.State.LOCKED;
                }
            }
            if (this.Item.HasInstances)
            {
                Dictionary <itemType, KeyValuePair <string, GameData.Desc> > itemTypes = new Dictionary <itemType, KeyValuePair <string, GameData.Desc> >();
                if (GameData.desc.ContainsKey(this.Item.type))
                {
                    foreach (KeyValuePair <string, GameData.Desc> item1 in GameData.desc[this.Item.type])
                    {
                        if (!(item1.Value.defaultValue is GameData.Instance))
                        {
                            continue;
                        }
                        itemTypes.Add(item1.Value.list, item1);
                    }
                }
                if (itemTypes.Count != 0)
                {
                    foreach (KeyValuePair <string, GameData.Instance> keyValuePair2 in this.Item.instanceData())
                    {
                        if (keyValuePair2.Value.getState() == GameData.State.REMOVED)
                        {
                            continue;
                        }
                        GameData.Item item2 = this.nav.ou.gameData.getItem(keyValuePair2.Value.sdata["ref"]);
                        Color         color = StateColours.GetStateColor(keyValuePair2.Value.getState());
                        bool          flag  = keyValuePair2.Value.getState() != GameData.State.LOCKED;
                        if (item2 == null || !itemTypes.TryGetValue(item2.type, out keyValuePair))
                        {
                            this.referenceList.addItem("Instances", keyValuePair2.Key, keyValuePair2.Value, "Object instances", new Color?(color), flag);
                        }
                        else
                        {
                            this.referenceList.addItem(keyValuePair.Key, keyValuePair2.Key, keyValuePair2.Value, keyValuePair.Value.description, new Color?(color), flag).Data = item2.type;
                        }
                    }
                }
                else
                {
                    foreach (KeyValuePair <string, GameData.Instance> keyValuePair3 in this.Item.instanceData())
                    {
                        if (keyValuePair3.Value.getState() == GameData.State.REMOVED)
                        {
                            continue;
                        }
                        bool  state1      = keyValuePair3.Value.getState() != GameData.State.LOCKED;
                        Color stateColor1 = StateColours.GetStateColor(keyValuePair3.Value.getState());
                        this.referenceList.addItem("Instances", keyValuePair3.Key, keyValuePair3.Value, "Object instances", new Color?(stateColor1), state1);
                    }
                }
                if (this.nav.FileMode == navigation.ModFileMode.SINGLE)
                {
                    foreach (KeyValuePair <string, GameData.Instance> keyValuePair4 in this.Item.instanceData())
                    {
                        if (keyValuePair4.Value.getState() != GameData.State.REMOVED)
                        {
                            continue;
                        }
                        Color color1 = StateColours.GetStateColor(keyValuePair4.Value.getState());
                        this.referenceList.addItem("Instances", keyValuePair4.Key, keyValuePair4.Value, "Object instances", new Color?(color1), false);
                    }
                }
            }
            this.referenceList.AutosizeDivider();
        }
 private void referenceTypes_SelectedIndexChanged(object sender, EventArgs e)
 {
     GameData.Desc desc = GameData.getDesc(this.Item.type, this.referenceTypes.Text);
     this.selected.Text    = this.referenceTypes.Text;
     this.description.Text = desc.description;
 }
Beispiel #16
0
 public void RefreshList()
 {
     ChangeListTree.ChangeData changeDatum;
     this.Cursor = Cursors.WaitCursor;
     this.Nodes  = new List <ChangeListTree.RootNode>();
     foreach (GameData.Item value in this.GameData.items.Values)
     {
         if (value.getState() == GameData.State.ORIGINAL || this.Filter != null && !this.Filter.Test(value) || value.getState() == GameData.State.OWNED && !this.ShowNew || value.getState() == GameData.State.MODIFIED && !this.ShowChanged || value.getState() == GameData.State.REMOVED && !this.ShowDeleted || value.getState() == GameData.State.LOCKED || value.getState() == GameData.State.LOCKED_REMOVED || value.getState() == GameData.State.REMOVED && value.OriginalName == null)
         {
             continue;
         }
         this.Nodes.Add(new ChangeListTree.RootNode(value));
     }
     this.Nodes = (
         from o in this.Nodes
         orderby o.Item.type, o.Item.Name
         select o).ToList <ChangeListTree.RootNode>();
     foreach (ChangeListTree.RootNode node in this.Nodes)
     {
         GameData.Item  item  = node.Item;
         GameData.State state = item.getState();
         if (state == GameData.State.OWNED)
         {
             continue;
         }
         if (item.Name != item.OriginalName)
         {
             ChangeListTree.ChangeData changeDatum1 = new ChangeListTree.ChangeData(ChangeListTree.ChangeType.NAME, item.OriginalName, item.Name, state)
             {
                 Text = "Name"
             };
             node.Add(changeDatum1);
         }
         foreach (KeyValuePair <string, object> keyValuePair in item)
         {
             GameData.State state1 = item.getState(keyValuePair.Key);
             if (state1 == GameData.State.ORIGINAL || state1 == GameData.State.LOCKED)
             {
                 continue;
             }
             node.Add(new ChangeListTree.ChangeData(ChangeListTree.ChangeType.VALUE, keyValuePair.Key, item.OriginalValue(keyValuePair.Key), item[keyValuePair.Key], state1));
         }
         foreach (string str in item.referenceLists())
         {
             GameData.Desc desc = GameData.getDesc(item.type, str);
             if (!(desc.defaultValue is GameData.TripleInt))
             {
                 desc = null;
             }
             foreach (KeyValuePair <string, GameData.TripleInt> keyValuePair1 in item.referenceData(str, true))
             {
                 GameData.State state2 = item.getState(str, keyValuePair1.Key);
                 if (state2 == GameData.State.ORIGINAL || state2 == GameData.State.LOCKED || state2 == GameData.State.LOCKED_REMOVED)
                 {
                     continue;
                 }
                 ChangeListTree.ChangeData changeDatum2 = null;
                 GameData.Item             item1        = this.GameData.getItem(keyValuePair1.Key);
                 if (state2 == GameData.State.REMOVED)
                 {
                     changeDatum2 = new ChangeListTree.ChangeData(ChangeListTree.ChangeType.DELREF, str, keyValuePair1.Key, null, null, state2);
                 }
                 else if (state2 == GameData.State.MODIFIED)
                 {
                     changeDatum2 = new ChangeListTree.ChangeData(ChangeListTree.ChangeType.MODREF, str, keyValuePair1.Key, this.FormatTripleInt(item.OriginalValue(str, keyValuePair1.Key), desc), this.FormatTripleInt(keyValuePair1.Value, desc), state2);
                 }
                 else if (state2 != GameData.State.OWNED)
                 {
                     if (state2 != GameData.State.INVALID)
                     {
                         continue;
                     }
                     changeDatum2 = new ChangeListTree.ChangeData(ChangeListTree.ChangeType.INVALIDREF, str, keyValuePair1.Key, null, this.FormatTripleInt(keyValuePair1.Value, desc), state2);
                 }
                 else
                 {
                     changeDatum2 = new ChangeListTree.ChangeData(ChangeListTree.ChangeType.NEWREF, str, keyValuePair1.Key, null, this.FormatTripleInt(keyValuePair1.Value, desc), state2);
                 }
                 changeDatum2.Text = string.Concat(str, " : ", (item1 == null ? keyValuePair1.Key : item1.Name));
                 node.Add(changeDatum2);
             }
         }
         foreach (KeyValuePair <string, GameData.Instance> keyValuePair2 in item.instanceData())
         {
             GameData.State state3 = keyValuePair2.Value.getState();
             if (state3 == GameData.State.ORIGINAL || state3 == GameData.State.LOCKED || state3 == GameData.State.LOCKED_REMOVED)
             {
                 continue;
             }
             changeDatum      = (state3 != GameData.State.OWNED ? new ChangeListTree.ChangeData(ChangeListTree.ChangeType.MODINST, keyValuePair2.Key, state3) : new ChangeListTree.ChangeData(ChangeListTree.ChangeType.NEWINST, keyValuePair2.Key, state3));
             changeDatum.Text = string.Concat("Instance : ", keyValuePair2.Key);
             node.Add(changeDatum);
             if (state3 != GameData.State.MODIFIED)
             {
                 continue;
             }
             foreach (KeyValuePair <string, object> value1 in keyValuePair2.Value)
             {
                 if (keyValuePair2.Value.getState(value1.Key) != GameData.State.MODIFIED)
                 {
                     continue;
                 }
                 changeDatum.Add(new ChangeListTree.ChangeData(ChangeListTree.ChangeType.INSTVALUE, keyValuePair2.Key, value1.Key, keyValuePair2.Value.OriginalValue(value1.Key), keyValuePair2.Value[value1.Key], state3));
             }
         }
     }
     this.initialiseMap();
     this.Cursor = Cursors.Default;
 }
Beispiel #17
0
        public bool Test(GameData.Item item)
        {
            object bah;
            bool   flag;

            if (this.type != itemType.NULL_ITEM && item.type != this.type)
            {
                return(false);
            }
            if (this.name != "" && !item.Name.ToLower().Contains(this.name) && !item.stringID.ToLower().Contains(this.name))
            {
                return(false);
            }
            List <ItemFilter.PropertyFilter> .Enumerator enumerator = this.property.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    ItemFilter.PropertyFilter current = enumerator.Current;
                    if (current.property == "Type")
                    {
                        bah = item.type;
                    }
                    else if (current.property == "StringID")
                    {
                        bah = item.stringID;
                    }
                    else if (item.ContainsKey(string.Concat(current.property, "0")))
                    {
                        bool flag1 = false;
                        int  num   = 0;
                        while (!flag1)
                        {
                            string str = string.Concat(current.property, num);
                            if (!item.ContainsKey(str))
                            {
                                break;
                            }
                            flag1 |= this.compareValue(item[str], current.@value, current.mode);
                            num++;
                        }
                        if (flag1)
                        {
                            continue;
                        }
                        flag = false;
                        return(flag);
                    }
                    else if (item.ContainsKey(current.property))
                    {
                        bah = item[current.property];
                        if (bah is int && current.mode <= ItemFilter.PropertyFilter.Mode.NOT)
                        {
                            GameData.Desc desc = GameData.getDesc(item.type, current.property);
                            if (desc != GameData.nullDesc)
                            {
                                Type type = desc.defaultValue.GetType();
                                if (type.IsEnum)
                                {
                                    bah = Enum.GetName(type, bah);
                                }
                                if (bah == null)
                                {
                                    flag = false;
                                    return(flag);
                                }
                            }
                        }
                    }
                    else if (!item.hasReference(current.property))
                    {
                        GameData.Desc desc1 = GameData.getDesc(item.type, current.property);
                        if (desc1 == null || desc1.list == itemType.NULL_ITEM)
                        {
                            flag = false;
                            return(flag);
                        }
                        else
                        {
                            bah = 0;
                        }
                    }
                    else
                    {
                        bah = item.getReferenceCount(current.property);
                    }
                    if (this.compareValue(bah, current.@value, current.mode))
                    {
                        continue;
                    }
                    flag = false;
                    return(flag);
                }
                return(true);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }

            return(flag);
        }