示例#1
0
        /// <summary>
        /// Retrieves the file path to the model's base skeleton file.
        /// </summary>
        /// <param name="fullMdlPath"></param>
        private static async Task <string> GetBaseSkelbPath(XivDependencyRootInfo root, XivRace race = XivRace.All_Races)
        {
            var skelFolder = "";
            var skelFile   = "";

            if (root.PrimaryType != XivItemType.human && root.PrimaryType != XivItemType.equipment && root.PrimaryType != XivItemType.accessory)
            {
                var typeName = XivItemTypes.GetSystemName(root.PrimaryType);
                var prefix   = XivItemTypes.GetSystemPrefix(root.PrimaryType);
                var id       = root.PrimaryId.ToString().PadLeft(4, '0');
                var bodyCode = "0001";
                var path     = $"chara/{typeName}/{prefix}{id}/skeleton/base/b{bodyCode}/skl_{prefix}{id}b{bodyCode}.sklb";
                return(path);
            }
            else
            {
                // Equipment and accessories need an external race passed in.
                var raceCode = race.GetRaceCode();
                if (root.PrimaryType == XivItemType.human && race != XivRace.All_Races)
                {
                    raceCode = root.PrimaryId.ToString().PadLeft(4, '0');
                }

                var bodyCode = "0001";
                skelFolder = $"chara/human/c{raceCode}/skeleton/base/b{bodyCode}";
                skelFile   = $"skl_c{raceCode}b{bodyCode}.sklb";
                return(skelFolder + "/" + skelFile);
            }
        }
示例#2
0
        private void PreviousSlotButton_Click(object sender, RoutedEventArgs e)
        {
            var type = _root.Info.PrimaryType;

            if (type == XivItemType.demihuman)
            {
                type = (XivItemType)_root.Info.SecondaryType;
            }

            var slots = XivItemTypes.GetAvailableSlots(type);

            var currentSlotIdx = Array.IndexOf(slots.ToArray(), _root.Info.Slot);
            var nextSlotIdx    = currentSlotIdx - 1;

            if (nextSlotIdx < 0)
            {
                nextSlotIdx = slots.Count - 1;
            }

            if (nextSlotIdx >= slots.Count || nextSlotIdx < 0)
            {
                // Can't change slots, this item only has one.
                return;
            }

            var nextSlot = slots[nextSlotIdx];

            var newRootInfo = (XivDependencyRootInfo)_root.Info.Clone();

            newRootInfo.Slot = nextSlot;

            var newRoot = newRootInfo.ToFullRoot();

            if (newRoot == null)
            {
                // Shouldn't ever actually hit this, but if we do, cancel the process.
                return;
            }

            SetRoot(newRoot);
        }
示例#3
0
        public static async Task <(string Folder, string File)> GetVfxPath(XivDependencyRootInfo root, int vfx)
        {
            var type      = root.PrimaryType;
            var id        = root.PrimaryId.ToString().PadLeft(4, '0');
            var bodyVer   = root.SecondaryId.ToString().PadLeft(4, '0');
            var prefix    = XivItemTypes.GetSystemPrefix(type);
            var vfxPrefix = GetVfxPrefix(root);

            string vfxFolder, vfxFile;

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

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

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

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

            return(vfxFolder, vfxFile);
        }
        /// <summary>
        /// Builds the set tree from XivCache.GetAllRoots().
        /// </summary>
        private void BuildSetTree()
        {
            // First we must generate all the dependency root nodes.
            var roots               = XivCache.GetAllRootsDictionary();
            var primaryTypeGroups   = new Dictionary <XivItemType, ItemTreeElement>();
            var primaryIdGroups     = new Dictionary <XivItemType, Dictionary <int, ItemTreeElement> >();
            var secondaryTypeGroups = new Dictionary <XivItemType, Dictionary <int, Dictionary <XivItemType, ItemTreeElement> > >();
            var secondaryIdGroups   = new Dictionary <XivItemType, Dictionary <int, Dictionary <XivItemType, Dictionary <int, ItemTreeElement> > > >();

            // This giant for loop monstrosity builds the actual root nodes based on the dictionaries returned by XivCache.GetAllRoots()
            foreach (var kvPrimaryType in roots)
            {
                var primaryType = kvPrimaryType.Key;

                // Create the new node.
                primaryTypeGroups.Add(primaryType, new ItemTreeElement(null, null, XivItemTypes.NiceNames[primaryType], true));

                // Add us to parent.
                SetElements.Add(primaryTypeGroups[primaryType]);

                // Ensure the other lists have our primary type reference.
                primaryIdGroups.Add(primaryType, new Dictionary <int, ItemTreeElement>());
                secondaryTypeGroups.Add(primaryType, new Dictionary <int, Dictionary <XivItemType, ItemTreeElement> >());
                secondaryIdGroups.Add(primaryType, new Dictionary <int, Dictionary <XivItemType, Dictionary <int, ItemTreeElement> > >());

                foreach (var kvPrimaryId in kvPrimaryType.Value)
                {
                    var primaryId = kvPrimaryId.Key;

                    // Create the new node.
                    primaryIdGroups[primaryType].Add(primaryId, new ItemTreeElement(null, primaryTypeGroups[primaryType], XivItemTypes.GetSystemPrefix(primaryType) + primaryId.ToString().PadLeft(4, '0'), true));

                    // Add us to parent.
                    primaryTypeGroups[primaryType].Children.Add(primaryIdGroups[primaryType][primaryId]);

                    // Ensure the other lists have our primary id reference.
                    secondaryTypeGroups[primaryType].Add(primaryId, new Dictionary <XivItemType, ItemTreeElement>());
                    secondaryIdGroups[primaryType].Add(primaryId, new Dictionary <XivItemType, Dictionary <int, ItemTreeElement> >());

                    foreach (var kvSecondaryType in kvPrimaryId.Value)
                    {
                        var secondaryType = kvSecondaryType.Key;

                        if (secondaryType != XivItemType.none)
                        {
                            // Create the new node.
                            secondaryTypeGroups[primaryType][primaryId].Add(secondaryType, new ItemTreeElement(null, primaryIdGroups[primaryType][primaryId], XivItemTypes.NiceNames[secondaryType], true));

                            // Add us to parent.
                            primaryIdGroups[primaryType][primaryId].Children.Add(secondaryTypeGroups[primaryType][primaryId][secondaryType]);

                            // Ensure the other lists have our secondary type reference.
                            secondaryIdGroups[primaryType][primaryId].Add(secondaryType, new Dictionary <int, ItemTreeElement>());
                        }

                        foreach (var kvSecondaryId in kvSecondaryType.Value)
                        {
                            var secondaryId = kvSecondaryId.Key;

                            if (secondaryType != XivItemType.none)
                            {
                                // Create the new node.
                                secondaryIdGroups[primaryType][primaryId][secondaryType].Add(secondaryId, new ItemTreeElement(null, secondaryTypeGroups[primaryType][primaryId][secondaryType], XivItemTypes.GetSystemPrefix(secondaryType) + secondaryId.ToString().PadLeft(4, '0'), true));

                                // Add us to parent.
                                secondaryTypeGroups[primaryType][primaryId][secondaryType].Children.Add(secondaryIdGroups[primaryType][primaryId][secondaryType][secondaryId]);
                            }

                            foreach (var kvSlot in kvSecondaryId.Value)
                            {
                                var root = kvSlot.Value;


                                var slotName = Mdl.SlotAbbreviationDictionary.FirstOrDefault(x => x.Value == root.Slot).Key;

                                if (secondaryType != XivItemType.none)
                                {
                                    // This root has no slots, just list the parent as the root element.
                                    if (String.IsNullOrWhiteSpace(slotName))
                                    {
                                        DependencyRootNodes.Add(root.ToString(), secondaryIdGroups[primaryType][primaryId][secondaryType][secondaryId]);
                                        break;
                                    }

                                    // Create the new node.
                                    var elem = new ItemTreeElement(null, secondaryIdGroups[primaryType][primaryId][secondaryType][secondaryId], slotName);

                                    // Add us to parent.
                                    secondaryIdGroups[primaryType][primaryId][secondaryType][secondaryId].Children.Add(elem);

                                    // Save us to the primary listing so the items can list themselves under us.
                                    DependencyRootNodes.Add(root.ToString(), elem);
                                }
                                else
                                {
                                    // This root has no slots, just list the parent as the root element.
                                    if (String.IsNullOrWhiteSpace(slotName))
                                    {
                                        DependencyRootNodes.Add(root.ToString(), primaryIdGroups[primaryType][primaryId]);
                                        break;
                                    }

                                    // Create the new node.
                                    var elem = new ItemTreeElement(null, primaryIdGroups[primaryType][primaryId], slotName);

                                    // Add us to parent.
                                    primaryIdGroups[primaryType][primaryId].Children.Add(elem);

                                    // Save us to the primary listing so the items can list themselves under us.
                                    DependencyRootNodes.Add(root.ToString(), elem);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#5
0
        public async Task <bool> SetRoot(XivDependencyRoot root, int defaultVariant = 0)
        {
            _root = root;
            if (_root == null)
            {
                return(false);
            }

            if (root.Info.PrimaryType == XivItemType.human)
            {
                if (_lastNumber > 0)
                {
                    if (_lastNumber != (int)root.Info.SecondaryId)
                    {
                        // Change root to the new "number" root.
                        var nRoot = new XivDependencyRootInfo()
                        {
                            PrimaryId     = _root.Info.PrimaryId,
                            PrimaryType   = _root.Info.PrimaryType,
                            SecondaryId   = _lastNumber,
                            SecondaryType = _root.Info.SecondaryType,
                            Slot          = _root.Info.Slot
                        };
                        _root = nRoot.ToFullRoot();
                    }
                }
                if (_root.Info.SecondaryId > 0)
                {
                    _lastNumber = (int)_root.Info.SecondaryId;
                }
            }

            SetLabel.Content  = XivItemTypes.GetSystemPrefix(root.Info.PrimaryType) + root.Info.PrimaryId.ToString().PadLeft(4, '0');
            SlotLabel.Content = Mdl.SlotAbbreviationDictionary.FirstOrDefault(x => x.Value == _root.Info.Slot).Key + "(" + _root.Info.Slot + ")";

            var items = await _root.GetAllItems();

            ItemNameBox.Text = "[" + items.Count + "] " + items[0].Name;

            var _modding = new Modding(XivCache.GameInfo.GameDirectory);
            var path     = _root.Info.GetRootFile();
            var mod      = await _modding.TryGetModEntry(path);

            if (mod == null)
            {
                ToggleButton.IsEnabled = false;
                ToggleButton.Content   = "Enable";
            }
            else
            {
                ToggleButton.IsEnabled = true;
                if (mod.enabled)
                {
                    ToggleButton.Content = "Disable";
                }
                else
                {
                    ToggleButton.Content = "Enable";
                }
            }

            return(await _vm.SetRoot(_root, defaultVariant));
        }