YesNoOption - ParzivalExe/guiapi GitHub Wiki

From Overview

Like the YesNoSetting, this is also a dumped-down version, this time of the AdditionalOptionsComponent. Here, there are only two additional options so that you can for example use this as Yes and No or any other two options you might come up with because the ComponentMeta of these two options is changeable here too, as you might have guessed already.

Of course you can also choose between NewInventory and UnderInventory in this Component.

Implementation

The YesNoOption-Component is again much more traditional. It is pretty much a focused version of the AdditionalOptionsComponent which only allows for two additionalOptions. Because of this, this Component is mainly used for Yes/No Questions, for example if you really want to delete something.

ComponentMeta yesNoMeta = new ComponentMeta("Options", new ItemStack(Material.TORCH));
//manipulate yesNoMeta here
YesNoOption yesNoOption = new YesNoOption(yesNoMeta);
//manipulate yesNoOption here

gui.addComponent(yesNoOption);

As you can see, this is more like the early Components in this Tutorial, but there are some additional options, that make this a bit more complex than it seems right now.

First of all, you can set the ComponentMeta for the Yes-Option by calling setYesMeta(ComponentMeta) and for the No-Option by calling setNoMeta(ComponentMeta).

You cal also (like with AdditionalOptionsComponent) change how these Options are opened, either OpenOption.UNDER_INVENTORY or OpenOption.NEW_INVENTORY by calling setOpenOption(OpenOption). If you do open it in a new gui/inventory you can then also set the Title of this inventory by calling setNewInvTitle(String). If this is not set, it will automatically use the Title of the YesNoOption-Component.

Events

ComponentClickedEvent = fired, when YesNoOption (or any other Component) is clicked

ExpandAdditionalOptionsEvent = fired, when the AdditionalOptionsComponent is clicked and either expanded or decreased. Because this is a modified AdditionalOptionsComponent, this event is also fired.

YesOptionClickedEvent = fired, when the YesOption is clicked

NoOptionClickedEvent = fired, when the NoOption is clicked

XML-Attributes

title="{Component-Title}" = sets the Title of this Component (example: title="Hello World")

look="{AMOUNT}xID:{DATA}{[DURABILITY]}" = sets the Look of this Component (example: look="3x322:1" or look="3xGOLDEN_APPLE")

description="[{line1}, {line2}...]" = sets the description of this Component (example: description="[This is a Description, with a \,]")

yesTitle="{yesTitle}" = Sets the Title of the Yes-Option (example: yesTitle="YES")

noTitle="{noTitle}" = Sets the Title of the No-Option (example: noTitle="no")

yesLook="{yesLook}" = Sets the Look of the Yes-Option (example: yesLook="351:10")

noLook="{noLook}" = Sets the Look of the No-Option (example: noLook="351:8")

place="{PLACE}" = sets the place this Component should be placed at in the Gui (example: place="4")

openOption="newInventory | underInventory" = sets how the YesNoOptions are displayed, either under the component or in a new gui/inventory (example: openOption="underInventory")

newInvTitle="{title}" = sets the title of the new Inventory if openOption is set to NewInventory (example: newInvTitle="TestTitle")

Resources

Component-Code: io.github.parzivalExe.guiApi.components.YesNoOption


RESPECT, you have finished all Tutorials about Components. Now you are fully equipped to create complex Guis. If you want a deeper look into all the Options the Gui itself offers look here, or go here if you need a totally different Component and want to create your own.

If you asked yourself what this XML-Stuff meant, than you should look here for the introduction into creation of Guis through XML.