Esempio n. 1
0
        public object EnsureIcon(Saint.Item sItem)
        {
            var iconId = (UInt16)sItem.GetRaw("Icon");

            if (_iconPathsByIconId.TryGetValue(iconId, out var iconPath))
            {
                return(iconPath);
            }

            // This item has no high-res icon, generate a low-res temporary instead.
            var temporaryId = "t/" + iconId;

            _iconPathsByIconId[iconId] = temporaryId;

            // Write the temporary.
            var path = Path.Combine(_itemIconPath, temporaryId) + ".png";

            if (File.Exists(path) && !_overwriteIcon)
            {
                return(temporaryId);
            }

            var image = sItem.Icon.GetImage();

            image.Save(path, System.Drawing.Imaging.ImageFormat.Png);

            return(temporaryId);
        }
Esempio n. 2
0
        public static object GetIconId(Saint.Item item)
        {
            if (IconDataByItemId.TryGetValue(item.Key, out var storedIconData))
            {
                storedIconData.RawIconKey     = (UInt16)item.GetRaw("Icon");
                _iconIdByImageFile[item.Icon] = storedIconData.IconId;
                return(storedIconData.IconId);
            }

            if (_iconIdByImageFile.TryGetValue(item.Icon, out var otherIconId))
            {
                return(otherIconId);
            }

            throw new InvalidOperationException("Item has no icon id.");
        }
Esempio n. 3
0
        private static void GenerateTemporaryIcon(Saint.Item item)
        {
            // Store alternates found for any item that needs an icon.
            if (_temporaryIcons.Contains(item.Icon))
            {
                if (!AlternatesNeedingIcons.TryGetValue(item.Icon, out var alternates))
                {
                    AlternatesNeedingIcons[item.Icon] = alternates = new Queue <Saint.Item>();
                }
                alternates.Enqueue(item);
            }

            // Generate the temp.
            ItemsNeedingIcons.Add(item);
            _temporaryIcons.Add(item.Icon);
            var temporaryId = "t/" + int.Parse(Path.GetFileNameWithoutExtension(item.Icon.Path));

            _iconIdByImageFile[item.Icon] = temporaryId;
        }
Esempio n. 4
0
        private static void CheckIconData(Saint.Item item)
        {
            if (!IconDataByItemId.TryGetValue(item.Key, out var storedIconData))
            {
                return;
            }

            var rawIconKey = (UInt16)item.GetRaw("Icon");

            // Ensure the stored data is still what we expect.
            if (rawIconKey != storedIconData.RawIconKey)
            {
                // Icon changed!  Remove data.
                DatabaseBuilder.PrintLine($"{item.Key} {item.Name} icon changed.  {rawIconKey} != {storedIconData.RawIconKey}.  Removing.");
                IconDataByItemId.Remove(item.Key);
            }
            else
            {
                // Have valid stored data.  Cross-reference the image file.
                _iconIdByImageFile[item.Icon] = storedIconData.IconId;
            }
        }
Esempio n. 5
0
        void BuildTutorial()
        {
            foreach (var sTutorial in _builder.Sheet("Tutorial"))
            {
                var sItems = new Saint.Item[]
                {
                    (Saint.Item)sTutorial["Reward{Tank}"],
                    (Saint.Item)sTutorial["Reward{Melee}"],
                    (Saint.Item)sTutorial["Reward{Ranged}"]
                };

                foreach (var sItem in sItems)
                {
                    if (sItem.Key == 0)
                    {
                        continue;
                    }

                    var item = _builder.Db.ItemsById[sItem.Key];
                    item.tutorialReward = 1;
                }
            }
        }
Esempio n. 6
0
        void BuildAttributes(dynamic item, Saint.Item sItem)
        {
            var attr     = new JObject();
            var attr_hq  = new JObject();
            var attr_max = new JObject();

            if (sItem is Saint.Items.Equipment sEquipment)
            {
                item.equip = 1;

                if (sEquipment.FreeMateriaSlots > 0)
                {
                    item.sockets = sEquipment.FreeMateriaSlots;

                    // Only equipment with slots should possibly be forbidden.
                    if (!sItem.IsAdvancedMeldingPermitted)
                    {
                        item.advancedMeldingForbidden = 1;
                    }
                }

                if (sEquipment.RepairItem != null && sEquipment.RepairItem.Key > 0)
                {
                    item.repair_item = sEquipment.RepairItem.Key;
                }

                if (sEquipment.IsPvP)
                {
                    item.pvp = 1;
                }

                if (sEquipment.IsCrestWorthy)
                {
                    item.crestworthy = 1;
                }

                if (sEquipment.IsGlamourous)
                {
                    item.glamourous = 1;
                }

                var expertSeals = sEquipment.ExpertDeliverySeals;
                if (expertSeals > 0)
                {
                    item.delivery = expertSeals;
                }

                if (_armoireIndex.Contains(sItem.Key))
                {
                    item.storable = 1;
                }

                item.slot = sEquipment.EquipSlotCategory.Key;
                item.elvl = sEquipment.EquipmentLevel;
                item.jobs = sEquipment.ClassJobCategory.Key;
                _builder.Localize.Column(item, sEquipment.ClassJobCategory, "Name", "jobCategories");

                // Set all normal and hq parameters specified on the item.
                Saint.BaseParam[] extraParams = null;
                foreach (var sParameter in sEquipment.AllParameters)
                {
                    if (_crafterParams.Contains(sParameter.BaseParam))
                    {
                        extraParams = _crafterParams;
                    }
                    else if (_gathererParams.Contains(sParameter.BaseParam))
                    {
                        extraParams = _gathererParams;
                    }

                    ParamHelper.SetValue(sParameter, attr, attr_hq, false);
                }

                // Set maximums for every parameter.
                foreach (var sBaseParam in _baseParams)
                {
                    ParamHelper.SetMaxValue(sEquipment, sBaseParam, attr_max);
                }

                // For gatherer and crafter equ, set normal attributes even
                // if they're 0 so their maximums always show up.
                if (extraParams != null)
                {
                    foreach (var sBaseParam in extraParams)
                    {
                        var key = sBaseParam.Name.ToString();
                        if (attr_max[key] != null && attr[key] == null && attr_hq[key] == null)
                        {
                            attr[key] = 0;
                        }
                    }
                }

                var characterType = sEquipment.GetModelCharacterType();
                if (characterType != 0 && !Hacks.NoModelCategories.Contains(sEquipment.ItemUICategory.Key))
                {
                    // Record model information for viewer.
                    item.models = new JArray();
                    item.models.Add(sEquipment.PrimaryModelKey.ToString().Replace(", ", "-"));
                    if (!sEquipment.SecondaryModelKey.IsEmpty)
                    {
                        item.models.Add(sEquipment.SecondaryModelKey.ToString().Replace(", ", "-"));
                    }

                    if (sEquipment.Rarity != 7)
                    {
                        var sEquipSlot = sEquipment.EquipSlotCategory.PossibleSlots.First();
                        var modelKey   = sEquipSlot.GetModelKey(sEquipment.PrimaryModelKey, characterType);

                        // We compare only the primary model key for now.
                        // Not sure if the secondary key is valuable too?
                        if (!_itemsBySlotModelId.TryGetValue(modelKey, out var itemsWithModel))
                        {
                            itemsWithModel = new List <dynamic>();
                            _itemsBySlotModelId[modelKey] = itemsWithModel;
                        }
                        itemsWithModel.Add(item);
                    }
                }

                // ItemSpecialBonus
                if (sEquipment.ItemSpecialBonus != null && sEquipment.ItemSpecialBonus.Name != "")
                {
                    item.special         = new JObject();
                    item.special.bonusId = sEquipment.ItemSpecialBonus.Key;

                    if (sEquipment.ItemSpecialBonusParam > 0)
                    {
                        item.special.bonusParam = sEquipment.ItemSpecialBonusParam;
                    }

                    if (sEquipment.ItemSeries.Key > 0)
                    {
                        item.special.seriesId = sEquipment.ItemSeries.Key;

                        if (!_builder.Db.ItemsBySeriesId.TryGetValue(sEquipment.ItemSeries.Key, out var itemsInSeries))
                        {
                            _builder.Db.ItemsBySeriesId[sEquipment.ItemSeries.Key] = itemsInSeries = new List <dynamic>();
                        }
                        itemsInSeries.Add(item);
                    }

                    item.special.attr = new JArray();
                    foreach (var sParam in sEquipment.SecondaryParameters)
                    {
                        foreach (var paramValue in sParam.Values.Select(pv => ParameterInfo.From(pv)))
                        {
                            if (paramValue.Type != Saint.ParameterType.Sanction &&
                                paramValue.Type != Saint.ParameterType.SetBonus &&
                                paramValue.Type != Saint.ParameterType.SetBonusCapped &&
                                paramValue.Type != Saint.ParameterType.EurekaEffect)
                            {
                                continue;
                            }

                            dynamic obj = new JObject();
                            obj.name  = sParam.BaseParam.Name.ToString();
                            obj.value = (int)paramValue.Amount;
                            obj.index = paramValue.Index;

                            item.special.attr.Add(obj);
                        }
                    }
                }
            }

            if (sItem is Saint.Items.Usable sUsable)
            {
                JObject action    = new JObject();
                JObject action_hq = new JObject();

                foreach (var param in sUsable.Parameters)
                {
                    ParamHelper.SetValue(param, action, action_hq, true);
                }

                if (action.Count > 0)
                {
                    attr.Add("action", action);
                }
                if (action_hq.Count > 0)
                {
                    attr_hq.Add("action", action_hq);
                }
            }

            if (attr.Count > 0)
            {
                item.attr = attr;
            }
            if (attr_hq.Count > 0)
            {
                item.attr_hq = attr_hq;
            }
            if (attr_max.Count > 0)
            {
                item.attr_max = attr_max;
            }
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="Entry" /> class.
 /// </summary>
 /// <param name="item"><see cref="Item" /> for the entry.</param>
 /// <param name="count">Item count of the entry.</param>
 /// <param name="isHq">A value indicating whether the <c>item</c> is high-quality.</param>
 public Entry(Item item, int count, bool isHq)
 {
     Item = item;
     Count = count;
     IsHq = isHq;
 }