public UIBestiaryNPCEntryPortrait( BestiaryEntry entry, Asset <Texture2D> portraitBackgroundAsset, Color portraitColor, List <IBestiaryBackgroundOverlayAndColorProvider> overlays) { this.Entry = entry; this.Height.Set(112f, 0.0f); this.Width.Set(193f, 0.0f); this.SetPadding(0.0f); UIElement element = new UIElement() { Width = new StyleDimension(-4f, 1f), Height = new StyleDimension(-4f, 1f), IgnoresMouseInteraction = true, OverflowHidden = true, HAlign = 0.5f, VAlign = 0.5f }; element.SetPadding(0.0f); if (portraitBackgroundAsset != null) { UIElement uiElement = element; UIImage uiImage = new UIImage(portraitBackgroundAsset); uiImage.HAlign = 0.5f; uiImage.VAlign = 0.5f; uiImage.ScaleToFit = true; uiImage.Width = new StyleDimension(0.0f, 1f); uiImage.Height = new StyleDimension(0.0f, 1f); uiImage.Color = portraitColor; uiElement.Append((UIElement)uiImage); } for (int index = 0; index < overlays.Count; ++index) { Asset <Texture2D> backgroundOverlayImage = overlays[index].GetBackgroundOverlayImage(); Color? backgroundOverlayColor = overlays[index].GetBackgroundOverlayColor(); UIElement uiElement = element; UIImage uiImage = new UIImage(backgroundOverlayImage); uiImage.HAlign = 0.5f; uiImage.VAlign = 0.5f; uiImage.ScaleToFit = true; uiImage.Width = new StyleDimension(0.0f, 1f); uiImage.Height = new StyleDimension(0.0f, 1f); uiImage.Color = backgroundOverlayColor.HasValue ? backgroundOverlayColor.Value : Color.Lerp(Color.White, portraitColor, 0.5f); uiElement.Append((UIElement)uiImage); } UIBestiaryEntryIcon bestiaryEntryIcon = new UIBestiaryEntryIcon(entry, true); element.Append((UIElement)bestiaryEntryIcon); this.Append(element); UIImage uiImage1 = new UIImage((Asset <Texture2D>)Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Portrait_Front", (AssetRequestMode)1)); uiImage1.VAlign = 0.5f; uiImage1.HAlign = 0.5f; uiImage1.IgnoresMouseInteraction = true; this.Append((UIElement)uiImage1); }
public UIBestiaryNPCEntryPortrait(BestiaryEntry entry, Asset <Texture2D> portraitBackgroundAsset, Color portraitColor, List <IBestiaryBackgroundOverlayAndColorProvider> overlays) { Entry = entry; Height.Set(112f, 0f); Width.Set(193f, 0f); SetPadding(0f); UIElement uIElement = new UIElement { Width = new StyleDimension(-4f, 1f), Height = new StyleDimension(-4f, 1f), IgnoresMouseInteraction = true, OverflowHidden = true, HAlign = 0.5f, VAlign = 0.5f }; uIElement.SetPadding(0f); if (portraitBackgroundAsset != null) { uIElement.Append(new UIImage(portraitBackgroundAsset) { HAlign = 0.5f, VAlign = 0.5f, ScaleToFit = true, Width = new StyleDimension(0f, 1f), Height = new StyleDimension(0f, 1f), Color = portraitColor }); } for (int i = 0; i < overlays.Count; i++) { Asset <Texture2D> backgroundOverlayImage = overlays[i].GetBackgroundOverlayImage(); Color? backgroundOverlayColor = overlays[i].GetBackgroundOverlayColor(); uIElement.Append(new UIImage(backgroundOverlayImage) { HAlign = 0.5f, VAlign = 0.5f, ScaleToFit = true, Width = new StyleDimension(0f, 1f), Height = new StyleDimension(0f, 1f), Color = (backgroundOverlayColor.HasValue ? backgroundOverlayColor.Value : Color.Lerp(Color.White, portraitColor, 0.5f)) }); } UIBestiaryEntryIcon element = new UIBestiaryEntryIcon(entry, isPortrait: true); uIElement.Append(element); Append(uIElement); Append(new UIImage(Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Portrait_Front", Main.content, (AssetRequestMode)1)) { VAlign = 0.5f, HAlign = 0.5f, IgnoresMouseInteraction = true }); }
public UIBestiaryEntryButton(BestiaryEntry entry, bool isAPrettyPortrait) { this.Entry = entry; this.Height.Set(72f, 0.0f); this.Width.Set(72f, 0.0f); this.SetPadding(0.0f); UIElement element = new UIElement() { Width = new StyleDimension(-4f, 1f), Height = new StyleDimension(-4f, 1f), IgnoresMouseInteraction = true, OverflowHidden = true, HAlign = 0.5f, VAlign = 0.5f }; element.SetPadding(0.0f); UIImage uiImage1 = new UIImage((Asset <Texture2D>)Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Slot_Back", (AssetRequestMode)1)); uiImage1.VAlign = 0.5f; uiImage1.HAlign = 0.5f; element.Append((UIElement)uiImage1); if (isAPrettyPortrait) { Asset <Texture2D> texture = this.TryGettingBackgroundImageProvider(entry); if (texture != null) { UIElement uiElement = element; UIImage uiImage2 = new UIImage(texture); uiImage2.HAlign = 0.5f; uiImage2.VAlign = 0.5f; uiElement.Append((UIElement)uiImage2); } } UIBestiaryEntryIcon bestiaryEntryIcon = new UIBestiaryEntryIcon(entry, isAPrettyPortrait); element.Append((UIElement)bestiaryEntryIcon); this.Append(element); this._icon = bestiaryEntryIcon; int?nullable = this.TryGettingDisplayIndex(entry); if (nullable.HasValue) { UIText uiText = new UIText(nullable.Value.ToString(), 0.9f, false); uiText.Top = new StyleDimension(10f, 0.0f); uiText.Left = new StyleDimension(10f, 0.0f); uiText.IgnoresMouseInteraction = true; this.Append((UIElement)uiText); } UIImage uiImage3 = new UIImage((Asset <Texture2D>)Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Slot_Selection", (AssetRequestMode)1)); uiImage3.VAlign = 0.5f; uiImage3.HAlign = 0.5f; uiImage3.IgnoresMouseInteraction = true; this._bordersGlow = uiImage3; UIImage uiImage4 = new UIImage((Asset <Texture2D>)Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Slot_Overlay", (AssetRequestMode)1)); uiImage4.VAlign = 0.5f; uiImage4.HAlign = 0.5f; uiImage4.IgnoresMouseInteraction = true; uiImage4.Color = Color.White * 0.6f; this._bordersOverlay = uiImage4; this.Append((UIElement)this._bordersOverlay); UIImage uiImage5 = new UIImage((Asset <Texture2D>)Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Slot_Front", (AssetRequestMode)1)); uiImage5.VAlign = 0.5f; uiImage5.HAlign = 0.5f; uiImage5.IgnoresMouseInteraction = true; this.Append((UIElement)uiImage5); this._borders = uiImage5; if (isAPrettyPortrait) { this.RemoveChild((UIElement)this._bordersOverlay); } if (isAPrettyPortrait) { return; } this.OnMouseOver += new UIElement.MouseEvent(this.MouseOver); this.OnMouseOut += new UIElement.MouseEvent(this.MouseOut); }
public UIBestiaryEntryButton(BestiaryEntry entry, bool isAPrettyPortrait) { Entry = entry; Height.Set(72f, 0f); Width.Set(72f, 0f); SetPadding(0f); UIElement uIElement = new UIElement { Width = new StyleDimension(-4f, 1f), Height = new StyleDimension(-4f, 1f), IgnoresMouseInteraction = true, OverflowHidden = true, HAlign = 0.5f, VAlign = 0.5f }; uIElement.SetPadding(0f); uIElement.Append(new UIImage(Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Slot_Back", Main.content, (AssetRequestMode)1)) { VAlign = 0.5f, HAlign = 0.5f }); if (isAPrettyPortrait) { Asset <Texture2D> val = TryGettingBackgroundImageProvider(entry); if (val != null) { uIElement.Append(new UIImage(val) { HAlign = 0.5f, VAlign = 0.5f }); } } UIBestiaryEntryIcon uIBestiaryEntryIcon = new UIBestiaryEntryIcon(entry, isAPrettyPortrait); uIElement.Append(uIBestiaryEntryIcon); Append(uIElement); _icon = uIBestiaryEntryIcon; int?num = TryGettingDisplayIndex(entry); if (num.HasValue) { UIText element = new UIText(num.Value.ToString(), 0.9f) { Top = new StyleDimension(10f, 0f), Left = new StyleDimension(10f, 0f), IgnoresMouseInteraction = true }; Append(element); } _bordersGlow = new UIImage(Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Slot_Selection", Main.content, (AssetRequestMode)1)) { VAlign = 0.5f, HAlign = 0.5f, IgnoresMouseInteraction = true }; _bordersOverlay = new UIImage(Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Slot_Overlay", Main.content, (AssetRequestMode)1)) { VAlign = 0.5f, HAlign = 0.5f, IgnoresMouseInteraction = true, Color = Color.White * 0.6f }; Append(_bordersOverlay); UIImage uIImage = new UIImage(Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Slot_Front", Main.content, (AssetRequestMode)1)) { VAlign = 0.5f, HAlign = 0.5f, IgnoresMouseInteraction = true }; Append(uIImage); _borders = uIImage; if (isAPrettyPortrait) { RemoveChild(_bordersOverlay); } if (!isAPrettyPortrait) { base.OnMouseOver += MouseOver; base.OnMouseOut += MouseOut; } }