コード例 #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>
 /// 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);
 }
コード例 #4
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);
 }
コード例 #5
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);
 }
コード例 #6
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);
 }
コード例 #7
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);
 }
コード例 #8
0
 /// <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);
 }
コード例 #9
0
ファイル: GuiElementSlider.cs プロジェクト: Archina/vsapi
 /// <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);
 }
コード例 #10
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);
 }
コード例 #11
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);
 }
コード例 #12
0
ファイル: GuiElementStatbar.cs プロジェクト: Archina/vsapi
 /// <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);
 }
コード例 #13
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);
 }
コード例 #14
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);
 }
コード例 #15
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);
        }
コード例 #16
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);
        }
コード例 #17
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);
        }
コード例 #18
0
        /// <summary>
        /// Adds a rich text element to the GUI
        /// </summary>
        /// <param name="composer"></param>
        /// <param name="vtmlCode"></param>
        /// <param name="baseFont"></param>
        /// <param name="bounds"></param>
        /// <param name="didClickLink"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static GuiComposer AddRichtext(this GuiComposer composer, string vtmlCode, CairoFont baseFont, ElementBounds bounds, Action <LinkTextComponent> didClickLink, string key = null)
        {
            if (!composer.Composed)
            {
                composer.AddInteractiveElement(new GuiElementRichtext(composer.Api, VtmlUtil.Richtextify(composer.Api, vtmlCode, baseFont, didClickLink), bounds), key);
            }

            return(composer);
        }
コード例 #19
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);
        }
コード例 #20
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);
        }
コード例 #21
0
        /// <summary>
        /// Adds a rich text element to the GUI
        /// </summary>
        /// <param name="composer"></param>
        /// <param name="components"></param>
        /// <param name="bounds"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static GuiComposer AddRichtext(this GuiComposer composer, RichTextComponentBase[] components, ElementBounds bounds, string key = null)
        {
            if (!composer.Composed)
            {
                composer.AddInteractiveElement(new GuiElementRichtext(composer.Api, components, bounds), key);
            }

            return(composer);
        }
コード例 #22
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);
 }
コード例 #23
0
ファイル: GuiElementStacklist.cs プロジェクト: Archina/vsapi
        public static GuiComposer AddHandbookStackList(this GuiComposer composer, ElementBounds bounds, API.Common.Action <int> onleftClick = null, List <GuiHandbookPage> stacks = null, string key = null)
        {
            if (!composer.composed)
            {
                composer.AddInteractiveElement(new GuiElementHandbookList(composer.Api, bounds, onleftClick, stacks), key);
            }

            return(composer);
        }
コード例 #24
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);
 }
コード例 #25
0
ファイル: GuiElementClip.cs プロジェクト: anegostudios/vsapi
 /// <summary>
 /// Add a clip area. Thhis select an area to be rendered, where anything outside will be invisible. Useful for scrollable content. Can be called multiple times, to reduce the render area further, but needs an equal amount of calls to EndClip()
 /// </summary>
 /// <param name="bounds">The bounds of the object.</param>
 public static GuiComposer BeginClip(this GuiComposer composer, ElementBounds bounds)
 {
     if (!composer.Composed)
     {
         composer.AddInteractiveElement(new GuiElementClip(composer.Api, true, bounds));
         composer.InsideClipBounds = bounds;
         composer.BeginChildElements();
     }
     return(composer);
 }
コード例 #26
0
ファイル: GuiElementClip.cs プロジェクト: anegostudios/vsapi
 /// <summary>
 /// Remove a previously added clip area.
 /// </summary>
 public static GuiComposer EndClip(this GuiComposer composer)
 {
     if (!composer.Composed)
     {
         composer.AddInteractiveElement(new GuiElementClip(composer.Api, false, ElementBounds.Empty));
         composer.InsideClipBounds = null;
         composer.EndChildElements();
     }
     return(composer);
 }
コード例 #27
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);
 }
コード例 #28
0
ファイル: GuiElementConfigList.cs プロジェクト: Archina/vsapi
        /// <summary>
        /// Adds a config List to the current GUI.
        /// </summary>
        /// <param name="items">The items to add.</param>
        /// <param name="OnItemClick">The event fired when the item is clicked.</param>
        /// <param name="font">The font of the Config List.</param>
        /// <param name="bounds">The bounds of the config list.</param>
        /// <param name="key">The name of the config list.</param>
        public static GuiComposer AddConfigList(this GuiComposer composer, List <ConfigItem> items, ConfigItemClickDelegate OnItemClick, CairoFont font, ElementBounds bounds, string key = null)
        {
            if (!composer.composed)
            {
                GuiElementConfigList element = new GuiElementConfigList(composer.Api, items, OnItemClick, font, bounds);

                composer.AddInteractiveElement(element, key);
            }
            return(composer);
        }
コード例 #29
0
        /// <summary>
        /// Adds multiple tabs to a group of vertical tabs.
        /// </summary>
        /// <param name="tabs">The tabs being added.</param>
        /// <param name="bounds">The boundaries of the tab group.</param>
        /// <param name="OnTabClicked">The event fired when any of the tabs are clicked.</param>
        /// <param name="key">The name of this tab group.</param>
        public static GuiComposer AddVerticalTabs(this GuiComposer composer, GuiTab[] tabs, ElementBounds bounds, Action <int, GuiTab> OnTabClicked, string key = null)
        {
            if (!composer.Composed)
            {
                CairoFont font         = CairoFont.WhiteDetailText().WithFontSize(17);
                CairoFont selectedFont = CairoFont.WhiteDetailText().WithFontSize(17).WithColor(GuiStyle.ActiveButtonTextColor);
                composer.AddInteractiveElement(new GuiElementVerticalTabs(composer.Api, tabs, font, selectedFont, bounds, OnTabClicked), key);
            }

            return(composer);
        }
コード例 #30
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);
 }