XGameStreamingUpdateTouchControlsState
触摸布局可用于更改其行为的所有流客户端上的更新状态。 对当前显示的触摸控件集进行的任何视觉更改将在更新全部变量后完成。
语法
HRESULT XGameStreamingUpdateTouchControlsState(
size_t operationCount,
const XGameStreamingTouchControlsStateOperation* operations
)
参数
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 中指定的数据类型相匹配的数据 |
备注
流式处理客户端使用的触控布局可以依赖于状态,其初始值将嵌入到触摸布局包中。 游戏可以更新状态,这可能会导致当前正在向播放器显示的布局发生更改。
游戏可以使用 XGameStreamingUpdateTouchControlsState
更新所有已连接客户端的状态,或者使用 XGameStreamingUpdateTouchControlsStateOnClient 更新特定已连接客户端的状态。
如果游戏需要同时更新状态和更改布局,可使用 XGameStreamingShowTouchControlsWithStateUpdate 或 XGameStreamingShowTouchControlsWithStateUpdateOnClient。
示例
// In this example, after the player has switched their active weapon - update the image of the fire
// button to match the current weapon and set the enabled state of reload based on whether the player has
// extra magazines.
//
// Assumes passing in game structure that includes the active weapon with appropriate state.
//
// Assumes a game speciic GetImageName function which returns a constant string for the specified weapoon
void GameStreamingClientManager::UpdateStateAfterWeaponChange(const playerWeapon& playerWeapon)
{
// create an update for the active weapon's image
XGameStreamingTouchControlsStateOperation weaponImage;
weaponImage.operationKind = XGameStreamingTouchControlsStateOperationKind::Replace;
weaponImage.path = "/ActiveWeaponImage";
weaponImage.value.valueKind = XGameStreamingTouchControlsStateValueKind::String;
weaponImage.value.stringValue = GetImageName(playerWeapon.activeWeapon.id);
// create an update for whether the reload button should be enabled
XGameStreamingTouchControlsStateOperation reloadEnabled;
reloadEnabled.operationKind = XGameStreamingTouchControlsStateOperationKind::Replace;
reloadEnabled.path = "/ReloadEnabled";
reloadEnabled.valueKind = XGameStreamingTouchControlsStateValueKind::Bool;
reloadEnabled.booleanValue = playerWeapon.activeWeapon.reloadClips > 0;
// combine all the updates into the update state call and make the call
XGameStreamingTouchControlsStateOperation[2] updateOperations = {weaponImage, reloadEnabled};
XGameStreamingUpdateTouchControlsState(updateOperations, _countof(updateOperations));
}
// In this example, after the player has gone to their inventory screen and had the ability to apply items
// to two active slots. Update the state for layouts to have layouts match the player's current
// loaded items from inventory (may or may not be the current layout being displayed).
//
// Assumes passing in game structure that includes the player's active inventory
void GameStreamingClientManager::AfterInventoryScreen(const PlayerInventory& playerInventory)
{
std::vector<XGameStreamingTouchControlsStateOperation> updateOperations;
// check the first inventory slots, if empty hide that button from the layout
// if item is placed in that slot, update the image to match the inventory items
XGameStreamingTouchControlsStateOperation slot1Visible;
slot1Visible.operationKind = XGameStreamingTouchControlsStateOperationKind::Replace;
slot1Visible.path = "/Slot1IsVisible";
slot1Visible.valueKind = XGameStreamingTouchControlsStateValueKind::Boolean;
slot1Visible.boolValue = playerInventory.slot1 != nullptr;
updateOperations.push_back(slot1Visible);
if (playerInventory.slot1 != nullptr)
{
// create an update for the active weapon's image
XGameStreamingTouchControlsStateOperation slot1Image;
slot1Image.operationKind = XGameStreamingTouchControlsStateOperationKind::Replace;
slot1Image.path = "/Slot1Image";
slot1Image.value.valueKind = XGameStreamingTouchControlsStateValueKind::String;
slot1Image.value.stringValue = GetImageName(playerInventory.slot1.id);
updateOperations.pushBack(slot1Image);
}
// ...
// do the same for the second inventory spot
// ...
// Update the state so that layouts will be updated correctly
XGameStreamingUpdateTouchControlsState(updateOperations.data(), updateOperations.size());
}
要求
头文件: XGameStreaming.h
库:xgameruntime.lib
支持平台:Windows、Xbox One 系列主机和 Xbox Series 主机
另请参阅
XGameStreaming
XGameStreamingTouchControlsStateOperationKind
XGameStreamingTouchControlsStateOperation
XGameStreamingTouchControlsStateValue
XGameStreamingShowTouchControlsWithStateUpdate
XGameStreamingShowTouchControlsWithStateUpdateOnClient
XGameStreamingUpdateTouchControlsStateOnClient