123 lines
2.9 KiB
C++
123 lines
2.9 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#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()
|
|
{
|
|
Super::NativeConstruct();
|
|
|
|
SetVisibility(ESlateVisibility::Hidden);
|
|
|
|
BPRefreshTaskList();
|
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
|
if (GameInstance)
|
|
{
|
|
GameInstance->OnRandomMeshesUpdated.AddDynamic(this, &UCaptureSettingsUserWidget::BPOnRandomMeshesUpdated);
|
|
}
|
|
}
|
|
|
|
void UCaptureSettingsUserWidget::OnAnimationFinished(const UWidgetAnimation* Animation)
|
|
{
|
|
Super::OnAnimationFinished(Animation);
|
|
|
|
if (CheckIsStopAnim(Animation))
|
|
{
|
|
OnOpenMenuStateChanged.Broadcast(bIsOpen);
|
|
}
|
|
}
|
|
|
|
void UCaptureSettingsUserWidget::ToggleMenu()
|
|
{
|
|
bIsOpen = !bIsOpen;
|
|
|
|
if (bIsOpen)
|
|
{
|
|
BPLoadSettings();
|
|
}
|
|
else
|
|
{
|
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
|
if (GameInstance && GameInstance->GameUserWidget)
|
|
{
|
|
GameInstance->GameUserWidget->DoAutoConfirm();
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
|
|
} |