You've already forked LuckyWorld
optimization some umg
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
#include "VaRestSubsystem.h"
|
||||
#include "Subsystems/SubsystemBlueprintLibrary.h"
|
||||
#include "Gameplay/TargetSelector.h"
|
||||
#include "UI/Settings/CaptureSettingsUserWidget.h"
|
||||
|
||||
void ULuckyRobotsGameInstance::DoSendMessage(const FString& SendValue)
|
||||
{
|
||||
@ -135,7 +136,10 @@ void ULuckyRobotsGameInstance::DoSetTempTaskValueChange(bool bIsClear)
|
||||
|
||||
if (GameUserWidget)
|
||||
{
|
||||
GameUserWidget->DoRefreshListView();
|
||||
if (GameUserWidget->GetCaptureSettingsUserWidget())
|
||||
{
|
||||
GameUserWidget->GetCaptureSettingsUserWidget()->BPRefreshTaskList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
36
Source/LuckyWorldV2/Private/Gameplay/NaviSplineCreator.cpp
Normal file
36
Source/LuckyWorldV2/Private/Gameplay/NaviSplineCreator.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Gameplay/NaviSplineCreator.h"
|
||||
#include "Core/LuckyRobotsGameInstance.h"
|
||||
|
||||
// Sets default values
|
||||
ANaviSplineCreator::ANaviSplineCreator()
|
||||
{
|
||||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void ANaviSplineCreator::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void ANaviSplineCreator::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
}
|
||||
|
||||
void ANaviSplineCreator::UpdateSplineVisibility()
|
||||
{
|
||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (GameInstance)
|
||||
{
|
||||
SetActorHiddenInGame(!GameInstance->bIsShowPath);
|
||||
}
|
||||
}
|
5
Source/LuckyWorldV2/Private/Object/ListviewObject.cpp
Normal file
5
Source/LuckyWorldV2/Private/Object/ListviewObject.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Object/ListviewObject.h"
|
||||
|
@ -3,6 +3,10 @@
|
||||
|
||||
#include "UI/GameUserWidget.h"
|
||||
#include "Core/LuckyRobotsGameInstance.h"
|
||||
#include "UI/Settings/CaptureSettingsUserWidget.h"
|
||||
#include "UI/Settings/SelectGoalUserWidget.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "Gameplay/NaviSplineCreator.h"
|
||||
|
||||
void UGameUserWidget::NativeConstruct()
|
||||
{
|
||||
@ -48,4 +52,105 @@ void UGameUserWidget::UpdateDownCount()
|
||||
}
|
||||
GetWorld()->GetTimerManager().ClearTimer(UpdateDownCountTimerHandle);
|
||||
}
|
||||
}
|
||||
|
||||
void UGameUserWidget::ToggleHide()
|
||||
{
|
||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (GameInstance)
|
||||
{
|
||||
GameInstance->bIsDebug = !GameInstance->bIsDebug;
|
||||
}
|
||||
}
|
||||
|
||||
void UGameUserWidget::ToggleTestMode()
|
||||
{
|
||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (GameInstance)
|
||||
{
|
||||
GameInstance->bIsWidgetTestMode = !GameInstance->bIsWidgetTestMode;
|
||||
}
|
||||
}
|
||||
|
||||
void UGameUserWidget::DoCapture()
|
||||
{
|
||||
if (GetCaptureSettingsUserWidget())
|
||||
{
|
||||
GetCaptureSettingsUserWidget()->ToggleMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void UGameUserWidget::DoAutoConfirm()
|
||||
{
|
||||
USelectGoalUserWidget* SelectGoalUserWidget = GetSelectGoalUserWidget();
|
||||
if (SelectGoalUserWidget)
|
||||
{
|
||||
SelectGoalUserWidget->DoAutoConfirm();
|
||||
}
|
||||
}
|
||||
|
||||
void UGameUserWidget::DoReset()
|
||||
{
|
||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (GameInstance)
|
||||
{
|
||||
if (GameInstance->bIsCapture)
|
||||
{
|
||||
if (GetCaptureSettingsUserWidget())
|
||||
{
|
||||
GetCaptureSettingsUserWidget()->BPChangeCaptureState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OnReset.Broadcast();
|
||||
}
|
||||
|
||||
void UGameUserWidget::DoExit()
|
||||
{
|
||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (GameInstance)
|
||||
{
|
||||
if (GameInstance->bIsCapture)
|
||||
{
|
||||
if (GetCaptureSettingsUserWidget())
|
||||
{
|
||||
GetCaptureSettingsUserWidget()->BPChangeCaptureState();
|
||||
}
|
||||
}
|
||||
|
||||
if (GameInstance->LobbyLevelObject)
|
||||
{
|
||||
UGameplayStatics::OpenLevelBySoftObjectPtr(this, GameInstance->LobbyLevelObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UGameUserWidget::SwitchGamePaused()
|
||||
{
|
||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (GameInstance)
|
||||
{
|
||||
GameInstance->SwitchGamePaused();
|
||||
}
|
||||
}
|
||||
|
||||
void UGameUserWidget::ToggleShowPath()
|
||||
{
|
||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (GameInstance)
|
||||
{
|
||||
GameInstance->bIsShowPath = !GameInstance->bIsShowPath;
|
||||
}
|
||||
|
||||
TArray<AActor*> AllNaviSplineCreator;
|
||||
UGameplayStatics::GetAllActorsOfClass(this, ANaviSplineCreator::StaticClass(), AllNaviSplineCreator);
|
||||
for (auto NaviSplineCreatorActor : AllNaviSplineCreator)
|
||||
{
|
||||
ANaviSplineCreator* NaviSplineCreator = Cast<ANaviSplineCreator>(NaviSplineCreatorActor);
|
||||
if (NaviSplineCreator)
|
||||
{
|
||||
NaviSplineCreator->UpdateSplineVisibility();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/Settings/AllRandomUserWidget.h"
|
||||
|
@ -4,6 +4,10 @@
|
||||
#include "UI/Settings/CaptureSettingsUserWidget.h"
|
||||
#include "Core/LuckyRobotsGameInstance.h"
|
||||
#include "UI/GameUserWidget.h"
|
||||
#include "UI/Settings/AllRandomUserWidget.h"
|
||||
#include "UI/Settings/TaskListViewUserWidget.h"
|
||||
#include "Components/ListView.h"
|
||||
#include "Object/ListviewObject.h"
|
||||
|
||||
void UCaptureSettingsUserWidget::NativeConstruct()
|
||||
{
|
||||
@ -19,6 +23,16 @@ void UCaptureSettingsUserWidget::NativeConstruct()
|
||||
}
|
||||
}
|
||||
|
||||
void UCaptureSettingsUserWidget::OnAnimationFinished(const UWidgetAnimation* Animation)
|
||||
{
|
||||
Super::OnAnimationFinished(Animation);
|
||||
|
||||
if (CheckIsStopAnim(Animation))
|
||||
{
|
||||
OnOpenMenuStateChanged.Broadcast(bIsOpen);
|
||||
}
|
||||
}
|
||||
|
||||
void UCaptureSettingsUserWidget::ToggleMenu()
|
||||
{
|
||||
bIsOpen = !bIsOpen;
|
||||
@ -39,4 +53,71 @@ void UCaptureSettingsUserWidget::ToggleMenu()
|
||||
OnOpenMenuStateChanged.Broadcast(bIsOpen);
|
||||
|
||||
ToggleMenuDisplay();
|
||||
}
|
||||
|
||||
void UCaptureSettingsUserWidget::DoStopCapture()
|
||||
{
|
||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (GameInstance)
|
||||
{
|
||||
GameInstance->bIsMouseOpen = false;
|
||||
}
|
||||
|
||||
OnStopCapture.Broadcast();
|
||||
}
|
||||
|
||||
void UCaptureSettingsUserWidget::ToggleRandomPannel()
|
||||
{
|
||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (GameInstance)
|
||||
{
|
||||
GameInstance->bIsRandomPannel = !GameInstance->bIsRandomPannel;
|
||||
if (GameInstance->bIsRandomPannel)
|
||||
{
|
||||
if (GameInstance->GameUserWidget && GameInstance->GameUserWidget->GetAllRandomUserWidget())
|
||||
{
|
||||
GameInstance->GameUserWidget->GetAllRandomUserWidget()->DoOpen();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UCaptureSettingsUserWidget::BPRefreshTaskList()
|
||||
{
|
||||
UTaskListViewUserWidget* TaskListViewUserWidget = GetTaskListViewUserWidget();
|
||||
UListView* TaskListView = nullptr;
|
||||
if (TaskListViewUserWidget)
|
||||
{
|
||||
TaskListView = TaskListViewUserWidget->GetTaskListView();
|
||||
}
|
||||
|
||||
if (TaskListViewUserWidget && TaskListView)
|
||||
{
|
||||
TaskListView->ClearListItems();
|
||||
}
|
||||
|
||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (GameInstance)
|
||||
{
|
||||
TArray<FGoalsTaskData> TaskList = GameInstance->GetTaskList();
|
||||
int index = 0;
|
||||
for (auto task : TaskList)
|
||||
{
|
||||
UListviewObject* ListviewObject = NewObject<UListviewObject>();
|
||||
if (ListviewObject)
|
||||
{
|
||||
ListviewObject->GoalsTaskData = task;
|
||||
++index;
|
||||
ListviewObject->Index = index;
|
||||
if (TaskListViewUserWidget && TaskListView)
|
||||
{
|
||||
TaskListView->AddItem(ListviewObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameInstance->UpdateTargetSelector();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/Settings/SelectGoalUserWidget.h"
|
||||
|
@ -0,0 +1,4 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/Settings/TaskListViewUserWidget.h"
|
@ -45,6 +45,9 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
|
||||
TSubclassOf<AActor> TargetSelectorClass;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
|
||||
TSoftObjectPtr<UWorld> LobbyLevelObject;
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
|
||||
TArray<FString> AlphabetForRandomList;
|
||||
|
29
Source/LuckyWorldV2/Public/Gameplay/NaviSplineCreator.h
Normal file
29
Source/LuckyWorldV2/Public/Gameplay/NaviSplineCreator.h
Normal file
@ -0,0 +1,29 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "NaviSplineCreator.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class LUCKYWORLDV2_API ANaviSplineCreator : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
ANaviSplineCreator();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void UpdateSplineVisibility();
|
||||
};
|
24
Source/LuckyWorldV2/Public/Object/ListviewObject.h
Normal file
24
Source/LuckyWorldV2/Public/Object/ListviewObject.h
Normal file
@ -0,0 +1,24 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/NoExportTypes.h"
|
||||
#include "SharedDef.h"
|
||||
#include "ListviewObject.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(Blueprintable)
|
||||
class LUCKYWORLDV2_API UListviewObject : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FGoalsTaskData GoalsTaskData;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int32 Index;
|
||||
};
|
@ -10,6 +10,8 @@
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnReset);
|
||||
|
||||
class UCaptureSettingsUserWidget;
|
||||
class USelectGoalUserWidget;
|
||||
class UAllRandomUserWidget;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -48,17 +50,41 @@ public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void DoWaitSecond();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void ToggleHide();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void ToggleTestMode();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void DoCapture();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void DoAutoConfirm();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void DoReset();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void DoExit();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SwitchGamePaused();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void ToggleShowPath();
|
||||
|
||||
void UpdateDownCount();
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
||||
void DoLogItemAdd(const FString& Topic, const FString& MsgText, ELogItemType LogItemType);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
||||
void DoRefreshListView();
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
||||
void DoAutoConfirm();
|
||||
|
||||
UFUNCTION(BlueprintPure, BlueprintImplementableEvent)
|
||||
UCaptureSettingsUserWidget* GetCaptureSettingsUserWidget();
|
||||
|
||||
UFUNCTION(BlueprintPure, BlueprintImplementableEvent)
|
||||
USelectGoalUserWidget* GetSelectGoalUserWidget();
|
||||
|
||||
UFUNCTION(BlueprintPure, BlueprintImplementableEvent)
|
||||
UAllRandomUserWidget* GetAllRandomUserWidget();
|
||||
};
|
||||
|
20
Source/LuckyWorldV2/Public/UI/Settings/AllRandomUserWidget.h
Normal file
20
Source/LuckyWorldV2/Public/UI/Settings/AllRandomUserWidget.h
Normal file
@ -0,0 +1,20 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "AllRandomUserWidget.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class LUCKYWORLDV2_API UAllRandomUserWidget : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
||||
void DoOpen();
|
||||
};
|
@ -11,6 +11,7 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnOpenMenuStateChanged, bool, Open)
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnStartCapture);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnStopCapture);
|
||||
|
||||
class UTaskListViewUserWidget;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -20,6 +21,7 @@ class LUCKYWORLDV2_API UCaptureSettingsUserWidget : public UUserWidget
|
||||
GENERATED_BODY()
|
||||
protected:
|
||||
virtual void NativeConstruct() override;
|
||||
void OnAnimationFinished(const UWidgetAnimation* Animation);
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
@ -38,10 +40,17 @@ public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void ToggleMenu();
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void DoStopCapture();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void ToggleRandomPannel();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void BPRefreshTaskList();
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
||||
void BPOnRandomMeshesUpdated();
|
||||
|
||||
@ -56,4 +65,10 @@ public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
||||
void BPChangeCaptureState();
|
||||
|
||||
UFUNCTION(BlueprintPure, BlueprintImplementableEvent)
|
||||
bool CheckIsStopAnim(const UWidgetAnimation* Animation);
|
||||
|
||||
UFUNCTION(BlueprintPure, BlueprintImplementableEvent)
|
||||
UTaskListViewUserWidget* GetTaskListViewUserWidget();
|
||||
};
|
||||
|
@ -0,0 +1,20 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "SelectGoalUserWidget.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class LUCKYWORLDV2_API USelectGoalUserWidget : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
||||
void DoAutoConfirm();
|
||||
};
|
@ -0,0 +1,21 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "TaskListViewUserWidget.generated.h"
|
||||
|
||||
class UListView;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class LUCKYWORLDV2_API UTaskListViewUserWidget : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintPure, BlueprintImplementableEvent)
|
||||
UListView* GetTaskListView();
|
||||
};
|
Reference in New Issue
Block a user