VoltAir
|
Represents a player's profile or "save game" state. More...
Public Types | |
enum | LoadState { UNLOADED, LOADING, LOADED } |
Current status of persistent data in the player profile. More... | |
Signals | |
void | newDataMerged () |
Emitted when new data from either local or cloud storage has been merged into the PlayerProfile. More... | |
Public Member Functions | |
LoadState | getLoadState () const |
Returns the current LoadState of the PlayerProfile. More... | |
LevelInfo * | getLastPlayedLevelInfo (const QString &progressionName) const |
Returns the LevelInfo of the level the player most recently played (or was set to play) in progressionName . More... | |
bool | isEnvironmentUnlocked (const QString &progressionName, const QString &environmentName) const |
Returns whether or not the Environment denoted by environmentName in the LevelProgression denoted by progressionName is unlocked. More... | |
bool | isLevelUnlocked (const QString &progressionName, const QString &levelName) const |
Returns whether or not the Environment denoted by levelName in the LevelProgression denoted by progressionName is unlocked. More... | |
int | getCurrentPlayerScore (int playerId=0) const |
Returns the current score for playerId . More... | |
const QMap< int, int > & | getCurrentPlayerScores () const |
Returns the scores for all players for the current level. More... | |
int | updatePlayerScore (int playerId, int amountChanged) |
Updates the current level score for playerId by amountChanged . More... | |
int | getNumStars (const QString &progressionName, const QString &levelName) const |
Returns the number of star achieved by the player on the level denoted by levelName in the LevelProgression denoted by progressionName . More... | |
bool | hasMinStars (const QString &progressionName, int minStars) const |
Returns whether or not the player has achieved at least a minimum number of stars on each level in the LevelProgression. More... | |
bool | hasMinStars (const QString &progressionName, const QString &environmentName, int minStars) const |
Returns whether or not the player has achieved a minimum number of stars on each level in the Environment. More... | |
void | unlockAchievement (const QString &name, bool immediately) |
Unlocks a Google Play Games Services achievement. More... | |
void | incrementAchievement (const QString &name, int numSteps, bool immediately) |
Increments a Google Play Games Services incremental achievement. More... | |
void | setAchievementSteps (const QString &name, int minSteps, bool immediately) |
Sets a Google Play Games Services incremental achievement to have a minimum number of steps. More... | |
void | revealAchievement (const QString &name, bool immediately) |
Reveals a Google Play Games Services achievement. More... | |
void | showAchievements () |
Requests that the PlayerProfile launch a view of the Google Play Games Services achievements. More... | |
void | startLoad () |
Asynchronously starts a full load of the PlayerProfile from local storage and, if available, cloud data. More... | |
bool | tryFinishLoad () |
Attempts to complete the loading of the PlayerProfile which was asynchronously started with startLoad(). More... | |
void | save () |
Saves the permanent state of the PlayerProfile to local storage and, if available, cloud storage. More... | |
void | saveAchievementsToCloud () |
Tries to push all buffered achievement state updates to the cloud. More... | |
void | reset (bool permanently) |
Clears the temporary and permanent data loaded into the PlayerProfile. More... | |
bool | hasCloudSave () const |
Returns whether or not the device supports cloud save. More... | |
bool | isSignedIntoCloud () const |
Returns whether or not the player is signed into Google Play Games Services. More... | |
bool | cloudSignInFailed () const |
Returns whether or not a previous attempt to sign into Google Play Games Services failed. More... | |
void | signIntoCloud () |
Attempts to sign the player into Google Play Games Services. More... | |
void | signOutOfCloud () |
Signs the player out of Google Play Games Services. More... | |
QJsonDocument | toJsonDocument () |
Returns the PlayerProfile serialized as a JSON document. More... | |
![]() | |
QObject (QObject *parent) | |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
virtual const QMetaObject * | metaObject () const |
QString | objectName () const |
void | setObjectName (const QString &name) |
bool | isWidgetType () const |
bool | isWindowType () const |
bool | signalsBlocked () const |
bool | blockSignals (bool block) |
QThread * | thread () const |
void | moveToThread (QThread *targetThread) |
int | startTimer (int interval, Qt::TimerType timerType) |
void | killTimer (int id) |
T | findChild (const QString &name, QFlags< Qt::FindChildOption > options) const |
QList< T > | findChildren (const QString &name, QFlags< Qt::FindChildOption > options) const |
QList< T > | findChildren (const QRegExp ®Exp, QFlags< Qt::FindChildOption > options) const |
QList< T > | findChildren (const QRegularExpression &re, QFlags< Qt::FindChildOption > options) const |
const QObjectList & | children () const |
void | setParent (QObject *parent) |
void | installEventFilter (QObject *filterObj) |
void | removeEventFilter (QObject *obj) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const |
bool | disconnect (const QObject *receiver, const char *method) const |
void | dumpObjectTree () |
void | dumpObjectInfo () |
bool | setProperty (const char *name, const QVariant &value) |
QVariant | property (const char *name) const |
QList< QByteArray > | dynamicPropertyNames () const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const |
bool | inherits (const char *className) const |
void | deleteLater () |
Friends | |
class | Game |
Additional Inherited Members | |
![]() | |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
![]() | |
QObject * | sender () const |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
virtual void | childEvent (QChildEvent *event) |
virtual void | customEvent (QEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
![]() | |
objectName | |
Represents a player's profile or "save game" state.
This class contains logic for storing information on both temporary game state information (e.g. current Level scores) and more persistent game state information (e.g. which levels are unlocked, stars achieved for completed levels, etc.). This persistent game state information is saved both locally and to the cloud if on an Android device. To have cloud storage be successful, the Android device must be signed into Google Play Games Services – a process which can be started by using signIntoCloud(). Finally, this class provides a mechanism for affecting Achievement changes through Google Play Games Services.
bool PlayerProfile::cloudSignInFailed | ( | ) | const |
Returns whether or not a previous attempt to sign into Google Play Games Services failed.
int PlayerProfile::getCurrentPlayerScore | ( | int | playerId = 0 | ) | const |
Returns the current score for playerId
.
0
is used for single player LevelProgressions. playerId | Player ID [0, 3] of player whose score to query |
|
inline |
Returns the scores for all players for the current level.
The returned value is a map from player ID to score.
Returns the LevelInfo of the level the player most recently played (or was set to play) in progressionName
.
progressionName | Name of the LevelProgression to get the last played LevelInfo for |
|
inline |
Returns the current LoadState of the PlayerProfile.
Returns the number of star achieved by the player on the level denoted by levelName
in the LevelProgression denoted by progressionName
.
progressionName
must be the name of a single player LevelProgression, since star scores are only assigned for single player levels. -1 will be returned if getCurrentLevelProgression()'s LevelProgression::multiplayer property is true
. progressionName | Name of the LevelProgression in which levelName resides |
levelName | Name of the LevelInfo to query for highest number of stars achieved |
bool PlayerProfile::hasCloudSave | ( | ) | const |
Returns whether or not the device supports cloud save.
bool PlayerProfile::hasMinStars | ( | const QString & | progressionName, |
int | minStars | ||
) | const |
Returns whether or not the player has achieved at least a minimum number of stars on each level in the LevelProgression.
progressionName | Name of LevelProgression to query for a minimum number of stars |
minStars | Threshold of stars to query for |
bool PlayerProfile::hasMinStars | ( | const QString & | progressionName, |
const QString & | environmentName, | ||
int | minStars | ||
) | const |
Returns whether or not the player has achieved a minimum number of stars on each level in the Environment.
progressionName | Name of LevelProgression in which environmentName resides |
environmentName | Name of Envirionment to query for a minimum number of stars |
minStars | Threshold of stars to query for |
void PlayerProfile::incrementAchievement | ( | const QString & | name, |
int | numSteps, | ||
bool | immediately | ||
) |
Increments a Google Play Games Services incremental achievement.
name | Android resource name used to locate the achievement id |
numSteps | Number of steps to increment the achievement |
immediately | Whether or not to sync the achievement change with Google Play Games Services now |
bool PlayerProfile::isEnvironmentUnlocked | ( | const QString & | progressionName, |
const QString & | environmentName | ||
) | const |
Returns whether or not the Environment denoted by environmentName
in the LevelProgression denoted by progressionName
is unlocked.
progressionName | Name of LevelProgression in which environmentName resides |
environmentName | Name of Environment to query for locked state |
bool PlayerProfile::isLevelUnlocked | ( | const QString & | progressionName, |
const QString & | levelName | ||
) | const |
Returns whether or not the Environment denoted by levelName
in the LevelProgression denoted by progressionName
is unlocked.
progressionName | Name of LevelProgression in which levelName resides |
levelName | Name of LevelInfo to query for locked state |
bool PlayerProfile::isSignedIntoCloud | ( | ) | const |
Returns whether or not the player is signed into Google Play Games Services.
|
signal |
Emitted when new data from either local or cloud storage has been merged into the PlayerProfile.
void PlayerProfile::reset | ( | bool | permanently | ) |
Clears the temporary and permanent data loaded into the PlayerProfile.
permanently | Whether or not to wipe the PlayerProfile data from local and cloud storage |
void PlayerProfile::revealAchievement | ( | const QString & | name, |
bool | immediately | ||
) |
Reveals a Google Play Games Services achievement.
name | Android resource name used to locate the achievement id |
immediately | Whether or not to sync the achievement change with Google Play Games Services now |
void PlayerProfile::save | ( | ) |
Saves the permanent state of the PlayerProfile to local storage and, if available, cloud storage.
void PlayerProfile::saveAchievementsToCloud | ( | ) |
Tries to push all buffered achievement state updates to the cloud.
void PlayerProfile::setAchievementSteps | ( | const QString & | name, |
int | minSteps, | ||
bool | immediately | ||
) |
Sets a Google Play Games Services incremental achievement to have a minimum number of steps.
name | Android resource name used to locate the achievement id |
minSteps | Lower bound for incremental progress |
immediately | Whether or not to sync the achievement change with Google Play Games Services now |
void PlayerProfile::showAchievements | ( | ) |
Requests that the PlayerProfile launch a view of the Google Play Games Services achievements.
void PlayerProfile::signIntoCloud | ( | ) |
Attempts to sign the player into Google Play Games Services.
void PlayerProfile::signOutOfCloud | ( | ) |
Signs the player out of Google Play Games Services.
void PlayerProfile::startLoad | ( | ) |
Asynchronously starts a full load of the PlayerProfile from local storage and, if available, cloud data.
QJsonDocument PlayerProfile::toJsonDocument | ( | ) |
Returns the PlayerProfile serialized as a JSON document.
bool PlayerProfile::tryFinishLoad | ( | ) |
Attempts to complete the loading of the PlayerProfile which was asynchronously started with startLoad().
void PlayerProfile::unlockAchievement | ( | const QString & | name, |
bool | immediately | ||
) |
Unlocks a Google Play Games Services achievement.
name | Android resource name used to locate the achievement id |
immediately | Whether or not to sync the achievement change with Google Play Games Services now |
int PlayerProfile::updatePlayerScore | ( | int | playerId, |
int | amountChanged | ||
) |
Updates the current level score for playerId
by amountChanged
.
playerId | Player ID [0, 3] of player whose score to change |
amountChanged | Delta value to change the score by |