Пример #1
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;
                if (style != EnumButtonStyle.Small)
                {
                    font1.FontWeight = FontWeight.Bold;
                    font2.FontWeight = FontWeight.Bold;
                }
                else
                {
                    font1.FontWeight = FontWeight.Normal;
                    font2.FontWeight = FontWeight.Normal;
                }
                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);
        }
Пример #2
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);
 }
Пример #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);
 }