メインコンテンツまでスキップ

Put it all together - Entitlements Essentials - (Unreal Engine module)

Last updated on July 28, 2025

Connect the UI to the entitlement query

  1. Open the OwnedCountWidgetEntry_Starter CPP file, find the RetrieveEntitlementWithForceRequest() function, and replace the existing implementation with the code below. This updated code calls the GetOrQueryUserItemEntitlement() function you implemented earlier and binds ShowOwnedCount() as the on-complete delegate.

    void UOwnedCountWidgetEntry_Starter::RetrieveEntitlementWithForceRequest(const bool bForceRequest)
    {
    SetVisibility(ESlateVisibility::Collapsed);

    W_Parent = GetFirstOccurenceOuter<UStoreItemListEntry>();
    if (W_Parent)
    {
    // Get item.
    const UStoreItemDataObject* ItemData = W_Parent->GetItemData();
    if (!ItemData)
    {
    return;
    }

    EntitlementsSubsystem->GetOrQueryUserItemEntitlement(
    GetOwningPlayer(),
    ItemData->GetStoreItemId(),
    FOnGetOrQueryUserItemEntitlementComplete::CreateUObject(this, &ThisClass::ShowOwnedCount),
    bForceRequest);
    }
    }
  2. Open the InventoryWidget_Starter CPP file, find the NativeOnActivated() function, and replace the existing implementation with the code below. This updated code calls the GetOrQueryUserEntitlements() function you implemented earlier when the widget opens.

    void UInventoryWidget_Starter::NativeOnActivated()
    {
    Super::NativeOnActivated();

    EntitlementsSubsystem = GetGameInstance()->GetSubsystem<UEntitlementsEssentialsSubsystem_Starter>();
    ensure(EntitlementsSubsystem);

    // bind
    Tv_Content->OnItemClicked().AddUObject(this, &UInventoryWidget_Starter::OnClickListItem);
    Btn_Back->OnClicked().AddUObject(this, &ThisClass::DeactivateWidget);
    Btn_Equip->OnClicked().AddUObject(this, &ThisClass::OnClickEquip);
    Btn_Unequip->OnClicked().AddUObject(this, &ThisClass::OnClickUnEquip);

    // reset UI
    Ws_Root->SetWidgetState(EAccelByteWarsWidgetSwitcherState::Loading);
    EntitlementsSubsystem->GetOrQueryUserEntitlements(
    GetOwningPlayer(),
    FOnGetOrQueryUserEntitlementsComplete::CreateUObject(this, &ThisClass::ShowEntitlements));

    SelectedItem = nullptr;
    SwitchToDefaultState();

    Btn_Equip->SetVisibility(ESlateVisibility::Collapsed);
    }

Resources