64 lines
1.3 KiB
C++
64 lines
1.3 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "MainMenuWidget.h"
|
|
|
|
#include "Components/Button.h"
|
|
#include "MainMenuPlayerController.h"
|
|
|
|
void UMainMenuWidget::NativeConstruct()
|
|
{
|
|
Super::NativeConstruct();
|
|
|
|
if (PlayButton)
|
|
{
|
|
PlayButton->OnClicked.AddDynamic(this, &UMainMenuWidget::HandlePlayClicked);
|
|
}
|
|
|
|
if (QuitButton)
|
|
{
|
|
QuitButton->OnClicked.AddDynamic(this, &UMainMenuWidget::HandleQuitClicked);
|
|
}
|
|
|
|
if (SettingsButton)
|
|
{
|
|
SettingsButton->OnClicked.AddDynamic(this, &UMainMenuWidget::HandleSettingsClicked);
|
|
}
|
|
|
|
// Les boutons de coop sont visibles mais inertes : ils annoncent la couleur
|
|
// sans promettre une partie qui echouerait.
|
|
if (HostButton)
|
|
{
|
|
HostButton->SetIsEnabled(false);
|
|
}
|
|
|
|
if (JoinButton)
|
|
{
|
|
JoinButton->SetIsEnabled(false);
|
|
}
|
|
}
|
|
|
|
void UMainMenuWidget::HandlePlayClicked()
|
|
{
|
|
if (AMainMenuPlayerController* Controller = GetOwningPlayer<AMainMenuPlayerController>())
|
|
{
|
|
Controller->StartSoloGame();
|
|
}
|
|
}
|
|
|
|
void UMainMenuWidget::HandleQuitClicked()
|
|
{
|
|
if (AMainMenuPlayerController* Controller = GetOwningPlayer<AMainMenuPlayerController>())
|
|
{
|
|
Controller->QuitGame();
|
|
}
|
|
}
|
|
|
|
void UMainMenuWidget::HandleSettingsClicked()
|
|
{
|
|
if (AMainMenuPlayerController* Controller = GetOwningPlayer<AMainMenuPlayerController>())
|
|
{
|
|
Controller->OpenSettings();
|
|
}
|
|
}
|