Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Content/Blueprints/Overlays/BP_OverlayActor.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Content/Blueprints/UI/BP_GameOverWinWidget.uasset
Binary file not shown.
Binary file removed Content/Blueprints/UI/BP_LevelIndicatorWidget.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Content/Blueprints/UI/BP_LifeWidget.uasset
Binary file not shown.
Binary file removed Content/Blueprints/UI/BP_LivesWidget.uasset
Binary file not shown.
Binary file removed Content/Blueprints/UI/BP_ScoreWidget.uasset
Binary file not shown.
Binary file modified Content/Blueprints/UI/BP_SettingsWidget.uasset
Binary file not shown.
Binary file modified Content/Blueprints/UI/BP_StartMenuWidget.uasset
Binary file not shown.
Binary file modified Content/Blueprints/UI/BP_UIManager.uasset
Binary file not shown.
Binary file not shown.
Binary file added Content/Blueprints/UI/WBP_Blur.uasset
Binary file not shown.
Binary file added Content/Blueprints/UI/WBP_Button.uasset
Binary file not shown.
Binary file added Content/Blueprints/UI/WBP_HUDScreen.uasset
Binary file not shown.
Binary file added Content/Blueprints/UI/WBP_Heading.uasset
Binary file not shown.
Binary file added Content/Blueprints/UI/WBP_LevelHistory.uasset
Binary file not shown.
Binary file not shown.
Binary file added Content/Blueprints/UI/WBP_Life.uasset
Binary file not shown.
Binary file added Content/Blueprints/UI/WBP_Lives.uasset
Binary file not shown.
Binary file added Content/Blueprints/UI/WBP_PauseMenu.uasset
Binary file not shown.
Binary file added Content/Blueprints/UI/WBP_Score.uasset
Binary file not shown.
Binary file added Content/Blueprints/UI/WBP_SettingsMenu.uasset
Binary file not shown.
Binary file added Content/Blueprints/UI/WBP_StartMenu.uasset
Binary file not shown.
Binary file not shown.
Binary file added Content/Blueprints/UI/WBP_YouWinScreen.uasset
Binary file not shown.
Binary file modified Content/Levels/Level1.uasset
Binary file not shown.
Binary file modified Content/Maps/GameWithAI.umap
Binary file not shown.
Binary file modified Content/Maps/MainMenu.umap
Binary file not shown.
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ A post-mortem technical write-up will be published when the project is done. Unt

| Gameplay System | Pull Request |
| --- | --- |
| https://github.com/nucleartide/Chomp/labels/UI | https://github.com/nucleartide/Chomp/pull/29 Implement a pause menu; refactor UI into componentized Widget Blueprints
| https://github.com/nucleartide/Chomp/labels/UI | https://github.com/nucleartide/Chomp/pull/28 Implement an options/settings menu
| https://github.com/nucleartide/Chomp/labels/UI | https://github.com/nucleartide/Chomp/pull/27 Finalize start menu UI/UX design
| https://github.com/nucleartide/Chomp/labels/UI | https://github.com/nucleartide/Chomp/pull/24 Fix scalability, resolution, aspect ratio, and fullscreen mode in shipping build
Expand Down
6 changes: 3 additions & 3 deletions Source/Chomp/Private/LevelGenerator/LevelDataAsset.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
class ULevelSymbolWidget;
class ABonusSymbol;

UCLASS(BlueprintType)
UCLASS(BlueprintType, Blueprintable)
class CHOMP_API ULevelDataAsset : public UDataAsset
{
GENERATED_BODY()

public:
UPROPERTY(EditInstanceOnly)
UPROPERTY(EditInstanceOnly, BlueprintReadOnly)
TSubclassOf<ABonusSymbol> BonusSymbol;

UPROPERTY(EditInstanceOnly)
UPROPERTY(EditInstanceOnly, BlueprintReadOnly)
TSubclassOf<ULevelSymbolWidget> BonusSymbolWidget;
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ class CHOMP_API ULevelSequenceDataAsset : public UDataAsset
TArray<ULevelDataAsset*> LevelSequence;

public:
UFUNCTION(BlueprintCallable)
TArray<ULevelDataAsset*> LastThree();
};
16 changes: 0 additions & 16 deletions Source/Chomp/Private/UI/LevelIndicatorWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
#include "LevelIndicatorWidget.h"

#include "LevelSymbolWidget.h"
#include "Components/HorizontalBox.h"
#include "Components/Image.h"
#include "LevelGenerator/LevelDataAsset.h"
#include "LevelGenerator/LevelSequenceDataAsset.h"

void ULevelIndicatorWidget::RenderLastThreeLevelSymbols(UWorld* WorldInstance) const
{
for (const auto LastThreeLevels = LevelSequence->LastThree(); const auto Level : LastThreeLevels)
{
const auto WidgetInstance = CreateWidget<UUserWidget>(WorldInstance, Level->BonusSymbolWidget);
check(WidgetInstance);
LevelIndicatorContainer->AddChild(WidgetInstance);
}
}
9 changes: 5 additions & 4 deletions Source/Chomp/Private/UI/LevelIndicatorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ class CHOMP_API ULevelIndicatorWidget : public UUserWidget
{
GENERATED_BODY()

UPROPERTY(meta = (BindWidget))
class UHorizontalBox* LevelIndicatorContainer;

UPROPERTY(EditDefaultsOnly)
protected:
UPROPERTY(EditAnywhere, Category = "LevelIndicatorWidget | Props", BlueprintReadOnly)
ULevelSequenceDataAsset* LevelSequence;

UPROPERTY(meta = (BindWidget), BlueprintReadOnly)
class UHorizontalBox* LevelIndicatorContainer;

public:
void RenderLastThreeLevelSymbols(UWorld* WorldInstance) const;
Expand Down
6 changes: 4 additions & 2 deletions Source/Chomp/Private/UI/LivesWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
#include "Blueprint/UserWidget.h"
#include "LivesWidget.generated.h"

class UHorizontalBox;

UCLASS(BlueprintType, Blueprintable)
class ULivesWidget : public UUserWidget
{
GENERATED_BODY()

public:
protected:
UPROPERTY(meta = (BindWidget), BlueprintReadOnly)
class UHorizontalBox* LivesContainer;
UHorizontalBox* LivesContainer;

UPROPERTY(meta = (BindWidget), BlueprintReadOnly)
class UTextBlock* OneUpText;
Expand Down
56 changes: 1 addition & 55 deletions Source/Chomp/Private/UI/UIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,20 @@
#include "ChompGameState.h"
#include "CoreGlobals.h"
#include "LevelIndicatorWidget.h"
#include "LivesWidget.h"
#include "Components/HorizontalBox.h"
#include "GameFramework/PlayerController.h"
#include "Kismet/GameplayStatics.h"
#include "UI/GameOverWidget.h"
#include "Utils/Debug.h"
#include "Utils/SafeGet.h"

AUIManager::AUIManager(): AActor()
{
PrimaryActorTick.bCanEverTick = true;
}

void AUIManager::BeginPlay()
{
Super::BeginPlay();

const auto World = FSafeGet::World(this);

ScoreWidgetInstance = CreateWidget(World, ScoreWidget);
check(ScoreWidgetInstance);
ScoreWidgetInstance->AddToViewport();

LivesWidgetInstance = CreateWidget(World, LivesWidget);
check(LivesWidgetInstance);
LivesWidgetInstance->AddToViewport();

LevelIndicatorWidgetInstance = CreateWidget<ULevelIndicatorWidget>(World, LevelIndicatorWidget);
check(LevelIndicatorWidgetInstance);
LevelIndicatorWidgetInstance->AddToViewport();
LevelIndicatorWidgetInstance->RenderLastThreeLevelSymbols(World);

const auto GameState = GetWorld()->GetGameState<AChompGameState>();
const auto GameState = FSafeGet::GameState<AChompGameState>(this);
GameState->OnDotsCleared.AddUniqueDynamic(this, &AUIManager::HandleDotsCleared);
GameState->OnGameStateChanged.AddUniqueDynamic(this, &AUIManager::HandlePlayerDeath);
GameState->OnLivesChanged.AddUniqueDynamic(this, &AUIManager::HandleLivesChanged);
}

void AUIManager::EndPlay(const EEndPlayReason::Type EndPlayReason)
Expand All @@ -47,20 +25,6 @@ void AUIManager::EndPlay(const EEndPlayReason::Type EndPlayReason)
const auto GameState = GetWorld()->GetGameState<AChompGameState>();
GameState->OnDotsCleared.RemoveDynamic(this, &AUIManager::HandleDotsCleared);
GameState->OnGameStateChanged.RemoveDynamic(this, &AUIManager::HandlePlayerDeath);
GameState->OnLivesChanged.RemoveDynamic(this, &AUIManager::HandleLivesChanged);

ScoreWidgetInstance->RemoveFromParent();
LivesWidgetInstance->RemoveFromParent();
LevelIndicatorWidgetInstance->RemoveFromParent();

ScoreWidgetInstance = nullptr;
LivesWidgetInstance = nullptr;
LevelIndicatorWidgetInstance = nullptr;
}

void AUIManager::Tick(const float DeltaTime)
{
Super::Tick(DeltaTime);
}

void AUIManager::HandleDotsCleared()
Expand Down Expand Up @@ -117,21 +81,3 @@ void AUIManager::HandleRestartGameClicked()
Controller->SetShowMouseCursor(false);
Controller->SetInputMode(FInputModeGameOnly());
}

// ReSharper disable once CppMemberFunctionMayBeConst
void AUIManager::HandleLivesChanged(const int NumberOfLives)
{
const auto LivesWidgetRef = Cast<ULivesWidget>(LivesWidgetInstance);
check(LivesWidgetRef);

const auto World = FSafeGet::World(this);

LivesWidgetRef->LivesContainer->ClearChildren();

for (auto i = 0; i < NumberOfLives; i++)
{
const auto LifeWidgetInstance = CreateWidget(World, LivesWidgetRef->LifeWidget);
LifeWidgetInstance->SetPadding(FMargin(LivesWidgetRef->HorizontalPadding, 0.0));
LivesWidgetRef->LivesContainer->AddChild(LifeWidgetInstance);
}
}
11 changes: 2 additions & 9 deletions Source/Chomp/Private/UI/UIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class ULivesWidget;
class UScoreWidget;

/**
* AUIManager manages the lifetime of the user interface of the game.
* AUIManager manages the lifetime of the user interface when in-game.
*/
UCLASS()
UCLASS(BlueprintType, Blueprintable)
class AUIManager : public AActor
{
GENERATED_BODY()
Expand Down Expand Up @@ -55,13 +55,9 @@ class AUIManager : public AActor
UPROPERTY(VisibleInstanceOnly)
ULevelIndicatorWidget* LevelIndicatorWidgetInstance;

public:
AUIManager();

protected:
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
virtual void Tick(float DeltaTime) override;

private:
UPROPERTY()
Expand All @@ -75,7 +71,4 @@ class AUIManager : public AActor

UFUNCTION()
void HandleRestartGameClicked();

UFUNCTION()
void HandleLivesChanged(const int NumberOfLives);
};