XGameStreamingShowTouchControlsWithStateUpdateOnClient
请求指定的流式处理客户端设备更新其触摸控制状态,然后显示指定的触控布局。 所有状态更新均在显示新的触摸布局之前发生。
语法
HRESULT XGameStreamingShowTouchControlsWithStateUpdateOnClient(
XGameStreamingClientId client,
const char* layout,
size_t operationCount,
const XGameStreamingTouchControlsStateOperation* operations
)
参数
client _In_
类型:XGameStreamingClientId
要更新状态和在其上显示触摸控件的流客户端设备。
layout _In_opt_z_
类型:char*
要显示的触摸控件布局的名称,或者使用 nullptr
以显示标准布局。
operationCount _In_
类型:size_t
正在传递的操作的数组大小。
operations _In_reads_opt_(operationCount)
类型:XGameStreamingTouchControlsStateOperation*
正在请求的所有状态变量更新的数组。
返回值
类型:HRESULT
如果成功,则返回 S_OK;否则返回错误代码。
可能的错误
错误代码 | 错误值 | 错误原因 |
---|---|---|
E_GAMESTREAMING_NOT_INITIALIZED | 0x89245400 | XGameStreaming 运行时尚未初始化。 在调用其他 API 之前,先调用 XGameStreamingInitialize。 |
E_GAMESTREAMING_CLIENT_NOT_CONNECTED | 0x89245401 | 指定的客户端未连接。 |
E_INVALIDARG | 0x80070057 | 指定的操作没有与操作 XGameStreamingTouchControlsStateValueKind 中指定的数据类型相匹配的数据 |
备注
如果游戏希望显示特定的触摸布局时,而该布局还需要一些可能影响其绘制的状态更新,则应使用此 API。 如果既要更新新的触摸布局中引用的变量的状态,又要切换到指定的流客户端设备上的触摸布局,请使用此 API。 此 API 确保在显示新布局之前进行所有状态更新。
如果只希望影响所有流式处理客户端设备,请使用 XGameStreamingShowTouchControlsWithStateUpdate。
如果游戏只需要更改布局,则游戏应改用 XGameStreamingShowTouchControlLayoutOnClient。
如果状态更新可能影响当前布局或其他布局,并且无论特定触摸布局如何更改均应进行更新,则游戏应改用 XGameStreamingUpdateTouchControlsStateOnClient。
示例
// In this example, the player has just selected a specific building in an strategy game
// and the game wants to populate the two building specific action slots with the appropriate imagery
// before selecting the layouts
//
// Assumes passing in game structure that refers to the selected building and a game function to get the image
// assets for a particular building capability and the client to be updated
void GameStreamingClientManager::UpdateBuildingStateAndControls(const BuildingProperties& building, XGameStreamingClientId clientId)
{
std::vector<XGameStreamingTouchControlsStateOperation> updateOperations;
// update the image for the first two building slots
XGameStreamingTouchControlsStateOperation buildingCapability1Image;
buildingCapability1Image.operationKind = XGameStreamingTouchControlsStateOperationKind::Replace;
buildingCapability1Image.path = "/buildingCapability1Image";
buildingCapability1Image.valueKind = XGameStreamingTouchControlsStateValueKind::String;
buildingCapability1Image.stringValue = GetImageName(building.capability[0].id);
updateOperations.push_back(buildingCapability1Image);
XGameStreamingTouchControlsStateOperation buildingCapability2Image;
buildingCapability2Image.operationKind = XGameStreamingTouchControlsStateOperationKind::Replace;
buildingCapability2Image.path = "/buildingCapability2Image";
buildingCapability2Image.valueKind = XGameStreamingTouchControlsStateValueKind::String;
buildingCapability2Image.stringValue = GetImageName(building.capability[1].id);
updateOperations.push_back(buildingCapability2Image);
// enable the second slot if the building is of level 3 or above, otherwise the third slot will be disabled
XGameStreamingTouchControlsStateOperation buildingCapability2Enabled;
buildingCapability2Enabled.operationKind = XGameStreamingTouchControlsStateOperationKind::Replace;
buildingCapability2Enabled.path = "/buildingCapability2IsEnabled";
buildingCapability2Enabled.valueKind = XGameStreamingTouchControlsStateValueKind::Boolean;
buildingCapability2Enabled.booleanValue = building.level >= 3;
updateOperations.push_back(buildingCapability2Enabled);
// Switch to the building layout with the state update being sent as well
XGameStreamingShowTouchControlsWithStateUpdateOnClient(clientId, "building", updateOperations.size(), updateOperations.data());
}
要求
头文件:XGameStreaming.h
库:xgameruntime.lib 支持的平台:Windows、Xbox One 系列主机和 Xbox 系列主机
另请参阅
XGameStreaming
XGameStreamingTouchControlsStateOperationKind
XGameStreamingTouchControlsStateOperation
XGameStreamingTouchControlsStateValue
XGameStreamingShowTouchControlsWithStateUpdate
XGameStreamingUpdateTouchControlsState
XGameStreamingUpdateTouchControlsStateOnClient