ed7c7fd991
Boucle de jeu complète : récolte, inventaire, consommation, stats de survie, mort et respawn. Gameplay en C++, Blueprints réservés au câblage d'assets. Assets binaires (.uasset, .umap, textures, audio) suivis via Git LFS. Binaries/, Intermediate/, Saved/ et DerivedDataCache/ sont ignorés : régénérés au build, ils pèsent 3 Go pour 1,3 Go de contenu utile. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
103 lines
2.6 KiB
C++
103 lines
2.6 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "ConfirmDialogWidget.h"
|
|
|
|
#include "Components/Button.h"
|
|
#include "Components/TextBlock.h"
|
|
#include "InputCoreTypes.h"
|
|
|
|
UConfirmDialogWidget::UConfirmDialogWidget(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
// Sans ce drapeau le widget ne peut pas prendre le focus clavier, et
|
|
// NativeOnKeyDown ne serait jamais appele. Il ne se change qu'a la
|
|
// construction, d'ou sa presence ici et pas dans Open().
|
|
SetIsFocusable(true);
|
|
}
|
|
|
|
void UConfirmDialogWidget::NativeConstruct()
|
|
{
|
|
Super::NativeConstruct();
|
|
|
|
if (ConfirmButton)
|
|
{
|
|
ConfirmButton->OnClicked.AddDynamic(this, &UConfirmDialogWidget::HandleConfirmClicked);
|
|
}
|
|
|
|
if (CancelButton)
|
|
{
|
|
CancelButton->OnClicked.AddDynamic(this, &UConfirmDialogWidget::HandleCancelClicked);
|
|
}
|
|
}
|
|
|
|
void UConfirmDialogWidget::Open(const FText& InMessage)
|
|
{
|
|
if (MessageText)
|
|
{
|
|
MessageText->SetText(InMessage);
|
|
}
|
|
|
|
SetVisibility(ESlateVisibility::Visible);
|
|
|
|
// Le focus doit etre repris a CHAQUE ouverture : le refermer le rend au
|
|
// menu, et une boite visible mais sans focus ignorerait le clavier.
|
|
SetKeyboardFocus();
|
|
}
|
|
|
|
void UConfirmDialogWidget::Close()
|
|
{
|
|
SetVisibility(ESlateVisibility::Collapsed);
|
|
}
|
|
|
|
FReply UConfirmDialogWidget::NativeOnKeyDown(const FGeometry& InGeometry, const FKeyEvent& InKeyEvent)
|
|
{
|
|
const FKey Key = InKeyEvent.GetKey();
|
|
|
|
// Virtual_Back en plus d'Echap : Slate y fait pointer le bouton "retour" de
|
|
// la manette selon la plateforme (B sur Xbox, Rond sur PlayStation). Une
|
|
// seule ligne et le clavier comme la manette sont couverts, sans avoir a
|
|
// enumerer les touches de chaque constructeur.
|
|
if (bCancelOnEscape && (Key == EKeys::Escape || Key == EKeys::Virtual_Back))
|
|
{
|
|
OnCancelled.Broadcast();
|
|
|
|
// Handled et non Unhandled : sans ca la touche continue de remonter et
|
|
// serait consommee une seconde fois par ce qui se trouve derriere.
|
|
return FReply::Handled();
|
|
}
|
|
|
|
if (bConfirmOnEnter && (Key == EKeys::Enter || Key == EKeys::Virtual_Accept))
|
|
{
|
|
OnConfirmed.Broadcast();
|
|
return FReply::Handled();
|
|
}
|
|
|
|
return Super::NativeOnKeyDown(InGeometry, InKeyEvent);
|
|
}
|
|
|
|
void UConfirmDialogWidget::HandleConfirmClicked()
|
|
{
|
|
OnConfirmed.Broadcast();
|
|
}
|
|
|
|
void UConfirmDialogWidget::HandleCancelClicked()
|
|
{
|
|
OnCancelled.Broadcast();
|
|
}
|
|
|
|
void UConfirmDialogWidget::NativeDestruct()
|
|
{
|
|
if (ConfirmButton)
|
|
{
|
|
ConfirmButton->OnClicked.RemoveDynamic(this, &UConfirmDialogWidget::HandleConfirmClicked);
|
|
}
|
|
|
|
if (CancelButton)
|
|
{
|
|
CancelButton->OnClicked.RemoveDynamic(this, &UConfirmDialogWidget::HandleCancelClicked);
|
|
}
|
|
|
|
Super::NativeDestruct();
|
|
}
|