Exemplo n.º 1
0
        public async Task <List <IItemModel> > GetSameVariantList(IItemModel item)
        {
            var sameModelItems = new List <IItemModel>();

            if (!item.PrimaryCategory.Equals(XivStrings.Gear))

            {
                sameModelItems.Add((IItemModel)item.Clone());
                return(sameModelItems);
            }
            sameModelItems = await GetSameModelList(item);

            var imc          = new Imc(_gameDirectory, XivDataFile._04_Chara);
            var originalInfo = await imc.GetImcInfo(item);

            var sameMaterialItems = new List <IItemModel>();

            foreach (var i in sameModelItems)
            {
                var info = await imc.GetImcInfo(i);

                if (info.Variant == originalInfo.Variant)
                {
                    sameMaterialItems.Add(i);
                }
            }

            return(sameMaterialItems);
        }
Exemplo n.º 2
0
        public async Task <Dictionary <string, char[]> > GetDemiHumanMountTextureEquipPartList(IItemModel itemModel)
        {
            var parts = new[] { 'a', 'b', 'c', 'd', 'e', 'f' };

            var equipPartDictionary = new Dictionary <string, char[]>();

            var index   = new Index(_gameDirectory);
            var imc     = new Imc(_gameDirectory, XivDataFile._04_Chara);
            var version = (await imc.GetImcInfo(itemModel, itemModel.ModelInfo)).Version.ToString().PadLeft(4, '0');

            var id      = itemModel.ModelInfo.ModelID.ToString().PadLeft(4, '0');
            var bodyVer = itemModel.ModelInfo.Body.ToString().PadLeft(4, '0');

            var mtrlFolder = $"chara/demihuman/d{id}/obj/equipment/e{bodyVer}/material/v{version}";

            var files = await index.GetAllHashedFilesInFolder(HashGenerator.GetHash(mtrlFolder), XivDataFile._04_Chara);

            foreach (var slotAbr in SlotAbbreviationDictionary)
            {
                var charList =
                    (from part in parts
                     let mtrlFile = $"mt_d{id}e{bodyVer}_{slotAbr.Value}_{part}.mtrl"
                                    where files.Contains(HashGenerator.GetHash(mtrlFile))
                                    select part).ToList();

                if (charList.Count > 0)
                {
                    equipPartDictionary.Add(slotAbr.Key, charList.ToArray());
                }
            }

            return(equipPartDictionary);
        }
        private async Task LoadItems()
        {
            List <string> children = new List <string>();
            var           root     = _item.GetRoot();

            if (root != null)
            {
                if (_level == XivDependencyLevel.Model)
                {
                    children = await root.GetModelFiles();
                }
                else if (_level == XivDependencyLevel.Material)
                {
                    var imc = new Imc(XivCache.GameInfo.GameDirectory);
                    try
                    {
                        var entry = await imc.GetImcInfo((IItemModel)_item);

                        children = await root.GetMaterialFiles(entry.Variant);
                    } catch
                    {
                        children = await root.GetMaterialFiles(0);
                    }
                }
                else if (_level == XivDependencyLevel.Texture)
                {
                    try
                    {
                        var imc   = new Imc(XivCache.GameInfo.GameDirectory);
                        var entry = await imc.GetImcInfo((IItemModel)_item);

                        children = await root.GetTextureFiles(entry.Variant);
                    }
                    catch
                    {
                        children = await root.GetTextureFiles(0);
                    }
                }
                else
                {
                    // Invalid or root, nothing listed.
                }
            }

            var index = new Index(XivCache.GameInfo.GameDirectory);

            foreach (var file in children)
            {
                var exists = await index.FileExists(file);

                if (!exists)
                {
                    continue;
                }

                Files.Add(new FileEntry(file));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the avfx path
        /// </summary>
        /// <param name="itemModel">The item to get the avfx path for</param>
        /// <param name="itemType">The type of the item</param>
        /// <returns>A tuple containing the path folder and file</returns>
        public static async Task <(string Folder, string File)> GetVfxPath(IItemModel itemModel)
        {
            // get the vfx version from the imc file
            var imc     = new Imc(XivCache.GameInfo.GameDirectory);
            var imcInfo = await imc.GetImcInfo(itemModel);

            int vfx = imcInfo.Vfx;

            var root = itemModel.GetRootInfo();

            return(await GetVfxPath(root, vfx));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the avfx path
        /// </summary>
        /// <param name="itemModel">The item to get the avfx path for</param>
        /// <param name="itemType">The type of the item</param>
        /// <returns>A tuple containing the path folder and file</returns>
        private async Task <(string Folder, string File)> GetVfxPath(IItemModel itemModel, XivItemType itemType)
        {
            // get the vfx version from the imc file
            var imc     = new Imc(_modding, _dataFile);
            var imcInfo = await imc.GetImcInfo(itemModel, itemModel.ModelInfo);

            int vfx = imcInfo.Vfx;

            var id      = itemModel.ModelInfo.ModelID.ToString().PadLeft(4, '0');
            var bodyVer = itemModel.ModelInfo.Body.ToString().PadLeft(4, '0');

            string vfxFolder, vfxFile;

            switch (itemType)
            {
            case XivItemType.equipment:
                vfxFolder = $"chara/{itemType}/e{id}/vfx/eff";
                vfxFile   = $"ve{vfx.ToString().PadLeft(4, '0')}.avfx";
                break;

            case XivItemType.weapon:
                vfxFolder = $"chara/{itemType}/w{id}/obj/body/b{bodyVer}/vfx/eff";
                vfxFile   = $"vw{vfx.ToString().PadLeft(4, '0')}.avfx";
                break;

            case XivItemType.monster:
                vfxFolder = $"chara/{itemType}/m{id}/obj/body/b{bodyVer}/vfx/eff";
                vfxFile   = $"vm{vfx.ToString().PadLeft(4, '0')}.avfx";
                break;

            case XivItemType.demihuman:
                vfxFolder = $"chara/{itemType}/d{id}/obj/equipment/e{bodyVer}/vfx/eff";
                vfxFile   = $"ve{vfx.ToString().PadLeft(4, '0')}.avfx";
                break;

            default:
                vfxFolder = "";
                vfxFile   = "";
                break;
            }

            return(vfxFolder, vfxFile);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the list of available mtrl parts for a given item
        /// </summary>
        /// <param name="itemModel">An item that contains model data</param>
        /// <param name="xivRace">The race for the requested data</param>
        /// <returns>A list of part characters</returns>
        public async Task <List <string> > GetTexturePartList(IItemModel itemModel, XivRace xivRace, XivDataFile dataFile, string type = "Primary")
        {
            var itemType = ItemType.GetItemType(itemModel);

            var version = "0001";

            var id           = itemModel.ModelInfo.ModelID.ToString().PadLeft(4, '0');
            var bodyVer      = itemModel.ModelInfo.Body.ToString().PadLeft(4, '0');
            var itemCategory = itemModel.ItemCategory;

            if (type.Equals("Secondary"))
            {
                var xivGear = itemModel as XivGear;

                id      = xivGear.SecondaryModelInfo.ModelID.ToString().PadLeft(4, '0');
                bodyVer = xivGear.SecondaryModelInfo.Body.ToString().PadLeft(4, '0');

                var imc = new Imc(_gameDirectory, xivGear.DataFile);
                version = (await imc.GetImcInfo(itemModel, xivGear.SecondaryModelInfo)).Version.ToString().PadLeft(4, '0');

                if (imc.ChangedType)
                {
                    itemType     = XivItemType.equipment;
                    xivRace      = XivRace.Hyur_Midlander_Male;
                    itemCategory = XivStrings.Hands;
                }
            }
            else
            {
                if (itemType != XivItemType.human && itemType != XivItemType.furniture)
                {
                    // Get the mtrl version for the given item from the imc file
                    var imc = new Imc(_gameDirectory, dataFile);
                    version = (await imc.GetImcInfo(itemModel, itemModel.ModelInfo)).Version.ToString().PadLeft(4, '0');
                }
            }

            var parts = new[] { 'a', 'b', 'c', 'd', 'e', 'f' };
            var race  = xivRace.GetRaceCode();

            string mtrlFolder = "", mtrlFile = "";

            switch (itemType)
            {
            case XivItemType.equipment:
                mtrlFolder = $"chara/{itemType}/e{id}/material/v{version}";
                mtrlFile   = $"mt_c{race}e{id}_{SlotAbbreviationDictionary[itemCategory]}_";
                break;

            case XivItemType.accessory:
                mtrlFolder = $"chara/{itemType}/a{id}/material/v{version}";
                mtrlFile   = $"mt_c{race}a{id}_{SlotAbbreviationDictionary[itemCategory]}_";
                break;

            case XivItemType.weapon:
                mtrlFolder = $"chara/{itemType}/w{id}/obj/body/b{bodyVer}/material/v{version}";
                mtrlFile   = $"mt_w{id}b{bodyVer}_";
                break;

            case XivItemType.monster:
                mtrlFolder = $"chara/{itemType}/m{id}/obj/body/b{bodyVer}/material/v{version}";
                mtrlFile   = $"mt_m{id}b{bodyVer}_";
                break;

            case XivItemType.demihuman:
                mtrlFolder = $"chara/{itemType}/d{id}/obj/body/e{bodyVer}/material/v{version}";
                mtrlFile   = $"mt_d{id}e{bodyVer}_";
                break;

            case XivItemType.human:
                if (itemCategory.Equals(XivStrings.Body))
                {
                    mtrlFolder = $"chara/{itemType}/c{id}/obj/body/b{bodyVer}/material/v{version}";
                    mtrlFile   = $"mt_c{id}b{bodyVer}_";
                }
                else if (itemCategory.Equals(XivStrings.Hair))
                {
                    mtrlFolder = $"chara/{itemType}/c{id}/obj/body/h{bodyVer}/material/v{version}";
                    mtrlFile   = $"mt_c{id}h{bodyVer}_{SlotAbbreviationDictionary[itemCategory]}_";
                }
                else if (itemCategory.Equals(XivStrings.Face))
                {
                    mtrlFolder = $"chara/{itemType}/c{id}/obj/body/f{bodyVer}/material/v{version}";
                    mtrlFile   = $"mt_c{id}f{bodyVer}_{SlotAbbreviationDictionary[itemCategory]}_";
                }
                else if (itemCategory.Equals(XivStrings.Tail))
                {
                    mtrlFolder = $"chara/{itemType}/c{id}/obj/body/t{bodyVer}/material/v{version}";
                    mtrlFile   = $"mt_c{id}t{bodyVer}_";
                }
                break;

            case XivItemType.furniture:
                if (itemCategory.Equals(XivStrings.Furniture_Indoor))
                {
                    mtrlFolder = $"bgcommon/hou/indoor/general/{id}/material";
                    mtrlFile   = $"fun_b0_m{id}_0";
                }
                else if (itemCategory.Equals(XivStrings.Furniture_Outdoor))
                {
                    mtrlFolder = $"bgcommon/hou/outdoor/general/{id}/material";
                    mtrlFile   = $"gar_b0_m{id}_0";
                }

                break;

            default:
                mtrlFolder = "";
                break;
            }

            // Get a list of hashed mtrl files that are in the given folder
            var files = await _index.GetAllHashedFilesInFolder(HashGenerator.GetHash(mtrlFolder), dataFile);

            // append the part char to the mtrl file and see if its hashed value is within the files list
            var partList =
                (from part in parts
                 let mtrlCheck = mtrlFile + part + ".mtrl"
                                 where files.Contains(HashGenerator.GetHash(mtrlCheck))
                                 select part.ToString()).ToList();

            if (partList.Count < 1 && itemType == XivItemType.furniture)
            {
                if (itemCategory.Equals(XivStrings.Furniture_Indoor))
                {
                    mtrlFile = $"fun_b0_m{id}_1";
                }
                else if (itemCategory.Equals(XivStrings.Furniture_Outdoor))
                {
                    mtrlFile = $"gar_b0_m{id}_1";
                }

                // Get a list of hashed mtrl files that are in the given folder
                files = await _index.GetAllHashedFilesInFolder(HashGenerator.GetHash(mtrlFolder), dataFile);

                // append the part char to the mtrl file and see if its hashed value is within the files list
                partList =
                    (from part in parts
                     let mtrlCheck = mtrlFile + part + ".mtrl"
                                     where files.Contains(HashGenerator.GetHash(mtrlCheck))
                                     select part.ToString()).ToList();
            }

            // returns the list of parts that exist within the mtrl folder
            return(partList);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the available races that contain texture data for the given gear
        /// </summary>
        /// <remarks>
        /// This checks to see if the mtrl file for each race exists in the mtrl folder
        /// It creates a list of the races which do have an available mtrl folder
        /// </remarks>
        /// <param name="xivGear">A gear item</param>
        /// <returns>A list of XivRace data</returns>
        public async Task <List <XivRace> > GetRacesForTextures(XivGear xivGear, XivDataFile dataFile)
        {
            // Get the material version for the item from the imc file
            var imc         = new Imc(_gameDirectory);
            var gearVersion = (await imc.GetImcInfo(xivGear)).Variant.ToString().PadLeft(4, '0');

            var modelID = xivGear.ModelInfo.PrimaryID.ToString().PadLeft(4, '0');

            var raceList = new List <XivRace>();

            var    itemType = ItemType.GetPrimaryItemType(xivGear);
            string mtrlFolder;

            if (itemType == XivItemType.weapon)
            {
                return(new List <XivRace> {
                    XivRace.All_Races
                });
            }

            switch (itemType)
            {
            case XivItemType.equipment:
                mtrlFolder = $"chara/{itemType}/e{modelID}/material/v{gearVersion}";
                break;

            case XivItemType.accessory:
                mtrlFolder = $"chara/{itemType}/a{modelID}/material/v{gearVersion}";
                break;

            default:
                mtrlFolder = "";
                break;
            }

            var testFilesDictionary = new Dictionary <int, string>();

            // loop through each race ID to create a dictionary containing [Hashed file name, race ID]
            foreach (var ID in IDRaceDictionary.Keys)
            {
                string mtrlFile;

                switch (itemType)
                {
                case XivItemType.equipment:
                    mtrlFile = $"mt_c{ID}e{modelID}_{xivGear.GetItemSlotAbbreviation()}_a.mtrl";
                    break;

                case XivItemType.accessory:
                    mtrlFile = $"mt_c{ID}a{modelID}_{xivGear.GetItemSlotAbbreviation()}_a.mtrl";
                    break;

                default:
                    mtrlFile = "";
                    break;
                }

                testFilesDictionary.Add(HashGenerator.GetHash(mtrlFile), ID);
            }

            // get the list of hashed file names from the mtrl folder
            var files = await _index.GetAllHashedFilesInFolder(HashGenerator.GetHash(mtrlFolder), dataFile);

            // Loop through each entry in the dictionary
            foreach (var testFile in testFilesDictionary)
            {
                // if the file in the dictionary entry is contained in the list of files from the folder
                // add that race to the race list
                if (files.Contains(testFile.Key))
                {
                    raceList.Add(IDRaceDictionary[testFile.Value]);
                }
            }

            return(raceList);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Gets the list of available mtrl parts for a given item
        /// </summary>
        /// <param name="itemModel">An item that contains model data</param>
        /// <param name="xivRace">The race for the requested data</param>
        /// <returns>A list of part characters</returns>
        public List <string> GetTexturePartList(IItemModel itemModel, XivRace xivRace, XivDataFile dataFile)
        {
            // Get the mtrl version for the given item from the imc file
            var imc     = new Imc(_gameDirectory, dataFile);
            var version = imc.GetImcInfo(itemModel, itemModel.PrimaryModelInfo).Version.ToString().PadLeft(4, '0');

            var id      = itemModel.PrimaryModelInfo.ModelID.ToString().PadLeft(4, '0');
            var bodyVer = itemModel.PrimaryModelInfo.Body.ToString().PadLeft(4, '0');
            var parts   = new[] { 'a', 'b', 'c', 'd', 'e', 'f' };
            var race    = xivRace.GetRaceCode();

            var index = new Index(_gameDirectory);

            var    itemType = ItemType.GetItemType(itemModel);
            string mtrlFolder = "", mtrlFile = "";

            switch (itemType)
            {
            case XivItemType.equipment:
                mtrlFolder = $"chara/{itemType}/e{id}/material/v{version}";
                mtrlFile   = $"mt_c{race}e{id}_{SlotAbbreviationDictionary[itemModel.ItemCategory]}_";
                break;

            case XivItemType.accessory:
                mtrlFolder = $"chara/{itemType}/a{id}/material/v{version}";
                mtrlFile   = $"mt_c{race}a{id}_{SlotAbbreviationDictionary[itemModel.ItemCategory]}_";
                break;

            case XivItemType.weapon:
                mtrlFolder = $"chara/{itemType}/w{id}/obj/body/b{bodyVer}/material/v{version}";
                mtrlFile   = $"mt_w{id}b{bodyVer}_";
                break;

            case XivItemType.monster:
                mtrlFolder = $"chara/{itemType}/m{id}/obj/body/b{bodyVer}/material/v{version}";
                mtrlFile   = $"mt_m{id}b{bodyVer}_";
                break;

            case XivItemType.demihuman:
                mtrlFolder = $"chara/{itemType}/d{id}/obj/body/e{bodyVer}/material/v{version}";
                mtrlFile   = $"mt_d{id}e{bodyVer}_";
                break;

            case XivItemType.human:
                if (itemModel.ItemCategory.Equals(XivStrings.Body))
                {
                    mtrlFolder = $"chara/{itemType}/c{id}/obj/body/b{bodyVer}/material/v{version}";
                    mtrlFile   = $"mt_c{id}b{bodyVer}_";
                }
                else if (itemModel.ItemCategory.Equals(XivStrings.Hair))
                {
                    mtrlFolder = $"chara/{itemType}/c{id}/obj/body/h{bodyVer}/material/v{version}";
                    mtrlFile   = $"mt_c{id}h{bodyVer}_{SlotAbbreviationDictionary[itemModel.ItemCategory]}_";
                }
                else if (itemModel.ItemCategory.Equals(XivStrings.Face))
                {
                    mtrlFolder = $"chara/{itemType}/c{id}/obj/body/f{bodyVer}/material/v{version}";
                    mtrlFile   = $"mt_c{id}f{bodyVer}_{SlotAbbreviationDictionary[itemModel.ItemCategory]}_";
                }
                else if (itemModel.ItemCategory.Equals(XivStrings.Tail))
                {
                    mtrlFolder = $"chara/{itemType}/c{id}/obj/body/t{bodyVer}/material/v{version}";
                    mtrlFile   = $"mt_c{id}t{bodyVer}_";
                }
                break;

            default:
                mtrlFolder = "";
                break;
            }

            // Get a list of hashed mtrl files that are in the given folder
            var files = index.GetAllHashedFilesInFolder(HashGenerator.GetHash(mtrlFolder), dataFile);

            // append the part char to the mtrl file and see if its hashed value is within the files list
            // returns the list of parts that exist within the mtrl folder
            return((from part in parts let mtrlCheck = mtrlFile + part + ".mtrl" where files.Contains(HashGenerator.GetHash(mtrlCheck)) select part.ToString()).ToList());
        }
        /// <summary>
        /// Exports the model
        /// </summary>
        /// <param name="fullModelName">The name chosen by the user for the full model export</param>
        private async Task Export(string fullModelName)
        {
            var pc = await this.ShowProgressAsync(UIMessages.ExportingFullModelTitle, UIMessages.PleaseStandByMessage);

            var fileFormat     = "fbx";
            var savePath       = new DirectoryInfo(Settings.Default.Save_Directory);
            var outputFilePath = $"{savePath}\\FullModel\\{fullModelName}\\{fullModelName}.{fileFormat}";

            // Create output directory
            Directory.CreateDirectory($"{savePath}\\FullModel\\{fullModelName}");

            var fmViewPortVM = viewport3DX.DataContext as FullModelViewport3DViewModel;

            var converterFolder = Directory.GetCurrentDirectory() + "\\converters\\" + fileFormat;

            Directory.CreateDirectory(converterFolder);
            var dbPath = converterFolder + "\\input.db";

            File.Delete(dbPath);

            // Create the DB where all models will be added and fill the metadata
            fmViewPortVM.shownModels.FirstOrDefault().Value.TtModel.SetFullModelDBMetaData(dbPath, fullModelName);

            // Export the materials for each model and save model to DB
            foreach (var model in fmViewPortVM.shownModels)
            {
                var mtrlVariant = 1;
                try
                {
                    var imc = new Imc(_gameDirectory);
                    mtrlVariant = (await imc.GetImcInfo(model.Value.ItemModel)).MaterialSet;
                }
                catch (Exception ex)
                {
                    // No-op, defaulted to 1.
                }

                await Mdl.ExportMaterialsForModel(model.Value.TtModel, outputFilePath, _gameDirectory, mtrlVariant, _fmvm.SelectedSkeleton.XivRace);

                // Save model to DB
            }

            TTModel.SaveFullToFile(dbPath, _fmvm.SelectedSkeleton.XivRace, fmViewPortVM.shownModels.Select(x => x.Value.TtModel).ToList());

            var proc = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName  = converterFolder + "\\converter.exe",
                    Arguments = "\"" + dbPath + "\"",
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    UseShellExecute        = false,
                    WorkingDirectory       = "" + converterFolder + "",
                    CreateNoWindow         = true
                }
            };

            proc.Start();
            proc.WaitForExit();
            var code = proc.ExitCode;

            if (code != 0)
            {
                throw new Exception("Exporter threw error code: " + proc.ExitCode);
            }

            var outputFile = converterFolder + "\\result." + fileFormat;

            // Just move the result file if we need to.
            if (!Path.Equals(outputFilePath, outputFile))
            {
                File.Delete(outputFilePath);
                File.Move(outputFile, outputFilePath);
            }

            await pc.CloseAsync();

            await this.ShowMessageAsync(UIMessages.FullModelExportSuccessTitle, string.Format(UIMessages.FullModelExportSuccessMessage, outputFilePath));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets the mtrl folder for a given item
        /// </summary>
        /// <param name="itemModel">Item that contains model data</param>
        /// <param name="xivRace">The race for the requested data</param>
        /// <param name="itemType">The type of the item</param>
        /// <returns>The mtrl Folder</returns>
        private string GetMtrlFolder(IItemModel itemModel, XivRace xivRace, XivItemType itemType)
        {
            // The default version number
            var version = "0001";

            if (itemType != XivItemType.human && itemType != XivItemType.furniture)
            {
                // get the items version from the imc file
                var imc     = new Imc(_gameDirectory, _dataFile);
                var imcInfo = imc.GetImcInfo(itemModel, itemModel.ModelInfo);
                version = imcInfo.Version.ToString().PadLeft(4, '0');
            }

            if (version.Equals("0000"))
            {
                version = "0001";
            }

            var id      = itemModel.ModelInfo.ModelID.ToString().PadLeft(4, '0');
            var bodyVer = itemModel.ModelInfo.Body.ToString().PadLeft(4, '0');
            var race    = xivRace.GetRaceCode();

            var mtrlFolder = "";

            switch (itemType)
            {
            case XivItemType.equipment:
                mtrlFolder = $"chara/{itemType}/e{id}/material/v{version}";
                break;

            case XivItemType.accessory:
                mtrlFolder = $"chara/{itemType}/a{id}/material/v{version}";
                break;

            case XivItemType.weapon:
                mtrlFolder = $"chara/{itemType}/w{id}/obj/body/b{bodyVer}/material/v{version}";
                break;

            case XivItemType.monster:
                mtrlFolder = $"chara/{itemType}/m{id}/obj/body/b{bodyVer}/material/v{version}";
                break;

            case XivItemType.demihuman:
                mtrlFolder = $"chara/{itemType}/d{id}/obj/equipment/e{bodyVer}/material/v{version}";
                break;

            case XivItemType.human:
                if (itemModel.ItemCategory.Equals(XivStrings.Body))
                {
                    mtrlFolder = $"chara/{itemType}/c{race}/obj/body/b{bodyVer}/material";
                }
                else if (itemModel.ItemCategory.Equals(XivStrings.Hair))
                {
                    // Hair has a version number, but no IMC, so we leave it at the default 0001
                    mtrlFolder = $"chara/{itemType}/c{race}/obj/hair/h{bodyVer}/material/v{version}";
                }
                else if (itemModel.ItemCategory.Equals(XivStrings.Face))
                {
                    mtrlFolder = $"chara/{itemType}/c{race}/obj/face/f{bodyVer}/material";
                }
                else if (itemModel.ItemCategory.Equals(XivStrings.Tail))
                {
                    mtrlFolder = $"chara/{itemType}/c{race}/obj/tail/t{bodyVer}/material";
                }
                break;

            case XivItemType.furniture:
                if (itemModel.ItemCategory.Equals(XivStrings.Furniture_Indoor))
                {
                    mtrlFolder = $"bgcommon/hou/indoor/general/{id}/material";
                }
                else if (itemModel.ItemCategory.Equals(XivStrings.Furniture_Outdoor))
                {
                    mtrlFolder = $"bgcommon/hou/outdoor/general/{id}/material";
                }
                break;

            default:
                mtrlFolder = "";
                break;
            }

            return(mtrlFolder);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Gets the mtrl path for a given item
        /// </summary>
        /// <param name="itemModel">Item that contains model data</param>
        /// <param name="xivRace">The race for the requested data</param>
        /// <param name="part">The mtrl part <see cref="GearInfo.GetPartList(IItemModel, XivRace)"/></param>
        /// <param name="itemType">The type of the item</param>
        /// <returns>A tuple containing the mtrl folder and file, and whether it has a vfx</returns>
        private (string Folder, string File, bool HasVfx) GetMtrlPath(IItemModel itemModel, XivRace xivRace, char part, XivItemType itemType)
        {
            // The default version number
            var version = "0001";

            var hasVfx = false;

            if (itemType != XivItemType.human && itemType != XivItemType.furniture)
            {
                // get the items version from the imc file
                var imc     = new Imc(_gameDirectory, _dataFile);
                var imcInfo = imc.GetImcInfo(itemModel, itemModel.ModelInfo);
                version = imcInfo.Version.ToString().PadLeft(4, '0');

                if (imcInfo.Vfx > 0)
                {
                    hasVfx = true;
                }
            }

            var id      = itemModel.ModelInfo.ModelID.ToString().PadLeft(4, '0');
            var bodyVer = itemModel.ModelInfo.Body.ToString().PadLeft(4, '0');
            var race    = xivRace.GetRaceCode();

            string mtrlFolder = "", mtrlFile = "";

            switch (itemType)
            {
            case XivItemType.equipment:
                mtrlFolder = $"chara/{itemType}/e{id}/material/v{version}";
                mtrlFile   = $"mt_c{race}e{id}_{SlotAbbreviationDictionary[itemModel.ItemCategory]}_{part}{MtrlExtension}";
                break;

            case XivItemType.accessory:
                mtrlFolder = $"chara/{itemType}/a{id}/material/v{version}";
                mtrlFile   = $"mt_c{race}a{id}_{SlotAbbreviationDictionary[itemModel.ItemCategory]}_{part}{MtrlExtension}";
                break;

            case XivItemType.weapon:
                mtrlFolder = $"chara/{itemType}/w{id}/obj/body/b{bodyVer}/material/v{version}";
                mtrlFile   = $"mt_w{id}b{bodyVer}_{part}{MtrlExtension}";
                break;

            case XivItemType.monster:
                mtrlFolder = $"chara/{itemType}/m{id}/obj/body/b{bodyVer}/material/v{version}";
                mtrlFile   = $"mt_m{id}b{bodyVer}_{part}{MtrlExtension}";
                break;

            case XivItemType.demihuman:
                mtrlFolder = $"chara/{itemType}/d{id}/obj/equipment/e{bodyVer}/material/v{version}";
                mtrlFile   = $"mt_d{id}e{bodyVer}_{SlotAbbreviationDictionary[itemModel.ItemSubCategory]}_{part}{MtrlExtension}";
                break;

            case XivItemType.human:
                if (itemModel.ItemCategory.Equals(XivStrings.Body))
                {
                    mtrlFolder = $"chara/{itemType}/c{race}/obj/body/b{bodyVer}/material";
                    mtrlFile   = $"mt_c{race}b{bodyVer}_{part}{MtrlExtension}";
                }
                else if (itemModel.ItemCategory.Equals(XivStrings.Hair))
                {
                    // Hair has a version number, but no IMC, so we leave it at the default 0001
                    mtrlFolder = $"chara/{itemType}/c{race}/obj/hair/h{bodyVer}/material/v{version}";
                    mtrlFile   = $"mt_c{race}h{bodyVer}_{SlotAbbreviationDictionary[itemModel.ItemSubCategory]}_{part}{MtrlExtension}";
                }
                else if (itemModel.ItemCategory.Equals(XivStrings.Face))
                {
                    mtrlFolder = $"chara/{itemType}/c{race}/obj/face/f{bodyVer}/material";
                    mtrlFile   = $"mt_c{race}f{bodyVer}_{SlotAbbreviationDictionary[itemModel.ItemSubCategory]}_{part}{MtrlExtension}";
                }
                else if (itemModel.ItemCategory.Equals(XivStrings.Tail))
                {
                    mtrlFolder = $"chara/{itemType}/c{race}/obj/tail/t{bodyVer}/material";
                    mtrlFile   = $"mt_c{race}t{bodyVer}_{part}{MtrlExtension}";
                }
                break;

            case XivItemType.furniture:
                if (itemModel.ItemCategory.Equals(XivStrings.Furniture_Indoor))
                {
                    mtrlFolder = $"bgcommon/hou/indoor/general/{id}/material";
                    mtrlFile   = $"fun_b0_m{id}_0{part}{MtrlExtension}";
                }
                else if (itemModel.ItemCategory.Equals(XivStrings.Furniture_Outdoor))
                {
                    mtrlFolder = $"bgcommon/hou/outdoor/general/{id}/material";
                    mtrlFile   = $"gar_b0_m{id}_0{part}{MtrlExtension}";
                }
                break;

            default:
                mtrlFolder = "";
                mtrlFile   = "";
                break;
            }

            return(mtrlFolder, mtrlFile, hasVfx);
        }
        private async Task LoadItems()
        {
            List <string> children = new List <string>();
            var           root     = _item.GetRoot();

            if (root != null)
            {
                if (_level == XivDependencyLevel.Model)
                {
                    children = await root.GetModelFiles();
                }
                else if (_level == XivDependencyLevel.Material)
                {
                    var imc = new Imc(XivCache.GameInfo.GameDirectory);
                    try
                    {
                        var entry = await imc.GetImcInfo((IItemModel)_item);

                        children = await root.GetMaterialFiles(entry.MaterialSet);
                    } catch
                    {
                        if (root.Info.SecondaryType == XivItemType.hair ||
                            root.Info.SecondaryType == XivItemType.tail ||
                            (root.Info.PrimaryType == XivItemType.human && root.Info.SecondaryType == XivItemType.body))
                        {
                            // These types don't have IMC entries, but have a material variant number.
                            // Kind of weird, but whatever.
                            children = await root.GetMaterialFiles(1);
                        }
                        else
                        {
                            children = await root.GetMaterialFiles(0);
                        }
                    }
                }
                else if (_level == XivDependencyLevel.Texture)
                {
                    try
                    {
                        var imc   = new Imc(XivCache.GameInfo.GameDirectory);
                        var entry = await imc.GetImcInfo((IItemModel)_item);

                        children = await root.GetTextureFiles(entry.MaterialSet);
                    }
                    catch
                    {
                        if (root.Info.SecondaryType == XivItemType.hair ||
                            root.Info.SecondaryType == XivItemType.tail ||
                            (root.Info.PrimaryType == XivItemType.human && root.Info.SecondaryType == XivItemType.body))
                        {
                            // These types don't have IMC entries, but have a material variant number.
                            // Kind of weird, but whatever.
                            children = await root.GetTextureFiles(1);
                        }
                        else
                        {
                            children = await root.GetTextureFiles(0);
                        }
                    }
                }
                else
                {
                    // Invalid or root, nothing listed.
                }
            }

            var index = new Index(XivCache.GameInfo.GameDirectory);

            foreach (var file in children)
            {
                var exists = await index.FileExists(file);

                if (!exists)
                {
                    continue;
                }

                Files.Add(new FileEntry(file));
            }
        }