Add investor startup sequence
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
// Copyright Pacificao. All Rights Reserved.
|
||||
|
||||
#include "AgrarianDemoNoticeActor.h"
|
||||
|
||||
#include "AgrarianDemoNoticeWidget.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "Engine/World.h"
|
||||
#include "TimerManager.h"
|
||||
|
||||
AAgrarianDemoNoticeActor::AAgrarianDemoNoticeActor()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = false;
|
||||
NoticeWidgetClass = UAgrarianDemoNoticeWidget::StaticClass();
|
||||
}
|
||||
|
||||
void AAgrarianDemoNoticeActor::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
APlayerController* PlayerController = GetWorld() ? GetWorld()->GetFirstPlayerController() : nullptr;
|
||||
if (!PlayerController || !NoticeWidgetClass)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ActiveNoticeWidget = CreateWidget<UAgrarianDemoNoticeWidget>(PlayerController, NoticeWidgetClass);
|
||||
if (!ActiveNoticeWidget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ActiveNoticeWidget->VersionLabel = VersionLabel;
|
||||
ActiveNoticeWidget->DemoNotice = DemoNotice;
|
||||
ActiveNoticeWidget->AddToViewport(100);
|
||||
|
||||
GetWorldTimerManager().SetTimer(RemoveNoticeTimerHandle, this, &AAgrarianDemoNoticeActor::RemoveNotice, NoticeDurationSeconds, false);
|
||||
}
|
||||
|
||||
void AAgrarianDemoNoticeActor::RemoveNotice()
|
||||
{
|
||||
if (ActiveNoticeWidget)
|
||||
{
|
||||
ActiveNoticeWidget->RemoveFromParent();
|
||||
ActiveNoticeWidget = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright Pacificao. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "AgrarianDemoNoticeActor.generated.h"
|
||||
|
||||
class UAgrarianDemoNoticeWidget;
|
||||
|
||||
UCLASS()
|
||||
class AGRARIANGAME_API AAgrarianDemoNoticeActor : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AAgrarianDemoNoticeActor();
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Demo")
|
||||
TSubclassOf<UAgrarianDemoNoticeWidget> NoticeWidgetClass;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Demo", meta = (ClampMin = "1.0"))
|
||||
float NoticeDurationSeconds = 9.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Demo")
|
||||
FText VersionLabel = FText::FromString(TEXT("Investor Demo v0.01"));
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Demo")
|
||||
FText DemoNotice = FText::FromString(TEXT("Beta prototype build - not for public distribution"));
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
TObjectPtr<UAgrarianDemoNoticeWidget> ActiveNoticeWidget;
|
||||
|
||||
FTimerHandle RemoveNoticeTimerHandle;
|
||||
|
||||
void RemoveNotice();
|
||||
};
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
// Copyright Pacificao. All Rights Reserved.
|
||||
|
||||
#include "AgrarianDemoNoticeWidget.h"
|
||||
|
||||
#include "Rendering/DrawElements.h"
|
||||
#include "Styling/CoreStyle.h"
|
||||
|
||||
int32 UAgrarianDemoNoticeWidget::NativePaint(
|
||||
const FPaintArgs& Args,
|
||||
const FGeometry& AllottedGeometry,
|
||||
const FSlateRect& MyCullingRect,
|
||||
FSlateWindowElementList& OutDrawElements,
|
||||
int32 LayerId,
|
||||
const FWidgetStyle& InWidgetStyle,
|
||||
bool bParentEnabled) const
|
||||
{
|
||||
LayerId = Super::NativePaint(Args, AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled);
|
||||
|
||||
const FVector2D Size = AllottedGeometry.GetLocalSize();
|
||||
const float PanelWidth = FMath::Min(860.0f, Size.X - 96.0f);
|
||||
const float PanelHeight = 210.0f;
|
||||
const FVector2D PanelPosition((Size.X - PanelWidth) * 0.5f, 42.0f);
|
||||
|
||||
FSlateDrawElement::MakeBox(
|
||||
OutDrawElements,
|
||||
++LayerId,
|
||||
AllottedGeometry.ToPaintGeometry(FVector2f(PanelWidth, PanelHeight), FSlateLayoutTransform(FVector2f(PanelPosition))),
|
||||
FCoreStyle::Get().GetBrush(TEXT("WhiteBrush")),
|
||||
ESlateDrawEffect::None,
|
||||
FLinearColor(0.02f, 0.03f, 0.025f, 0.82f));
|
||||
|
||||
FSlateDrawElement::MakeBox(
|
||||
OutDrawElements,
|
||||
++LayerId,
|
||||
AllottedGeometry.ToPaintGeometry(FVector2f(PanelWidth, 3.0f), FSlateLayoutTransform(FVector2f(PanelPosition))),
|
||||
FCoreStyle::Get().GetBrush(TEXT("WhiteBrush")),
|
||||
ESlateDrawEffect::None,
|
||||
FLinearColor(0.45f, 0.72f, 0.40f, 1.0f));
|
||||
|
||||
const FSlateFontInfo MottoFont = FCoreStyle::GetDefaultFontStyle("Bold", 30);
|
||||
const FSlateFontInfo VersionFont = FCoreStyle::GetDefaultFontStyle("Regular", 18);
|
||||
const FSlateFontInfo NoticeFont = FCoreStyle::GetDefaultFontStyle("Regular", 16);
|
||||
|
||||
DrawCenteredText(OutDrawElements, LayerId, AllottedGeometry, Motto, PanelPosition.Y + 34.0f, MottoFont, FLinearColor(0.86f, 0.94f, 0.78f, 1.0f));
|
||||
DrawCenteredText(OutDrawElements, LayerId, AllottedGeometry, VersionLabel, PanelPosition.Y + 94.0f, VersionFont, FLinearColor(0.82f, 0.86f, 0.78f, 1.0f));
|
||||
DrawCenteredText(OutDrawElements, LayerId, AllottedGeometry, DemoNotice, PanelPosition.Y + 126.0f, NoticeFont, FLinearColor(0.78f, 0.82f, 0.75f, 1.0f));
|
||||
DrawCenteredText(OutDrawElements, LayerId, AllottedGeometry, CopyrightNotice, PanelPosition.Y + 158.0f, NoticeFont, FLinearColor(0.66f, 0.70f, 0.64f, 1.0f));
|
||||
|
||||
return LayerId;
|
||||
}
|
||||
|
||||
void UAgrarianDemoNoticeWidget::DrawCenteredText(
|
||||
FSlateWindowElementList& OutDrawElements,
|
||||
int32& LayerId,
|
||||
const FGeometry& AllottedGeometry,
|
||||
const FText& Text,
|
||||
float Y,
|
||||
const FSlateFontInfo& Font,
|
||||
const FLinearColor& Color) const
|
||||
{
|
||||
const FVector2D Size = AllottedGeometry.GetLocalSize();
|
||||
const FString TextString = Text.ToString();
|
||||
const float EstimatedWidth = FMath::Min(Size.X - 96.0f, static_cast<float>(TextString.Len()) * Font.Size * 0.52f);
|
||||
const FVector2D TextPosition((Size.X - EstimatedWidth) * 0.5f, Y);
|
||||
|
||||
FSlateDrawElement::MakeText(
|
||||
OutDrawElements,
|
||||
++LayerId,
|
||||
AllottedGeometry.ToPaintGeometry(FVector2f(EstimatedWidth, Font.Size + 12.0f), FSlateLayoutTransform(FVector2f(TextPosition))),
|
||||
Text,
|
||||
Font,
|
||||
ESlateDrawEffect::None,
|
||||
Color);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright Pacificao. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "AgrarianDemoNoticeWidget.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class AGRARIANGAME_API UAgrarianDemoNoticeWidget : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Demo")
|
||||
FText Motto = FText::FromString(TEXT("What survives after you are gone?"));
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Demo")
|
||||
FText VersionLabel = FText::FromString(TEXT("Investor Demo v0.01"));
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Demo")
|
||||
FText DemoNotice = FText::FromString(TEXT("Beta prototype build - not for public distribution"));
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Demo")
|
||||
FText CopyrightNotice = FText::FromString(TEXT("Copyright (c) 2026 Agrarian Studio. All rights reserved."));
|
||||
|
||||
protected:
|
||||
virtual int32 NativePaint(
|
||||
const FPaintArgs& Args,
|
||||
const FGeometry& AllottedGeometry,
|
||||
const FSlateRect& MyCullingRect,
|
||||
FSlateWindowElementList& OutDrawElements,
|
||||
int32 LayerId,
|
||||
const FWidgetStyle& InWidgetStyle,
|
||||
bool bParentEnabled) const override;
|
||||
|
||||
private:
|
||||
void DrawCenteredText(
|
||||
FSlateWindowElementList& OutDrawElements,
|
||||
int32& LayerId,
|
||||
const FGeometry& AllottedGeometry,
|
||||
const FText& Text,
|
||||
float Y,
|
||||
const FSlateFontInfo& Font,
|
||||
const FLinearColor& Color) const;
|
||||
};
|
||||
|
||||
@@ -19,7 +19,8 @@ public class AgrarianGame : ModuleRules
|
||||
"GameplayStateTreeModule",
|
||||
"UMG",
|
||||
"Landscape",
|
||||
"Slate"
|
||||
"Slate",
|
||||
"SlateCore"
|
||||
});
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { });
|
||||
|
||||
Reference in New Issue
Block a user