/// <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; }
/// <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; }
/// <summary> /// Creates a button with text. /// </summary> /// <param name="capi">The Client API</param> /// <param name="text">The text of the button.</param> /// <param name="font">The font of the text.</param> /// <param name="hoverFont">The font of the text when the player is hovering over the button.</param> /// <param name="onClick">The event fired when the button is clicked.</param> /// <param name="bounds">The bounds of the button.</param> /// <param name="style">The style of the button.</param> public GuiElementTextButton(ICoreClientAPI capi, string text, CairoFont font, CairoFont hoverFont, ActionConsumable onClick, ElementBounds bounds, EnumButtonStyle style = EnumButtonStyle.Normal) : base(capi, bounds) { hoverTexture = new LoadedTexture(capi); disabledTexture = new LoadedTexture(capi); this.buttonStyle = style; normalText = new GuiElementStaticText(capi, text, EnumTextOrientation.Center, bounds, font); normalText.AutoBoxSize(true); pressedText = new GuiElementStaticText(capi, text, EnumTextOrientation.Center, bounds.CopyOnlySize(), hoverFont); bounds = normalText.Bounds; this.onClick = onClick; }