Merge pull request 'martin' (#30) from martin into main

Reviewed-on: #30
This commit is contained in:
martinluckyrobots 2025-04-21 05:08:21 +00:00
commit 8f6b3942e2
33 changed files with 254 additions and 1 deletions

3
.gitignore vendored
View File

@ -52,6 +52,9 @@ Binaries/*
# Builds
Build/*
# robotdata
robotdata/
# Whitelist PakBlacklist-<BuildConfiguration>.txt files
!Build/*/
Build/*/**

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "UI/Common/MenuTitleUserWidget.h"

View File

@ -0,0 +1,11 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "UI/Common/TextFieldUserWidget.h"
void UTextFieldUserWidget::NativeConstruct()
{
Super::NativeConstruct();
UpdateDisplay();
}

View File

@ -2,4 +2,66 @@
#include "UI/Settings/ObjectsListUserWidget.h"
#include "Engine/StreamableManager.h"
#include "Engine/AssetManager.h"
#include "Engine/Texture2D.h"
#include "Core/LuckyRobotsGameInstance.h"
void UObjectsListUserWidget::NativeConstruct()
{
Super::NativeConstruct();
SelectableItemData.Icon;
SetVisibility(ESlateVisibility::Collapsed);
if (!SelectableItemData.Icon.IsNull())
{
FStreamableManager& Streamable = UAssetManager::GetStreamableManager();
Streamable.RequestAsyncLoad(SelectableItemData.Icon.ToSoftObjectPath(),
FStreamableDelegate::CreateUObject(this, &UObjectsListUserWidget::OnIconLoaded));
}
DoUpdateChecked();
}
void UObjectsListUserWidget::OnIconLoaded()
{
UTexture2D* LoadedTexture = Cast<UTexture2D>(SelectableItemData.Icon.Get());
if (LoadedTexture)
{
UpdateIcon(LoadedTexture);
SetVisibility(ESlateVisibility::Visible);
}
}
void UObjectsListUserWidget::DoUpdateChecked()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
bIsChecked = GameInstance->GetCurrentRandomMeshes().Find(SelectableItemData.Mesh) >= 0;
}
DoDisplayChecked();
}
void UObjectsListUserWidget::ToggleChecked()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
if (GameInstance->GetCurrentRandomMeshes().Find(SelectableItemData.Mesh) >= 0)
{
GameInstance->CurrentCaptureSettingsData.RandomMeshes.Remove(SelectableItemData.Mesh);
}
else
{
GameInstance->CurrentCaptureSettingsData.RandomMeshes.Add(SelectableItemData.Mesh);
}
GameInstance->OnRandomMeshesUpdated.Broadcast();
}
DoUpdateChecked();
}

View File

@ -2,3 +2,40 @@
#include "UI/Settings/TaskListViewUserWidget.h"
#include "Components/VerticalBox.h"
#include "Components/WidgetSwitcher.h"
#include "Core/LuckyRobotsGameInstance.h"
#include "UI/Settings/ObjectsListUserWidget.h"
void UTaskListViewUserWidget::DoUpdateObject(TArray<TSoftObjectPtr<UStaticMesh>> StaticMeshList)
{
if (GetObjectListView())
{
GetObjectListView()->ClearChildren();
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
TArray<FSelectableItemData> SelectableItemList = GameInstance->GetSelectableItemList(EItemCategory::Furniture);
for (auto TempStaticMesh : StaticMeshList)
{
for (auto SelectableItem : SelectableItemList)
{
if (SelectableItem.Mesh == TempStaticMesh)
{
UObjectsListUserWidget* ObjectsListUserWidget = CreateWidget<UObjectsListUserWidget>(this, ObjectsListUserWidgetClass);
if (ObjectsListUserWidget)
{
ObjectsListUserWidget->SelectableItemData = SelectableItem;
GetObjectListView()->AddChild(ObjectsListUserWidget);
ObjectsListUserWidget->SetPadding(FMargin(0.0f, 5.0f, 0.0f, 0.0f));
}
break;
}
}
}
}
GetWidgetSwitcher()->SetActiveWidgetIndex(1);
}
}

View File

@ -0,0 +1,27 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "MenuTitleUserWidget.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnClickCloseButton);
/**
*
*/
UCLASS()
class LUCKYWORLDV2_API UMenuTitleUserWidget : public UUserWidget
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
FString MenuTitle;
public:
UPROPERTY(BlueprintCallable, BlueprintAssignable)
FOnClickCloseButton OnClickCloseButton;
};

View File

@ -0,0 +1,42 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "TextFieldUserWidget.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnEditText, FString, editstr);
/**
*
*/
UCLASS()
class LUCKYWORLDV2_API UTextFieldUserWidget : public UUserWidget
{
GENERATED_BODY()
protected:
virtual void NativeConstruct() override;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
FString SettingFieldLabel;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UTexture2D* SettingIcon;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
FString SettingString;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
FLinearColor SettingColor;
public:
UPROPERTY(BlueprintCallable, BlueprintAssignable)
FOnEditText OnEditText;
public:
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void UpdateDisplay();
};

View File

@ -14,8 +14,29 @@ UCLASS()
class LUCKYWORLDV2_API UObjectsListUserWidget : public UUserWidget
{
GENERATED_BODY()
protected:
virtual void NativeConstruct() override;
void OnIconLoaded();
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsChecked;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FSelectableItemData SelectableItemData;
public:
UFUNCTION(BlueprintCallable)
void DoUpdateChecked();
UFUNCTION(BlueprintCallable)
void ToggleChecked();
public:
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void UpdateIcon(UTexture2D* Image);
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void DoDisplayChecked();
};

View File

@ -6,7 +6,13 @@
#include "Blueprint/UserWidget.h"
#include "TaskListViewUserWidget.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnAddButtonClick);
class UListView;
class UVerticalBox;
class UWidgetSwitcher;
class UObjectsListUserWidget;
class UStaticMesh;
/**
*
*/
@ -15,7 +21,46 @@ class LUCKYWORLDV2_API UTaskListViewUserWidget : public UUserWidget
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
FString TaskListLabel;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
bool bIsEnableSetting;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
FString SettingFieldLabel;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UTexture2D* SettingIcon;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
FString SettingString;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
bool bIsEnableAddButton;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
FString AddButtonLabel;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
TSubclassOf<UObjectsListUserWidget> ObjectsListUserWidgetClass;
public:
UPROPERTY(BlueprintCallable, BlueprintAssignable)
FOnAddButtonClick OnAddButtonClick;
public:
UFUNCTION(BlueprintCallable)
void DoUpdateObject(TArray<TSoftObjectPtr<UStaticMesh>> StaticMeshList);
public:
UFUNCTION(BlueprintPure, BlueprintImplementableEvent)
UListView* GetTaskListView();
UFUNCTION(BlueprintPure, BlueprintImplementableEvent)
UVerticalBox* GetObjectListView();
UFUNCTION(BlueprintPure, BlueprintImplementableEvent)
UWidgetSwitcher* GetWidgetSwitcher();
};