A bunch of bug placement improvements, an indicator when leaving the bug placer, configuration options, early server access code... there's a lot here. Not even gonna try to be coherent. It's just a lot.

This commit is contained in:
Jamie Greunbaum 2023-03-21 03:20:34 -04:00
parent 2a3fc4e75c
commit a19e70d8f6
16 changed files with 112 additions and 29 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -3,6 +3,7 @@
#include "BugPlacerPawn.h"
#include "BugMarkerActor.h"
#include "ExitingBugPlacementScreen.h"
#include "UnrealzillaGlobalSettings.h"
#include "Components/MaterialBillboardComponent.h"
@ -50,19 +51,6 @@ void ABugPlacerPawn::BeginPlay()
this->OriginalPlayer = UGameplayStatics::GetPlayerCharacter(this, 0);
// Create the bug marker we will be placing.
//if (this->BugPlacerBlueprintClass.IsValid())
//{
// FActorSpawnParameters SpawnParams;
// SpawnParams.Name = TEXT("BugMarker");
// SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
//#if WITH_EDITOR
// SpawnParams.bHideFromSceneOutliner = true;
//#endif
// this->BugMarker = this->GetWorld()->SpawnActor<ABugMarkerActor>(this->BugPlacerBlueprintClass.Get(), this->SphereComponent->GetComponentTransform(), SpawnParams);
// this->BugMarker->AttachToComponent(this->PlacementMarkerRoot, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
//}
this->Activate();
Super::BeginPlay();
@ -158,7 +146,7 @@ void ABugPlacerPawn::PlaceBugMarker()
SpawnParams.bHideFromSceneOutliner = true;
#endif
ABugMarkerActor *Marker = this->GetWorld()->SpawnActor<ABugMarkerActor>(this->BugPlacerBlueprintClass.Get(), this->PlacementMarkerRoot->GetComponentTransform(), SpawnParams);
ABugMarkerActor *Marker = this->GetWorld()->SpawnActor<ABugMarkerActor>(this->BugMarkerBlueprintClass.Get(), this->PlacementMarkerRoot->GetComponentTransform(), SpawnParams);
Marker->LoadBugSubmissionForm();
}
}
@ -177,3 +165,55 @@ void ABugPlacerPawn::Deactivate()
this->Destroy();
}
void ABugPlacerPawn::ExitStarted()
{
if (this->ExitingBugPlacementScreenClass.IsValid())
{
this->ExitingBugPlacementScreen = CreateWidget<UExitingBugPlacementScreen>(UGameplayStatics::GetPlayerController(this, 0), this->ExitingBugPlacementScreenClass.Get());
this->ExitingBugPlacementScreen->AddToViewport(GetDefault<UUnrealzillaGlobalSettings>()->BugReportWidgetDepth + 10);
}
else
{
this->ExitingBugPlacementScreen = nullptr;
}
}
void ABugPlacerPawn::ExitOngoing(const float ElapsedSeconds)
{
if (this->ExitingBugPlacementScreen)
{
this->ExitingBugPlacementScreen->SetPercent(ElapsedSeconds);
}
}
void ABugPlacerPawn::ExitTriggered()
{
if (this->ExitingBugPlacementScreen)
{
this->ExitingBugPlacementScreen->RemoveFromParent();
this->Deactivate();
}
}
void ABugPlacerPawn::ExitCanceled()
{
if (this->ExitingBugPlacementScreen)
{
this->ExitingBugPlacementScreen->RemoveFromParent();
}
}
void ABugPlacerPawn::SpawnBugPlacerPawn(const UObject *WorldContextObject, TSoftClassPtr<ABugPlacerPawn> Class)
{
if (Class.IsValid())
{
const FTransform &Transform = UGameplayStatics::GetPlayerCameraManager(WorldContextObject, 0)->GetActorTransform();
FActorSpawnParameters SpawnParams;
//SpawnParams.Name = TEXT("BugPlacerPawn");
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
WorldContextObject->GetWorld()->SpawnActor<ABugPlacerPawn>(Class.Get(), Transform, SpawnParams);
}
}

View File

@ -7,6 +7,7 @@
#include "CommonTextBlock.h"
#include "HttpModule.h"
#include "UnrealzillaGlobalSettings.h"
#include "Components/Overlay.h"
#include "Kismet/GameplayStatics.h"
@ -38,6 +39,8 @@ void UBugSubmissionForm::SetMarkerData(ABugMarkerActor *BugMarker)
{
this->BugMarkerActor = BugMarker;
MapNameValue->SetText(FText::FromString(this->GetWorld()->GetMapName().RightChop(this->GetWorld()->StreamingLevelsPrefix.Len())));
const FVector MarkerLocation = this->BugMarkerActor->GetActorLocation();
FFormatNamedArguments MarkerLocationArgs;
MarkerLocationArgs.Add("X", FormatFloatToText(MarkerLocation.X, 1, 4));
@ -53,10 +56,9 @@ void UBugSubmissionForm::SetMarkerData(ABugMarkerActor *BugMarker)
const FText MarkerUpVectorText = FText::Format(NSLOCTEXT("BugSubmissionForm", "MarkerUpVector", "{X},{Y},{Z}"), MarkerUpVectorArgs);
FFormatNamedArguments MapDataArgs;
MapDataArgs.Add("MapName", FText::FromString(this->GetWorld()->GetMapName().RightChop(this->GetWorld()->StreamingLevelsPrefix.Len())));
MapDataArgs.Add("MarkerLocation", MarkerLocationText);
MapDataArgs.Add("MarkerUpVector", MarkerUpVectorText);
const FText MapDataText = FText::Format(NSLOCTEXT("BugSubmissionForm", "MapDataFormat", "{MapName}\n{MarkerLocation}\n{MarkerUpVector}"), MapDataArgs);
const FText MapDataText = FText::Format(NSLOCTEXT("BugSubmissionForm", "MapDataFormat", "{MarkerLocation}\n{MarkerUpVector}"), MapDataArgs);
this->LocationValue->SetText(MapDataText);
}
@ -64,8 +66,10 @@ void UBugSubmissionForm::SetMarkerData(ABugMarkerActor *BugMarker)
void UBugSubmissionForm::SubmitForm()
{
this->ProcessingRequestOverlay->SetVisibility(ESlateVisibility::Visible);
const FString RESTURL = "/rest.cgi";
const FString RequestURL = "/bug/7";
const FString RequestURL = "/bug";
const FString QueryString = "api_key=" + GetDefault<UUnrealzillaGlobalSettings>()->APIKey;
FHttpModule &HttpModule = FHttpModule::Get();
@ -78,8 +82,6 @@ void UBugSubmissionForm::SubmitForm()
Request->ProcessRequest();
this->OnFormSubmit.ExecuteIfBound();
this->CloseForm();
}
void UBugSubmissionForm::CancelForm()
@ -94,7 +96,7 @@ void UBugSubmissionForm::CancelForm()
void UBugSubmissionForm::CloseForm()
{
UGameplayStatics::GetPlayerController(this, 0)->SetInputMode(FInputModeGameOnly());
UGameplayStatics::GetPlayerController(this, 0)->bShowMouseCursor = true;
UGameplayStatics::GetPlayerController(this, 0)->bShowMouseCursor = false;
this->RemoveFromParent();
}
@ -104,6 +106,8 @@ void UBugSubmissionForm::ServerResponse(FHttpRequestPtr Request, FHttpResponsePt
if (Success)
{
UE_LOG(LogTemp, Log, TEXT("%s"), *Response->GetContentAsString());
this->CloseForm();
}
else
{
@ -121,7 +125,7 @@ void UBugSubmissionForm::ServerResponse(FHttpRequestPtr Request, FHttpResponsePt
UE_LOG(LogTemp, Error, TEXT("Connection failed"));
break;
case EHttpRequestStatus::Succeeded:
UE_LOG(LogTemp, Warning, TEXT("Connection succeeded"));
UE_LOG(LogTemp, Log, TEXT("Connection succeeded"));
break;
default:
UE_LOG(LogTemp, Error, TEXT("Request failed"));

View File

@ -0,0 +1,6 @@
// ©2022 Batty Bovine Productions, LLC. All Rights Reserved.
#include "ExitingBugPlacementScreen.h"

View File

@ -27,6 +27,9 @@ public:
UFUNCTION(BlueprintCallable)
void Deactivate();
UFUNCTION(BlueprintCallable, meta=(WorldContext="WorldContextObject"))
static void SpawnBugPlacerPawn(const UObject *WorldContextObject, TSoftClassPtr<class ABugPlacerPawn> Class);
protected:
UFUNCTION(BlueprintCallable)
void SetArbitraryPlacement(bool bSet);
@ -34,40 +37,46 @@ protected:
UFUNCTION(BlueprintCallable)
void PlaceBugMarker();
UFUNCTION(BlueprintCallable)
void ExitStarted();
UFUNCTION(BlueprintCallable)
void ExitOngoing(const float ElapsedSeconds);
UFUNCTION(BlueprintCallable)
void ExitTriggered();
UFUNCTION(BlueprintCallable)
void ExitCanceled();
// Collision sphere, and root component
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
TObjectPtr<class USphereComponent> SphereComponent;
// Follows the collision point of a line trace, and indicates where the bug marker will be placed.
UPROPERTY(BlueprintReadOnly, EditAnywhere)
TObjectPtr<class USceneComponent> PlacementMarkerRoot;
// The glowing end point of the laser, to indicate a surface where a marker can be placed.
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
TObjectPtr<class UMaterialBillboardComponent> LaserGlow;
// The origin of our line trace; line extends from this origin position along the component's
// forward vector a set distance to check for surfaces where a bug marker can be placed.
UPROPERTY(BlueprintReadOnly, EditAnywhere)
TObjectPtr<class USceneComponent> TraceOriginComponent;
// Basic movement component to allow the bug placer to fly through a level.
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
TObjectPtr<class UFloatingPawnMovement> PawnMovement;
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
TSoftClassPtr<class ABugMarkerActor> BugPlacerBlueprintClass;
TSoftClassPtr<class ABugMarkerActor> BugMarkerBlueprintClass;
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
TSoftClassPtr<class UExitingBugPlacementScreen> ExitingBugPlacementScreenClass;
UPROPERTY(BlueprintReadWrite)
float SavedMaxSpeed = 0.0f;
private:
uint8 bArbitraryPlacement : 1;
uint8 bCurrentTraceHit : 1;
TObjectPtr<class ACharacter> OriginalPlayer;
TObjectPtr<class ABugMarkerActor> BugMarker;
TObjectPtr<class UExitingBugPlacementScreen> ExitingBugPlacementScreen;
};

View File

@ -28,6 +28,8 @@ protected:
UPROPERTY(BlueprintReadOnly, meta=(BindWidget))
TObjectPtr<class UCommonTextBlock> ProductNameValue;
UPROPERTY(BlueprintReadOnly, meta=(BindWidget))
TObjectPtr<class UCommonTextBlock> MapNameValue;
UPROPERTY(BlueprintReadOnly, meta=(BindWidget))
TObjectPtr<class UCommonTextBlock> LocationValue;
@ -36,6 +38,9 @@ protected:
UPROPERTY(BlueprintReadOnly, meta=(BindWidget))
TObjectPtr<class UCommonButtonBase> SubmitButton;
UPROPERTY(BlueprintReadOnly, meta=(BindWidget))
TObjectPtr<class UOverlay> ProcessingRequestOverlay;
private:
void ServerResponse(FHttpRequestPtr Request, FHttpResponsePtr Response, bool Success);

View File

@ -0,0 +1,19 @@
// ©2022 Batty Bovine Productions, LLC. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "ExitingBugPlacementScreen.generated.h"
UCLASS()
class UNREALZILLA_API UExitingBugPlacementScreen : public UUserWidget
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintImplementableEvent)
void SetPercent(const float Percent);
};