Пример #1
0
        /// <summary>
        /// Adds multiple buttons with Text.
        /// </summary>
        /// <param name="texts">The texts on all the buttons.</param>
        /// <param name="font">The font for the buttons</param>
        /// <param name="onToggle">The event fired when the button is pressed.</param>
        /// <param name="bounds">The bounds of the buttons.</param>
        /// <param name="key">The key given to the bundle of buttons.</param>
        public static GuiComposer AddTextToggleButtons(this GuiComposer composer, string[] texts, CairoFont font, API.Common.Action <int> onToggle, ElementBounds[] bounds, string key = null)
        {
            if (!composer.composed)
            {
                int quantityButtons = texts.Length;

                for (int i = 0; i < texts.Length; i++)
                {
                    int index = i;

                    composer.AddInteractiveElement(
                        new GuiElementToggleButton(composer.Api, "", texts[i], font, (on) => {
                        if (on)
                        {
                            onToggle(index);
                            for (int j = 0; j < quantityButtons; j++)
                            {
                                if (j == index)
                                {
                                    continue;
                                }
                                composer.GetToggleButton(key + "-" + j).SetValue(false);
                            }
                        }
                        else
                        {
                            composer.GetToggleButton(key + "-" + index).SetValue(true);
                        }
                    }, bounds[i], true),
                        key + "-" + i
                        );
                }
            }
            return(composer);
        }
Пример #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;
                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);
        }
Пример #3
0
        /// <summary>
        /// Creates a new title bar.
        /// </summary>
        /// <param name="capi">The Client API.</param>
        /// <param name="text">The text on the title bar.</param>
        /// <param name="composer">The GuiComposer for the title bar.</param>
        /// <param name="OnClose">The event fired when the title bar is closed.</param>
        /// <param name="font">The font of the title bar.</param>
        /// <param name="bounds">The bounds of the title bar.</param>
        public GuiElementDialogTitleBar(ICoreClientAPI capi, string text, GuiComposer composer, Action OnClose = null, CairoFont font = null, ElementBounds bounds = null) : base(capi, text, font, bounds)
        {
            closeIconHoverTexture = new LoadedTexture(capi);
            menuIconHoverTexture  = new LoadedTexture(capi);

            if (bounds == null)
            {
                this.Bounds = ElementStdBounds.TitleBar();
            }
            if (font == null)
            {
                this.Font = CairoFont.WhiteSmallText();
            }
            this.OnClose = OnClose;

            ElementBounds dropDownBounds = ElementBounds.Fixed(0, 0, 100, 25);

            this.Bounds.WithChild(dropDownBounds);

            listMenu = new GuiElementListMenu(capi, new string[] { "auto", "manual" }, new string[] { Lang.Get("Fixed"), Lang.Get("Movable") }, 0, onSelectionChanged, dropDownBounds, CairoFont.WhiteSmallText(), false)
            {
                HoveredIndex = 0
            };

            baseComposer = composer;
        }
Пример #4
0
 /// <summary>
 /// Adds a slider to the current GUI.
 /// </summary>
 /// <param name="onNewSliderValue">The event that fires when the slider's value is changed.</param>
 /// <param name="bounds">The bounds of the slider.</param>
 /// <param name="key">the internal name of the slider.</param>
 public static GuiComposer AddSlider(this GuiComposer composer, ActionConsumable <int> onNewSliderValue, ElementBounds bounds, string key = null)
 {
     if (!composer.composed)
     {
         composer.AddInteractiveElement(new GuiElementSlider(composer.Api, onNewSliderValue, bounds), key);
     }
     return(composer);
 }
Пример #5
0
 /// <summary>
 /// Adds a dynamic custom draw component to the GUI.
 /// </summary>
 /// <param name="bounds">The bounds of the component.</param>
 /// <param name="OnDraw">The event fired when the element is drawn.</param>
 /// <param name="key">The name of the element.</param>
 public static GuiComposer AddDynamicCustomDraw(this GuiComposer composer, ElementBounds bounds, DrawDelegateWithBounds OnDraw, string key = null)
 {
     if (!composer.Composed)
     {
         composer.AddInteractiveElement(new GuiElementCustomDraw(composer.Api, bounds, OnDraw, true), key);
     }
     return(composer);
 }
Пример #6
0
 /// <summary>
 /// Adds a static custom draw component to the GUI.
 /// </summary>
 /// <param name="bounds">The bounds of the component.</param>
 /// <param name="OnDraw">The event fired when the element is drawn.</param>
 public static GuiComposer AddStaticCustomDraw(this GuiComposer composer, ElementBounds bounds, DrawDelegateWithBounds OnDraw)
 {
     if (!composer.Composed)
     {
         composer.AddStaticElement(new GuiElementCustomDraw(composer.Api, bounds, OnDraw));
     }
     return(composer);
 }
Пример #7
0
 /// <summary>
 /// Adds a gray background to the current GUI.
 /// </summary>
 /// <param name="bounds">The bounds of the backgrounds.</param>
 public static GuiComposer AddGrayBG(this GuiComposer composer, ElementBounds bounds)
 {
     if (!composer.composed)
     {
         composer.AddStaticElement(new GuiElementGrayBackground(composer.Api, bounds));
     }
     return(composer);
 }
Пример #8
0
 /// <summary>
 /// Adds an embossed text component to the GUI.
 /// </summary>
 /// <param name="text">The text of the component.</param>
 /// <param name="font">The font of the text.</param>
 /// <param name="bounds">The bounds of the component.</param>
 /// <param name="key">The name of the component.</param>
 public static GuiComposer AddEmbossedText(this GuiComposer composer, string text, CairoFont font, ElementBounds bounds, string key = null)
 {
     if (!composer.composed)
     {
         composer.AddInteractiveElement(new GuiElementEmbossedText(composer.Api, text, font, bounds), key);
     }
     return(composer);
 }
Пример #9
0
 /// <summary>
 /// Adds a stat bar with filling in the opposite direction. Default values are from 0 to 100.
 /// </summary>
 /// <param name="bounds">the bounds of the stat bar.</param>
 /// <param name="color">the color of the stat bar.</param>
 /// <param name="key">The internal name of the stat bar.</param>
 public static GuiComposer AddInvStatbar(this GuiComposer composer, ElementBounds bounds, double[] color, string key = null)
 {
     if (!composer.composed)
     {
         composer.AddInteractiveElement(new GuiElementStatbar(composer.Api, bounds, color, true), key);
     }
     return(composer);
 }
Пример #10
0
 /// <summary>
 /// Adds a skill item grid to the GUI.
 /// </summary>
 /// <param name="skillItems">The items that represent skills.</param>
 /// <param name="columns">the columns in the skill item grid.</param>
 /// <param name="rows">The rows in the skill item grid.</param>
 /// <param name="OnSlotClick">The effect when a slot is clicked.</param>
 /// <param name="bounds">The bounds of the item grid.</param>
 /// <param name="key">The name of the item grid to add.</param>
 public static GuiComposer AddSkillItemGrid(this GuiComposer composer, List <SkillItem> skillItems, int columns, int rows, Action <int> OnSlotClick, ElementBounds bounds, string key = null)
 {
     if (!composer.Composed)
     {
         composer.AddInteractiveElement(new GuiElementSkillItemGrid(composer.Api, skillItems, columns, rows, OnSlotClick, bounds), key);
     }
     return(composer);
 }
 /// <summary>
 /// Adds a background to the current GUI
 /// </summary>
 /// <param name="bounds">The bounds of the background</param>
 /// <param name="textureLoc">The name of the background texture.</param>
 /// <param name="brightness">The brightness of the texture (default: 1f)</param>
 public static GuiComposer AddImageBG(this GuiComposer composer, ElementBounds bounds, AssetLocation textureLoc, float brightness = 1f)
 {
     if (!composer.Composed)
     {
         composer.AddStaticElement(new GuiElementImageBackground(composer.Api, bounds, textureLoc, brightness));
     }
     return(composer);
 }
Пример #12
0
 /// <summary>
 /// Adds an inset to the current GUI.
 /// </summary>
 /// <param name="bounds">The bounds of the inset.</param>
 /// <param name="depth">The depth of the inset.</param>
 /// <param name="brightness">The brightness of the inset.</param>
 public static GuiComposer AddInset(this GuiComposer composer, ElementBounds bounds, int depth = 4, float brightness = 0.85f)
 {
     if (!composer.Composed)
     {
         composer.AddStaticElement(new GuiElementInset(composer.Api, bounds, depth, brightness));
     }
     return(composer);
 }
Пример #13
0
 /// <summary>
 /// Adds a static text component to the GUI
 /// </summary>
 /// <param name="text">The text of the text component.</param>
 /// <param name="font">The font of the text.</param>
 /// <param name="orientation">The orientation of the text.</param>
 /// <param name="bounds">The bounds of the text container.</param>
 /// <param name="key">The name of the component.</param>
 public static GuiComposer AddStaticText(this GuiComposer composer, string text, CairoFont font, EnumTextOrientation orientation, ElementBounds bounds, string key = null)
 {
     if (!composer.composed)
     {
         composer.AddStaticElement(new GuiElementStaticText(composer.Api, text, orientation, bounds, font), key);
     }
     return(composer);
 }
Пример #14
0
 /// <summary>
 /// Adds a background to the current GUI
 /// </summary>
 /// <param name="bounds">The bounds of the background</param>
 /// <param name="textureName">The name of the background texture.</param>
 /// <param name="brightness">The brightness of the texture (default: 1f)</param>
 public static GuiComposer AddImageBG(this GuiComposer composer, ElementBounds bounds, string textureName, float brightness = 1f)
 {
     if (!composer.composed)
     {
         composer.AddStaticElement(new GuiElementImageBackground(composer.Api, bounds, textureName, brightness));
     }
     return(composer);
 }
Пример #15
0
 /// <summary>
 /// Creates a toggle button with the given parameters.
 /// </summary>
 /// <param name="text">The text of the button.</param>
 /// <param name="font">The font of the text.</param>
 /// <param name="onToggle">The event that happens once the button is toggled.</param>
 /// <param name="bounds">The bounding box of the button.</param>
 /// <param name="key">The name of the button for easy access.</param>
 public static GuiComposer AddToggleButton(this GuiComposer composer, string text, CairoFont font, API.Common.Action <bool> onToggle, ElementBounds bounds, string key = null)
 {
     if (!composer.composed)
     {
         composer.AddInteractiveElement(new GuiElementToggleButton(composer.Api, "", text, font, onToggle, bounds, true), key);
     }
     return(composer);
 }
Пример #16
0
 /// <summary>
 /// Adds a static custom draw component to the GUI.
 /// </summary>
 /// <param name="bounds">The bounds of the component.</param>
 /// <param name="OnDraw">The event fired when the element is drawn.</param>
 public static GuiComposer AddCustomRender(this GuiComposer composer, ElementBounds bounds, RenderDelegateWithBounds onRender)
 {
     if (!composer.composed)
     {
         composer.AddInteractiveElement(new GuiElementCustomRender(composer.Api, bounds, onRender));
     }
     return(composer);
 }
Пример #17
0
 /// <summary>
 /// Adds an icon button.
 /// </summary>
 /// <param name="icon">The name of the icon.</param>
 /// <param name="onToggle">The event that happens once the button is toggled.</param>
 /// <param name="bounds">The bounding box of the button.</param>
 /// <param name="key">The name of the button for easy access.</param>
 public static GuiComposer AddIconButton(this GuiComposer composer, string icon, API.Common.Action <bool> onToggle, ElementBounds bounds, string key = null)
 {
     if (!composer.composed)
     {
         composer.AddInteractiveElement(new GuiElementToggleButton(composer.Api, icon, "", CairoFont.WhiteDetailText(), onToggle, bounds, false), key);
     }
     return(composer);
 }
 // Single rectangle shape
 /// <summary>
 /// Adds a single rectangle background to the GUI.
 /// </summary>
 /// <param name="bounds">The bounds of the GUI</param>
 /// <param name="withTitleBar">Minor style adjustments to accomodate titlebars</param>
 /// <param name="topPadding">The amount of padding at the top of the gui.</param>
 public static GuiComposer AddShadedDialogBG(this GuiComposer composer, ElementBounds bounds, bool withTitleBar = true, double strokeWidth = 5)
 {
     if (!composer.Composed)
     {
         composer.AddStaticElement(new GuiElementDialogBackground(composer.Api, bounds, withTitleBar, strokeWidth));
     }
     return(composer);
 }
Пример #19
0
 public static GuiComposer AddImage(this GuiComposer composer, ElementBounds bounds, AssetLocation imageAsset)
 {
     if (!composer.Composed)
     {
         composer.AddStaticElement(new GuiElementImage(composer.Api, bounds, imageAsset));
     }
     return(composer);
 }
 /// <summary>
 /// Adds a compact vertical scrollbar to the current GUI.
 /// </summary>
 /// <param name="onNewScrollbarValue">The event fired for the change in the scrollbar.</param>
 /// <param name="bounds">the bounds of the scrollbar.</param>
 /// <param name="key">the internal name of the scrollbar.</param>
 public static GuiComposer AddCompactVerticalScrollbar(this GuiComposer composer, Action <float> onNewScrollbarValue, ElementBounds bounds, string key = null)
 {
     if (!composer.Composed)
     {
         composer.AddInteractiveElement(new GuiElementCompactScrollbar(composer.Api, onNewScrollbarValue, bounds), key);
     }
     return(composer);
 }
Пример #21
0
 /// <summary>
 /// Adds a dropdown to the current GUI instance.
 /// </summary>
 /// <param name="values">The values of the current drodown.</param>
 /// <param name="names">The names of those values.</param>
 /// <param name="selectedIndex">The default selected index.</param>
 /// <param name="onSelectionChanged">The event fired when the index is changed.</param>
 /// <param name="bounds">The bounds of the index.</param>
 /// <param name="key">The name of this dropdown.</param>
 public static GuiComposer AddDropDown(this GuiComposer composer, string[] values, string[] names, int selectedIndex, SelectionChangedDelegate onSelectionChanged, ElementBounds bounds, CairoFont font, string key = null)
 {
     if (!composer.composed)
     {
         composer.AddInteractiveElement(new GuiElementDropDown(composer.Api, values, names, selectedIndex, onSelectionChanged, bounds, font, false), key);
     }
     return(composer);
 }
Пример #22
0
 /// <summary>
 /// Adds a switch to the GUI.
 /// </summary>
 /// <param name="onToggle">The event that happens when the switch is toggled.</param>
 /// <param name="bounds">The bounds of the switch.</param>
 /// <param name="key">the name of the switch. (Default: null)</param>
 /// <param name="size">The size of the switch (Default: 30)</param>
 /// <param name="padding">The padding around the switch (Default: 5)</param>
 public static GuiComposer AddSwitch(this GuiComposer composer, Action <bool> onToggle, ElementBounds bounds, string key = null, double size = 30, double padding = 4)
 {
     if (!composer.Composed)
     {
         composer.AddInteractiveElement(new GuiElementSwitch(composer.Api, onToggle, bounds, size, padding), key);
     }
     return(composer);
 }
Пример #23
0
        /// <summary>
        /// Adds a set of horizontal tabs to the GUI.
        /// </summary>
        /// <param name="tabs">The collection of tabs.</param>
        /// <param name="bounds">The bounds of the horizontal tabs.</param>
        /// <param name="OnTabClicked">The event fired when the tab is clicked.</param>
        /// <param name="font">The font of the tabs.</param>
        /// <param name="key">The key for the added horizontal tabs.</param>
        public static GuiComposer AddHorizontalTabs(this GuiComposer composer, GuiTab[] tabs, ElementBounds bounds, API.Common.Action <int> OnTabClicked, CairoFont font, CairoFont selectedFont, string key = null)
        {
            if (!composer.composed)
            {
                composer.AddInteractiveElement(new GuiElementHorizontalTabs(composer.Api, tabs, font, selectedFont, bounds, OnTabClicked), key);
            }

            return(composer);
        }
Пример #24
0
 /// <summary>
 /// Adds dynamic text to the GUI.
 /// </summary>
 /// <param name="composer"></param>
 /// <param name="text"></param>
 /// <param name="font"></param>
 /// <param name="orientation"></param>
 /// <param name="bounds"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public static GuiComposer AddDynamicText(this GuiComposer composer, string text, CairoFont font, EnumTextOrientation orientation, ElementBounds bounds, string key = null)
 {
     if (!composer.composed)
     {
         GuiElementDynamicText elem = new GuiElementDynamicText(composer.Api, text, font, orientation, bounds);
         composer.AddInteractiveElement(elem, key);
     }
     return(composer);
 }
Пример #25
0
 /// <summary>
 /// Adds an ItemSlotGrid with Exclusions.
 /// </summary>
 /// <param name="inventory">The attached inventory.</param>
 /// <param name="SendPacket">A handler that should send supplied network packet to the server, if the inventory modifications should be synced</param>
 /// <param name="columns">The number of columns.</param>
 /// <param name="excludingSlots">The slots that have been excluded from the slot grid.</param>
 /// <param name="bounds">The bounds of the slot grid.</param>
 /// <param name="key">The name of the slot grid.</param>
 public static GuiComposer AddItemSlotGridExcl(this GuiComposer composer, IInventory inventory, API.Common.Action <object> SendPacket, int columns, int[] excludingSlots, ElementBounds bounds, string key = null)
 {
     if (!composer.composed)
     {
         composer.AddInteractiveElement(new GuiElementItemSlotGridExcl(composer.Api, inventory, SendPacket, columns, excludingSlots, bounds), key);
         GuiElementItemSlotGridBase.UpdateLastSlotGridFlag(composer);
     }
     return(composer);
 }
Пример #26
0
 /// <summary>
 /// Adds a hover text to the GUI.
 /// </summary>
 /// <param name="text">The text of the text.</param>
 /// <param name="font">The font of the text.</param>
 /// <param name="width">The width of the text.</param>
 /// <param name="bounds">The bounds of the text.</param>
 /// <param name="key">The name of this hover text component.</param>
 public static GuiComposer AddHoverText(this GuiComposer composer, string text, CairoFont font, int width, ElementBounds bounds, TextBackground background, string key = null)
 {
     if (!composer.composed)
     {
         GuiElementHoverText elem = new GuiElementHoverText(composer.Api, text, font, width, bounds, background);
         composer.AddInteractiveElement(elem, key);
     }
     return(composer);
 }
Пример #27
0
        /// <summary>
        /// Adds a passive item slot to the GUI.
        /// </summary>
        /// <param name="bounds">The bounds of the Slot</param>
        /// <param name="inventory">The inventory attached to the slot.</param>
        /// <param name="slot">The internal slot of the slot.</param>
        /// <param name="drawBackground">Do we draw the background for this slot? (Default: true)</param>
        public static GuiComposer AddPassiveItemSlot(this GuiComposer composer, ElementBounds bounds, IInventory inventory, ItemSlot slot, bool drawBackground = true)
        {
            if (!composer.composed)
            {
                composer.AddInteractiveElement(new GuiElementPassiveItemSlot(composer.Api, bounds, inventory, slot, drawBackground));
            }

            return(composer);
        }
Пример #28
0
        /// <summary>
        /// Adds a container to the current GUI. Can be used to add any gui element within a scrollable window.
        /// </summary>
        /// <param name="composer"></param>
        /// <param name="bounds">The bounds of the cell.</param>
        /// <param name="key">The identifier for the list.</param>
        public static GuiComposer AddContainer(this GuiComposer composer, ElementBounds bounds, string key = null)
        {
            if (!composer.Composed)
            {
                composer.AddInteractiveElement(new GuiElementContainer(composer.Api, bounds), key);
            }

            return(composer);
        }
Пример #29
0
        /// <summary>
        /// Adds a chat input to the GUI.
        /// </summary>
        /// <param name="bounds">The bounds of the text.</param>
        /// <param name="OnTextChanged">The event fired when the text is changed.</param>
        /// <param name="key">The name of this chat component.</param>
        public static GuiComposer AddChatInput(this GuiComposer composer, ElementBounds bounds, API.Common.Action <string> OnTextChanged, string key = null)
        {
            if (!composer.composed)
            {
                composer.AddInteractiveElement(new GuiElementChatInput(composer.Api, bounds, OnTextChanged), key);
            }

            return(composer);
        }
Пример #30
0
        // Single rectangle shape
        /// <summary>
        /// Adds a dialog title bar to the GUI.
        /// </summary>
        /// <param name="text">The text of the title bar.</param>
        /// <param name="OnClose">The event fired when the title bar is closed.</param>
        /// <param name="font">The font of the title bar.</param>
        /// <param name="bounds">The bounds of the title bar.</param>
        public static GuiComposer AddDialogTitleBar(this GuiComposer composer, string text, Action OnClose = null, CairoFont font = null, ElementBounds bounds = null)
        {
            if (!composer.composed)
            {
                composer.AddInteractiveElement(new GuiElementDialogTitleBar(composer.Api, text, composer, OnClose, font, bounds));
            }

            return(composer);
        }