public static void Postfix(Transform elementRoot, Piece.Requirement req, Player player, bool craft, int quality) { var instance = InventoryGui.instance; if ((instance.InCraftTab() || instance.InUpradeTab()) && req?.m_resItem != null) { var item = req.m_resItem; var icon = elementRoot.transform.Find("res_icon").GetComponent <Image>(); var bgIconTransform = elementRoot.Find("bgIcon"); if (item.m_itemData.UseMagicBackground()) { if (bgIconTransform == null) { bgIconTransform = Object.Instantiate(icon, elementRoot, true).transform; bgIconTransform.name = "bgIcon"; bgIconTransform.SetSiblingIndex(icon.transform.GetSiblingIndex()); } bgIconTransform.gameObject.SetActive(true); var bgIcon = bgIconTransform.GetComponent <Image>(); bgIcon.sprite = EpicLoot.GetMagicItemBgSprite(); bgIcon.color = item.m_itemData.GetRarityColor(); } else if (bgIconTransform != null) { bgIconTransform.gameObject.SetActive(false); } } }
public static void Postfix(InventoryGui __instance, Player player, float dt) { var activeTab = GetActiveTabController(); if (activeTab != null) { var icon = EpicLoot.HasAuga ? Auga.API.RequirementsPanel_GetIcon(activeTab.AugaTabData.RequirementsPanelGO) : __instance.m_recipeIcon; var magicItemBG = icon.transform.parent.Find("MagicItemBG"); Image bgImage; if (magicItemBG == null) { bgImage = Object.Instantiate(icon, icon.transform.parent, true); bgImage.name = "MagicItemBG"; bgImage.transform.SetSiblingIndex(icon.transform.GetSiblingIndex()); bgImage.sprite = EpicLoot.GetMagicItemBgSprite(); bgImage.color = Color.white; bgImage.rectTransform.anchorMin = new Vector2(0, 0); bgImage.rectTransform.anchorMax = new Vector2(1, 1); bgImage.rectTransform.sizeDelta = new Vector2(0, 0); bgImage.rectTransform.anchoredPosition = new Vector2(0, 0); } else { bgImage = magicItemBG.GetComponent <Image>(); } activeTab.UpdateRecipe(__instance, player, dt, bgImage); } }
public static bool SetupRequirement( InventoryGui __instance, Transform elementRoot, ItemDrop item, int amount, Player player) { var icon = elementRoot.transform.Find("res_icon").GetComponent <Image>(); var nameText = elementRoot.transform.Find("res_name").GetComponent <Text>(); var amountText = elementRoot.transform.Find("res_amount").GetComponent <Text>(); var tooltip = elementRoot.GetComponent <UITooltip>(); if (item != null) { icon.gameObject.SetActive(true); nameText.gameObject.SetActive(true); amountText.gameObject.SetActive(true); if (item.m_itemData.IsMagicCraftingMaterial()) { var rarity = item.m_itemData.GetCraftingMaterialRarity(); icon.sprite = item.m_itemData.m_shared.m_icons[EpicLoot.GetRarityIconIndex(rarity)]; } else { icon.sprite = item.m_itemData.GetIcon(); } icon.color = Color.white; var bgIconTransform = icon.transform.parent.Find("bgIcon"); if (item.m_itemData.UseMagicBackground()) { if (bgIconTransform == null) { bgIconTransform = Object.Instantiate(icon, icon.transform.parent, true).transform; bgIconTransform.name = "bgIcon"; bgIconTransform.SetSiblingIndex(icon.transform.GetSiblingIndex()); } bgIconTransform.gameObject.SetActive(true); var bgIcon = bgIconTransform.GetComponent <Image>(); bgIcon.sprite = EpicLoot.GetMagicItemBgSprite(); bgIcon.color = item.m_itemData.GetRarityColor(); } else if (bgIconTransform != null) { bgIconTransform.gameObject.SetActive(false); } tooltip.m_text = Localization.instance.Localize(item.m_itemData.m_shared.m_name); nameText.text = Localization.instance.Localize(item.m_itemData.m_shared.m_name); if (amount <= 0) { InventoryGui.HideRequirement(elementRoot); return(false); } amountText.text = amount.ToString(); amountText.color = Color.white; } return(true); }
public static void Postfix(InventoryGui __instance, Player player, Recipe recipe, ItemDrop.ItemData item, bool canCraft) { var selectedCraftingItem = __instance.InCraftTab() && recipe.m_item != null; var selectedUpgradeItem = __instance.InUpradeTab() && item != null; if (selectedCraftingItem || selectedUpgradeItem) { var thisItem = selectedCraftingItem ? recipe.m_item.m_itemData : item; if (thisItem.UseMagicBackground()) { var element = __instance.m_recipeList.LastOrDefault(); if (element != null) { var image = element.transform.Find("icon").GetComponent <Image>(); var bgImage = Object.Instantiate(image, image.transform.parent, true); bgImage.name = "MagicItemBG"; bgImage.transform.SetSiblingIndex(image.transform.GetSiblingIndex()); bgImage.sprite = EpicLoot.GetMagicItemBgSprite(); bgImage.color = thisItem.GetRarityColor(); if (!canCraft) { bgImage.color -= new Color(0, 0, 0, 0.66f); } var nameText = element.transform.Find("name").GetComponent <Text>(); nameText.color = canCraft ? thisItem.GetRarityColor() : new Color(0.66f, 0.66f, 0.66f, 1f); } } } }
public void AddRecipeToList(InventoryGui __instance, DisenchantRecipe recipe, int index) { var count = __instance.m_recipeList.Count; var element = Object.Instantiate(__instance.m_recipeElementPrefab, __instance.m_recipeListRoot); element.SetActive(true); element.RectTransform().anchoredPosition = new Vector2(0.0f, count * -__instance.m_recipeListSpace); var item = recipe.FromItem; var image = element.transform.Find("icon").GetComponent <Image>(); image.sprite = item.GetIcon(); image.color = Color.white; if (item.UseMagicBackground()) { var bgImage = Object.Instantiate(image, image.transform.parent, true); bgImage.name = "MagicItemBG"; bgImage.transform.SetSiblingIndex(image.transform.GetSiblingIndex()); bgImage.sprite = EpicLoot.GetMagicItemBgSprite(); bgImage.color = item.GetRarityColor(); } var nameText = element.transform.Find("name").GetComponent <Text>(); nameText.text = Localization.instance.Localize(item.GetDecoratedName()); if (item.m_shared.m_maxStackSize > 1 && item.m_stack > 1) { nameText.text += $" x{item.m_stack}"; } var durability = element.transform.Find("Durability").GetComponent <GuiBar>(); if (item.m_shared.m_useDurability && item.m_durability < item.GetMaxDurability()) { durability.gameObject.SetActive(true); durability.SetValue(item.GetDurabilityPercentage()); } else { durability.gameObject.SetActive(false); } var quality = element.transform.Find("QualityLevel").GetComponent <Text>(); quality.gameObject.SetActive(item.m_shared.m_maxQuality > 1); quality.text = item.m_quality.ToString(); element.GetComponent <Button>().onClick.AddListener(() => OnSelectedRecipe(__instance, index)); __instance.m_recipeList.Add(element); }
public void AddRecipeToList(InventoryGui __instance, AugmentRecipe recipe, int index) { var count = __instance.m_recipeList.Count; var element = Object.Instantiate(__instance.m_recipeElementPrefab, __instance.m_recipeListRoot); element.SetActive(true); element.RectTransform().anchoredPosition = new Vector2(0.0f, count * -__instance.m_recipeListSpace); //var canCraft = Player.m_localPlayer.HaveRequirements(recipe.GetRequirementArray(), false, 1); var item = recipe.FromItem; var image = element.transform.Find("icon").GetComponent <Image>(); image.sprite = item.GetIcon(); image.color = Color.white; var bgImage = Object.Instantiate(image, image.transform.parent, true); bgImage.name = "MagicItemBG"; bgImage.transform.SetSiblingIndex(image.transform.GetSiblingIndex()); bgImage.sprite = EpicLoot.GetMagicItemBgSprite(); bgImage.color = EpicLoot.GetRarityColorARGB(item.GetRarity()); var nameText = element.transform.Find("name").GetComponent <Text>(); nameText.text = Localization.instance.Localize(item.GetDecoratedName()); if (item.GetMagicItem() != null && item.GetMagicItem().HasBeenAugmented()) { nameText.text += $" {EpicLoot.GetMagicEffectPip(true)}"; } nameText.color = Color.white; var durability = element.transform.Find("Durability").GetComponent <GuiBar>(); if (item.m_shared.m_useDurability && item.m_durability < item.GetMaxDurability()) { durability.gameObject.SetActive(true); durability.SetValue(item.GetDurabilityPercentage()); } else { durability.gameObject.SetActive(false); } var quality = element.transform.Find("QualityLevel").GetComponent <Text>(); quality.gameObject.SetActive(true); quality.text = item.m_quality.ToString(); element.GetComponent <Button>().onClick.AddListener(() => OnSelectedRecipe(__instance, index)); __instance.m_recipeList.Add(element); }
public static CraftSuccessDialog Create(Transform parent) { var inventoryGui = InventoryGui.instance; var newDialog = Instantiate(inventoryGui.m_variantDialog, parent); var dialog = newDialog.gameObject.AddComponent <CraftSuccessDialog>(); Destroy(newDialog); dialog.gameObject.name = "CraftingSuccessDialog"; dialog.Frame = dialog.gameObject.transform.Find("VariantFrame").gameObject.RectTransform(); dialog.Frame.gameObject.name = "Frame"; for (var i = 1; i < dialog.Frame.childCount; ++i) { var child = dialog.Frame.GetChild(i); Destroy(child.gameObject); } dialog.Frame.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 380); dialog.Frame.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 550); dialog.Frame.anchoredPosition += new Vector2(20, -270); dialog.MagicBG = Instantiate(inventoryGui.m_recipeIcon, dialog.Frame); dialog.MagicBG.name = "MagicItemBG"; dialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite(); dialog.MagicBG.color = Color.white; dialog.NameText = Instantiate(inventoryGui.m_recipeName, dialog.Frame); dialog.Description = Instantiate(inventoryGui.m_recipeDecription, dialog.Frame); dialog.Description.rectTransform.anchoredPosition += new Vector2(0, -110); dialog.Description.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 460); dialog.Icon = Instantiate(inventoryGui.m_recipeIcon, dialog.Frame); var closeButton = dialog.gameObject.GetComponentInChildren <Button>(); closeButton.onClick = new Button.ButtonClickedEvent(); closeButton.onClick.AddListener(dialog.Close); closeButton.transform.SetAsLastSibling(); return(dialog); }
public static void Postfix(InventoryGui __instance, Player player, float dt) { var activeTab = GetActiveTabController(); if (activeTab != null) { var magicItemBG = __instance.m_recipeIcon.transform.parent.Find("MagicItemBG"); Image bgImage; if (magicItemBG == null) { bgImage = Object.Instantiate(__instance.m_recipeIcon, __instance.m_recipeIcon.transform.parent, true); bgImage.name = "MagicItemBG"; bgImage.transform.SetSiblingIndex(__instance.m_recipeIcon.transform.GetSiblingIndex()); bgImage.sprite = EpicLoot.GetMagicItemBgSprite(); bgImage.color = Color.white; } else { bgImage = magicItemBG.GetComponent <Image>(); } activeTab.UpdateRecipe(__instance, player, dt, bgImage); } }
private static void AugaFixItemBG(GameObject obj) { var magicBG = obj.transform.Find("MagicBG"); if (magicBG != null) { var image = magicBG.GetComponent <Image>(); if (image != null) { image.sprite = EpicLoot.GetMagicItemBgSprite(); } } var icon = obj.transform.Find("Icon"); if (icon != null) { var iconBG = Object.Instantiate(icon, icon.parent); iconBG.SetSiblingIndex(2); var image = iconBG.GetComponent <Image>(); image.sprite = Auga.API.GetItemBackgroundSprite(); image.color = new Color(0, 0, 0, 0.5f); } }
public static void Postfix(InventoryGui __instance) { var recipeDesc = __instance.m_recipeDecription; if (EpicLoot.UseScrollingCraftDescription.Value && recipeDesc.GetComponent <ContentSizeFitter>() == null) { var contentSizeFitter = recipeDesc.gameObject.AddComponent <ContentSizeFitter>(); contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; recipeDesc.resizeTextForBestFit = false; recipeDesc.fontSize = 18; recipeDesc.rectTransform.anchorMin = new Vector2(0, 1); recipeDesc.rectTransform.anchorMax = new Vector2(1, 1); // pin top, stretch horiz recipeDesc.rectTransform.pivot = new Vector2(0, 1); recipeDesc.horizontalOverflow = HorizontalWrapMode.Wrap; recipeDesc.rectTransform.anchoredPosition = new Vector2(4, 4); recipeDesc.raycastTarget = false; var scrollRectGO = new GameObject("ScrollView", typeof(RectTransform), typeof(ScrollRect), typeof(Image)); scrollRectGO.transform.SetParent(__instance.m_recipeDecription.transform.parent, false); scrollRectGO.transform.SetSiblingIndex(0); var rt = scrollRectGO.transform as RectTransform; rt.anchorMin = new Vector2(0, 1); rt.anchorMax = new Vector2(0, 1); rt.pivot = new Vector2(0, 1); rt.anchoredPosition = new Vector2(11, -74); rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 330); rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 300); scrollRectGO.GetComponent <Image>().color = new Color(0, 0, 0, 0.2f); var viewport = new GameObject("Viewport", typeof(RectTransform), typeof(RectMask2D)); viewport.transform.SetParent(scrollRectGO.transform, false); var vrt = viewport.transform as RectTransform; vrt.anchorMin = new Vector2(0, 0); vrt.anchorMax = new Vector2(1, 1); vrt.sizeDelta = new Vector2(0, 0); recipeDesc.transform.SetParent(vrt, false); var scrollRect = scrollRectGO.GetComponent <ScrollRect>(); scrollRect.viewport = vrt; scrollRect.content = recipeDesc.rectTransform; scrollRect.horizontal = false; scrollRect.vertical = true; scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHide; scrollRect.scrollSensitivity = 30; scrollRect.inertia = false; scrollRect.movementType = ScrollRect.MovementType.Clamped; scrollRect.onValueChanged.RemoveAllListeners(); var newScrollbar = Object.Instantiate(__instance.m_recipeListScroll, scrollRectGO.transform); newScrollbar.size = 0.4f; scrollRect.onValueChanged.AddListener((_) => newScrollbar.size = 0.4f); scrollRect.verticalScrollbar = newScrollbar; } if (__instance.InCraftTab() && __instance.m_selectedRecipe.Key != null && __instance.m_selectedRecipe.Key.m_item.m_itemData.IsMagicCraftingMaterial()) { var localizedName = Localization.instance.Localize(__instance.m_selectedRecipe.Key.m_item.m_itemData.GetDecoratedName()); if (__instance.m_selectedRecipe.Key.m_amount > 1) { localizedName = localizedName + " x" + __instance.m_selectedRecipe.Key.m_amount; } __instance.m_recipeName.text = localizedName; __instance.m_recipeIcon.sprite = __instance.m_selectedRecipe.Key.m_item.m_itemData.GetIcon(); __instance.m_variantButton.gameObject.SetActive(false); } if (__instance.InCraftTab() || __instance.InUpradeTab()) { Image bgImage = null; var magicItemBG = __instance.m_recipeIcon.transform.parent.Find("MagicItemBG"); if (magicItemBG != null) { bgImage = magicItemBG.GetComponent <Image>(); } else { bgImage = Object.Instantiate(__instance.m_recipeIcon, __instance.m_recipeIcon.transform.parent, true); bgImage.name = "MagicItemBG"; bgImage.transform.SetSiblingIndex(__instance.m_recipeIcon.transform.GetSiblingIndex()); bgImage.sprite = EpicLoot.GetMagicItemBgSprite(); } var item = __instance.InCraftTab() ? __instance.m_selectedRecipe.Key?.m_item?.m_itemData : __instance.m_selectedRecipe.Value; if (item != null && item.UseMagicBackground()) { bgImage.enabled = item.UseMagicBackground(); bgImage.color = item.GetRarityColor(); __instance.m_recipeName.text = Localization.instance.Localize(item.GetDecoratedName()); } else { bgImage.enabled = false; } } if (__instance.InUpradeTab() && __instance.m_selectedRecipe.Value != null) { var newQuality = Mathf.Min(__instance.m_selectedRecipe.Value.m_quality + 1, __instance.m_selectedRecipe.Value.m_shared.m_maxQuality); var tooltip = ItemDrop.ItemData.GetTooltip(__instance.m_selectedRecipe.Value, newQuality, true); __instance.m_recipeDecription.text = Localization.instance.Localize(tooltip); } }
public override void TryInitialize(InventoryGui inventoryGui, int tabIndex, Action <TabController> onTabPressed) { base.TryInitialize(inventoryGui, tabIndex, onTabPressed); if (ChoiceDialog == null) { ChoiceDialog = CreateDialog <AugmentChoiceDialog>(inventoryGui, "AugmentChoiceDialog"); var background = ChoiceDialog.gameObject.transform.Find("Frame").gameObject.RectTransform(); ChoiceDialog.MagicBG = Object.Instantiate(inventoryGui.m_recipeIcon, background); ChoiceDialog.MagicBG.name = "MagicItemBG"; ChoiceDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite(); ChoiceDialog.MagicBG.color = Color.white; ChoiceDialog.NameText = Object.Instantiate(inventoryGui.m_recipeName, background); ChoiceDialog.Description = Object.Instantiate(inventoryGui.m_recipeDecription, background); ChoiceDialog.Description.rectTransform.anchoredPosition += new Vector2(0, -47); ChoiceDialog.Description.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 340); ChoiceDialog.Icon = Object.Instantiate(inventoryGui.m_recipeIcon, background); var closeButton = ChoiceDialog.gameObject.GetComponentInChildren <Button>(); Object.Destroy(closeButton.gameObject); for (int i = 0; i < 3; i++) { var button = Object.Instantiate(inventoryGui.m_craftButton, background); var rt = button.gameObject.RectTransform(); rt.anchoredPosition = new Vector2(0, -155 - (i * 45)); rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 40); ChoiceDialog.EffectChoiceButtons.Add(button); } } if (AvailableAugmentsDialog == null) { AvailableAugmentsDialog = CreateDialog <AugmentsAvailableDialog>(inventoryGui, "AvailableAugmentsDialog"); var background = AvailableAugmentsDialog.gameObject.transform.Find("Frame").gameObject.RectTransform(); AvailableAugmentsDialog.MagicBG = Object.Instantiate(inventoryGui.m_recipeIcon, background); AvailableAugmentsDialog.MagicBG.name = "MagicItemBG"; AvailableAugmentsDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite(); AvailableAugmentsDialog.MagicBG.color = Color.white; AvailableAugmentsDialog.NameText = Object.Instantiate(inventoryGui.m_recipeName, background); AvailableAugmentsDialog.Description = Object.Instantiate(inventoryGui.m_recipeDecription, background); AvailableAugmentsDialog.Description.rectTransform.anchoredPosition += new Vector2(0, -110); AvailableAugmentsDialog.Description.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 460); AvailableAugmentsDialog.Description.resizeTextForBestFit = true; AvailableAugmentsDialog.Icon = Object.Instantiate(inventoryGui.m_recipeIcon, background); var closeButton = AvailableAugmentsDialog.gameObject.GetComponentInChildren <Button>(); closeButton.onClick = new Button.ButtonClickedEvent(); closeButton.onClick.AddListener(AvailableAugmentsDialog.OnClose); closeButton.transform.SetAsLastSibling(); } if (AvailableAugmentsButton == null) { AvailableAugmentsButton = Object.Instantiate(inventoryGui.m_variantButton, inventoryGui.m_variantButton.transform.parent, true); AvailableAugmentsButton.gameObject.name = "AvailableAugmentsButton"; AvailableAugmentsButton.gameObject.SetActive(false); AvailableAugmentsButton.onClick = new Button.ButtonClickedEvent(); AvailableAugmentsButton.onClick.AddListener(ShowAvailableAugmentsDialog); var text = AvailableAugmentsButton.GetComponentInChildren <Text>(); text.text = "Available Effects"; var rt = AvailableAugmentsButton.gameObject.RectTransform(); rt.anchoredPosition += new Vector2(50, 0); rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 150); } }
public override void TryInitialize(InventoryGui inventoryGui, int tabIndex, Action <TabController> onTabPressed) { base.TryInitialize(inventoryGui, tabIndex, onTabPressed); if (RarityButtons.Count == 0) { var index = 0; var startPos = new Vector2(60, -95); foreach (ItemRarity rarity in Enum.GetValues(typeof(ItemRarity))) { var rarityColor = EpicLoot.GetRarityColorARGB(rarity); var rarityButton = Object.Instantiate(inventoryGui.m_variantButton, inventoryGui.m_variantButton.transform.parent, true); rarityButton.gameObject.name = $"{rarity}EnchantButton"; rarityButton.gameObject.SetActive(false); rarityButton.onClick = new Button.ButtonClickedEvent(); rarityButton.onClick.AddListener(() => OnSelectedRarity(rarity)); rarityButton.colors = new ColorBlock() { disabledColor = Color.white, highlightedColor = Color.white, pressedColor = Color.white, normalColor = new Color(0.7f, 0.7f, 0.7f, 1) }; rarityButton.spriteState = new SpriteState() { disabledSprite = rarityButton.spriteState.selectedSprite, selectedSprite = rarityButton.spriteState.selectedSprite, pressedSprite = rarityButton.spriteState.pressedSprite, highlightedSprite = rarityButton.spriteState.highlightedSprite }; var outlineGO = new GameObject("EnchantOutline", typeof(RectTransform), typeof(Image)); var outline = outlineGO.GetComponent <Image>(); outlineGO.transform.SetParent(rarityButton.transform, false); outline.type = Image.Type.Sliced; outline.sprite = EpicLoot.Assets.SmallButtonEnchantOverlay; outline.rectTransform.anchorMin = new Vector2(0, 0); outline.rectTransform.anchorMax = new Vector2(1, 1); outline.rectTransform.anchoredPosition = new Vector2(0, 0); outline.rectTransform.sizeDelta = new Vector2(0, 0); outline.color = rarityColor; outline.enabled = true; var buttonTextColor = rarityButton.GetComponent <ButtonTextColor>(); buttonTextColor.m_defaultColor = rarityColor; buttonTextColor.m_defaultColor.a = 0.7f; buttonTextColor.m_disabledColor = rarityColor; var text = rarityButton.GetComponentInChildren <Text>(); text.text = rarity.ToString(); text.color = rarityColor; RarityButtons.Add(rarityButton); var rt = rarityButton.gameObject.RectTransform(); rt.anchoredPosition = startPos + (index * new Vector2(rt.rect.width + 4, 0)); index++; } } if (SuccessDialog == null) { var newDialog = Object.Instantiate(inventoryGui.m_variantDialog, inventoryGui.m_variantDialog.transform.parent); SuccessDialog = newDialog.gameObject.AddComponent <CraftSuccessDialog>(); Object.Destroy(newDialog); SuccessDialog.gameObject.name = "CraftingSuccessDialog"; var background = SuccessDialog.gameObject.transform.Find("VariantFrame").gameObject.RectTransform(); background.gameObject.name = "Frame"; for (int i = 1; i < background.transform.childCount; ++i) { var child = background.transform.GetChild(i); Object.Destroy(child.gameObject); } background.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 380); background.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 550); background.anchoredPosition += new Vector2(20, -270); SuccessDialog.MagicBG = Object.Instantiate(inventoryGui.m_recipeIcon, background); SuccessDialog.MagicBG.name = "MagicItemBG"; SuccessDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite(); SuccessDialog.MagicBG.color = Color.white; SuccessDialog.NameText = Object.Instantiate(inventoryGui.m_recipeName, background); SuccessDialog.Description = Object.Instantiate(inventoryGui.m_recipeDecription, background); SuccessDialog.Description.rectTransform.anchoredPosition += new Vector2(0, -110); SuccessDialog.Description.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 460); SuccessDialog.Icon = Object.Instantiate(inventoryGui.m_recipeIcon, background); var closeButton = SuccessDialog.gameObject.GetComponentInChildren <Button>(); closeButton.onClick = new Button.ButtonClickedEvent(); closeButton.onClick.AddListener(SuccessDialog.OnClose); closeButton.transform.SetAsLastSibling(); } }
public static bool SetupRequirement( InventoryGui __instance, Transform elementRoot, ItemDrop item, int amount, Player player, bool showOutOfMaterials, out bool haveMaterials) { haveMaterials = false; var icon = elementRoot.transform.Find("res_icon").GetComponent <Image>(); var nameText = elementRoot.transform.Find("res_name").GetComponent <Text>(); var amountText = elementRoot.transform.Find("res_amount").GetComponent <Text>(); var tooltip = elementRoot.GetComponent <UITooltip>(); if (item != null) { icon.gameObject.SetActive(true); nameText.gameObject.SetActive(true); amountText.gameObject.SetActive(true); if (item.m_itemData.IsMagicCraftingMaterial()) { var rarity = item.m_itemData.GetCraftingMaterialRarity(); icon.sprite = item.m_itemData.m_shared.m_icons[EpicLoot.GetRarityIconIndex(rarity)]; } else { icon.sprite = item.m_itemData.GetIcon(); } icon.color = Color.white; var bgIconTransform = (RectTransform)icon.transform.parent.Find("bgIcon"); if (item.m_itemData.UseMagicBackground()) { if (bgIconTransform == null) { bgIconTransform = (RectTransform)Object.Instantiate(icon, icon.transform.parent, true).transform; bgIconTransform.name = "bgIcon"; bgIconTransform.SetSiblingIndex(icon.transform.GetSiblingIndex()); bgIconTransform.anchorMin = Vector2.zero; bgIconTransform.anchorMax = new Vector2(1, 1); bgIconTransform.sizeDelta = Vector2.zero; bgIconTransform.pivot = new Vector2(0.5f, 0.5f); bgIconTransform.anchoredPosition = Vector2.zero; } bgIconTransform.gameObject.SetActive(true); var bgIcon = bgIconTransform.GetComponent <Image>(); bgIcon.sprite = EpicLoot.GetMagicItemBgSprite(); bgIcon.color = item.m_itemData.GetRarityColor(); } else if (bgIconTransform != null) { bgIconTransform.gameObject.SetActive(false); } tooltip.m_text = Localization.instance.Localize(item.m_itemData.m_shared.m_name); nameText.text = Localization.instance.Localize(item.m_itemData.m_shared.m_name); if (amount <= 0) { InventoryGui.HideRequirement(elementRoot); return(false); } amountText.text = amount.ToString(); haveMaterials = player.HaveRequirements(new [] { new Piece.Requirement() { m_resItem = item, m_amount = amount } }, false, 1); if (showOutOfMaterials && !haveMaterials) { amountText.color = Mathf.Sin(Time.time * 10.0f) > 0.0f ? Color.red : Color.white; } else { amountText.color = Color.white; } } else { var bgIconTransform = icon.transform.parent.Find("bgIcon"); if (bgIconTransform != null) { bgIconTransform.gameObject.SetActive(false); } } return(true); }
public override void TryInitialize(InventoryGui inventoryGui, int tabIndex, Action <TabController> onTabPressed) { base.TryInitialize(inventoryGui, tabIndex, onTabPressed); if (ChoiceDialog == null) { if (EpicLoot.HasAuga) { var resultDialog = Auga.API.Workbench_CreateNewResultsPanel(); resultDialog.SetActive(false); ChoiceDialog = resultDialog.AddComponent <AugmentChoiceDialog>(); var icon = ChoiceDialog.transform.Find("InventoryElement/icon").GetComponent <Image>(); ChoiceDialog.MagicBG = Object.Instantiate(icon, icon.transform.parent); ChoiceDialog.MagicBG.name = "MagicItemBG"; ChoiceDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite(); ChoiceDialog.MagicBG.color = Color.white; ChoiceDialog.MagicBG.rectTransform.anchorMin = new Vector2(0, 0); ChoiceDialog.MagicBG.rectTransform.anchorMax = new Vector2(1, 1); ChoiceDialog.MagicBG.rectTransform.sizeDelta = new Vector2(0, 0); ChoiceDialog.MagicBG.rectTransform.anchoredPosition = new Vector2(0, 0); ChoiceDialog.NameText = ChoiceDialog.transform.Find("Topic").GetComponent <Text>(); var closeButton = ChoiceDialog.gameObject.GetComponentInChildren <Button>(); Object.Destroy(closeButton.gameObject); var tooltip = (RectTransform)ChoiceDialog.transform.Find("TooltipScrollContainer"); tooltip.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 360); var scrollbar = (RectTransform)ChoiceDialog.transform.Find("ScrollBar"); scrollbar.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 360); for (var i = 0; i < 3; i++) { var button = Auga.API.MediumButton_Create(resultDialog.transform, $"AugmentButton{i}", string.Empty); Auga.API.Button_SetTextColors(button, Color.white, Color.white, Color.white, Color.white, Color.white, Color.white); button.navigation = new Navigation { mode = Navigation.Mode.None }; var rt = (RectTransform)button.transform; rt.anchoredPosition = new Vector2(0, -220 - (i * 40)); rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 295); ChoiceDialog.EffectChoiceButtons.Add(button); } } else { ChoiceDialog = CreateDialog <AugmentChoiceDialog>(inventoryGui, "AugmentChoiceDialog"); var background = ChoiceDialog.gameObject.transform.Find("Frame").gameObject.RectTransform(); ChoiceDialog.MagicBG = Object.Instantiate(inventoryGui.m_recipeIcon, background); ChoiceDialog.MagicBG.name = "MagicItemBG"; ChoiceDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite(); ChoiceDialog.MagicBG.color = Color.white; ChoiceDialog.NameText = Object.Instantiate(inventoryGui.m_recipeName, background); ChoiceDialog.Description = Object.Instantiate(inventoryGui.m_recipeDecription, background); ChoiceDialog.Description.rectTransform.anchoredPosition += new Vector2(0, -47); ChoiceDialog.Description.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 340); ChoiceDialog.Icon = Object.Instantiate(inventoryGui.m_recipeIcon, background); var closeButton = ChoiceDialog.gameObject.GetComponentInChildren <Button>(); Object.Destroy(closeButton.gameObject); for (var i = 0; i < 3; i++) { var button = Object.Instantiate(inventoryGui.m_craftButton, background); var rt = button.gameObject.RectTransform(); rt.anchoredPosition = new Vector2(0, -155 - (i * 45)); rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 40); ChoiceDialog.EffectChoiceButtons.Add(button); } } } if (!EpicLoot.HasAuga) { if (AvailableAugmentsDialog == null) { AvailableAugmentsDialog = CreateDialog <AugmentsAvailableDialog>(inventoryGui, "AvailableAugmentsDialog"); var background = AvailableAugmentsDialog.gameObject.transform.Find("Frame").gameObject.RectTransform(); AvailableAugmentsDialog.MagicBG = Object.Instantiate(inventoryGui.m_recipeIcon, background); AvailableAugmentsDialog.MagicBG.name = "MagicItemBG"; AvailableAugmentsDialog.MagicBG.sprite = EpicLoot.GetMagicItemBgSprite(); AvailableAugmentsDialog.MagicBG.color = Color.white; AvailableAugmentsDialog.NameText = Object.Instantiate(inventoryGui.m_recipeName, background); AvailableAugmentsDialog.Description = Object.Instantiate(inventoryGui.m_recipeDecription, background); AvailableAugmentsDialog.Description.rectTransform.anchoredPosition += new Vector2(0, -110); AvailableAugmentsDialog.Description.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 460); AvailableAugmentsDialog.Description.resizeTextForBestFit = true; AvailableAugmentsDialog.Icon = Object.Instantiate(inventoryGui.m_recipeIcon, background); var closeButton = AvailableAugmentsDialog.gameObject.GetComponentInChildren <Button>(); closeButton.onClick = new Button.ButtonClickedEvent(); closeButton.onClick.AddListener(AvailableAugmentsDialog.OnClose); closeButton.transform.SetAsLastSibling(); } if (AvailableAugmentsButton == null) { AvailableAugmentsButton = Object.Instantiate(inventoryGui.m_variantButton, inventoryGui.m_variantButton.transform.parent, true); AvailableAugmentsButton.gameObject.name = "AvailableAugmentsButton"; AvailableAugmentsButton.gameObject.SetActive(false); AvailableAugmentsButton.onClick = new Button.ButtonClickedEvent(); AvailableAugmentsButton.onClick.AddListener(ShowAvailableAugmentsDialog); var text = AvailableAugmentsButton.GetComponentInChildren <Text>(); text.text = Localization.instance.Localize("$mod_epicloot_augment_availableeffects"); var rt = AvailableAugmentsButton.gameObject.RectTransform(); rt.anchoredPosition += new Vector2(50, 0); rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 150); } } }