示例#1
0
        /// <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;
        }
示例#2
0
        /// <summary>
        /// Creates a small button for the current GUI.
        /// </summary>
        /// <param name="text">The text on 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. (Default: Normal)</param>
        /// <param name="orientation">The orientation of the text. (Default: center)</param>
        /// <param name="key">The internal name of the button.</param>
        public static GuiComposer AddSmallButton(this GuiComposer composer, string text, ActionConsumable onClick, ElementBounds bounds, EnumButtonStyle style = EnumButtonStyle.Normal, EnumTextOrientation orientation = EnumTextOrientation.Center, string key = null)
        {
            if (!composer.composed)
            {
                CairoFont font1 = CairoFont.ButtonText();
                CairoFont font2 = CairoFont.ButtonPressedText();
                font1.Fontname         = GuiStyle.StandardFontName;
                font2.Fontname         = GuiStyle.StandardFontName;
                font1.FontWeight       = FontWeight.Bold;
                font2.FontWeight       = FontWeight.Bold;
                font1.UnscaledFontsize = GuiStyle.SmallFontSize;
                font2.UnscaledFontsize = GuiStyle.SmallFontSize;

                GuiElementTextButton elem = new GuiElementTextButton(composer.Api, text, font1, font2, onClick, bounds, style);
                elem.SetOrientation(orientation);
                composer.AddInteractiveElement(elem, key);
            }
            return(composer);
        }
示例#3
0
 /// <summary>
 /// Creates a button for the current GUI.
 /// </summary>
 /// <param name="text">The text on 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="buttonFont">The font of the button.</param>
 /// <param name="style">The style of the button. (Default: Normal)</param>
 /// <param name="orientation">The orientation of the text. (Default: center)</param>
 /// <param name="key">The internal name of the button.</param>
 public static GuiComposer AddButton(this GuiComposer composer, string text, ActionConsumable onClick, ElementBounds bounds, CairoFont buttonFont, EnumButtonStyle style = EnumButtonStyle.Normal, EnumTextOrientation orientation = EnumTextOrientation.Center, string key = null)
 {
     if (!composer.composed)
     {
         CairoFont            hoverFont = buttonFont.Clone().WithColor(GuiStyle.ActiveButtonTextColor);
         GuiElementTextButton elem      = new GuiElementTextButton(composer.Api, text, buttonFont, hoverFont, onClick, bounds, style);
         elem.SetOrientation(orientation);
         composer.AddInteractiveElement(elem, key);
     }
     return(composer);
 }
示例#4
0
 /// <summary>
 /// Creates a button for the current GUI.
 /// </summary>
 /// <param name="text">The text on 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. (Default: Normal)</param>
 /// <param name="orientation">The orientation of the text. (Default: center)</param>
 /// <param name="key">The internal name of the button.</param>
 public static GuiComposer AddButton(this GuiComposer composer, string text, ActionConsumable onClick, ElementBounds bounds, EnumButtonStyle style = EnumButtonStyle.Normal, EnumTextOrientation orientation = EnumTextOrientation.Center, string key = null)
 {
     if (!composer.composed)
     {
         GuiElementTextButton elem = new GuiElementTextButton(composer.Api, text, CairoFont.ButtonText(), CairoFont.ButtonPressedText(), onClick, bounds, style);
         elem.SetOrientation(orientation);
         composer.AddInteractiveElement(elem, key);
     }
     return(composer);
 }
示例#5
0
 public GuiElementTextButtonExt(ICoreClientAPI capi, string text, BlockPos teleportPos, CairoFont font, CairoFont hoverFont, ActionConsumable onClick, ElementBounds bounds, EnumButtonStyle style = EnumButtonStyle.Normal) : base(capi, text, font, hoverFont, onClick, bounds, style)
 {
     this.TeleportPos = teleportPos;
 }