Modules
Sub-elements
A module made of several independently draggable parts, the way the Armor HUD is, can hand those parts to the editor one at a time.
Returning the parts
Override getSubElements() and return a list of objects that implement IHudElement. The editor then treats each part as its own draggable element instead of moving the whole module. An empty list, the default, keeps the module as one element.
@Override
public List<IHudElement> getSubElements() {
// Independent parts, such as Helmet and Chestplate.
// Empty means the whole module is dragged as one.
return mySubElementsList;
}Parts share their module's page. Right-clicking one of your parts lands on your module's page in the settings screen: parts do not get pages of their own.
What a part implements
IHudElement is the interface HudModule itself implements, so a part answers the same questions a module does. Everything below a part's size and position has a default.
int getX()
int getY()since 1.2.0Where the part is drawn this frame.
int getWidth()
int getHeight()since 1.2.0Its size, for hit-testing and snapping.
int getXOffset()
int getYOffset()since 1.2.0Its offset, which the editor reads as you drag.
void setXOffset(int x)
void setYOffset(int y)since 1.2.0Called by the editor as the part moves. Store the value in your own config.
String getName()since 1.2.0A unique key for the part.
int getLayoutWidth()
int getLayoutHeight()since 1.2.0The room the layout reserves. Defaults to getWidth() and getHeight().
int getScale()
void setScale(int scale)since 1.2.0Return 100 and do nothing by default.
void resetToDefaults()since 1.2.0What Reset Position does to the part. A no-op by default.
List<HudModuleSetting> getContextMenuSettings()since 1.2.0Rows for the part's own right-click menu. Empty by default.
void onPositionUpdated()since 1.2.0Called when a drag or a nudge of the part finishes. A no-op by default.