Skip to main content

Views, tabs and inheritance

A view is one screen of a menu. All views share the same shell (the tab strip, the footer), and only the content changes.

Declare views​

In views, add one entry per screen:

FieldRole
idUsed by gui:view and by the tabs.
nameLabel used in the breadcrumb. Falls back to the id.
titleTitle of this view. Empty keeps the menu title. Accepts {breadcrumb}, {view} and {root}.
parentIdParent view, for the breadcrumb and to keep the parent's tab lit.
framesExplicit mapping from a frame id to a layout id.
criteria, viewPermissionThe view is unreachable and its tab hidden when they do not pass.
activeStyleHow the tab looks while active: glint, material, customModelData, nameFormat, loreSuffix.

On the Open GUI, defaultViewId is the view opened first (the first declared one when empty). breadcrumbSeparator is the MiniMessage text between breadcrumb segments, and pushHistoryOnViewSwitch makes gui:back return to the previous view after a tab change.

Fill the frames​

In a frame layout, set the layoutId of a frame to @view. For the active view, the extension looks for the layout in this order:

  1. the view's frames mapping for that frame id;
  2. a layout named <view id>_<frame id>, for example island_content for the frame content and the view island;
  3. the same two lookups on the parentId chain.

A frame that resolves to nothing stays empty. Only the root layout of the menu (mainLayoutId) resolves @view frames.

Tabs​

Give a tab item buttonPrefix view: and buttonType equal to the view id. Clicking it switches to the view, and it takes the activeStyle of the view while that view or one of its children is active. Tabs of unreachable views are hidden.

The first view the player can reach is used when the requested one is hidden. A requested view that does not exist is logged as Unknown view.

Inherit a menu​

baseMenuId is the entry id of a template Open GUI. The child inherits its layoutPool, views, mainLayoutId, defaultViewId and size, and the chain is followed up to the root, so a menu can inherit a domain template that itself inherits a global shell. A layout of the child with the same id replaces the inherited one, and the same goes for views. The storagePool is inherited from the direct parent only. A blank mainLayoutId on the child uses the parent's.

Check that the parent exists, that every layoutId exists in the merged pool, and that two menus do not inherit from each other.

In practice​

Create a template menu with a fixed tab frame and a @view content frame, then create one child per domain that only overrides the content layouts. Content layouts can be simple, scrollable or paginated without touching the tab strip.