예제 #1
0
        /// <summary>
        /// Gets the MTRL data for the given item
        /// </summary>
        /// <remarks>
        /// It requires a race (The default is usually <see cref="XivRace.Hyur_Midlander_Male"/>)
        /// It also requires an mtrl part <see cref="GearInfo.GetPartList(IItemModel, XivRace)"/> (default is 'a')
        /// </remarks>
        /// <param name="itemModel">Item that contains model data</param>
        /// <param name="race">The race for the requested data</param>
        /// <param name="part">The Mtrl part </param>
        /// <returns>XivMtrl containing all the mtrl data</returns>
        public XivMtrl GetMtrlData(IItemModel itemModel, XivRace race, char part, int dxVersion)
        {
            var index    = new Index(_gameDirectory);
            var itemType = ItemType.GetItemType(itemModel);

            // Get mtrl path
            var mtrlPath       = GetMtrlPath(itemModel, race, part, itemType);
            var mtrlStringPath = $"{mtrlPath.Folder}/{mtrlPath.File}";

            // Get mtrl offset
            var mtrlOffset = index.GetDataOffset(HashGenerator.GetHash(mtrlPath.Folder), HashGenerator.GetHash(mtrlPath.File),
                                                 _dataFile);

            if (mtrlOffset == 0 && itemType == XivItemType.furniture)
            {
                mtrlPath.File  = mtrlPath.File.Replace("_0", "_1");
                mtrlStringPath = $"{mtrlPath.Folder}/{mtrlPath.File}";

                // Get mtrl offset
                mtrlOffset = index.GetDataOffset(HashGenerator.GetHash(mtrlPath.Folder), HashGenerator.GetHash(mtrlPath.File),
                                                 _dataFile);
            }

            if (mtrlOffset == 0)
            {
                throw new Exception($"Could not find offest for {mtrlStringPath}");
            }

            var mtrlData = GetMtrlData(mtrlOffset, mtrlStringPath, dxVersion);

            if (mtrlPath.HasVfx)
            {
                var atex = new ATex(_gameDirectory, _dataFile);
                mtrlData.TextureTypePathList.AddRange(atex.GetAtexPaths(itemModel));
            }

            return(mtrlData);
        }
예제 #2
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;
        }