1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
|
/********************************************************
* *
* Copyright (C) Microsoft. All rights reserved. *
* *
********************************************************/
// Sentient Client AvatarSuperstars Avatar API
//
// Include this to get access to all Avatar-related Sentient features.
#pragma once
#include "SenClientRawData.h"
#include "SenClientResource.h"
#include "SenClientSys.h"
#include "SenClientXML.h"
#include <xnamath.h>
#include <xonline.h>
namespace Sentient
{
//====================//
// //
// Avatar Types //
// //
//====================//
// When enumerating avatars, these are the options for pre-sorting the
// returned list.
enum SenAvatarSortBy
{
SenAvatarSortBy_Default = 0,
// ... TBD ...
};
// This structure contains the information needed to download the
// raw data for a given gender.
struct SenAvatarGenderInfo
{
SenRawDataTransferInfo metadata;
SenRawDataTransferInfo assets;
SenRawDataTransferInfo xml;
SenRawDataTransferInfo icon;
};
// This structure contains the original uploaded info plus info
// needed to download raw data.
struct SenAvatarInfo : public SenResourceInfo
{
int vipLevel;
SenAvatarGenderInfo female;
SenAvatarGenderInfo male;
};
struct SenAvatarPalette
{
XMCOLOR entry[3];
};
struct SenAvatarNamedPalette : SenAvatarPalette
{
wchar_t name[57+1];
};
/// @brief Extra avatar information.
///
/// @details This structure contains additional data about the avatar, such as localized strings and palettes.
///
struct SenAvatarExtraInfo
{
wchar_t title[XMARKETPLACE_MAX_TITLE_NAME_LENGTH+1]; ///< The localized game title associated with the avatar.
wchar_t name[XMARKETPLACE_MAX_OFFER_NAME_LENGTH+1]; ///< The localized name associated with the avatar.
wchar_t description[XMARKETPLACE_MAX_OFFER_SELL_TEXT_LENGTH+1]; ///< The localized short description associated with the avatar.
size_t paletteCount;
SenAvatarNamedPalette palette[16];
};
//========================//
// //
// Avatar Functions //
// //
//========================//
/// @brief Search the database for all the avatars that match the search criteria.
///
/// @param[in] userIndex
/// The index of the initiating user on the console. Note: This is NOT a XUID.
///
/// @param[in] avatarInfoCountMax
/// The number of SenAvatarInfo structures available in @a out_avatarInfoList.
///
/// @param[out] out_avatarInfoCount
/// This is the number of entries actually enumerated by the call.
///
/// @param[out] out_avatarInfoList
/// The structures to fill in with the enumerated information.
/// It is assumed that this is preallocated to at least @a avatarInfoCountMax entries.
///
/// @param[in] userCallback
/// If this call returns a success code, the userCallback will be called at the end of the asynchronous process.
///
/// @param[in] userCallbackData
/// Data to be passed to the @a userCallback on completion.
///
/// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include:
/// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first.
/// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call.
/// E_POINTER: out_avatarInfoList is NULL.
/// E_FAIL: Failed to spawn server call.
/// S_OK: Server call spawned successfully.
///
/// @details Enumerates in default order, at the current time, for all titles.
///
/// @related SenAvatarDownloadExtraInfo()
/// @related SenAvatarDownloadMetadata()
/// @related SenAvatarDownloadAssets()
/// @related SenAvatarDownloadIcon()
///
HRESULT SenAvatarEnumerate(
int userIndex,
size_t avatarInfoCountMax,
size_t *out_avatarInfoCount,
SenAvatarInfo *out_avatarInfoList,
SenSysCompletedCallback userCallback,
void *userCallbackData );
// Search the database for a specific avatar at the current time.
/// @brief Search the database for a specific avatar at the current time
///
/// @param[in] titleID
/// The ID of the title that the avatar item is associated with.
///
/// @param[in] resourceID
/// The ID of the specific asset about which information should be returned.
///
/// @param[out] out_avatarInfo
/// The structures to fill in with the information.
/// It is assumed that this is preallocated to at least 1 entry.
///
/// @param[in] userCallback
/// If this call returns a success code, the userCallback will be called at the end of the asynchronous process.
///
/// @param[in] userCallbackData
/// Data to be passed to the @a userCallback on completion.
///
/// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include:
/// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first.
/// SENTIENT_E_GUEST_ACCESS_VIOLATION: A guest may not spawn this call.
/// E_POINTER: out_avatarInfo is NULL.
/// E_FAIL: Failed to spawn server call.
/// S_OK: Server call spawned successfully.
///
/// @related SenAvatarEnumerate()
/// @related SenAvatarDownloadExtraInfo()
/// @related SenAvatarDownloadMetadata()
/// @related SenAvatarDownloadAssets()
/// @related SenAvatarDownloadIcon()
///
HRESULT SenAvatarFind(
SenSysTitleID titleID,
SenResourceID resourceID,
SenAvatarInfo *out_avatarInfo,
SenSysCompletedCallback userCallback,
void *userCallbackData );
/// @brief Download the avatar metadata to the client.
///
/// @param[in] avatarInfo
/// The info describing the attributes and data of the avatar asset.
/// This is obtained from SenAvatarEnumerate().
///
/// @param[in] male
/// Whether or not to receive information about the male avatar (vs. the female)
///
/// @param[in] dataSizeMax
/// Used to indicate the size of the buffer pointed to by @a out_data.
/// If the actual size of the data exceeds this, you will receive an error.
/// It is assumed that this is at least @a avatarInfo.[fe]male.metadata.GetBufferSize() bytes.
///
/// @param[out] out_data
/// The buffer to fill in with the metadata.
///
/// @param[in] userCallback
/// If this call returns a success code, the userCallback will be called at the end of the asynchronous process.
///
/// @param[in] userCallbackData
/// Data to be passed to the @a userCallback on completion.
///
/// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include:
/// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first.
/// E_INVALIDARG: avatarInfo.resourceID or avatarInfo.[fe]male.metadata is invalid.
/// E_POINTER: out_data is NULL.
/// E_FAIL: Failed to spawn server call.
/// S_OK: Server call spawned successfully.
///
/// @related SenAvatarEnumerate()
/// @related SenAvatarDownloadExtraInfo()
/// @related SenAvatarDownloadAssets()
/// @related SenAvatarDownloadIcon()
///
HRESULT SenAvatarDownloadMetadata(
const SenAvatarInfo &avatarInfo,
bool male,
size_t dataSizeMax,
void *out_data,
SenSysCompletedCallback userCallback,
void *userCallbackData );
/// @brief Download the avatar asset binary data to the client.
///
/// @param[in] avatarInfo
/// The info describing the attributes and data of the avatar asset.
/// This is obtained from SenAvatarEnumerate().
///
/// @param[in] male
/// Whether or not to receive information about the male avatar (vs. the female)
///
/// @param[in] dataSizeMax
/// Used to indicate the size of the buffer pointed to by @a out_data.
/// If the actual size of the data exceeds this, you will receive an error.
/// It is assumed that this is at least @a avatarInfo.[fe]male.assets.GetBufferSize() bytes.
///
/// @param[out] out_data
/// The buffer to fill in with the asset data.
///
/// @param[in] userCallback
/// If this call returns a success code, the userCallback will be called at the end of the asynchronous process.
///
/// @param[in] userCallbackData
/// Data to be passed to the @a userCallback on completion.
///
/// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include:
/// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first.
/// E_INVALIDARG: avatarInfo.resourceID or avatarInfo.[fe]male.assets is invalid.
/// E_POINTER: out_data is NULL.
/// E_FAIL: Failed to spawn server call.
/// S_OK: Server call spawned successfully.
///
/// @related SenAvatarEnumerate()
/// @related SenAvatarDownloadExtraInfo()
/// @related SenAvatarDownloadMetadata()
/// @related SenAvatarDownloadIcon()
///
HRESULT SenAvatarDownloadAssets(
const SenAvatarInfo &avatarInfo,
bool male,
size_t dataSizeMax,
void *out_data,
SenSysCompletedCallback userCallback,
void *userCallbackData );
/// @brief Download the avatar icon binary data to the client.
///
/// @param[in] avatarInfo
/// The info describing the attributes and data of the avatar asset.
/// This is obtained from SenAvatarEnumerate().
///
/// @param[in] male
/// Whether or not to receive information about the male avatar (vs. the female)
///
/// @param[in] dataSizeMax
/// Used to indicate the size of the buffer pointed to by @a out_data.
/// If the actual size of the data exceeds this, you will receive an error.
/// It is assumed that this is at least @a avatarInfo.[fe]male.icon.GetBufferSize() bytes.
///
/// @param[out] out_data
/// The buffer to fill in with the binary icon data.
///
/// @param[in] userCallback
/// If this call returns a success code, the userCallback will be called at the end of the asynchronous process.
///
/// @param[in] userCallbackData
/// Data to be passed to the @a userCallback on completion.
///
/// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include:
/// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first.
/// E_INVALIDARG: avatarInfo.resourceID or avatarInfo.[fe]male.icon is invalid.
/// E_POINTER: out_data is NULL.
/// E_FAIL: Failed to spawn server call.
/// S_OK: Server call spawned successfully.
///
/// @related SenAvatarEnumerate()
/// @related SenAvatarDownloadExtraInfo()
/// @related SenAvatarDownloadMetadata()
/// @related SenAvatarDownloadAssets()
///
HRESULT SenAvatarDownloadIcon(
const SenAvatarInfo &avatarInfo,
bool male,
size_t dataSizeMax,
void *out_data,
SenSysCompletedCallback userCallback,
void *userCallbackData );
/// @brief Download extra information about a given avatar to the client.
///
/// @param[in] avatarInfo
/// The info describing the attributes and data of the avatar.
/// This is obtained from SenAvatarEnumerate().
///
/// @param[in] male
/// Whether or not to receive information about the male avatar (vs. the female).
///
/// @param[out] out_avatarExtraInfo
/// The structure to populate with extra information.
///
/// @param[in] userCallback
/// If this call returns a success code, the userCallback will be called at the end of the asynchronous process.
///
/// @param[in] userCallbackData
/// Data to be passed to the @a userCallback on completion.
///
/// @return Check SUCCEEDED( hresult ) or FAILED( hresult ) to determine success. Specific values include:
/// SENTIENT_E_NOT_INITIALIZED: You did not call SentientInitialize() first.
/// E_INVALIDARG: avatarInfo.resourceID or avatarInfo.xml is invalid.
/// E_POINTER: out_avatarExtraInfo is NULL.
/// E_FAIL: Failed to spawn server call.
/// S_OK: Server call spawned successfully.
///
/// @details On completion, the structure will contain extra information, such as localized strings.
///
/// @related SenAvatarEnumerate()
/// @related SenAvatarDownloadMetadata()
/// @related SenAvatarDownloadAssets()
/// @related SenAvatarDownloadIcon()
///
HRESULT SenAvatarDownloadExtraInfo(
const SenAvatarInfo &avatarInfo,
bool male,
SenAvatarExtraInfo *out_avatarExtraInfo,
SenSysCompletedCallback userCallback, void *userCallbackData );
// Download the raw binary data to the client.
// It is assumed that out_data is preallocated to (at least) dataSizeMax bytes,
// which in turn should be at least avatarInfo.[fe]male.xml.GetBufferSize() bytes.
HRESULT SenAvatarDownloadXML(
const SenAvatarInfo &avatarInfo,
bool male,
size_t dataSizeMax,
void *out_data,
SenSysCompletedCallback userCallback,
void *userCallbackData );
// Obtain a wide, localized string with a given avatar's game title.
//
// Assumes you have already downloaded the XML and run it through
// SenXMLParse() to get a SenXML struct.
//
// First method, filling a fixed-size buffer:
//
// wchar_t buffer[1234];
// SenAvatarXMLGetTitle( xml, loc, _countof(buffer), NULL, buffer );
//
// Second method, filling a dynamically-allocated buffer:
//
// size_t bufferLength;
// SenAvatarXMLGetTitle( xml, loc, 0, &bufferLength, NULL );
// wchar_t buffer = new wchar_t[bufferLength];
// SenAvatarXMLGetTitle( xml, loc, bufferLength, NULL, buffer );
//
// Note that bufferLength is in wchars, and includes the terminating nul.
// The actual length of the _string_ is (*out_bufferLength - 1).
//
HRESULT SenAvatarXMLGetTitle(
const SenXML &senXML,
size_t bufferLengthMax,
size_t *out_bufferLength, // optional
wchar_t *out_buffer ); // optional
// Obtain a wide, localized string with a given avatar's name.
// See the similar SenAvatarGetTitle() for details.
HRESULT SenAvatarXMLGetName(
const SenXML &senXML,
size_t bufferLengthMax,
size_t *out_bufferLength, // optional
wchar_t *out_buffer ); // optional
// Obtain a wide, localized string with a given avatar's description.
// See the similar SenAvatarGetTitle() for details.
HRESULT SenAvatarXMLGetDescription(
const SenXML &senXML,
size_t bufferLengthMax,
size_t *out_bufferLength, // optional
wchar_t *out_buffer ); // optional
// Obtain the number of custom avatar palettes.
HRESULT SenAvatarXMLGetPaletteCount(
const SenXML &senXML,
size_t *out_paletteCount );
// Obtain the localized name for an avatar palettes.
// See the similar SenAvatarGetTitle() for details.
HRESULT SenAvatarXMLGetPaletteName(
const SenXML &senXML,
int paletteIndex,
size_t bufferLengthMax,
size_t *out_bufferLength, // optional
wchar_t *out_buffer ); // optional
// Obtain a single palette at a given index in the list of palettes
// for a given avatar.
HRESULT SenAvatarXMLGetPalette(
const SenXML &senXML,
int paletteIndex,
SenAvatarPalette *out_palette );
// Extract all palette entries at once.
// It is assumed that out_paletteList is preallocated to (at least)
// paletteCountMax entries.
HRESULT SenAvatarXMLGetPalettes(
const SenXML &senXML,
size_t paletteCountMax,
size_t *out_paletteCount, // optional
SenAvatarPalette *out_paletteList );
} // namespace Sentient
|