UI (MVVM)

The PulseOnlineMVVM module provides view models for the party and for leaderboards. They update only when the data changes.

Party view model (UPulseOnlinePartyViewModel)

FieldNotify properties: bIsInParty, bIsLocalPlayerLeader, PartyState, MemberCount, MaxMembers, LeaderDisplayName, bIsBeaconConnected, bCanStartMatchmaking, PartyData, Members, and with the voice module bIsInPartyVoice, bIsInGameVoice, VoiceTransmitMode.

  • With bUseFixedSlots (setting Use Fixed Party Slots) Members always has MaxPartySize entries; empty slots have bIsValid = false. Slot 0 is the local player.
  • Member view models are reused per member: when somebody joins or leaves, the other members keep their view model instance and widget bindings.
  • Commands return the started request (use it with Execute Online Request): CreateParty, LeaveParty, StartMatchmaking, CancelMatchmaking, KickMember, PromoteMember, InviteFriend, SetLocalMemberData, ReturnToLobby, SendMessage. Voice: ToggleMuteMember, SetTransmitMode, RefreshVoice (called automatically when the voice state changes).
  • OnMessageReceived(SenderViewModel, Message) forwards party messages (payload via GetMessagePayload).

Member view model (UPulseOnlinePartyMemberViewModel)

FieldNotify properties: bIsValid, NetId, DisplayName, bIsLeader, bIsLocal, Status, SlotIndex, Data, bIsTalking, bIsMuted (voice, see Voice Chat). Helpers GetDataString/Int/Float/Bool, command SendMessageTo.

Game specific fields: derive, add FieldNotify properties and override SyncFromMember:

UCLASS()
class UMyPartyMemberViewModel : public UPulseOnlinePartyMemberViewModel
{
	GENERATED_BODY()
public:
	UPROPERTY(BlueprintReadOnly, FieldNotify, Category = "Party")
	FName CharacterId;

	UPROPERTY(BlueprintReadOnly, FieldNotify, Category = "Party")
	bool bIsReady = false;

protected:
	virtual void SyncFromMember_Implementation(const FPulseOnlinePartyMember& Member) override
	{
		const FPulseOnlineSetting* character = Member.Data.Find(TEXT("Character"));
		UE_MVVM_SET_PROPERTY_VALUE(CharacterId, character ? FName(character->GetAsString()) : NAME_None);
		UE_MVVM_SET_PROPERTY_VALUE(bIsReady, UPulseOnlineSettingLibrary::FindBool(Member.Data, TEXT("Ready"), false));
	}
};

Set it as Party Member View Model Class in the settings (and an own party view model class if needed).

Getting the view model in a widget

UPulseOnlinePartyViewModelSubsystem (local player subsystem) creates and keeps one party view model per local player.

  • In the widget’s View Bindings add a Pulse Party Viewmodel with Creation Type = Resolver and pick Pulse Party Viewmodel Resolver. The widget gets the view model of its owning local player (split screen works).
  • Or with Register Party View Model Globally: Creation Type Global Viewmodel Collection, context name PulseParty.
  • C++: UPulseOnlinePartyViewModelSubsystem::GetPartyViewModel(LocalPlayer).

Example: lobby widget

  • Four slot widgets, each bound to Members[i]: name → DisplayName, crown visibility → bIsLeader, ready check → bIsReady of your subclass, “In match” label → Status, whole slot visibility → bIsValid.
  • Play button: enabled → bCanStartMatchmaking, click → StartMatchmaking.
  • The 3D spots in the lobby world can use the same member view models (e.g. FindMember(NetId) or Members[i]), so widgets and scene always show the same slot.

Blueprint: Lobby widget commands with the party view model

  1. View Bindings: Pulse Party Viewmodel, Creation Type Resolver, resolver Pulse Party Viewmodel Resolver.
  2. Play button On Clicked → Party Viewmodel → Start Matchmaking (Search Request and Host Request can stay empty for the defaults) → Execute Online Request.
  3. Slot widget kick button → Party Viewmodel → Kick Member (the slot’s member view model).
  4. Slot widget mute button → Party Viewmodel → Toggle Mute Member (the slot’s member view model).

Leaderboard view model (UPulseOnlineLeaderboardViewModel)

Shows a part of a leaderboard (module PulseOnlineStats, see Stats and Leaderboards). Set LeaderboardId, Range (Top, AroundUser, Friends) and Count (0 = Default Leaderboard Count), then call Refresh(WorldContext) (e.g. on construct of the widget).

FieldNotify properties: Entries (row view models, best first), LocalUserEntry (the row of the local user or null), bIsLoading, bIsEmpty, ErrorText. Rows are reused by index, so list widgets keep their entries. When the same leaderboard is read anywhere else in the game instance, the rows update too.

Row view model UPulseOnlineLeaderboardEntryViewModel: Rank, UserId, DisplayName, Score, bIsLocalUser. For own fields derive, set EntryClass on the leaderboard view model and override SyncFromEntry.


This site uses Just the Docs, a documentation theme for Jekyll.