Ejemplo n.º 1
0
        private void ItemList_ItemSelected(object sender, IItem item)
        {
            if (item == null)
            {
                return;
            }

            SelectedItem = item;

            var root = item.GetRoot();

            TextureMapComboBox.Items.Clear();
            ModelTypeComboBox.Items.Clear();
            MaterialComboBox.Items.Clear();

            if (OptionList.SelectedItem == null)
            {
                return;
            }


            var modding = new Modding(_gameDirectory);
            //var modList = modding.GetModList();
            var _imc = new Imc(_gameDirectory);

            int    mSet         = -1;
            string metadataFile = null;
            var    models       = new List <string>();
            var    materials    = new List <string>();
            var    textures     = new List <string>();

            Task.Run(async() =>
            {
                if (root != null)
                {
                    // Get ALL THE THINGS
                    // Meta Entries, Models, Materials, Textures, Icons, and VFX Elements.
                    var im = (IItemModel)item;
                    var df = IOUtil.GetDataFileFromPath(root.Info.GetRootFile());

                    metadataFile = root.Info.GetRootFile();
                    mSet         = await _imc.GetMaterialSetId(im);
                    models       = await root.GetModelFiles();
                    materials    = await root.GetMaterialFiles(mSet);
                    textures     = await root.GetTextureFiles(mSet);

                    var _tex  = new Tex(XivCache.GameInfo.GameDirectory);
                    var icons = await _tex.GetItemIcons(im);

                    foreach (var icon in icons)
                    {
                        textures.Add(icon.Path);
                    }

                    var _atex = new ATex(XivCache.GameInfo.GameDirectory, df);
                    var paths = await _atex.GetAtexPaths(im);
                    foreach (var path in paths)
                    {
                        textures.Add(path.Path);
                    }
                }
                else
                {
                    if (item.GetType() == typeof(XivCharacter))
                    {
                        // Face Paint/Equipment Decals jank-items.  Ugh.
                        if (item.SecondaryCategory == XivStrings.Face_Paint)
                        {
                            var _character = new Character(XivCache.GameInfo.GameDirectory, XivCache.GameInfo.GameLanguage);

                            var paths = await _character.GetDecalPaths(Character.XivDecalType.FacePaint);

                            foreach (var path in paths)
                            {
                                textures.Add(path);
                            }
                        }
                        else if (item.SecondaryCategory == XivStrings.Equipment_Decals)
                        {
                            var _character = new Character(XivCache.GameInfo.GameDirectory, XivCache.GameInfo.GameLanguage);
                            var paths      = await _character.GetDecalPaths(Character.XivDecalType.Equipment);
                            foreach (var path in paths)
                            {
                                textures.Add(path);
                            }
                        }
                    }
                    else
                    {
                        // This is a UI item or otherwise an item which has no root, and only has textures.
                        var uiItem = (XivUi)item;
                        var paths  = await uiItem.GetTexPaths();
                        foreach (var kv in paths)
                        {
                            textures.Add(kv.Value);
                        }
                    }
                }
            }).Wait();

            MetadataPathBox.Text = metadataFile;

            foreach (var file in models)
            {
                var fe = new FileEntry();
                fe.Path = file;
                fe.Name = MakeFriendlyFileName(file);

                ModelTypeComboBox.Items.Add(fe);
            }

            foreach (var file in materials)
            {
                var fe = new FileEntry();
                fe.Path = file;
                fe.Name = MakeFriendlyFileName(file);

                MaterialComboBox.Items.Add(fe);
            }

            foreach (var file in textures)
            {
                var fe = new FileEntry();
                fe.Path = file;
                fe.Name = MakeFriendlyFileName(file);

                TextureMapComboBox.Items.Add(fe);
            }

            if (String.IsNullOrEmpty(metadataFile))
            {
                AddMetadataButton.IsEnabled = false;
            }
            else
            {
                AddMetadataButton.IsEnabled = true;
            }

            if (TextureMapComboBox.Items.Count > 0)
            {
                AddCurrentTextureButton.IsEnabled = true;
                AddCustomTextureButton.IsEnabled  = true;
                TextureMapComboBox.SelectedIndex  = 0;
            }
            else
            {
                AddCurrentTextureButton.IsEnabled = false;
                AddCustomTextureButton.IsEnabled  = false;
            }

            if (ModelTypeComboBox.Items.Count > 0)
            {
                AddCurrentModelButton.IsEnabled = true;
                AdvOptionsButton.IsEnabled      = true;
                ModelTypeComboBox.SelectedIndex = 0;
            }
            else
            {
                AddCurrentModelButton.IsEnabled = false;
                AdvOptionsButton.IsEnabled      = false;
            }

            if (MaterialComboBox.Items.Count > 0)
            {
                AddCurrentMaterialButton.IsEnabled = true;
                MaterialComboBox.SelectedIndex     = 0;
            }
            else
            {
                AddCurrentMaterialButton.IsEnabled = false;
            }

            SelectModGroup.IsEnabled = true;
        }