Skip to content

Components

Tobero edited this page Sep 18, 2023 · 19 revisions

Components

Javadoc ToberoCat - GuiEngine Donate PayPal stars - GuiEngine forks - GuiEngine GitHub release issues - GuiEngine SpigotMain - GuiEngine

Common parts of components

All components share some properties. Common Properties:

  • priority - This is the render priority of the component. It defines when the compoent will be drawn and when it recieves events. Default to NORMAL. Possible values are: HIGHEST, HIGH, NORMAL, LOW, LOWEST
  • id - Set the id of the component. This makes it easier to find components for developers and yourself when debugged why a gui doesn't work. It also provides the ability to use component specific actions (See PagedComponent). It defaults to a random 36 letter uuid.
  • x - Define the x position of the component. It starts with 0 and goes to the width of your gui - 1. Defaults to 0
  • y - Define the y position of the component. It starts with 0 and goes to the height of your gui - 1. Defaults to 0
  • hidden - Tell the component to render itself or not. Defaults to false. Possible values are: false, true
  • on-click - This is a multi value property. You have to define it in the body of the component. It takes a type, representing the function you want to execute and a value, enclosed by the on-click tag. Defaults to no functions. These functions get called when the component gets clicked
  • on-drag - This is a multi value property. You have to define it in the body of the component. It takes a type, representing the function you want to execute and a value, enclosed by the on-drag tag. Defaults to no functions. These functions get called when one fo the slots of the component is included in a drag event.
  • on-close - This is a multi value property. You have to define it in the body of the component. It takes a type, representing the function you want to execute and a value, enclosed by the on-close tag. Defaults to no functions. These functions call when the components gets closed. This usually is the case when the gui gets closed or incase of an embedded gui, when the gui gets replaced by another gui.

SimpleItemComponent

Use this component by setting the type property to item

Properties:

  • Common properties
  • name - The name of the item. Supports color codes. If not provided, it will default to nothing (" ")
  • material - This is a required property. You must always set it when using this component, as long as the head-texture isn't set or the head-owner, which automatically sets it to PLAYER_HEAD. Visit the beginner guide to see the trick to get the material from an item.
  • lore - This is a multivalue property. You must set it in the component body. Supports color codes. Defaults to an empty lore. The items will be handled sequenially
  • head-texture - Set this property to make this item a player head with a custom texture. You can find the textures on minecraft-heads. Once you found a head you like, copy the value at the bottom into this property. Defaults to an empty texture
  • flag - Allows setting certain flags. Defaults to all flags, hiding values. Can be set like this: No flags: <flag/>; <flag>HIDE_ATTRIBUTES</flag>
  • head-owner - Set this property to make tis item a player head with the texture of the specified owner. When head-tetxure is set, this property will be ignored.

ToggleitemComponent

Use this component by setting the type property to toggle

Properties:

  • Common properties
  • selected - This is a required number. Set this to the index of the component specified (Count the components until you reach your desired component)
  • Component Body - This is required. You simple start typing your components you want to toggle between in the component body, but all items in there have a extra property, called value. This can be used by developers to parse the selection model into an enum. Example usage: grafik

Embedded

Use this component to show a different gui in the current one. Set the type to embedded to use it. This componet was designed to make it easier to create tileable segments for server owners. A example would be a navigation bar, used to navigate multiple guis. Instead of copying all components in every gui, you can instead create a seperate gui to hold them and then embbed them into the guis you want. g

This (bad) graphic tries to explain what's going one behind the scenes. The separator.gui's components get pasted into the place of the embedded gui component. This makes the component so useful. You can view the 7 line gui instead of the one with 27 lines.

Note: That's just a simplied version for explaination purposes of what actually happens behind the scenes. The result looks the same, so there's no need to understand what actually happens.

Properties:

  • Common properties
  • copy-air - Define if you empty slots should be copied. Defaults to false. Possible values are: true, false
  • interactions - Define if you want any events to reach the underlying gui. Possible values are true, false. Defaults to true
  • width - Set the width of the embedded gui. It doesn't has to match the target gui's dimensions. This is required
  • height - Set the height of the embbeded gui. It doesn't has to match the target gui's dimensions. This is required
  • target-gui - Set the target gui. Only allows gui's within the same api scope. This is required. This must be the id of a gui (Just likethe part after the api when using the open command)

PagedComponent

This component extends the embedded gui to make use of this virtualisation technique used. Set the type to paged to use it grafik This is a example of the component being used.

Properties:

  • Common Properties
  • EmbeddedComponet Properties
  • target-gui - This is no longer required or a option
  • showing-page - This is optional, defualts to 0.
  • pattern - This is required. The pattern defines how components get placed. When all pattern slots are used, a new page gets added, restarting the pattern. Example pattern would be: 0,1,2,3,4,5,6,7,8. The pattern is composed of slots, starting at 0 for the origin of the component
  • Component Body - You can create components body to add them to the paged component. x and y are being ignored. If you add a component called fill-empty, it will be placed on every pattern slot not occupied by a component.

Local actions:

When you give this component a id, you can access the actions for slipping the page. See this example: grafik

Clone this wiki locally