MVVM & UI
Table of Contents
- Overview
- Getting the View Model
- View Model Hierarchy
UMVVMPulseQuestManagerUMVVMPulseQuestUMVVMPulseObjectiveUMVVMPulseQuestManagerData- Binding in UMG
Overview
The module PulseQuestMVVM has UMVVMViewModelBase view models (plugin ModelViewViewModel) for the runtime objects. They follow the quest manager on every machine, including clients. The core module does not know them; they listen to the events of the runtime, quest data, objectives and manager data.
C++ users add PulseQuestMVVM to their module dependencies.
Getting the View Model
Get Quest Manager View Model (Quest Manager) → UMVVMPulseQuestManager
UMVVMPulseQuestManager::GetQuestManagerViewModel creates the view model on the first call and keeps it as long as the quest manager lives, so every widget gets the same one. Use it in the view model creation of a widget (“Create Instance” with a Blueprint function or “Resolver”).
View Model Hierarchy
UMVVMPulseQuestManager
├─ QuestManagerData: UMVVMPulseQuestManagerData history, story flags, tracked quest
├─ ActiveQuestsMap: tag → UMVVMPulseQuest
│ └─ ObjectivesMap: handle → UMVVMPulseObjective
└─ TrackedQuest: UMVVMPulseQuest
The classes are set in Project Settings → Pulse → Quest → UI (UPulseQuestMVVMSettings). Empty uses the base class.
UMVVMPulseQuestManager
| Field notify | Description |
|---|---|
QuestManagerData | View model of the manager data (null on clients until the data arrived) |
ActiveQuestsMap / Get Active Quests | Running quests |
Get Active Objectives | Objectives of all running quests, e.g. for a HUD tracker |
TrackedQuest | The quest the player tracks |
Find Quest(Tag). Events: OnQuestStartedEvent, OnQuestFinishedEvent (the quest view model is removed from the active quests after it). Blueprint overrides: Initialize, On Quest Started, On Quest Finished.
UMVVMPulseQuest
| Field notify | Description |
|---|---|
DisplayName / Description | Texts of the quest asset |
FinishResult / Is Finished | Result, None while the quest runs |
bTracked | Whether the player tracks this quest |
ObjectivesMap / Get Objectives / Get Visible Objectives | Running objectives (visible: without bHidden) |
Get Quest, Get Quest Tag, Get Quest Manager, Find Objective(Handle), QuestData. Events: OnObjectiveStartedEvent, OnObjectiveCompletedEvent. Blueprint overrides: Initialize, On Objective Started, On Objective Completed.
UMVVMPulseObjective
| Field notify | Description |
|---|---|
CompletionStatus / Is Completed | InProgress, Success, Failure, Stopped |
DisplayText | Display text with {Progress} and {Target} applied |
Progress / TargetProgress / Get Progress Ratio / Has Progress | Progress of the objective |
bOptional / bHidden | UI hints |
Targets | Marker targets (actor or location, radius) for compass and map |
Get Objective Handle, Get Quest Data, Objective. Blueprint override: Initialize. RefreshFromObjective is virtual for own fields in a subclass.
UMVVMPulseQuestManagerData
| Field notify | Description |
|---|---|
QuestHistory | Finished quests |
StoryFlags | Story flags |
TrackedQuest | Tag of the tracked quest |
Get Finished Quests(Results) filters the history, e.g. for a list of completed quests.
Binding in UMG
Blueprint: Quest list widget with MVVM
- Optional: set own view model classes in Project Settings → Pulse → Quest UI.
- Widget: add a view model of type
MVVMPulse Quest Manager, creation typeManual; on construct:Find Quest Manager(owning player) →Get Quest Manager View Model→Set View Model. - Bind a list view to
Get Active Quests; each entry widget gets itsMVVMPulse Quest, bind texts toDisplay NameandDescription. - Objectives: entry widget bound to
Get Visible Objectivesof the quest view model,Display Text,Get Progress RatioandIs Completedfor the state. - HUD tracker: bind to
Tracked Questof the manager view model.
The player chooses the tracked quest in the UI: call a server RPC of your player controller that calls Set Tracked Quest on the manager data.