private string GenerateEnchantTooltip(EnchantRecipe recipe) { var sb = new StringBuilder(); var rarityColor = EpicLoot.GetRarityColor(SelectedRarity); var rarityDisplay = EpicLoot.GetRarityDisplayName(SelectedRarity); sb.AppendLine(); sb.AppendLine(); sb.AppendLine($"{recipe.FromItem.m_shared.m_name} \u2794 <color={rarityColor}>{rarityDisplay}</color> {recipe.FromItem.GetDecoratedName(rarityColor)}"); sb.AppendLine($"<color={rarityColor}>"); var effectCountWeights = LootRoller.GetEffectCountsPerRarity(SelectedRarity); float totalWeight = effectCountWeights.Sum(x => x.Value); foreach (var effectCountEntry in effectCountWeights) { var count = effectCountEntry.Key; var weight = effectCountEntry.Value; var percent = (int)(weight / totalWeight * 100.0f); var label = count == 1 ? $"{count} $mod_epicloot_enchant_effect" : $"{count} $mod_epicloot_enchant_effects"; sb.AppendLine($" ‣ {label} {percent}%"); } sb.Append("</color>"); return(sb.ToString()); }
public override void UpdateRecipe(InventoryGui __instance, Player player, float dt, Image bgImage) { if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count) { var recipe = Recipes[SelectedRecipe]; var itemData = recipe.FromItem; var rarityColor = EpicLoot.GetRarityColor(recipe.ToRarity); var rarityColorARGB = EpicLoot.GetRarityColorARGB(recipe.ToRarity); __instance.m_recipeIcon.enabled = true; __instance.m_recipeIcon.sprite = itemData.GetIcon(); __instance.m_recipeName.enabled = true; __instance.m_recipeName.text = Localization.instance.Localize(itemData.GetDecoratedName(rarityColor)); __instance.m_recipeDecription.enabled = true; __instance.m_recipeDecription.text = Localization.instance.Localize(GenerateEnchantTooltip(recipe)); bgImage.color = rarityColorARGB; bgImage.enabled = true; __instance.m_itemCraftType.gameObject.SetActive(false); __instance.m_variantButton.gameObject.SetActive(false); SetupRequirementList(__instance, player, recipe); __instance.m_minStationLevelIcon.gameObject.SetActive(false); var canCraft = Player.m_localPlayer.HaveRequirements(recipe.GetRequirementArray(), false, 1); __instance.m_craftButton.interactable = canCraft; __instance.m_craftButton.GetComponentInChildren <Text>().text = "Enchant"; __instance.m_craftButton.GetComponent <UITooltip>().m_text = canCraft ? "" : Localization.instance.Localize("$msg_missingrequirement"); } }
public void SetItem(SecretStashItemInfo itemInfo, Currencies currencies) { ItemInfo = itemInfo; var canAfford = CanAfford(currencies); Icon.sprite = ItemInfo.Item.GetIcon(); Icon.color = canAfford ? Color.white : new Color(1.0f, 0.0f, 1.0f, 0.0f); NameText.text = Localization.instance.Localize(ItemInfo.Item.GetDecoratedName(canAfford ? null : "grey")); CoinsCostText.text = ItemInfo.Cost.Coins.ToString(); CoinsCostText.transform.parent.gameObject.SetActive(ItemInfo.Cost.Coins > 0); ForestTokenCostText.text = ItemInfo.Cost.ForestTokens.ToString(); ForestTokenCostText.transform.parent.gameObject.SetActive(ItemInfo.Cost.ForestTokens > 0); IronBountyTokenCostText.text = ItemInfo.Cost.IronBountyTokens.ToString(); IronBountyTokenCostText.transform.parent.gameObject.SetActive(ItemInfo.Cost.IronBountyTokens > 0); GoldBountyTokenCostText.text = ItemInfo.Cost.GoldBountyTokens.ToString(); GoldBountyTokenCostText.transform.parent.gameObject.SetActive(ItemInfo.Cost.GoldBountyTokens > 0); if (!canAfford) { CoinsCostText.color = Color.grey; ForestTokenCostText.color = Color.grey; IronBountyTokenCostText.color = Color.grey; GoldBountyTokenCostText.color = Color.grey; } MagicBG.enabled = itemInfo.GuaranteedRarity || ItemInfo.Item.UseMagicBackground(); if (canAfford) { MagicBG.color = itemInfo.GuaranteedRarity ? EpicLoot.GetRarityColorARGB(itemInfo.Rarity) : ItemInfo.Item.GetRarityColor(); } else { MagicBG.color = new Color(1.0f, 0.0f, 1.0f, 0.0f); } Button.onClick.RemoveAllListeners(); Button.onClick.AddListener(() => OnSelected?.Invoke(ItemInfo)); Tooltip.m_topic = Localization.instance.Localize(ItemInfo.Item.GetDecoratedName()); Tooltip.m_text = Localization.instance.Localize(ItemInfo.Item.GetTooltip()); if (ItemInfo.IsGamble) { var color = canAfford ? (itemInfo.GuaranteedRarity ? EpicLoot.GetRarityColor(itemInfo.Rarity) : "white") : "grey"; var rarityDisplay = itemInfo.GuaranteedRarity ? EpicLoot.GetRarityDisplayName(itemInfo.Rarity) : "$mod_epicloot_merchant_unknown"; NameText.text = Localization.instance.Localize($"<color={color}>{rarityDisplay} {ItemInfo.Item.m_shared.m_name}</color>"); Tooltip.m_topic = NameText.text; Tooltip.m_text = GetGambleTooltip(); } }
public static void Postfix(ItemDrop __instance) { if (__instance.m_itemData.IsMagicCraftingMaterial()) { var particleContainer = __instance.transform.Find("Particles"); if (particleContainer != null) { particleContainer.gameObject.AddComponent <AlwaysPointUp>(); } var rarity = __instance.m_itemData.GetCraftingMaterialRarity(); var magicColor = EpicLoot.GetRarityColor(rarity); var variant = EpicLoot.GetRarityIconIndex(rarity); if (ColorUtility.TryParseHtmlString(magicColor, out var rgbaColor)) { __instance.gameObject.AddComponent <BeamColorSetter>().SetColor(rgbaColor); } __instance.m_itemData.m_variant = variant; } else if (__instance.m_itemData.IsRunestone()) { var particleContainer = __instance.transform.Find("Particles"); if (particleContainer != null) { particleContainer.gameObject.AddComponent <AlwaysPointUp>(); } var rarity = __instance.m_itemData.GetRunestoneRarity(); var magicColor = EpicLoot.GetRarityColor(rarity); if (ColorUtility.TryParseHtmlString(magicColor, out var rgbaColor)) { __instance.gameObject.AddComponent <BeamColorSetter>().SetColor(rgbaColor); } __instance.m_itemData.m_variant = 0; } }
private string GetGambleTooltip() { _sb.Clear(); _sb.AppendLine("$mod_epicloot_gamble_tooltip"); _sb.AppendLine(); _sb.AppendLine("$mod_epicloot_gamble_tooltip_chance"); var rarityChance = AdventureDataManager.Config.Gamble.GambleRarityChance; if (ItemInfo.GuaranteedRarity) { rarityChance = AdventureDataManager.Config.Gamble.GambleRarityChanceByRarity[(int)ItemInfo.Rarity]; } var labels = new[] { "$mod_epicloot_gamble_tooltip_nonmagic", EpicLoot.GetRarityDisplayName(ItemRarity.Magic), EpicLoot.GetRarityDisplayName(ItemRarity.Rare), EpicLoot.GetRarityDisplayName(ItemRarity.Epic), EpicLoot.GetRarityDisplayName(ItemRarity.Legendary) }; var totalWeight = (float)AdventureDataManager.Config.Gamble.GambleRarityChance.Sum(); for (var i = 0; i < 5; ++i) { var color = i == 0 ? "white" : EpicLoot.GetRarityColor((ItemRarity)(i - 1)); var percent = rarityChance[i] / totalWeight * 100; if (percent >= 0.01) { _sb.AppendLine($"<color={color}>{labels[i]}: {percent:0.#}%</color>"); } } return(Localization.instance.Localize(_sb.ToString())); }
public static string GetCraftingMaterialRarityColor(this ItemDrop.ItemData item) { return(EpicLoot.GetRarityColor(item.GetCraftingMaterialRarity())); }
public override void UpdateRecipe(InventoryGui __instance, Player player, float dt, Image bgImage) { __instance.m_craftButton.GetComponentInChildren <Text>().text = Localization.instance.Localize("$mod_epicloot_enchant"); if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count) { var recipe = Recipes[SelectedRecipe]; var itemData = recipe.FromItem; var rarityColor = EpicLoot.GetRarityColor(SelectedRarity); var rarityColorARGB = EpicLoot.GetRarityColorARGB(SelectedRarity); var isCrafting = __instance.m_craftTimer >= 0.0f; for (var index = 0; index < RarityButtons.Count; index++) { var rarityButton = RarityButtons[index]; var rarity = (ItemRarity)index; var canEnchantRarity = CanEnchantRarity(player, rarity); rarityButton.gameObject.SetActive(!isCrafting && canEnchantRarity); rarityButton.interactable = SelectedRarity != rarity; if (!EpicLoot.HasAuga) { var outline = rarityButton.transform.Find("EnchantOutline").GetComponent <Image>(); outline.enabled = !rarityButton.interactable; } } bgImage.color = rarityColorARGB; bgImage.enabled = true; __instance.m_itemCraftType.gameObject.SetActive(false); __instance.m_variantButton.gameObject.SetActive(false); __instance.m_minStationLevelIcon.gameObject.SetActive(false); var canCraft = Player.m_localPlayer.HaveRequirements(GetRecipeRequirementArray(recipe, SelectedRarity), false, 1); __instance.m_craftButton.interactable = canCraft; __instance.m_craftButton.GetComponent <UITooltip>().m_text = canCraft ? "" : Localization.instance.Localize("$msg_missingrequirement"); SetupRequirementList(__instance, player, recipe, canCraft); if (EpicLoot.HasAuga) { AugaTabData.ItemInfoGO.SetActive(true); AugaTabData.RequirementsPanelGO.SetActive(true); Auga.API.ComplexTooltip_ClearTextBoxes(AugaTabData.ItemInfoGO); Auga.API.ComplexTooltip_SetItemNoTextBoxes(AugaTabData.ItemInfoGO, itemData, itemData.m_quality, itemData.m_variant); Auga.API.ComplexTooltip_SetTopic(AugaTabData.ItemInfoGO, Localization.instance.Localize(itemData.GetDecoratedName())); __instance.m_itemCraftType.text = ""; var textbox = Auga.API.ComplexTooltip_AddTwoColumnTextBox(AugaTabData.ItemInfoGO); Auga.API.TooltipTextBox_AddLine(textbox, GenerateEnchantTooltip(recipe)); } else { __instance.m_recipeIcon.enabled = true; __instance.m_recipeIcon.sprite = itemData.GetIcon(); __instance.m_recipeName.enabled = true; __instance.m_recipeName.text = Localization.instance.Localize(itemData.GetDecoratedName(rarityColor)); __instance.m_recipeDecription.enabled = true; __instance.m_recipeDecription.text = Localization.instance.Localize(GenerateEnchantTooltip(recipe)); } } else { if (EpicLoot.HasAuga) { AugaTabData.ItemInfoGO.SetActive(false); AugaTabData.RequirementsPanelGO.SetActive(false); } bgImage.enabled = false; __instance.m_itemCraftType.gameObject.SetActive(false); __instance.m_variantButton.gameObject.SetActive(false); __instance.m_minStationLevelIcon.gameObject.SetActive(false); __instance.m_recipeIcon.enabled = false; __instance.m_recipeName.enabled = false; __instance.m_recipeDecription.enabled = false; foreach (var rarityButton in RarityButtons) { rarityButton.gameObject.SetActive(false); } foreach (var req in __instance.m_recipeRequirementList) { InventoryGui.HideRequirement(req.transform); } __instance.m_craftButton.interactable = false; } }
public override void UpdateRecipe(InventoryGui __instance, Player player, float dt, Image bgImage) { if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count) { var recipe = Recipes[SelectedRecipe]; var itemData = recipe.FromItem; var rarityColor = EpicLoot.GetRarityColor(SelectedRarity); var rarityColorARGB = EpicLoot.GetRarityColorARGB(SelectedRarity); for (var index = 0; index < RarityButtons.Count; index++) { var rarityButton = RarityButtons[index]; var rarity = (ItemRarity)index; var canEnchantRarity = CanEnchantRarity(player, rarity); rarityButton.gameObject.SetActive(canEnchantRarity); rarityButton.interactable = SelectedRarity != rarity; var outline = rarityButton.transform.Find("EnchantOutline").GetComponent <Image>(); outline.enabled = !rarityButton.interactable; } __instance.m_recipeIcon.enabled = true; __instance.m_recipeIcon.sprite = itemData.GetIcon(); __instance.m_recipeName.enabled = true; __instance.m_recipeName.text = Localization.instance.Localize(itemData.GetDecoratedName(rarityColor)); __instance.m_recipeDecription.enabled = true; __instance.m_recipeDecription.text = Localization.instance.Localize(GenerateEnchantTooltip(recipe)); bgImage.color = rarityColorARGB; bgImage.enabled = true; __instance.m_itemCraftType.gameObject.SetActive(false); __instance.m_variantButton.gameObject.SetActive(false); SetupRequirementList(__instance, player, recipe); __instance.m_minStationLevelIcon.gameObject.SetActive(false); var canCraft = Player.m_localPlayer.HaveRequirements(GetRecipeRequirementArray(recipe, SelectedRarity), false, 1); __instance.m_craftButton.interactable = canCraft; __instance.m_craftButton.GetComponentInChildren <Text>().text = "Enchant"; __instance.m_craftButton.GetComponent <UITooltip>().m_text = canCraft ? "" : Localization.instance.Localize("$msg_missingrequirement"); } else { bgImage.enabled = false; __instance.m_itemCraftType.gameObject.SetActive(false); __instance.m_variantButton.gameObject.SetActive(false); __instance.m_minStationLevelIcon.gameObject.SetActive(false); __instance.m_recipeIcon.enabled = false; __instance.m_recipeName.enabled = false; __instance.m_recipeDecription.enabled = false; foreach (var rarityButton in RarityButtons) { rarityButton.gameObject.SetActive(false); } foreach (var req in __instance.m_recipeRequirementList) { InventoryGui.HideRequirement(req.transform); } __instance.m_craftButton.interactable = false; } }