Implement interaction prompt
This commit is contained in:
@@ -4,12 +4,13 @@
|
||||
#include "AgrarianGameCharacter.h"
|
||||
#include "AgrarianInventoryComponent.h"
|
||||
#include "AgrarianSurvivalComponent.h"
|
||||
#include "Engine/Canvas.h"
|
||||
|
||||
void AAgrarianDebugHUD::DrawHUD()
|
||||
{
|
||||
Super::DrawHUD();
|
||||
|
||||
if (!bShowDebugHUD || !Canvas)
|
||||
if (!Canvas)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -20,12 +21,34 @@ void AAgrarianDebugHUD::DrawHUD()
|
||||
return;
|
||||
}
|
||||
|
||||
float Y = 32.0f;
|
||||
constexpr float X = 32.0f;
|
||||
DrawInteractionPrompt(AgrarianCharacter);
|
||||
|
||||
DrawLine(TEXT("AGRARIAN DEV HUD"), X, Y, FColor(160, 220, 140));
|
||||
DrawSurvival(AgrarianCharacter->GetSurvivalComponent(), X, Y);
|
||||
DrawInventory(AgrarianCharacter->GetInventoryComponent(), X, Y);
|
||||
if (bShowDebugHUD)
|
||||
{
|
||||
float Y = 32.0f;
|
||||
constexpr float X = 32.0f;
|
||||
|
||||
DrawLine(TEXT("AGRARIAN DEV HUD"), X, Y, FColor(160, 220, 140));
|
||||
DrawSurvival(AgrarianCharacter->GetSurvivalComponent(), X, Y);
|
||||
DrawInventory(AgrarianCharacter->GetInventoryComponent(), X, Y);
|
||||
}
|
||||
}
|
||||
|
||||
void AAgrarianDebugHUD::DrawInteractionPrompt(const AAgrarianGameCharacter* AgrarianCharacter)
|
||||
{
|
||||
if (!bShowInteractionPrompt || !AgrarianCharacter || !AgrarianCharacter->HasInteractionPrompt() || !Canvas)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const FString Prompt = FString::Printf(TEXT("[E] %s"), *AgrarianCharacter->GetInteractionPromptText().ToString());
|
||||
float TextWidth = 0.0f;
|
||||
float TextHeight = 0.0f;
|
||||
GetTextSize(Prompt, TextWidth, TextHeight, nullptr, PromptTextScale);
|
||||
|
||||
const float X = (Canvas->ClipX - TextWidth) * 0.5f;
|
||||
const float Y = Canvas->ClipY * 0.62f;
|
||||
DrawText(Prompt, FColor(245, 245, 225), X, Y, nullptr, PromptTextScale, true);
|
||||
}
|
||||
|
||||
void AAgrarianDebugHUD::DrawSurvival(const UAgrarianSurvivalComponent* SurvivalComponent, float X, float& Y)
|
||||
|
||||
Reference in New Issue
Block a user