Skip to main content

Put it all together - Login Queue - (Unreal Engine module)

Last updated on June 5, 2024

Connect the UI to show the Login Queue status

  1. Open the LoginQueueWidget_Starter CPP file, navigate to the NativeOnActivated function, and add the highlighted code below. This is to bind the UI functionalities to the delegates that you have set up in the subsystem.

    void ULoginQueueWidget_Starter::NativeOnActivated()
    {
    ...
    Btn_CancelQueue->OnClicked().AddUObject(this, &ThisClass::CancelQueue);
    LoginQueueSubsystem->OnLoginQueueCancelCompletedDelegates.AddUObject(this, &ThisClass::OnCancelQueueCompleted);
    LoginQueueSubsystem->OnLoginQueuedDelegates.AddUObject(this, &ThisClass::OnLoginQueued);
    LoginQueueSubsystem->OnLoginTicketStatusUpdatedDelegates.AddUObject(this, &ThisClass::OnLoginStatusUpdated);
    }
  2. Still in the CPP file, navigate to the NativeOnDeactivated function and add the highlighted code below. Here, we make sure that the UI functionality is unbound when the UI closes to prevent any unwanted behavior.

    void ULoginQueueWidget_Starter::NativeOnDeactivated()
    {
    ...
    Btn_CancelQueue->OnClicked().RemoveAll(this);
    LoginQueueSubsystem->OnLoginQueueCancelCompletedDelegates.RemoveAll(this);
    LoginQueueSubsystem->OnLoginQueuedDelegates.RemoveAll(this);
    LoginQueueSubsystem->OnLoginTicketStatusUpdatedDelegates.RemoveAll(this);
    }
  3. Then, navigate to the CancelQueue function. As you might notice, there's a placeholder inline comment within that function. Replace that inline comment with the highlighted code below. Call the cancel request functionality here.

    void ULoginQueueWidget_Starter::CancelQueue() const
    {
    Ws_Root->SetActiveWidget(W_Loading);
    LoginQueueSubsystem->CancelLoginQueue(GetOwningPlayer());
    }
  4. Build the AccelByteWars project and make sure there is no compile errors.

Resources