Technical Overview
This is a broad-strokes overview of how the PROTO Profiles & Options plugin operates.
Subsystem
The central hub for logic in the plugin is UProtoProfilesSubsystem, an Engine Subsystem.
This singleton class is created when the engine starts. It reads the static data for Save Categories defined in Project Settings, and uses this data to create UProtoProfilesSaveManager objects for those Categories.
- Global Categories each get Save Managers, created at Engine-start.
- Profile Categories each get Save Managers, created by-request when Profiles are “opened”.
The Subsystem has a large suite of Blueprint-exposed functions for accessing and manipulating all saved data. Generally, users of the plugin only need to use the Subsystem to do everything they need to do. You can browse the full suite of functions here.
Save Manager
The UProtoProfilesSaveManager class manages all logic for one given Save Category.
Save Managers are designed to interact with the Subsystem (see above), and not be interacted-with directly by users of the plugin.
Save Managers handle various tasks:
- Tracking the state of each Savefield in the Category.
- Caching changes to Savefields, for “committing” and “reverting” changes.
- For Global Categories, handling logic for manipulating GameUserSettings
- Loading data from-file, and saving data to-file.
Save Managers store the state of Savefields in a UProtoProfilesSaveGame.
For Global Categories, Savefields that manipulate GameUserSettings are handled separately, and only save to .INI files. This means Save Managers have various points where logic branches for GameUserSetting Savefields. The goal is to abstract GameUserSettings-specific logic away from users, allowing them to be accessed in the same way as other Savefields.
Categories that Appear in Menus
If a Category is set to appear in menus, its Save Manager will spawn additional UObjects to facilitate virtualized lists in UMG (See “ListView / ListEntry”, below)
This adds a little overhead to a Save Manager, which is why you can specify whether a Category appears in menus in your Project Settings. Additionally, if you need to display Savefields in menus for development/debug purposes, you can choose for them to only appear in menus in dev builds and not ship builds.
Save Game
The class UProtoProfilesSaveGame is a subclass of USaveGame, and is used to store the value of all Savefields in a single Category. A UProtoProfilesSaveManager uses it to store Savefields in memory, and serializes it when saving values to-file.
This save game class will be serialized into a binary .sav file, similar to Unreal’s default save/load logic in GameplayStatics.h.
ListView / ListEntry
For displaying Savefields in menus, the classes UProtoProfilesListView and UProtoProfilesListEntry implement a specialized UListView for displaying a virtualized list of menus.
Virtualized lists (using Unreal’s UListView) use arrays of UObjects that implement IUserObjectListEntry in order to populate their list.
BenUI has a good article to learn about UListView here.