private void ColorSelected(int index) { BEPlayer mp = Main.LocalPlayer.GetModPlayer <BEPlayer>(); if (!colorAvailable[index] && !mp.infinitePaintBucketEquipped) { return; } for (int i = 0; i < colorElements.Length; i++) { colorElements[i].SetVisibility(1f, 0.85f); } colorOverlay.Hide(); if (colorIndex != index) { colorElements[index].SetVisibility(1f, 1f); colorOverlay.Left = colorElements[index].Left; colorOverlay.Top = colorElements[index].Top; colorOverlay.Show(); colorIndex = index; } else { colorIndex = -1; } }
public ShrineUIPanel(float scale = 1f, float opacity = 1f) : base(scale, opacity) { Instance = this; Width.Set(width, 0); Height.Set(height, 0); Left.Set(Main.screenWidth / 2 - width, 0); Top.Set(Main.screenHeight / 2 - height, 0); SetPadding(0); BorderColor = Microsoft.Xna.Framework.Color.Transparent; BackgroundColor = Microsoft.Xna.Framework.Color.Transparent; #region UI Initialization //Background CustomUIImage background = new CustomUIImage(GetTexture("LivingWorldMod/Textures/UIElements/ShrineMenu/Background"), 1f); background.Width.Set(0, 0); background.Height.Set(0f, 0); background.Left.Set(-12f, 0); background.Top.Set(-12f, 0); Append(background); //Cross to Close Menu CustomUIImage closeMenuCross = new CustomUIImage(GetTexture("LivingWorldMod/Textures/UIElements/ShrineMenu/CloseCross"), 1f); closeMenuCross.Width.Set(19f, 0); closeMenuCross.Height.Set(19f, 0); closeMenuCross.Left.Set(width - 35f, 0); closeMenuCross.Top.Set(-7f, 0); closeMenuCross.OnClick += (__, _) => Hide(); Append(closeMenuCross); #region Item in itemSlot info //Gift Item Image CustomUIImage giftItem = new CustomUIImage(Main.itemTexture[0], 1f); giftItem.SetScaleToFit(true); giftItem.Left.Set(165f, 0); giftItem.Top.Set(35f, 0); Append(giftItem); giftItem.Hide(); //Undiscovered Gift CustomUIText undiscoveredGift = new CustomUIText("?", 1f); undiscoveredGift.TextColor = Microsoft.Xna.Framework.Color.LightGray; undiscoveredGift.Left.Set(195f, 0); undiscoveredGift.Top.Set(40f, 0); Append(undiscoveredGift); undiscoveredGift.Hide(); //Amount gifted CustomUIText giftAmount = new CustomUIText("", 0.9f); giftAmount.Left.Set(110f, 0); giftAmount.Top.Set(30f, 0); Append(giftAmount); giftAmount.Hide(); //Liking Neutral CustomUIText giftLiking = new CustomUIText("", 0.9f); giftLiking.Left.Set(110f, 0); giftLiking.Top.Set(50f, 0); Append(giftLiking); giftLiking.Hide(); #endregion //ItemSlot itemSlot = new CustomItemSlot(); itemSlot.Width.Set(54f, 0); itemSlot.Height.Set(54f, 0); itemSlot.Left.Set(5f, 0); itemSlot.Top.Set(25f, 0); itemSlot.OnItemEquipped += _ => ShowItemSlotInfo(); itemSlot.OnItemRemoved += _ => HideItemSlotInfo(); itemSlot.SetBackgroundTexture(GetTexture("LivingWorldMod/Textures/UIElements/ShrineMenu/ItemSlot")); Append(itemSlot); //Gift Texture2D giftTexture = GetTexture("LivingWorldMod/Textures/UIElements/ShrineMenu/Gift"); Texture2D giftTexture2 = GetTexture("LivingWorldMod/Textures/UIElements/ShrineMenu/Gift2"); UIImageButton gift = new UIImageButton(giftTexture); gift.Width.Set(26f, 0); gift.Height.Set(26f, 0); gift.Left.Set(66f, 0); gift.Top.Set(38f, 0); gift.SetVisibility(1f, 1f); gift.OnMouseOver += (__, _) => { gift.SetImage(giftTexture2); }; gift.OnMouseOut += (__, _) => { gift.SetImage(giftTexture); }; gift.OnMouseDown += (__, _) => { gift.Top.Set(gift.Top.Pixels + 1f, 0); GiftItem(); HideItemSlotInfo(); }; gift.OnMouseUp += (__, _) => { gift.Top.Set(gift.Top.Pixels - 1f, 0); }; Append(gift); //Gifts Text CustomUIText repText = new CustomUIText("Gifts: ", 0.8f); repText.Left.Set(8f, 0); repText.Top.Set(95f, 0); Append(repText); //Gifts ProgressBar Color Color = new Color(63, 113, 169); ShrineProgressBar repFrame = new ShrineProgressBar(true, 100, Color); repFrame.Width.Set(170f, 0); repFrame.Height.Set(16f, 0); repFrame.Left.Set(48f, 0); repFrame.Top.Set(95f, 0); repFrame.Activate(); Append(repFrame); //Stage Text CustomUIText stageText = new CustomUIText("Stage: ", 0.8f); stageText.Left.Set(5f, 0); stageText.Top.Set(120f, 0); Append(stageText); //Stage ProgressBar ShrineProgressBar stageFrame = new ShrineProgressBar(false, 5, Color); stageFrame.Width.Set(170f, 0); stageFrame.Height.Set(16f, 0); stageFrame.Left.Set(48f, 0); stageFrame.Top.Set(120f, 0); stageFrame.Activate(); Append(stageFrame); #region Methods void GiftItem() { int itemType = itemSlot.Item.type; LWMWorld.AddGiftToProgress(shrineType, itemType); itemSlot.Item.TurnToAir(); } void ShowItemSlotInfo() { giftItem.SetImage(Main.itemTexture[itemSlot.Item.type]); giftItem.SetSize(24f, 24f); Color color; if (LWMWorld.GetGiftAmount(shrineType, itemSlot.Item.type) == 0) { color = new Color(66, 66, 66); giftItem.Show(); undiscoveredGift.Show(); } else { color = Microsoft.Xna.Framework.Color.White; } giftItem.SetOverlayColor(color); //Update Amount Gifted int amount = LWMWorld.GetGiftAmount(shrineType, itemSlot.Item.type); string amountText = "Gifted: " + (amount == 0 ? "" : amount.ToString()); giftAmount.SetText(amountText); //Update Gift Liking int liking = LivingWorldMod.GetGiftValue(shrineType, itemSlot.Item.type); string likingText = "Liking: "; if (amount != 0 && Math.Abs(liking) == 3) { likingText += liking > 0 ? "Good" : "Bad"; } else if (amount != 0 && Math.Abs(liking) == 5) { likingText += liking > 0 ? "Great" : "Awful"; } else if (amount != 0 && liking == 0) { likingText += "Neutral"; } giftLiking.SetText(likingText); giftAmount.Show(); giftLiking.Show(); } void HideItemSlotInfo() { giftItem.Hide(); giftAmount.Hide(); giftLiking.Hide(); undiscoveredGift.Hide(); } #endregion #endregion }
public PaintWheel(float scale = 1f, float opacity = 1f) { paints = new int[30]; for (int i = 0; i < 27; i++) { paints[i] = (1073 + i); //Basic && Deep colors type } for (int i = 0; i < 3; i++) { paints[i + 27] = (1966 + i); //Extra Color Effects type } Width.Set(width, 0); Height.Set(height, 0); Left.Set(Main.screenWidth / 2 - width, 0); Top.Set(Main.screenHeight / 2 - height, 0); BorderColor = Color.Transparent; BackgroundColor = Color.Transparent; string texturePath = "BuilderEssentials/Textures/UIElements/Paint/"; colorElements = new UIImageButton[30]; noPaintOverlay = new CustomUIImage[30]; colorAvailable = new bool[30]; for (int i = 0; i < 30; i++) { colorElements[i] = new UIImageButton(ModContent.GetTexture(texturePath + "Paint" + i)); noPaintOverlay[i] = new CustomUIImage(ModContent.GetTexture(texturePath + "NoPaint"), 1f); } toolTextures = new Texture2D[6]; for (int i = 0; i < toolTextures.Length; i++) { toolTextures[i] = ModContent.GetTexture(texturePath + "Tool" + i); } toolElements = new UIImageButton[3]; for (int i = 0; i < toolElements.Length; i++) { toolElements[i] = new UIImageButton(toolTextures[i]); } colorOverlay = new CustomUIImage(ModContent.GetTexture(texturePath + "PaintSelected"), 1f); toolOverlay = new CustomUIImage(ModContent.GetTexture(texturePath + "ToolSelected"), 1f); int radius = 155; double angle = Math.PI / 12; const float colorElementSize = 40f; for (int i = 0; i < 12; i++) { int index = i; Vector2 offset = new Vector2(width - colorElementSize, height - colorElementSize) / 2; double x = offset.X - (radius * Math.Cos(angle * (i + .48)) * 0.95); double y = offset.Y - (radius * Math.Sin(angle * (i + .48))); var left = new StyleDimension((float)x - colorElementSize / 4, 0); var top = new StyleDimension((float)y + 40, 0); colorElements[i].Left = noPaintOverlay[i].Left = left; colorElements[i].Top = noPaintOverlay[i].Top = top; colorElements[i].SetVisibility(1f, 0.85f); colorElements[i].OnMouseDown += (__, _) => ColorSelected(index); colorElements[i].OnMouseOver += (__, _) => elementHovered = true; colorElements[i].OnMouseOut += (__, _) => elementHovered = false; Append(colorElements[i]); Append(noPaintOverlay[i]); } radius = 190; for (int i = 12; i < 24; i++) { int index = i; Vector2 offset = new Vector2(width - colorElementSize, height - colorElementSize) / 2; double x = offset.X + (radius * Math.Cos(angle * (i + .48)) * 1); double y = offset.Y - (radius * Math.Sin(-angle * (i + .48))); var left = new StyleDimension((float)x - colorElementSize / 4, 0); var top = new StyleDimension((float)y + 30, 0); colorElements[i].Left = noPaintOverlay[i].Left = left; colorElements[i].Top = noPaintOverlay[i].Top = top; colorElements[i].SetVisibility(1f, 0.85f); colorElements[i].OnMouseDown += (__, _) => ColorSelected(index); colorElements[i].OnMouseOver += (__, _) => elementHovered = true; colorElements[i].OnMouseOut += (__, _) => elementHovered = false; Append(colorElements[i]); Append(noPaintOverlay[i]); } radius = 95; angle = Math.PI / 6; for (int i = 24; i < 30; i++) { int index = i; Vector2 offset = new Vector2(width - colorElementSize, height - colorElementSize) / 2; double x = offset.X - (radius * Math.Cos(angle * (i + .50)) * 1.10); double y = offset.Y + (radius * Math.Sin(-angle * (i + .50)) * 1.25); var left = new StyleDimension((float)x - colorElementSize / 4, 0); var top = new StyleDimension((float)y + 50, 0); colorElements[i].Left = noPaintOverlay[i].Left = left; colorElements[i].Top = noPaintOverlay[i].Top = top; colorElements[i].SetVisibility(1f, 0.85f); colorElements[i].OnMouseDown += (__, _) => ColorSelected(index); colorElements[i].OnMouseOver += (__, _) => elementHovered = true; colorElements[i].OnMouseOut += (__, _) => elementHovered = false; Append(colorElements[i]); Append(noPaintOverlay[i]); } for (int i = 0; i < toolElements.Length; i++) { int index = i; double x = (width / 3) * i + 35f; double y = (width / 2) + 15f; toolElements[i].Left.Set((float)x - colorElementSize / 4, 0); toolElements[i].Top.Set((float)y, 0); toolElements[i].SetVisibility(1f, .8f); toolElements[i].OnMouseDown += (__, _) => ToolSelected(index); toolElements[i].OnMouseOver += (__, _) => elementHovered = true; toolElements[i].OnMouseOut += (__, _) => elementHovered = false; Append(toolElements[i]); } Append(colorOverlay); colorOverlay.Hide(); toolOverlay.Left = toolElements[toolIndex].Left; toolOverlay.Top = toolElements[toolIndex].Top; toolElements[toolIndex].SetVisibility(1f, 1f); Append(toolOverlay); }