JD2022-TU1/main/extern/UplaySDK/include/Uplay/UplayWin.h

317 lines
11 KiB
C

/**
* @file UplayWin.h
* @brief The Uplay PC User API
*/
#ifndef UPLAY_WIN_H
#define UPLAY_WIN_H
#include "Uplay/UplayOverlapped.h"
#include "Uplay/UplayTypes.h"
#if _MSC_VER > 1000
#pragma once
#endif
#ifndef UPLAY_API
#ifdef _WIN32
#if defined EXPORTING_DLL
#define UPLAY_API __declspec(dllexport)
#elif defined IMPORTING_DLL
#define UPLAY_API __declspec(dllimport)
#else
#define UPLAY_API
#endif
#endif // _Win32
#ifdef __APPLE__
#define UPLAY_API __attribute__((visibility("default")))
#define __cdecl
#endif // __APPLE__
#endif // UPLAY_API
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
/**
* @defgroup win Win
* @brief Functions for the Win subsystem
*
* @{
*/
#pragma pack(push, 8)
typedef struct UPLAY_WIN_ConditionalRewardNameList
{
/** The number of entries in the \c list member */
UPLAY_uint32 count;
/** A list of names */
const char** list;
} UPLAY_WIN_ConditionalRewardNameList;
/************************************************************************************//**
* @struct UPLAY_WIN_Action
* @brief Struct containing information about a Uplay Action
*/
typedef struct UPLAY_WIN_Action_t
{
/** Null terminated UTF-8 string containing the platform specific id. */
const char* idUtf8;
/** Null terminated UTF-8 string containing the name. */
const char* nameUtf8;
/** Null terminated UTF-8 string containing the description. */
const char* descriptionUtf8;
/** Null terminated UTF-8 string containing the image URL. */
const char* imageUrlUtf8;
/** The amount of units the action is worth. */
UPLAY_uint32 units;
/** Determines whether the action has been completed or not. Valid values are UPLAY_true or UPLAY_false. */
UPLAY_uint8 completed;
/** List of conditional names. Null if the action is not conditional. */
UPLAY_WIN_ConditionalRewardNameList* conditionalRewardNames;
/** Null terminated UTF-8 string containing the code. */
const char* codeUtf8;
} UPLAY_WIN_Action;
/************************************************************************************//**
* @struct UPLAY_WIN_Reward
* @brief Struct containing information about a Uplay Reward
*/
typedef struct UPLAY_WIN_Reward_t
{
/** Null terminated UTF-8 string containing the id of the reward. */
const char* idUtf8;
/** Null terminated UTF-8 string containing the name. */
const char* nameUtf8;
/** Null terminated UTF-8 string containing the description. */
const char* descriptionUtf8;
/** Null terminated UTF-8 string containing the URL of the reward. */
const char* urlUtf8;
/** The unit cost */
UPLAY_uint32 units;
/** Null terminated UTF-8 string containing the Uplay Game Code of the corresponding game. */
const char* gameCodeUtf8;
/** Null terminated UTF-8 string containing the Uplay Platform Code of the corresponding game. */
const char* platformCodeUtf8;
/** Null terminated UTF-8 string containing the image URL of the reward. */
const char* imageUrlUtf8;
/** Determines whether the reward has been redeemed or not. Valid values are UPLAY_true or UPLAY_false. */
UPLAY_uint8 redeemed;
} UPLAY_WIN_Reward;
/************************************************************************************//**
* @struct UPLAY_WIN_ActionList
* @brief Struct representing a list of Uplay Actions
*/
typedef struct UPLAY_WIN_ActionList_t
{
/** Number of elements in the list */
UPLAY_uint32 count;
/** List of Uplay Actions */
const UPLAY_WIN_Action** list;
} UPLAY_WIN_ActionList;
/************************************************************************************//**
* @struct UPLAY_WIN_RewardList
* @brief Struct representing a list of Uplay Rewards
*/
typedef struct UPLAY_WIN_RewardList_t
{
/** Number of elements in the list */
UPLAY_uint32 count;
/** List of Uplay Rewards */
const UPLAY_WIN_Reward** list;
} UPLAY_WIN_RewardList;
/*==========================
* Events
*/
/************************************************************************************//**
* @struct UPLAY_WIN_RewardReedemed
* @brief Event struct for when a Reward has been redeemed.
*/
struct UPLAY_WIN_RewardReedemed
{
/** The redeemed Reward */
const UPLAY_WIN_Reward* reward;
};
/************************************************************************************//**
* @struct UPLAY_WIN_UnitBalanceChanged
* @brief Event struct for when the unit balance is changed.
*/
struct UPLAY_WIN_UnitBalanceChanged
{
/** The balance */
UPLAY_uint32 balance;
};
#pragma pack(pop)
/************************************************************************************//**
* @fn int UPLAY_WIN_SetActionsCompleted(const char*, UPLAY_Overlapped*)
* @brief Set actions as completed.
*
* Call this method to set actions as completed. If the call fails, the call has to be done
* again until succeeded. If actions are already completed calling this method has no effect.
* To make sure all necessary actions are completed, it's recommended to call this method on
* every game startup.
*
* The following ::UPLAY_OverlappedResult values can be returned:
*
* Result | Description
* -------------------------------------- | -----------
* UPLAY_OverlappedResult_Failed | Unknown error
* UPLAY_OverlappedResult_Ok | Success
*
* @note More overlapped results can be added in future versions of the API.
*
* @param aActionIdsUtf8
* An array of null terminated UTF-8 strings with IDs of the actions to complete.
* @param aActionIdsCount
* The size of the array.
* @param aOverlapped
* Overlapped struct.
*
* @returns Non-zero on success
*/
int
UPLAY_API UPLAY_WIN_SetActionsCompleted(
const char* const* aActionIdsUtf8,
UPLAY_uint32 aActionIdsCount,
UPLAY_Overlapped* aOverlapped);
/************************************************************************************//**
* @fn int UPLAY_WIN_GetActions(UPLAY_WIN_ActionsList**, UPLAY_Overlapped*)
* @brief Get all Actions for the current user
*
* The following ::UPLAY_OverlappedResult values can be returned:
*
* Result | Description
* -------------------------------------- | -----------
* UPLAY_OverlappedResult_ConnectionError | Dropped connection with the platform
* UPLAY_OverlappedResult_Failed | Unknown error
* UPLAY_OverlappedResult_Ok | Success
*
* @note More overlapped results can be added in future versions of the API.
*
* @param aOutActionList
* Pointer to the list of Actions will be stored here. Call ::UPLAY_WIN_ReleaseActionList() to release the memory.
* @param aOverlapped
* Overlapped struct
*
* @returns Non-zero on success
*/
int
UPLAY_API UPLAY_WIN_GetActions(
UPLAY_WIN_ActionList** aOutActionList,
UPLAY_Overlapped* aOverlapped);
/************************************************************************************//**
* @fn int UPLAY_WIN_ReleaseActionList(UPLAY_WIN_ActionList* aActionsList)
* @brief Release allocated memory from UPLAY_WIN_GetActions
*
* @param aActionList
* Pointer to the allocated UPLAY_WIN_GetActions actions list
*
* @returns Non-zero on success
*/
int
UPLAY_API UPLAY_WIN_ReleaseActionList(
UPLAY_WIN_ActionList* aActionList);
/************************************************************************************//**
* @fn int UPLAY_WIN_GetRewards(UPLAY_WIN_RewardList**, UPLAY_Overlapped*)
* @brief Get all Rewards for the current user.
*
* The following ::UPLAY_OverlappedResult values can be returned:
*
* Result | Description
* -------------------------------------- | -----------
* UPLAY_OverlappedResult_ConnectionError | Dropped connection with the platform
* UPLAY_OverlappedResult_Failed | Unknown error
* UPLAY_OverlappedResult_Ok | Success
*
* @note More overlapped results can be added in future versions of the API.
*
* @param aOutRewardsList
* Pointer to the list of Rewards will be stored here. Call ::UPLAY_WIN_ReleaseRewardList() to release the memory.
* @param aOverlapped
* Overlapped struct
*
* @returns Non-zero on success
*
*/
int
UPLAY_API UPLAY_WIN_GetRewards(
UPLAY_WIN_RewardList** aOutRewardList,
UPLAY_Overlapped* aOverlapped);
/************************************************************************************//**
* @fn int UPLAY_WIN_ReleaseRewardList(UPLAY_WIN_RewardList* aRewardList)
* @brief Release allocated memory from UPLAY_WIN_GetRewards
*
* @param aRewardsList
* Pointer to the allocated UPLAY_WIN_GetRewards rewards list
*
* @returns Non-zero on success
*/
int
UPLAY_API UPLAY_WIN_ReleaseRewardList(
UPLAY_WIN_RewardList* aRewardList);
/************************************************************************************//**
* @fn int UPLAY_WIN_GetUnitBalance(UPLAY_uint32*, UPLAY_Overlapped*)
* @brief Get the unit balance for current user.
*
* The following ::UPLAY_OverlappedResult values can be returned:
*
* Result | Description
* -------------------------------------- | -----------
* UPLAY_OverlappedResult_ConnectionError | Dropped connection with the platform
* UPLAY_OverlappedResult_Failed | Unknown error
* UPLAY_OverlappedResult_Ok | Success
*
* @note More overlapped results can be added in future versions of the API.
*
* @param aOutBalance
* Pointer where the balance will be stored.
* @param aOverlapped
* Overlapped struct
*
* @returns Non-zero on success
*
*/
int
UPLAY_API UPLAY_WIN_GetUnitBalance(
UPLAY_uint32* aOutBalance,
UPLAY_Overlapped* aOverlapped);
/************************************************************************************//**
* @fn int UPLAY_WIN_RefreshActions()
* @brief Refresh actions in Uplay PC so that completion status is displayed properly
* in overlay and Uplay PC application
*
* @note If UbiServices API is used to set action as completed, then game should call
* UPLAY_WIN_RefreshActions() after action was marked as completed from UbiServices.
* If UPLAY_WIN_SetActionsCompleted is used to set action as completed,
* using UPLAY_WIN_RefreshActions() is not required and even not recommended
* as it generates additional load on the servers.
*
* @returns Non-zero on success
*/
int
UPLAY_API UPLAY_WIN_RefreshActions();
/** @} */
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // UPLAY_WIN_H