gurkan.erdinc.temp2 #34

Merged
gurkan merged 2 commits from gurkan.erdinc.temp2 into main 2025-04-22 19:46:21 +00:00
9 changed files with 110 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -14,6 +14,8 @@
#include "Gameplay/TargetSelector.h"
#include "UI/Settings/CaptureSettingsUserWidget.h"
#include "Subsystem/UISubsystem.h"
#include "Engine/World.h"
#include "Engine/Engine.h"
void ULuckyRobotsGameInstance::Init()
{
@ -601,4 +603,94 @@ void ULuckyRobotsGameInstance::SetWidgetTotalHit(int32 Value)
int32 ULuckyRobotsGameInstance::GetWidgetTotalHit() const
{
return WidgetTotalHit;
}
}
void ULuckyRobotsGameInstance::SetLuckyRobot(FString RobotName)
{
bool bFound = false;
for (int32 i = 0; i <= static_cast<int32>(ERobotsName::SO100Robot); i++)
{
ERobotsName EnumVal = static_cast<ERobotsName>(i);
FString EnumString = StaticEnum<ERobotsName>()->GetNameStringByValue(i); // Enum name
if (EnumString.Equals(RobotName, ESearchCase::IgnoreCase))
{
CurrentSelectRobot = EnumVal;
bFound = true;
UE_LOG(LogTemp, Warning, TEXT("Robot selected: %s"), *EnumString);
// Current level reopen
if (UWorld* World = GetWorld())
{
FString CurrentLevelName = World->GetMapName();
// Remove PIE prefix if present
FString ShortName = FPackageName::GetShortName(CurrentLevelName);
ShortName.RemoveFromStart(TEXT("UEDPIE_0_")); // Adjust for PIE prefix
if (!ShortName.IsEmpty())
{
UE_LOG(LogTemp, Warning, TEXT("Reopening level: %s"), *ShortName);
UGameplayStatics::OpenLevel(World, FName(*ShortName));
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to extract short name from level: %s"), *CurrentLevelName);
}
}
break;
}
}
if (!bFound)
{
UE_LOG(LogTemp, Error, TEXT("Invalid robot name: %s"), *RobotName);
}
}
void ULuckyRobotsGameInstance::LuckyRobots()
{
UEnum* EnumPtr = StaticEnum<ERobotsName>();
if (!EnumPtr) return;
for (int32 i = 0; i < EnumPtr->NumEnums() - 1; ++i) // Last is _MAX usually
{
FString Name = EnumPtr->GetNameStringByIndex(i);
Name = Name.Replace(TEXT("ERobotsName::"), TEXT(""));
GameUserWidget->DoLogItemAdd("Robot:", Name, ELogItemType::Consol);
UE_LOG(LogTemp, Display, TEXT("Robot: %s"), *Name);
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, FString::Printf(TEXT("Robot selected: %s"), *Name));
}
}
}
EUnrealBuildType ULuckyRobotsGameInstance::CheckBuildConfiguration() const
{
#if UE_BUILD_DEBUG
{
UE_LOG(LogTemp, Warning, TEXT("This is a Debug build"));
return EUnrealBuildType::Debug;
}
#elif UE_BUILD_DEVELOPMENT
{
UE_LOG(LogTemp, Warning, TEXT("This is a Development build"));
return EUnrealBuildType::Development;
}
#elif UE_BUILD_TEST
{
UE_LOG(LogTemp, Warning, TEXT("This is a Test build"));
return EUnrealBuildType::Test;
}
#elif UE_BUILD_SHIPPING
{
return EUnrealBuildType::Shipping;
UE_LOG(LogTemp, Warning, TEXT("This is a Shipping build"));
}
#else
{
UE_LOG(LogTemp, Warning, TEXT("Unknown build configuration"));
return EUnrealBuildType::None;
}
#endif
}

View File

@ -121,7 +121,7 @@ public:
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ERobotsName CurrentSelectRobot = ERobotsName::None;
ERobotsName CurrentSelectRobot = ERobotsName::SO100Robot;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ELevelEnum CurrentSelectLevel = ELevelEnum::None;
@ -323,5 +323,12 @@ public:
UFUNCTION(BlueprintPure)
int32 GetWidgetTotalHit() const;
UFUNCTION(exec)
void SetLuckyRobot(FString RobotName);
UFUNCTION(exec)
void LuckyRobots();
UFUNCTION(BlueprintPure)
EUnrealBuildType CheckBuildConfiguration() const;
};

View File

@ -35,6 +35,15 @@ enum class ERobotsName : uint8
SO100Robot UMETA(DisplayName = "SO100 Arm Robot")
};
UENUM(BlueprintType)
enum class EUnrealBuildType : uint8
{
None UMETA(DisplayName = "Unknown build configuration"),
Debug UMETA(DisplayName = "Debug build configuration"),
Development UMETA(DisplayName = "Development build configuration"),
Shipping UMETA(DisplayName = "Shipping build configuration")
};
UENUM(BlueprintType)
enum class ELevelType : uint8
{