/// <summary> /// Creates an ItemStackInfo element. /// </summary> /// <param name="capi">The client API</param> /// <param name="bounds">The bounds of the object.</param> /// <param name="OnRequireInfoText">The function that is called when an item information is called.</param> public GuiElementItemstackInfo(ICoreClientAPI capi, ElementBounds bounds, InfoTextDelegate OnRequireInfoText) : base(capi, "", CairoFont.WhiteSmallText(), bounds) { this.OnRequireInfoText = OnRequireInfoText; texture = new LoadedTexture(capi); ElementBounds textBounds = bounds.CopyOnlySize(); ElementBounds descBounds = textBounds.CopyOffsetedSibling(ItemStackSize + 50, MarginTop, -ItemStackSize - 50, 0); descBounds.WithParent(bounds); textBounds.WithParent(bounds); descriptionElement = new GuiElementRichtext(capi, new RichTextComponentBase[0], descBounds); //new GuiElementStaticText(capi, "", EnumTextOrientation.Left, textBounds.CopyOffsetedSibling(ItemStackSize + 50, MarginTop, -ItemStackSize - 50, 0), Font); descriptionElement.zPos = 1001; titleFont = Font.Clone(); titleFont.FontWeight = FontWeight.Bold; titleElement = new GuiElementRichtext(capi, new RichTextComponentBase[0], textBounds); titleElement.zPos = 1001; maxWidth = bounds.fixedWidth; }
public ItemstackComponentBase(ICoreClientAPI capi) : base(capi) { this.capi = capi; dummyInv = new DummyInventory(capi); dummyInv.OnAcquireTransitionSpeed = (transType, stack, mul) => { return(0); }; renderedTooltipSlot = new DummySlot(null, dummyInv); stackInfoBounds = ElementBounds .FixedSize(EnumDialogArea.None, GuiElementItemstackInfo.BoxWidth, 0) .WithFixedPadding(10) .WithFixedPosition(20, 40) ; parentBounds = ElementBounds.Fixed(0, 0, 1, 1); parentBounds.WithParent(ElementBounds.Empty); stackInfoBounds.WithParent(parentBounds); stackInfo = new GuiElementItemstackInfo(capi, stackInfoBounds, OnRequireInfoText); stackInfo.SetSourceSlot(renderedTooltipSlot); stackInfo.ComposeElements(null, null); stackInfo.RecompCheckIgnoredStackAttributes = GlobalConstants.IgnoredStackAttributes; }
/// <summary> /// Creates a new instance of hover text. /// </summary> /// <param name="capi">The client API.</param> /// <param name="text">The text of the text.</param> /// <remarks>For the text and the text.</remarks> /// <param name="font">The font of the text.</param> /// <param name="maxWidth">The width of the text.</param> /// <param name="bounds">the bounds of the text.</param> public GuiElementHoverText(ICoreClientAPI capi, string text, CairoFont font, int maxWidth, ElementBounds bounds, TextBackground background = null) : base(capi, text, font, bounds) { this.Background = background; if (background == null) { this.Background = GuiElementHoverText.DefaultBackground; } this.unscaledMaxWidth = maxWidth; hoverTexture = new LoadedTexture(capi); padding = Background.Padding; ElementBounds descBounds = bounds.CopyOnlySize(); descBounds.WithFixedPadding(0); descBounds.WithParent(bounds); descBounds.IsDrawingSurface = true; descBounds.fixedWidth = maxWidth; descriptionElement = new GuiElementRichtext(capi, new RichTextComponentBase[0], descBounds); descriptionElement.zPos = 1001; }