parent
f798fd22b1
commit
e70d03fec5
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,29 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "MyMainMenu.h"
|
||||||
|
|
||||||
|
#include "Components/Button.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
|
void UMyMainMenu::NativeConstruct()
|
||||||
|
{
|
||||||
|
Super::NativeConstruct();
|
||||||
|
|
||||||
|
HostOnlineGameButton->OnClicked.AddDynamic(this, &ThisClass::UMyMainMenu::OnHostOnlineGameButtonClicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UMyMainMenu::OnHostOnlineGameButtonClicked()
|
||||||
|
{
|
||||||
|
GetMyGameSubsystem()->CreateSession(2, true);
|
||||||
|
UGameplayStatics::OpenLevel(GetWorld(), FName(TEXT("BattleFieldMap")));
|
||||||
|
this->RemoveFromParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
UMyGameInstanceSubsystem* UMyMainMenu::GetMyGameSubsystem() const
|
||||||
|
{
|
||||||
|
const UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(GetWorld());
|
||||||
|
UMyGameInstanceSubsystem* GameInstanceSubsystem = GameInstance->GetSubsystem<UMyGameInstanceSubsystem>();
|
||||||
|
return GameInstanceSubsystem;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Blueprint/UserWidget.h"
|
||||||
|
#include "MyGameInstanceSubsystem.h"
|
||||||
|
|
||||||
|
#include "MyMainMenu.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class TURNBASEDTUTORIAL_API UMyMainMenu : public UUserWidget
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
class UButton* HostOnlineGameButton;
|
||||||
|
|
||||||
|
virtual void NativeConstruct() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
UFUNCTION()
|
||||||
|
void OnHostOnlineGameButtonClicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
UMyGameInstanceSubsystem* GetMyGameSubsystem() const;
|
||||||
|
};
|
@ -0,0 +1,32 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "MySessionListWidget.h"
|
||||||
|
|
||||||
|
#include "MyGameInstanceSubsystem.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
|
void UMySessionListWidget::NativeConstruct()
|
||||||
|
{
|
||||||
|
Super::NativeConstruct();
|
||||||
|
|
||||||
|
const auto MyGameInstanceSubsystem = GetMyGameSubsystem();
|
||||||
|
MyGameInstanceSubsystem->OnFindSessionsCompleteEvent.AddUObject(this, &ThisClass::FillSessionListFromDelegate);
|
||||||
|
|
||||||
|
|
||||||
|
// Initiate search
|
||||||
|
MyGameInstanceSubsystem->FindSessions(10, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UMySessionListWidget::FillSessionListFromDelegate(const TArray<FOnlineSessionSearchResult>& SessionResults,
|
||||||
|
bool bSuccessful)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("FIND SESSION DELEGATED %d %d"), bSuccessful, SessionResults.Num());
|
||||||
|
}
|
||||||
|
|
||||||
|
UMyGameInstanceSubsystem* UMySessionListWidget::GetMyGameSubsystem() const
|
||||||
|
{
|
||||||
|
const UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(GetWorld());
|
||||||
|
UMyGameInstanceSubsystem* GameInstanceSubsystem = GameInstance->GetSubsystem<UMyGameInstanceSubsystem>();
|
||||||
|
return GameInstanceSubsystem;
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "MyGameInstanceSubsystem.h"
|
||||||
|
|
||||||
|
#include "Blueprint/UserWidget.h"
|
||||||
|
#include "MySessionListWidget.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class TURNBASEDTUTORIAL_API UMySessionListWidget : public UUserWidget
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void NativeConstruct() override;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
class UButton* ConnectToSelectedSessionButton;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
class UButton* GoBackToMainMenuButton;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
class UListView* AvailableSessionsList;
|
||||||
|
|
||||||
|
void FillSessionListFromDelegate(const TArray<FOnlineSessionSearchResult>& SessionResults, bool bSuccessful);
|
||||||
|
|
||||||
|
private:
|
||||||
|
UMyGameInstanceSubsystem* GetMyGameSubsystem() const;
|
||||||
|
};
|
Loading…
Reference in new issue