Duckstation/dep/rcheevos/include/rc_api_info.h

228 lines
8.1 KiB
C
Raw Normal View History

2022-07-18 12:46:12 +00:00
#ifndef RC_API_INFO_H
#define RC_API_INFO_H
#include "rc_api_request.h"
2023-11-06 09:41:10 +00:00
#include <stdint.h>
2022-07-18 12:46:12 +00:00
#include <time.h>
2024-01-13 04:24:04 +00:00
RC_BEGIN_C_DECLS
2022-07-18 12:46:12 +00:00
/* --- Fetch Achievement Info --- */
/**
* API parameters for a fetch achievement info request.
*/
typedef struct rc_api_fetch_achievement_info_request_t {
/* The username of the player */
const char* username;
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the achievement */
2023-11-06 09:41:10 +00:00
uint32_t achievement_id;
2022-07-18 12:46:12 +00:00
/* The 1-based index of the first entry to retrieve */
2023-11-06 09:41:10 +00:00
uint32_t first_entry;
2022-07-18 12:46:12 +00:00
/* The number of entries to retrieve */
2023-11-06 09:41:10 +00:00
uint32_t count;
2022-07-18 12:46:12 +00:00
/* Non-zero to only return unlocks earned by the user's friends */
2023-11-06 09:41:10 +00:00
uint32_t friends_only;
2022-07-18 12:46:12 +00:00
}
rc_api_fetch_achievement_info_request_t;
/* An achievement awarded entry */
typedef struct rc_api_achievement_awarded_entry_t {
/* The user associated to the entry */
const char* username;
/* When the achievement was awarded */
time_t awarded;
}
rc_api_achievement_awarded_entry_t;
/**
* Response data for a fetch achievement info request.
*/
typedef struct rc_api_fetch_achievement_info_response_t {
/* The unique identifier of the achievement */
2023-11-06 09:41:10 +00:00
uint32_t id;
2022-07-18 12:46:12 +00:00
/* The unique identifier of the game to which the leaderboard is associated */
2023-11-06 09:41:10 +00:00
uint32_t game_id;
2022-07-18 12:46:12 +00:00
/* The number of times the achievement has been awarded */
2023-11-06 09:41:10 +00:00
uint32_t num_awarded;
2022-07-18 12:46:12 +00:00
/* The number of players that have earned at least one achievement for the game */
2023-11-06 09:41:10 +00:00
uint32_t num_players;
2022-07-18 12:46:12 +00:00
/* An array of recently rewarded entries */
rc_api_achievement_awarded_entry_t* recently_awarded;
/* The number of items in the recently_awarded array */
2023-11-06 09:41:10 +00:00
uint32_t num_recently_awarded;
2022-07-18 12:46:12 +00:00
/* Common server-provided response information */
rc_api_response_t response;
}
rc_api_fetch_achievement_info_response_t;
2024-01-13 04:24:04 +00:00
RC_EXPORT int RC_CCONV rc_api_init_fetch_achievement_info_request(rc_api_request_t* request, const rc_api_fetch_achievement_info_request_t* api_params);
2024-06-24 01:27:43 +00:00
/* [deprecated] use rc_api_process_fetch_achievement_info_server_response instead */
2024-01-13 04:24:04 +00:00
RC_EXPORT int RC_CCONV rc_api_process_fetch_achievement_info_response(rc_api_fetch_achievement_info_response_t* response, const char* server_response);
RC_EXPORT int RC_CCONV rc_api_process_fetch_achievement_info_server_response(rc_api_fetch_achievement_info_response_t* response, const rc_api_server_response_t* server_response);
RC_EXPORT void RC_CCONV rc_api_destroy_fetch_achievement_info_response(rc_api_fetch_achievement_info_response_t* response);
2022-07-18 12:46:12 +00:00
/* --- Fetch Leaderboard Info --- */
/**
* API parameters for a fetch leaderboard info request.
*/
typedef struct rc_api_fetch_leaderboard_info_request_t {
/* The unique identifier of the leaderboard */
2023-11-06 09:41:10 +00:00
uint32_t leaderboard_id;
2022-07-18 12:46:12 +00:00
/* The number of entries to retrieve */
2023-11-06 09:41:10 +00:00
uint32_t count;
2022-07-18 12:46:12 +00:00
/* The 1-based index of the first entry to retrieve */
2023-11-06 09:41:10 +00:00
uint32_t first_entry;
2022-07-18 12:46:12 +00:00
/* The username of the player around whom the entries should be returned */
const char* username;
}
rc_api_fetch_leaderboard_info_request_t;
/* A leaderboard info entry */
typedef struct rc_api_lboard_info_entry_t {
/* The user associated to the entry */
const char* username;
/* The rank of the entry */
2023-11-06 09:41:10 +00:00
uint32_t rank;
2022-07-18 12:46:12 +00:00
/* The index of the entry */
2023-11-06 09:41:10 +00:00
uint32_t index;
2022-07-18 12:46:12 +00:00
/* The value of the entry */
2023-11-06 09:41:10 +00:00
int32_t score;
2022-07-18 12:46:12 +00:00
/* When the entry was submitted */
time_t submitted;
}
rc_api_lboard_info_entry_t;
/**
* Response data for a fetch leaderboard info request.
*/
typedef struct rc_api_fetch_leaderboard_info_response_t {
/* The unique identifier of the leaderboard */
2023-11-06 09:41:10 +00:00
uint32_t id;
2022-07-18 12:46:12 +00:00
/* The format to pass to rc_format_value to format the leaderboard value */
int format;
/* If non-zero, indicates that lower scores appear first */
2023-11-06 09:41:10 +00:00
uint32_t lower_is_better;
2022-07-18 12:46:12 +00:00
/* The title of the leaderboard */
const char* title;
/* The description of the leaderboard */
const char* description;
/* The definition of the leaderboard to be passed to rc_runtime_activate_lboard */
const char* definition;
/* The unique identifier of the game to which the leaderboard is associated */
2023-11-06 09:41:10 +00:00
uint32_t game_id;
2022-07-18 12:46:12 +00:00
/* The author of the leaderboard */
const char* author;
/* When the leaderboard was first uploaded to the server */
time_t created;
/* When the leaderboard was last modified on the server */
time_t updated;
/* An array of requested entries */
rc_api_lboard_info_entry_t* entries;
/* The number of items in the entries array */
2023-11-06 09:41:10 +00:00
uint32_t num_entries;
2022-07-18 12:46:12 +00:00
/* Common server-provided response information */
rc_api_response_t response;
}
rc_api_fetch_leaderboard_info_response_t;
2024-01-13 04:24:04 +00:00
RC_EXPORT int RC_CCONV rc_api_init_fetch_leaderboard_info_request(rc_api_request_t* request, const rc_api_fetch_leaderboard_info_request_t* api_params);
2024-06-24 01:27:43 +00:00
/* [deprecated] use rc_api_process_fetch_leaderboard_info_server_response instead */
2024-01-13 04:24:04 +00:00
RC_EXPORT int RC_CCONV rc_api_process_fetch_leaderboard_info_response(rc_api_fetch_leaderboard_info_response_t* response, const char* server_response);
RC_EXPORT int RC_CCONV rc_api_process_fetch_leaderboard_info_server_response(rc_api_fetch_leaderboard_info_response_t* response, const rc_api_server_response_t* server_response);
RC_EXPORT void RC_CCONV rc_api_destroy_fetch_leaderboard_info_response(rc_api_fetch_leaderboard_info_response_t* response);
2022-07-18 12:46:12 +00:00
/* --- Fetch Games List --- */
/**
* API parameters for a fetch games list request.
*/
typedef struct rc_api_fetch_games_list_request_t {
/* The unique identifier of the console to query */
2023-11-06 09:41:10 +00:00
uint32_t console_id;
2022-07-18 12:46:12 +00:00
}
rc_api_fetch_games_list_request_t;
/* A game list entry */
typedef struct rc_api_game_list_entry_t {
/* The unique identifier of the game */
2023-11-06 09:41:10 +00:00
uint32_t id;
2022-07-18 12:46:12 +00:00
/* The name of the game */
const char* name;
}
rc_api_game_list_entry_t;
/**
* Response data for a fetch games list request.
*/
typedef struct rc_api_fetch_games_list_response_t {
/* An array of requested entries */
rc_api_game_list_entry_t* entries;
/* The number of items in the entries array */
2023-11-06 09:41:10 +00:00
uint32_t num_entries;
2022-07-18 12:46:12 +00:00
/* Common server-provided response information */
rc_api_response_t response;
}
rc_api_fetch_games_list_response_t;
2024-01-13 04:24:04 +00:00
RC_EXPORT int RC_CCONV rc_api_init_fetch_games_list_request(rc_api_request_t* request, const rc_api_fetch_games_list_request_t* api_params);
2024-06-24 01:27:43 +00:00
/* [deprecated] use rc_api_process_fetch_games_list_server_response instead */
2024-01-13 04:24:04 +00:00
RC_EXPORT int RC_CCONV rc_api_process_fetch_games_list_response(rc_api_fetch_games_list_response_t* response, const char* server_response);
RC_EXPORT int RC_CCONV rc_api_process_fetch_games_list_server_response(rc_api_fetch_games_list_response_t* response, const rc_api_server_response_t* server_response);
RC_EXPORT void RC_CCONV rc_api_destroy_fetch_games_list_response(rc_api_fetch_games_list_response_t* response);
2022-07-18 12:46:12 +00:00
2024-06-24 01:27:43 +00:00
/* --- Fetch Game Titles --- */
/**
* API parameters for a fetch games list request.
*/
typedef struct rc_api_fetch_game_titles_request_t {
/* An array of game ids to fetch titles for */
const uint32_t* game_ids;
/* The number of items in the game_ids array */
uint32_t num_game_ids;
}
rc_api_fetch_game_titles_request_t;
/* A game title entry */
typedef struct rc_api_game_title_entry_t {
/* The unique identifier of the game */
uint32_t id;
/* The title of the game */
const char* title;
/* The image name for the game badge */
const char* image_name;
}
rc_api_game_title_entry_t;
/**
* Response data for a fetch games title request.
*/
typedef struct rc_api_fetch_game_titles_response_t {
/* An array of requested entries */
rc_api_game_title_entry_t* entries;
/* The number of items in the entries array */
uint32_t num_entries;
/* Common server-provided response information */
rc_api_response_t response;
}
rc_api_fetch_game_titles_response_t;
RC_EXPORT int RC_CCONV rc_api_init_fetch_game_titles_request(rc_api_request_t* request, const rc_api_fetch_game_titles_request_t* api_params);
RC_EXPORT int RC_CCONV rc_api_process_fetch_game_titles_server_response(rc_api_fetch_game_titles_response_t* response, const rc_api_server_response_t* server_response);
RC_EXPORT void RC_CCONV rc_api_destroy_fetch_game_titles_response(rc_api_fetch_game_titles_response_t* response);
2024-01-13 04:24:04 +00:00
RC_END_C_DECLS
2022-07-18 12:46:12 +00:00
#endif /* RC_API_INFO_H */