UI widgets
The PulseSkillUI module has ready-made CommonUI widgets that show skill trees. They are built on the view models and work the same on the server and on clients. Use them as they are, restyle them with the UI theme of Pulse Foundation, or derive from them.
| Widget | Base | Description |
|---|---|---|
UPulseSkillMenuWidget | UCommonActivatableWidget | Complete menu: one tab per tree, the tree, details, points, failure messages. |
UPulseSkillTreeWidget | UCommonUserWidget | One tree: places the nodes with a layout, draws the connections, pan and zoom. |
UPulseSkillNodeWidget | UCommonButtonBase | One skill. Click unlocks, right click refunds. |
UPulseSkillNodeDetailsWidget | UCommonUserWidget | Details of a skill, used as tooltip and as details panel. |
UPulseSkillConnectionsWidget | UWidget | Draws the connections (SPulseSkillConnections). |
UPulseSkillTreeTabList, UPulseSkillTreeTabButton | CommonUI tab list / button | Tabs of the menu. |
The module needs the CommonUI and Enhanced Input plugins, which Pulse Skill enables.
Assets in the plugin
/PulseSkill/UI/ (enable Show Plugin Content in the content browser) has a ready-made look to use or duplicate:
| Asset | Content |
|---|---|
WBP_PulseSkillMenu | Menu: tabs, points, tree, details panel (360 wide), failure text. |
WBP_PulseSkillTree | Tree with BackgroundBorder, NodeCanvas and Connections; uses WBP_PulseSkillNode. |
WBP_PulseSkillNode | Round node with icon and rank; tooltip WBP_PulseSkillNodeDetails. |
WBP_PulseSkillNodeDetails | Rounded panel with icon, name, rank and all texts. |
WBP_PulseSkillTreeTab | Tab button with the tree name. |
DA_PulseSkill_Theme | UI theme extension: button styles of the nodes per state, icon tints, connection colors. |
DA_PulseSkillTreeStyle_Default | Default layout (project setting DefaultStyle): node size, opacity per state, curved connections. |
Styles/BS_PulseSkillNode_*, Styles/BS_PulseSkillTab | CommonUI button styles (the theme extension names the node styles). |
Styles/TS_PulseSkill_* | CommonUI text styles of the WBPs in the designer; at runtime the text roles of the theme apply. |
Copy them into your project before changing them, so plugin updates do not overwrite your look.
Quick start
- Call Open Skill Menu (
UPulseSkillUILibrary::OpenSkillMenu(PlayerController), also Close and Toggle): the UI presenter of Pulse Foundation opens the menu on its menu layer, so a game with a UI host shows it in its own stack and without one it goes into the viewport. The class isMenu Classof the Skill UI settings (defaultWBP_PulseSkillMenu). On activation it finds the skill component of the owning player withUPulseSkillLibrary::GetSkillComponent(player state, pawn or controller). CallSetSkillComponentif the component is somewhere else. - That’s it: every tree of the component gets a tab, the skills are laid out automatically, and clicking a skill calls
TryUnlockSkill.
Only one tree, e.g. inside your own menu: put a UPulseSkillTreeWidget into your widget and call SetSkillComponent(Component, TreeTag) (empty tag: the first tree) or SetTreeViewModel(TreeViewModel).
UPulseSkillTreeWidget* treeWidget = CreateWidget<UPulseSkillTreeWidget>(PlayerController, UPulseSkillTreeWidget::StaticClass());
treeWidget->SetSkillComponent(UPulseSkillLibrary::GetSkillComponent(PlayerController), TAG_SkillTree_Warrior);
Layout
UPulseSkillTreeWidget::Layout is an inline object (UPulseSkillTreeLayout):
-
Layered (default,
UPulseSkillTreeLayout_Layered): the roots (skills without prerequisites in the tree) come first, every other skill one layer after its deepest prerequisite. A root with two follow-up skills shows them side by side on the same height, symmetrically below it.Property Default Description DirectionTopToBottomAlso BottomToTop,LeftToRight,RightToLeft.AlignmentTreeTree: like a family tree, every skill is centered above the skills that follow it and every subtree gets its own band, so nothing overlaps. Skills with several prerequisites sit below the first one.AlignToParents: every skill as close as possible to the middle of all its prerequisites (good for many merges).CenterLayers: every layer centered.LayerSpacing220 Distance between the centers of two layers. NodeSpacing180 Smallest distance between two skills of a layer. OrderSweeps2 Passes that reorder the skills of a layer to avoid crossing lines. 0 keeps the node order. -
Editor Position (
UPulseSkillTreeLayout_EditorPosition): the positions from the skill tree editor, scaled byScale.
Own layouts: derive from UPulseSkillTreeLayout (C++ or Blueprint) and override ComputeLayout (centers per skill tag, any origin) and GetFlowDirection (how connections leave the nodes). Layouts work on the tree asset only and must not keep state.
Look: the UI theme
Colors, button and text styles and the background come from the UI theme of Pulse Foundation, so the skill menu looks like the rest of the game. The plugin’s theme extension DA_PulseSkill_Theme fills the roles of the skill widgets; a theme of the game, or a theme extension with a higher priority, changes them. The widgets restyle themselves when the player’s theme changes.
| Role | Used for |
|---|---|
Pulse.UI.Button.Skill.Node.Locked, .Available, .Unlocked, .Maxed | Button style of a node per state |
Pulse.UI.Color.Skill.Node.Locked, .Available, .Unlocked, .Maxed | Tint of the skill icon per state |
Pulse.UI.Color.Skill.Connection.Locked, .Available, .Active | Connection colors: prerequisite not met, met, both unlocked |
Pulse.UI.Brush.Skill.TreeBackground | Background brush of a tree (none: no background) |
Pulse.UI.Text.Heading, .Label, .Number, .Body, .Button | Skill names, node names, ranks, details texts, tab titles (shared roles) |
Pulse.UI.Color.Highlight, .Accent, .TextMuted, .Positive, .Negative, .Surface, .Backdrop | Rank and rank text, costs, requirements, rewards, failures, details panel, menu (shared roles) |
Pulse.UI.Button.Tab | Tabs of the trees (shared role) |
The roles are in Style/PulseSkillUITheme.h (Pulse::Skill::UI::Tags); without a theme value the widgets keep the plugin’s former colors. The tool Tools/build_skill_theme.py (editor Python) writes DA_PulseSkill_Theme again.
Layout
A Skill Tree Style (UPulseSkillTreeStyle, data asset) holds the layout all widgets share:
| Property | Description |
|---|---|
NodeSize | Size of a node. |
Locked, Available, Unlocked, Maxed | Per state: opacity of the node. |
RankFormat, bShowRankOfSingleRankSkills | Rank text, e.g. {Rank}/{MaxRank}. |
Connections | Shape (Straight, Curve, Orthogonal), thickness, curve strength and anti-aliasing. |
ContentPadding | Space around the nodes. |
Set it with TreeStyle on the tree or menu widget (they pass it on to nodes and details) or SetTreeStyle at runtime, e.g. a different layout per island. Widgets without one use Project Settings > Pulse > Skill > UI > Default Style (UPulseSkillUISettings, default: /PulseSkill/UI/DA_PulseSkillTreeStyle_Default), else the C++ defaults.
Building your own look
Every widget works from C++ alone: a native class without a designer layout builds a simple default layout. For your own look, create a Widget Blueprint derived from the widget class and add widgets with these names (all optional, BindWidgetOptional):
| Widget | Parts |
|---|---|
| Node | IconImage (Image), NameText, RankText (CommonTextBlock) |
| Node details | IconImage, NameText, RankText, DescriptionText, RankDescriptionText, CostText, RequirementText, RewardText, FailureText (empty texts are collapsed) |
| Tree | NodeCanvas (CanvasPanel, needed), Connections (child of NodeCanvas, created if missing), BackgroundBorder, DetailsPanel, TreeNameText, PointsSpentText, ResetButton |
| Menu | TreeTabs (any CommonUI tab list), TreeWidget, DetailsPanel, AvailablePointsText, FailureText |
| Tab list / button | TabButtonBox (panel) / TitleText |
A Widget Blueprint with an empty hierarchy shows nothing; add at least the parts you need. Then set the classes: NodeWidgetClass on the tree, TooltipWidgetClass on the node, TabButtonClass on the menu. MVVM bindings to the node and tree view models work in these Blueprints as well.
In the designer, set PreviewTree on a tree widget to see the layout with all skills locked.
Extending
| Where | Override | Use |
|---|---|---|
| Tree | GetNodeWidgetClass(Node) | Different node widgets, e.g. by SkillTags of the skill. |
| Tree | OnNodeWidgetCreated(NodeWidget), ConfigureNodeSlot (C++) | Change new nodes or their placement. |
| Tree | GetConnectionState(From, To, MinRank) | Own rules for the connection colors. |
| Tree | HandleNodeUnlockRequested / HandleNodeRefundRequested | Return true to handle a click yourself, e.g. show a confirmation first. |
| Tree | OnTreeRebuilt, OnNodeClicked, OnSelectedNodeChanged | React to changes. |
| Node | OnNodeUpdated(Node), OnNodeStateChanged(Old, New) | Own visuals, unlock animations. |
| Details | OnDetailsUpdated(Node) | Own visuals. |
| Menu | OnTreeSelected, OnTabButtonCreated, SelectTree | Own tabs or tree switching. |
| Connections | SPulseSkillConnections::PaintConnection (C++) | Own line shapes; create the widget in UPulseSkillConnectionsWidget::RebuildWidget. |
Input
- Mouse: click unlocks, right click refunds (
bRefundOnRightClickon the node), hovering shows the tooltip. Drag the background with any mouse button to pan (bAllowPan), mouse wheel zooms (bAllowZoom,MinZoom,MaxZoom,ZoomStep). - Gamepad and keyboard: the nodes are CommonUI buttons, so focus navigation and the accept action work as usual. The focused node is shown in the details panel and scrolled into view (
bKeepFocusedNodeVisible). SetRefundInputAction(data table row) orRefundEnhancedInputActionon the tree widget to refund the focused node. bFitToViewfits the whole tree into the view (at mostMaxFitZoom) until the player pans or zooms.FitToView,CenterOnNodeandSetZoommove the view from code.