The menu system is created using the Slate UI framework. It consists of menus, menu widgets, and menu items.
Each menu has a single menu widget (SPlatformerMenuWidget
) that is responsible for layout, internal event handling, and animations
for all of the menu items. Menu items (SPlatformerMenuItem
) are compound objects that can perform actions and contain any number
of other menu items. These can be as simple as a label or button or "tabs" that contain complete submenus made up of other menu items.
This menu can be operated using keyboard or controller, but there is only limited mouse support at this time.
Each menu is constructed via the Construct()
function, which adds all of the necessary menu items, including sub-items,
and attaches delegates to them where necessary. This is done using the helper methods - AddMenuItem()
, AddMenuItemSP()
, etc. -
defined in the MenuHelper
namespace in the SPlatformerMenuWidget.h
file.
Navigation to previous menus is done using an array of shared pointers to menus and is stored in the MenuHistory
variable of
the menu widget. MenuHistory
acts like stack to hold previously entered menus and makes it easy to go back. By using this method,
no direct relationship is created between menus and the same menu can be reused in different places if necessary.
Animations are performed using interpolation curves defined in SPlatformerMenuWidget::SetupAnimations()
. Each curve has start time,
duration, and interpolation method. Animations can be played forward and in reverse and their attributes can be animated at specific time
using GetLerp()
, which returns a value from 0.0f to 1.0f. There are several different interpolation methods available defined in
ECurveEaseFunction::Type
in SlateAnimation.h
.