Inventory UI
The module PulseInventoryUI adds a hotbar and item tooltips to the HUD and a carry weight menu for the game menu. It reads the equipment of the player (UPulseEquipmentComponent, see Equipment) and, if present, cooldowns of consumables from PulseInventoryEffects (Item effects). The inventory modules themselves have no UI code.
At a glance
- Give the player a
UPulseEquipmentComponentwith hotbar slots (Pulse.Equipment.Hotbar.*). - The default HUD layout
W_DefaultHUDWidgetalready containsW_DefaultHotbar(bottom center). It hides itself while the player has no equipment. - Equip items into hotbar slots. The hotbar shows icon, count, slot number, the active slot, cooldowns and wear; clicking a slot selects it (
RequestSelectHotbarSlot), hovering or focusing it shows the item tooltip.
Hotbar
| Class | What it does |
|---|---|
UMVVMPulseHotbar | View model of the owning player’s hotbar: one slot view model per hotbar slot of the equipment (in the order of Slots), plus empty slots up to MinSlotCount. Follows pawn changes, equipment changes and cooldowns. BindToPlayer, Unbind, Refresh, SelectSlot, GetSlots, field ActiveSlotIndex. |
UMVVMPulseItemSlot | One slot: SlotTag, SlotIndex, Definition, DisplayName, Icon, StackCount, bHasItem, bIsActive, CooldownFraction, CooldownRemaining, DurabilityPercent, bHasDurability (all FieldNotify). |
UPulseHotbarWidget | Creates one SlotClass widget per slot in the bound panel SlotPanel. MinSlotCount (default 8), bHideWithoutEquipment, designer preview PreviewSlotCount. |
UPulseHotbarSlotWidget | A CommonUI button. Optional bound widgets: IconImage, CountText, KeyCap (Pulse Key Cap with the key of SlotKeys), KeyText (slot number), CooldownImage (image with a material that takes CooldownParameter, e.g. M_PulseUI_RadialWipe), CooldownText, ActiveFrame, DurabilityBar. bShowTooltip, bHideSingleCount. |
Cooldowns are read from the cooldown effects (Pulse.Item.Cooldown.* tags of FPulseItemTrait_Consumable) on the ability system of the player’s pawn or player state, so they also show on clients. The view model only ticks while the equipment is still missing or a slot has a cooldown group (CooldownUpdateInterval).
Default widgets in /PulseGameplay/Inventory/UI/: W_DefaultHotbar (panel role Pulse.UI.Panel.HUD), W_DefaultHotbarSlot (76 x 76 inset slot, number top left, count bottom right, dark radial wipe with the seconds left, glowing accent frame on the active slot), button style BS_PulseHotbarSlot.
A UI host without a layout of its own (the default presenter of Pulse Foundation, or a game presenter) shows no hotbar by itself. With Add By Code in HotbarPlacement of the settings, UPulseInventoryUISubsystem adds W_DefaultHotbar (or the Widget Class of the placement, a child of UPulseHotbarWidget) to the gameplay part of the host at the bottom center, 24 px above the edge, once the host is ready and again after every map change; a hotbar the host already shows is used instead (Get Hotbar returns either). The subsystem exists only while the placement adds by code (off by default, because W_DefaultHUDWidget contains the hotbar). Specs: PulseInventoryUI.Placement.
Item tooltip
UPulseItemTooltipWidget is a HUD tooltip (UPulseHUDTooltipWidget, a tooltip widget of the UI host) for items. Make Item Tooltip Request (Definition, instance traits, stack count) builds an FPulseUITooltipRequest with the name, the description, the payload FPulseItemTooltipPayload and ItemTooltipClass of the settings as widget class; show it with Show Tooltip of the UI host (Pulse::UI::GetPresenter(Widget)->ShowTooltip(Controller, Request, Anchor, bFollowMouse, Delay), hide it with Hide Tooltip). Hotbar slots do this by themselves; with the Pulse HUD the tooltip shows in its tooltip layer, for the mouse and for gamepad focus. With the default presenter of Pulse Foundation the engine shows it while the mouse is over the slot, so a slot that only has gamepad focus shows none. The widget reads the payload in On Tooltip Request Set.
It shows the rarity in its color (RarityText), the name (TitleText), a stat grid (StatsPanel, one StatRowClass widget per row, StatsDivider hidden without rows) and the description (MessageText). Rows come from tooltip sections in the settings, in order:
| Section | Rows |
|---|---|
FPulseItemTooltipSection_Consumable | Healing, use time, cooldown |
FPulseItemTooltipSection_EquippedStats | Stats while equipped (FPulseItemTrait_EquippedStats) |
FPulseItemTooltipSection_RolledStats | Rolled stats of the instance (FPulseItemTrait_RolledStats), value color role configurable |
FPulseItemTooltipSection_Durability | “80 / 100”, warning color below LowFraction, negative when broken |
FPulseItemTooltipSection_Freshness | Freshness of perishable items “75 %”, warning color below LowFraction, “Spoiled” at 0 |
Own rows: derive a struct from FPulseItemTooltipSection, override AddRows(Context, Rows) (read traits with Context.FindTrait<T>(), the instance’s trait first) and add it to TooltipSections. A row is FPulseItemTooltipRow (Label, Value, ValueColorRole). Stat rows take the name and format of a stat (Pulse.Stat.*) from the stat register of PulseFoundation (Pulse::Stats::GetDisplayName, FormatValue with a “+” for positive values); name or write a stat of your own in Project Settings > Pulse > Foundation > Stats. Pure helpers in Pulse::InventoryUI: BuildTooltipRows, GetItemRarity, GetCooldownFraction, GetHotbarSlots (specs: PulseInventoryUI, also for Make Item Tooltip Request).
Default widgets: W_DefaultItemTooltip, W_DefaultItemStatRow.
Rarity names and colors
The tooltip shows the rarity (Pulse.Rarity.*) with a name and color from the UI theme. The theme extension /PulseGameplay/Inventory/UI/DA_PulseInventory_RarityTheme of PulseInventoryUI adds them to every theme: a text per rarity (Common, Uncommon, Rare, Epic, Legendary) and an alias to a color role (common = muted, uncommon = positive, rare = accent, epic = highlight, legendary = warning). Change them in your theme (its values win over extensions) or add rarities with an extension of your own (see the UI themes page of the Pulse Foundation docs). A rarity without a name in the theme shows no rarity line. Pulse::InventoryUI::GetRarityName and GetRarityColor read them in C++.
Carry weight menu
UPulseCarryWeightMenu (Pulse Carry Weight Menu, a CommonUI activatable widget built in code in the UI theme, like the difficulty menu of Pulse Difficulty) shows the carry weight of the local player’s inventory: the first UPulseInventoryComponent on the actors of the owning player (controller, player state, pawn), or the one given with Set Inventory.
- Headline “36.4 / 120 kg” (red when overloaded) and a bar in the progress bar role (accent, warning from 90 %, negative when overloaded); without a weight limit only the load.
- State line: “{weight} free”, “No weight limit.” or “Overloaded: {weight} over the limit. You cannot pick up anything more.”
- Load and Limit as tooltip lines (
Pulse::Inventory::FormatItemTraitValue): “13 -> 12 kg (Backpack, Hard)”, “100 -> 120 kg (Strong back)”, plus Carry weight factor “x1.2” when the factor is not 1. - What changes it: every source with a Weight trait modifier (the Item Modifiers trait of the inventory first, then the sources of the owner from
GetModifierView/GetItemModifiers: Wearer Modifiers of equipped items, Item Modifiers of the tuning) with the weight it adds to the load now (“-5 kg” positive color, “+4 kg” negative, “0 kg” when no item it changes is carried), and the tuning sources ofPulse.Tuning.Inventory.CarryWeightfor the owner with their factor (“Limit x1.2”). - A Close button (
bShowCloseButton) that deactivates the menu; it gets the gamepad focus.
It updates on the events of the inventory (stacks, traits, OnInventoryChanged, which the component fires for a new limit, factor or modifier sources). WeightUnit is the unit (default “kg”). A Blueprint child with a tree of its own reads Get Report (FPulseCarryWeightReport) and On Report Changed. The designer shows Preview Report (sample values: 40 -> 36.4 of 100 -> 120 kg, Backpack -5.6 kg, Hard +2 kg, Strong back x1.2).
Opening it. Open Carry Weight Menu (UPulseCarryWeightLibrary::OpenCarryWeightMenu(PlayerController, MenuClass, Inventory)) opens it through the UI presenter of Pulse Foundation on the Menu layer (UPulseUIPresenter::OpenWidget; with an inventory OpenWidgetOnLayer with a setup that sets it before the activation). Menu Class takes a Blueprint child of it, empty opens the default. In Pulse Frontend add an entry with the action Open Widget and the class Pulse Carry Weight Menu (or a child) to the Pause Menu Entries (Project Settings > Pulse > Gameplay > Frontend): the frontend presenter puts it into the stack of the pause menu, Close or the back key of the menu goes back. An entry in the Main Menu Entries works as well, but there is no player pawn yet, so it shows “No inventory”.
The rules are pure in Pulse::InventoryUI (PulseCarryWeightTypes.h): BuildCarryWeightReport (of a view, also a planned state, with the limit sources as a parameter; or of a component, which adds the tuning sources and takes load, limit and overloaded from the component), GetLoadFraction, GetFreeWeight, FormatCarryWeight, FormatCarryWeightLoad, FormatCarryWeightLimit, FormatWeightChange, FormatLimitFactor. Specs: PulseInventoryUI.CarryWeight.
Settings (UPulseInventoryUISettings, Project Settings > Pulse > Gameplay > Inventory UI)
| Setting | Meaning |
|---|---|
ItemTooltipClass | Tooltip widget of items (default W_DefaultItemTooltip). |
TooltipSections | Sections of the stat grid (default: consumable, equipped stats, rolled stats, durability). |
CooldownUpdateInterval | Seconds between two cooldown updates while one runs. |
HotbarPlacement | Adds the hotbar by code when the UI host shows none (bAddByCode, default off; W_DefaultHotbar, anchor (0.5, 1), offset (0, 24)). |
HotbarViewModelClass | View model the hotbar widget creates for itself (default UMVVMPulseHotbar). A child class (C++ or Blueprint) adds fields of its own without a widget subclass; the widget sets MinSlotCount on it right after creating it. Empty or a class that does not fit uses UMVVMPulseHotbar. |
ItemSlotViewModelClass | View model of one hotbar slot, created by the hotbar view model (default UMVVMPulseItemSlot); empty uses the base class. |
Specs of the view model classes: PulseInventoryUI.ViewModels.
Switching it off. UPulseInventoryUISubsystem is switchable: add it to Disabled Subsystems (Project Settings > Pulse > Foundation > Subsystems) when your game brings its own hotbar. See Replacing and switching off subsystems.
Cheats
| Cheat | Does |
|---|---|
PulseInventoryUITooltip <item> [seed] | Shows the tooltip of an item definition at the mouse (seed: rolls its random stats), again hides it. Needs the Pulse HUD (other UI hosts show tooltips only over a widget). |
To try the hotbar: PulseCombatInventorySetup, PulseInventoryGive DA_PulseExample_Potion 4, PulseInventoryEquip DA_PulseExample_Potion Pulse.Equipment.Hotbar.2, PulseInventoryUse DA_PulseExample_Potion (the example items in /PulseGameplay/Combat/Examples have icons).