From 2e554be13aeb7b20ae603fce21d8c6a50a60e1a5 Mon Sep 17 00:00:00 2001 From: baz Date: Mon, 27 May 2024 20:30:23 +0100 Subject: [PATCH] Add SaveGameEntry OnClick functionality --- Source/Nakatomi/UI/SaveGameEntryUserWidget.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Source/Nakatomi/UI/SaveGameEntryUserWidget.cpp b/Source/Nakatomi/UI/SaveGameEntryUserWidget.cpp index 8ca4fa8..f138e13 100644 --- a/Source/Nakatomi/UI/SaveGameEntryUserWidget.cpp +++ b/Source/Nakatomi/UI/SaveGameEntryUserWidget.cpp @@ -3,6 +3,10 @@ #include "../UI/SaveGameEntryUserWidget.h" +#include "Blueprint/WidgetBlueprintLibrary.h" +#include "Kismet/GameplayStatics.h" +#include "Nakatomi/NakatomiGameInstance.h" + void USaveGameEntryUserWidget::NativeConstruct() { Super::NativeConstruct(); @@ -30,7 +34,17 @@ void USaveGameEntryUserWidget::SetSaveInfo(FNakatomiSaveFileInfo SaveFile) void USaveGameEntryUserWidget::LoadSaveButtonOnClicked() { - // TODO: implement loading of stuff + UNakatomiGameInstance* gameInstance = Cast(UGameplayStatics::GetGameInstance(GetWorld())); + UNakatomiSaveGame* Save = gameInstance->LoadGameFromSlot(SaveFileInfo.PlayerName); + UGameplayStatics::OpenLevel(GetWorld(), FName(Save->LevelName)); + + if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0)) + { + PlayerController->bShowMouseCursor = false; + UWidgetBlueprintLibrary::SetInputMode_GameOnly(PlayerController); + } + + SetIsFocusable(false); } void USaveGameEntryUserWidget::LoadSaveButtonHoveredDelegate()