FAchievements
Achievements and stats for game code, whatever platform is (or is not) up. Every write lands in a local store first — the game reads its own values back with no Steam client, and the editor can test unlock logic in PIE — and is queued for the primary online service. The queue drains once that service has the player's current values, and a debounced StoreStats uploads it; the shutdown flush stores whatever is left. When the platform's values arrive, unlocks and stats the player earned offline are pushed up and ones earned elsewhere are pulled down (stats keep the larger value).
- Module
- Networking
- Header
#include "Networking/Achievements.h"- Namespace
Mowo
Constructors
| Signature | Name | Description |
|---|---|---|
FAchievements(const FAchievements&) = delete | FAchievements |
Public functions
| Returns | Name | Description |
|---|---|---|
FAchievements& | Get | |
FAchievements& | operator= | |
bool | LoadDefinitions | Definitions from an Achievements.ini; false (and nothing defined) when the file is missing or malformed. |
bool | LoadDefinitionsFromText | |
bool | LoadProjectDefinitions | Config/Achievements.ini under configDir, or under the packaged game's Config/ when empty. |
const std::vector<FAchievementDefinition>& | GetAchievements | |
const std::vector<FStatDefinition>& | GetStats | |
const FAchievementDefinition* | FindAchievement | |
const FStatDefinition* | FindStat | |
void | SetLocalStorePath | The local store's file. |
const std::string& | GetLocalStorePath | |
bool | SetAchievement | |
bool | ClearAchievement | |
bool | IsAchievementUnlocked | |
bool | SetStatInt | |
bool | SetStatFloat | |
bool | AddStatInt | |
int32_t | GetStatInt | |
float | GetStatFloat | |
bool | IndicateProgress | Shows the platform's progress popup; unlocking stays with SetAchievement or the achievement's ProgressStat. |
void | Update | The per-frame pump (FOnlineServices::UpdateAll): binds the primary service's callbacks, drains the queue into it once its stats are ready, and stores after StoreDelaySeconds without a new write (at most 4 x StoreDelaySeconds after the first one). |
void | Update | |
void | Flush | Drains, stores and saves now. |
void | UnbindService | The service FAchievements registered its callbacks on is going away. |
size_t | GetPendingCount | |
uint32_t | GetStoreCount | |
void | SetStoreDelaySeconds | |
float | GetStoreDelaySeconds | |
void | SetUnlockHandler | Runs once per achievement the player newly unlocks, platform or not — the game's own toast. |
std::string | PopUnlocked | |
void | Reset | Forgets definitions, values, the queue and the store path. |
Function details
FAchievements
FAchievements(const FAchievements&) = deleteGet
static FAchievements& Get()operator=
FAchievements& operator=(const FAchievements&) = deleteLoadDefinitions
bool LoadDefinitions(const std::string& path)Definitions from an Achievements.ini; false (and nothing defined) when the file is missing or malformed. The text form is what the tests drive.
LoadDefinitionsFromText
bool LoadDefinitionsFromText(const std::string& text)LoadProjectDefinitions
bool LoadProjectDefinitions(const std::string& configDir)Config/Achievements.ini under configDir, or under the packaged game's Config/ when empty.
GetAchievements
const std::vector<FAchievementDefinition>& GetAchievements() constGetStats
const std::vector<FStatDefinition>& GetStats() constFindAchievement
const FAchievementDefinition* FindAchievement(const std::string& id) constFindStat
const FStatDefinition* FindStat(const std::string& id) constSetLocalStorePath
void SetLocalStorePath(const std::string& path)The local store's file. Unset, it is AchievementProgress.ini beside the player's save games (the project's Saved/SaveGames in the editor). Setting it loads that file.
GetLocalStorePath
const std::string& GetLocalStorePath()SetAchievement
bool SetAchievement(const std::string& id)ClearAchievement
bool ClearAchievement(const std::string& id)IsAchievementUnlocked
bool IsAchievementUnlocked(const std::string& id)SetStatInt
bool SetStatInt(const std::string& id, int32_t value)SetStatFloat
bool SetStatFloat(const std::string& id, float value)AddStatInt
bool AddStatInt(const std::string& id, int32_t delta)GetStatInt
int32_t GetStatInt(const std::string& id)GetStatFloat
float GetStatFloat(const std::string& id)IndicateProgress
bool IndicateProgress(const std::string& id, uint32_t current, uint32_t max)Shows the platform's progress popup; unlocking stays with SetAchievement or the achievement's ProgressStat.
Update
void Update()The per-frame pump (FOnlineServices::UpdateAll): binds the primary service's callbacks, drains the queue into it once its stats are ready, and stores after StoreDelaySeconds without a new write (at most 4 x StoreDelaySeconds after the first one).
Update
void Update(double nowSeconds)Flush
void Flush()Drains, stores and saves now. Runs before the services shut down.
UnbindService
void UnbindService()The service FAchievements registered its callbacks on is going away.
GetPendingCount
size_t GetPendingCount() constGetStoreCount
uint32_t GetStoreCount() constSetStoreDelaySeconds
void SetStoreDelaySeconds(float seconds)GetStoreDelaySeconds
float GetStoreDelaySeconds() constSetUnlockHandler
void SetUnlockHandler(std::function<void(const std::string&)> handler)Runs once per achievement the player newly unlocks, platform or not — the game's own toast. Unlocks also wait in a queue a Visual Script graph polls with PopUnlocked (empty when none).
PopUnlocked
std::string PopUnlocked()Reset
void Reset()Forgets definitions, values, the queue and the store path. Tests only.