Example #1
0
        private ListViewItem RetrieveVirtualItem(int index)
        {
            if (this.itemCache != null && index >= this.cacheOffset && index < this.cacheOffset + (int)this.itemCache.Length)
            {
                return(this.itemCache[index - this.cacheOffset]);
            }
            if (this.mappedNodes[index] is ChangeListTree.RootNode)
            {
                GameData.Item item         = (this.mappedNodes[index] as ChangeListTree.RootNode).Item;
                ListViewItem  listViewItem = new ListViewItem(item.Name);
                ListViewItem.ListViewSubItemCollection subItems = listViewItem.SubItems;
                itemType _itemType = item.type;
                subItems.Add(_itemType.ToString(), listViewItem.ForeColor, listViewItem.BackColor, listViewItem.Font);
                listViewItem.SubItems.Add("");
                listViewItem.Checked   = this.mappedNodes[index].Checked;
                listViewItem.ForeColor = StateColours.GetStateColor(item.getState());
                listViewItem.Tag       = this.mappedNodes[index];
                return(listViewItem);
            }
            if (!(this.mappedNodes[index] is ChangeListTree.ChangeData))
            {
                return(null);
            }
            ChangeListTree.ChangeData changeDatum = this.mappedNodes[index] as ChangeListTree.ChangeData;
            ListViewItem @checked = new ListViewItem(changeDatum.Text ?? changeDatum.Key);

            ListViewItem.ListViewSubItemCollection listViewSubItemCollections = @checked.SubItems;
            ChangeListTree.ChangeType type = changeDatum.Type;
            listViewSubItemCollections.Add(type.ToString(), @checked.ForeColor, @checked.BackColor, @checked.Font);
            @checked.SubItems.Add(changeDatum.ToString(), @checked.ForeColor, @checked.BackColor, @checked.Font);
            @checked.Checked   = changeDatum.Checked;
            @checked.ForeColor = changeDatum.Colour;
            @checked.Tag       = changeDatum;
            return(@checked);
        }
Example #2
0
 public ChangeData(ChangeListTree.ChangeType type, object oldVal, object newVal, GameData.State state)
 {
     this.Type     = type;
     this.OldValue = oldVal;
     this.NewValue = newVal;
     this.Colour   = StateColours.GetStateColor(state);
 }
        private void resetValue_Click(object sender, EventArgs e)
        {
            string name = this.grid.SelectedItem.Name;

            if (name != "Name")
            {
                if (!this.Item.ContainsKey(name))
                {
                    return;
                }
                if (this.Item.getState() != GameData.State.OWNED || this.nav.FileMode != navigation.ModFileMode.SINGLE)
                {
                    object obj = this.Item.OriginalValue(name);
                    if (obj == null)
                    {
                        this.grid.removeItem(this.grid.SelectedSection.Name, name);
                        if (this.grid.SelectedSection.Items.Count == 0)
                        {
                            this.grid.removeSection(this.grid.SelectedSection.Name);
                        }
                    }
                    else
                    {
                        this.Item[name] = obj;
                        object value = this.grid.SelectedItem.Value;
                        if (value is Color)
                        {
                            this.grid.SelectedItem.Value = Color.FromArgb(255, Color.FromArgb((int)obj));
                        }
                        else if (!value.GetType().IsEnum)
                        {
                            this.grid.SelectedItem.Value = this.Item.OriginalValue(name);
                        }
                        else
                        {
                            this.grid.SelectedItem.Value = Enum.ToObject(value.GetType(), obj);
                        }
                        this.grid.SelectedItem.TextColour = StateColours.GetStateColor(this.Item.getState(name));
                    }
                }
                else
                {
                    this.Item.Remove(name);
                    this.grid.removeItem(this.grid.SelectedSection.Name, name);
                    if (this.grid.SelectedSection.Items.Count == 0)
                    {
                        this.grid.removeSection(this.grid.SelectedSection.Name);
                    }
                }
            }
            else
            {
                this.Item.Name = this.Item.OriginalName;
                this.grid.SelectedItem.Value      = this.Item.Name;
                this.grid.SelectedItem.TextColour = StateColours.GetStateColor(this.Item.getNameState());
            }
            this.grid.Invalidate();
            this.nav.refreshState(this.Item);
            this.nav.HasChanges = true;
        }
        private void swapTextures_Click(object sender, EventArgs e)
        {
            object bah = this.Item["texture map"];

            this.Item["texture map"]   = this.Item["texture map 2"];
            this.Item["texture map 2"] = bah;
            bah = this.Item["normal map"];
            this.Item["normal map"]   = this.Item["normal map 2"];
            this.Item["normal map 2"] = bah;
            bool flag = this.Item.ContainsKey("metalness map 2");

            if (flag)
            {
                bah = this.Item["metalness map"];
                this.Item["metalness map"]   = this.Item["metalness map 2"];
                this.Item["metalness map 2"] = bah;
            }
            this.grid.getItem("texture map").Value        = this.Item["texture map"];
            this.grid.getItem("texture map 2").Value      = this.Item["texture map 2"];
            this.grid.getItem("normal map").Value         = this.Item["normal map"];
            this.grid.getItem("normal map 2").Value       = this.Item["normal map 2"];
            this.grid.getItem("texture map").TextColour   = StateColours.GetStateColor(this.Item.getState("texture map"));
            this.grid.getItem("normal map").TextColour    = StateColours.GetStateColor(this.Item.getState("normal map"));
            this.grid.getItem("texture map 2").TextColour = StateColours.GetStateColor(this.Item.getState("texture map 2"));
            this.grid.getItem("normal map 2").TextColour  = StateColours.GetStateColor(this.Item.getState("normal map 2"));
            if (flag)
            {
                this.grid.getItem("metalness map").Value        = this.Item["metalness map"];
                this.grid.getItem("metalness map 2").Value      = this.Item["metalness map 2"];
                this.grid.getItem("metalness map").TextColour   = StateColours.GetStateColor(this.Item.getState("metalness map"));
                this.grid.getItem("metalness map 2").TextColour = StateColours.GetStateColor(this.Item.getState("metalness map 2"));
            }
            this.grid.Invalidate();
            this.nav.HasChanges = true;
        }
 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 grid_OnPropertyChanged(object sender, PropertyChangedArgs e)
 {
     GameData.Desc desc;
     if (e.Item.Value == null)
     {
         e.Item.Value = e.OldValue;
         return;
     }
     if (e.Item.Name == "Name")
     {
         this.Item.Name = (string)e.Item.Value;
         this.grid.SelectedItem.TextColour = StateColours.GetStateColor(this.Item.getNameState());
     }
     else if (e.Item.Name != "String ID")
     {
         if (e.Item.Value.GetType().IsEnum)
         {
             this.Item[e.Item.Name] = (int)e.Item.Value;
         }
         else if (e.Item.Value is Color)
         {
             GameData.Item item  = this.Item;
             string        name  = e.Item.Name;
             Color         value = (Color)e.Item.Value;
             item[name] = value.ToArgb() & 16777215;
         }
         else if (!(e.Item.Property is FileProperty))
         {
             this.Item[e.Item.Name] = e.Item.Value;
         }
         else
         {
             string str = this.validateFile(e.Item.Value.ToString());
             if (str == null)
             {
                 MessageBox.Show("文件必须在游戏data目录或者你MOD目录下的某个地方", "无效路径", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                 e.Item.Value = e.OldValue;
             }
             else
             {
                 e.Item.Value           = new GameData.File(str);
                 this.Item[e.Item.Name] = e.Item.Value;
             }
         }
         GameData.State state = this.Item.getState(e.Item.Name);
         e.Item.TextColour = StateColours.GetStateColor(state);
     }
     else
     {
         this.nav.ou.gameData.changeID(this.Item, (string)e.Item.Value);
     }
     this.nav.refreshState(this.Item);
     this.nav.HasChanges = true;
     if (this.Item.isLooper(e.Item.Name, out desc))
     {
         this.ProcessLooper(e.Item.Name, desc);
     }
     this.updateConditions(e.Item.Name);
 }
Example #7
0
 public ChangeData(ChangeListTree.ChangeType type, string section, string key, object oldVal, object newVal, GameData.State state)
 {
     this.Type     = type;
     this.OldValue = oldVal;
     this.NewValue = newVal;
     this.Key      = key;
     this.Section  = section;
     this.Colour   = StateColours.GetStateColor(state);
 }
        private void grid_OnPropertyChanged(object sender, PropertyChangedArgs e)
        {
            string str = e.Item.Data.ToString();

            this.Item.setReferenceValue(e.Section.Name, str, (GameData.TripleInt)e.Item.Value);
            e.Item.TextColour = StateColours.GetStateColor(this.Item.getState(e.Section.Name, str));
            this.nav.refreshState(this.Item);
            this.nav.HasChanges = true;
        }
        private void contextMenu_Opening(object sender, CancelEventArgs e)
        {
            if (this.grid.SelectedItem == null)
            {
                e.Cancel = true;
                return;
            }
            bool textColour = this.grid.SelectedItem.TextColour != StateColours.GetStateColor(GameData.State.LOCKED);

            this.removeItem.Enabled = textColour;
            this.revertItem.Enabled = textColour;
        }
Example #10
0
 public ChangeData(ChangeListTree.ChangeType type, string key, GameData.State state)
 {
     this.Type   = type;
     this.Key    = key;
     this.Colour = StateColours.GetStateColor(state);
 }
        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);
            }
        }