XGameStreamingShowTouchControlsWithStateUpdate

请求所有连接的流式客户端设备更新其触摸控制状态,然后显示指定的触摸布局。 所有状态更新均在显示新的触摸布局之前发生。

语法

HRESULT XGameStreamingShowTouchControlsWithStateUpdate(  
         const char* layout,  
         size_t operationCount,  
         const XGameStreamingTouchControlsStateOperation* operations  
)  

参数

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_INVALIDARG 0x80070057 指定的操作没有与操作 XGameStreamingTouchControlsStateValueKind 中指定的数据类型相匹配的数据

备注

当游戏需要显示特定的触控布局,而且该布局还需要一些可能影响其渲染的状态更新时,则应使用此 API。 如果既要更新新的触摸布局中引用的变量的状态,又要切换到所有连接的流客户端设备上的触摸布局,请使用此 API。 此 API 确保在显示新布局之前进行所有状态更新。

如果希望仅影响特定客户端,请使用 XGameStreamingShowTouchControlsWithStateUpdateOnClient

如果游戏只是希望更改布局,则该游戏应使用 XGameStreamingShowTouchControlLayout

如果状态更新可能影响当前布局或其他布局,并且无论特定的触控布局如何更改都应进行更新,则游戏应使用 XGameStreamingUpdateTouchControlsState

示例

// 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.


void GameStreamingClientManager::UpdateBuildingStateAndControls(const BuildingProperties& building)
{
    
    

    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
    XGameStreamingShowTouchControlsWithStateUpdate("building", updateOperations.size(), updateOperations.data());
}

要求

头文件: XGameStreaming.h

库:xgameruntime.lib
支持平台:Windows、Xbox One 系列主机和 Xbox Series 主机

另请参阅

XGameStreaming
XGameStreamingTouchControlsStateOperationKind
XGameStreamingTouchControlsStateOperation
XGameStreamingTouchControlsStateValue
XGameStreamingShowTouchControlsWithStateUpdateOnClient
XGameStreamingUpdateTouchControlsState
XGameStreamingUpdateTouchControlsStateOnClient