Put it all together - Login Queue - (Unreal Engine module)
Last updated on October 24, 2024
Connect the UI to show the Login Queue status
Open the
LoginQueueWidget_Starter
CPP file, navigate to theNativeOnActivated
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);
}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()
{
Super::NativeOnDeactivated();
Btn_CancelQueue->OnClicked().RemoveAll(this);
LoginQueueSubsystem->OnLoginQueueCancelCompletedDelegates.RemoveAll(this);
LoginQueueSubsystem->OnLoginQueuedDelegates.RemoveAll(this);
LoginQueueSubsystem->OnLoginTicketStatusUpdatedDelegates.RemoveAll(this);
}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 code below. Call the cancel request functionality here.void ULoginQueueWidget_Starter::CancelQueue() const
{
Ws_Root->SetActiveWidget(W_Loading);
LoginQueueSubsystem->CancelLoginQueue(GetOwningPlayer());
}Build the AccelByteWars project and make sure there is no compile errors.
Resources
- The files used in this tutorial section are available in the Byte Wars GitHub repository.