Create OptionsUIWidget

This commit is contained in:
baz 2023-10-06 23:14:26 +01:00
parent 483add816a
commit 2115c4456c
2 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,64 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "OptionsUIWidget.h"
#include "GameFramework/GameUserSettings.h"
void UOptionsUIWidget::NativeConstruct()
{
Super::NativeConstruct();
if (ApplyButton)
{
ApplyButton->OnClicked.AddUniqueDynamic(this, &UOptionsUIWidget::ApplyButtonOnClicked);
}
if (BackButton)
{
BackButton->OnClicked.AddUniqueDynamic(this, &UOptionsUIWidget::BackButtonOnClicked);
}
if (ResetToDefaultsButton)
{
ResetToDefaultsButton->OnClicked.AddUniqueDynamic(this, &UOptionsUIWidget::ResetToDefaultsButtonOnClicked);
}
if (FullscreenBox)
{
switch (GEngine->GameUserSettings->GetFullscreenMode())
{
case EWindowMode::Fullscreen:
FullscreenBox->SetCheckedState(ECheckBoxState::Checked);
break;
case EWindowMode::WindowedFullscreen:
FullscreenBox->SetCheckedState(ECheckBoxState::Unchecked);
break;
case EWindowMode::Windowed:
FullscreenBox->SetCheckedState(ECheckBoxState::Unchecked);
break;
case EWindowMode::NumWindowModes:
FullscreenBox->SetCheckedState(ECheckBoxState::Unchecked);
break;
default:
FullscreenBox->SetCheckedState(ECheckBoxState::Unchecked);
}
}
}
void UOptionsUIWidget::ApplyButtonOnClicked()
{
// TODO: Implement Functionality
}
void UOptionsUIWidget::BackButtonOnClicked()
{
// TODO: Implement Functionality
}
void UOptionsUIWidget::ResetToDefaultsButtonOnClicked()
{
// TODO: Implement Functionality
GEngine->GameUserSettings->SetToDefaults(); // :)
}

View File

@ -0,0 +1,49 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Components/ComboBox.h"
#include "Components/CheckBox.h"
#include "Components/Button.h"
#include "OptionsUIWidget.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API UOptionsUIWidget : public UUserWidget
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UComboBox* ResolutionSelector;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UCheckBox* FullscreenBox;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* ApplyButton;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* BackButton;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* ResetToDefaultsButton;
public:
virtual void NativeConstruct() override;
private:
UFUNCTION()
void ApplyButtonOnClicked();
UFUNCTION()
void BackButtonOnClicked();
UFUNCTION()
void ResetToDefaultsButtonOnClicked();
};